pending/1082: Patches to build krb524.dll and other bits...

Dave Bailey D.Bailey at bristol.ac.uk
Wed Apr 3 09:28:12 EST 2002


>Number:         1082
>Category:       pending
>Synopsis:       Patches to build krb524.dll and other bits...
>Confidential:   yes
>Severity:       serious
>Priority:       medium
>Responsible:    gnats-admin
>State:          open
>Class:          sw-bug
>Submitter-Id:   unknown
>Arrival-Date:   Wed Apr  3 09:30:00 EST 2002
>Last-Modified:
>Originator:
>Organization:
>Release:
>Environment:
>Description:
>How-To-Repeat:
>Fix:
>Audit-Trail:
>Unformatted:
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_000_01C1DB1B.C8C5A300
Content-Type: text/plain;
	charset="iso-8859-1"

Hi all,

Attached is a patch for krb5-1.2.4 that includes krb524.dll in the build
process. It also fixes up krb524d.c to build under windows but does not
compile it by default. Krb524d.exe on windows will only read from the
default keyfile, but I have it working here at Bristol. If you build it, a
console app is created that does behave as advertised. I've also included
code in krb524d.c to build it as a WIN32 service, just use the WIN32SVC
switch.

One further addition is a command line switch to kinit to take a password
from the command line (new switch -w <password>) which I needed when adding
krb5 functionality to the AFS credentials GUI utility.

Two files are attached, krb5.patch and make.win. make.win should just be
copied into src/krb524. To apply the patch, just go to the top level of the
source distribution and do patch -p3 < krb5.patch

Cheers,
	Dave
                                              __  _
David Bailey                              .-.'  `; `-._  __  _
Bristol University                       (_,         .-:'  `; `-._
Email: D.Bailey at Bristol.ac.uk          ,'o"(        (_,           )
Tel:   +44 117 9546879                (__,-'      ,'o"(            )>
Fax:   +44 117 9255624                   (       (__,-'            )
                                          `-'._.--._(             )
                                             |||  |||`-'._.--._.-'
                                                        |||  |||


------_=_NextPart_000_01C1DB1B.C8C5A300
Content-Type: application/octet-stream;
	name="krb5.patch"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="krb5.patch"

*** src/Makefile.in	Thu Feb 28 01:15:15 2002=0A=
--- /h/krb5-1.2.4/src/Makefile.in	Wed Mar 20 17:00:57 2002=0A=
***************=0A=
*** 31,36 ****=0A=
--- 31,39 ----=0A=
  	@echo Making in clients=0A=
  	cd ..\clients=0A=
  	$(MAKE) -$(MFLAGS)=0A=
+ 	@echo Making in krb524=0A=
+ 	cd ..\krb524=0A=
+ 	$(MAKE) -f make.win KRB5_DLL_FILE=3D1 -$(MFLAGS)=0A=
  	@echo Making in appl\gss-sample=0A=
  	cd ..\appl\gss-sample=0A=
  	$(MAKE) -$(MFLAGS)=0A=
***************=0A=
*** 162,168 ****=0A=
  	windows\Makefile windows\lib\Makefile \=0A=
  	windows\cns\Makefile windows\gina\Makefile \=0A=
  	windows\gss\Makefile windows\ms2mit\Makefile \=0A=
! 	windows\wintel\Makefile=0A=
  =0A=
  ##DOS##Makefile-windows:: $(MKFDEP) $(WINMAKEFILES)=0A=
  =0A=
--- 165,172 ----=0A=
  	windows\Makefile windows\lib\Makefile \=0A=
  	windows\cns\Makefile windows\gina\Makefile \=0A=
  	windows\gss\Makefile windows\ms2mit\Makefile \=0A=
! 	windows\wintel\Makefile \=0A=
! 	krb524\make.win=0A=
  =0A=
  ##DOS##Makefile-windows:: $(MKFDEP) $(WINMAKEFILES)=0A=
  =0A=
***************=0A=
*** 276,281 ****=0A=
--- 280,287 ----=0A=
  ##DOS##	$(WCONFIG) config < $@.in > $@=0A=
  ##DOS##windows\wintel\Makefile: windows\wintel\Makefile.in =
$(MKFDEP)=0A=
  ##DOS##	$(WCONFIG) config < $@.in > $@=0A=
+ ##DOS##krb524\make.win:=0A=
+ ##DOS##	@echo Making krb524 make.win=0A=
  =0A=
  clean-windows:: Makefile-windows=0A=
  	@echo Making clean in util=0A=
***************=0A=
*** 327,333 ****=0A=
  	lib/krb5/error_tables/* \=0A=
  	lib/krb5/keytab/* lib/krb5/keytab/file/* lib/krb5/keytab/srvtab/* =
\=0A=
  	lib/krb5/os/* lib/krb5/posix/* lib/krb5/rcache/* \=0A=
! 	util/* util/et/* util/profile/*=0A=
  =0A=
  WINFILES=3D util/windows/* windows/* windows/lib/* windows/cns/* \=0A=
  	windows/wintel/* windows/gss/* windows/gina/* windows/ms2mit/*=0A=
--- 333,340 ----=0A=
  	lib/krb5/error_tables/* \=0A=
  	lib/krb5/keytab/* lib/krb5/keytab/file/* lib/krb5/keytab/srvtab/* =
\=0A=
  	lib/krb5/os/* lib/krb5/posix/* lib/krb5/rcache/* \=0A=
! 	util/* util/et/* util/profile/* \=0A=
! 	krb524/*=0A=
  =0A=
  WINFILES=3D util/windows/* windows/* windows/lib/* windows/cns/* \=0A=
  	windows/wintel/* windows/gss/* windows/gina/* windows/ms2mit/*=0A=
***************=0A=
*** 351,356 ****=0A=
--- 358,365 ----=0A=
  GG  =3D lib/gssapi/generic/=0A=
  GK  =3D lib/gssapi/krb5/=0A=
  PR  =3D util/profile/=0A=
+ K524 =3D krb524/=0A=
+ KA5 =3D lib/kadm5/=0A=
  =0A=
  ETOUT =3D	$(INC)asn1_err.h $(ET)asn1_err.c \=0A=
  	$(INC)kdb5_err.h $(ET)kdb5_err.c \=0A=
***************=0A=
*** 360,366 ****=0A=
  	$(INC)/kerberosIV/krb_err.h lib/krb4/krb_err.c \=0A=
  	$(PR)prof_err.h $(PR)prof_err.c \=0A=
  	$(GG)gssapi_err_generic.h $(GG)gssapi_err_generic.c \=0A=
! 	$(GK)gssapi_err_krb5.h $(GK)gssapi_err_krb5.c=0A=
  =0A=
  HOUT =3D	$(INC)krb5.h $(GG)gssapi.h $(PR)profile.h=0A=
  =0A=
--- 369,380 ----=0A=
  	$(INC)/kerberosIV/krb_err.h lib/krb4/krb_err.c \=0A=
  	$(PR)prof_err.h $(PR)prof_err.c \=0A=
  	$(GG)gssapi_err_generic.h $(GG)gssapi_err_generic.c \=0A=
! 	$(GK)gssapi_err_krb5.h $(GK)gssapi_err_krb5.c \=0A=
! 	$(K524)krb524_err.h $(K524)krb524_err.c \=0A=
! 	$(KA5)kadm_err.h $(KA5)kadm_err.c \=0A=
! 	$(KA5)adb_err.h $(KA5)adb_err.c \=0A=
! 	$(KA5)chpass_util_strings.h \=0A=
! 	$(KA5)chpass_util_strings.c=0A=
  =0A=
  HOUT =3D	$(INC)krb5.h $(GG)gssapi.h $(PR)profile.h=0A=
  =0A=
***************=0A=
*** 468,473 ****=0A=
--- 482,495 ----=0A=
  	$(AWK) -f $(AH) outfile=3D$@ $(GG)gssapi_err_generic.et=0A=
  $(GK)gssapi_err_krb5.h: $(AH) $(GK)gssapi_err_krb5.et=0A=
  	$(AWK) -f $(AH) outfile=3D$@ $(GK)gssapi_err_krb5.et=0A=
+ $(K524)krb524_err.h: $(AH) $(K524)krb524_err.et=0A=
+ 	$(AWK) -f $(AH) outfile=3D$@ $(K524)krb524_err.et=0A=
+ $(KA5)kadm_err.h: $(AH) $(KA5)kadm_err.et=0A=
+ 	$(AWK) -f $(AH) outfile=3D$@ $(KA5)kadm_err.et=0A=
+ $(KA5)adb_err.h: $(AH) $(KA5)adb_err.et=0A=
+ 	$(AWK) -f $(AH) outfile=3D$@ $(KA5)adb_err.et=0A=
+ $(KA5)chpass_util_strings.h: $(AH) $(KA5)chpass_util_strings.et=0A=
+ 	$(AWK) -f $(AH) outfile=3D$@ $(KA5)chpass_util_strings.et=0A=
  =0A=
  $(ET)asn1_err.c: $(AC) $(ET)asn1_err.et=0A=
  	$(AWK) -f $(AC) outfile=3D$@ $(ET)asn1_err.et=0A=
***************=0A=
*** 487,492 ****=0A=
--- 509,522 ----=0A=
  	$(AWK) -f $(AC) outfile=3D$@ $(GG)gssapi_err_generic.et=0A=
  $(GK)gssapi_err_krb5.c: $(AC) $(GK)gssapi_err_krb5.et=0A=
  	$(AWK) -f $(AC) outfile=3D$@ $(GK)gssapi_err_krb5.et=0A=
+ $(K524)krb524_err.c: $(AC) $(K524)krb524_err.et=0A=
+ 	$(AWK) -f $(AC) outfile=3D$@ $(K524)krb524_err.et=0A=
+ $(KA5)kadm_err.c: $(AC) $(KA5)kadm_err.et=0A=
+ 	$(AWK) -f $(AC) outfile=3D$@ $(KA5)kadm_err.et=0A=
+ $(KA5)adb_err.c: $(AC) $(KA5)adb_err.et=0A=
+ 	$(AWK) -f $(AC) outfile=3D$@ $(KA5)adb_err.et=0A=
+ $(KA5)chpass_util_strings.c: $(AC) $(KA5)chpass_util_strings.et=0A=
+ 	$(AWK) -f $(AC) outfile=3D$@ $(KA5)chpass_util_strings.et=0A=
  =0A=
  KRBHDEP =3D $(INC)krb5.hin $(INC)krb5_err.h $(INC)kdb5_err.h \=0A=
  	$(INC)kv5m_err.h $(INC)asn1_err.h=0A=
*** src/clients/kinit/kinit.c	Thu Feb 28 01:15:18 2002=0A=
--- /h/krb5-1.2.4/src/clients/kinit/kinit.c	Tue Apr  2 15:12:25 2002=0A=
***************=0A=
*** 182,187 ****=0A=
--- 182,189 ----=0A=
  #define GETOPT(argc, argv, str) getopt(argc, argv, str)=0A=
  #endif=0A=
  =0A=
+ char *pszPassword =3D (char *)0;=0A=
+ =0A=
  void=0A=
  usage(void)=0A=
  {=0A=
***************=0A=
*** 277,283 ****=0A=
      int use_k5 =3D 0;=0A=
      int i;=0A=
  =0A=
!     while ((i =3D GETOPT(argc, argv, "r:fpFP54AVl:s:c:kt:RS:v"))=0A=
  	   !=3D -1) {=0A=
  	switch (i) {=0A=
  	case 'V':=0A=
--- 279,285 ----=0A=
      int use_k5 =3D 0;=0A=
      int i;=0A=
  =0A=
!     while ((i =3D GETOPT(argc, argv, =
"r:fpFP54AVl:s:c:kt:RS:v:w:"))=0A=
  	   !=3D -1) {=0A=
  	switch (i) {=0A=
  	case 'V':=0A=
***************=0A=
*** 397,402 ****=0A=
--- 399,407 ----=0A=
  	    }=0A=
  	    use_k5 =3D 1;=0A=
  	    break;=0A=
+ 	case 'w':=0A=
+ 	  pszPassword =3D optarg;=0A=
+ 	  break;=0A=
  	default:=0A=
  	    errflg++;=0A=
  	    break;=0A=
***************=0A=
*** 776,783 ****=0A=
--- 781,796 ----=0A=
  =0A=
      switch (opts->action) {=0A=
      case INIT_PW:=0A=
+       if (pszPassword =3D=3D (char *)0)=0A=
  	code =3D krb5_get_init_creds_password(k5->ctx, &my_creds, k5->me,=0A=
  					    0, kinit_prompter, 0,=0A=
+ 					    opts->starttime, =0A=
+ 					    opts->service_name,=0A=
+ 					    &options);=0A=
+       else=0A=
+ 	code =3D krb5_get_init_creds_password(k5->ctx, &my_creds, k5->me,=0A=
+ 					    pszPassword, =0A=
+ 					    kinit_prompter, 0,=0A=
  					    opts->starttime, =0A=
  					    opts->service_name,=0A=
  					    &options);=0A=
*** src/include/k5-int.h	Thu Feb 28 01:15:19 2002=0A=
--- /h/krb5-1.2.4/src/include/k5-int.h	Tue Mar 26 14:08:16 2002=0A=
***************=0A=
*** 409,416 ****=0A=
  #ifndef KRB5_EXT_PROTO__=0A=
  #define KRB5_EXT_PROTO__=0A=
  =0A=
! #ifdef HAVE_STDLIB_H=0A=
  #include <stdlib.h>=0A=
  #else=0A=
  #if defined(__STDC__) || defined(_MSDOS)=0A=
  #include <fake-stdlib.h>=0A=
--- 409,419 ----=0A=
  #ifndef KRB5_EXT_PROTO__=0A=
  #define KRB5_EXT_PROTO__=0A=
  =0A=
! #if defined(HAVE_STDLIB_H) || defined(_WIN32) =0A=
  #include <stdlib.h>=0A=
+ #ifdef _WIN32=0A=
+ #include <malloc.h>=0A=
+ #endif=0A=
  #else=0A=
  #if defined(__STDC__) || defined(_MSDOS)=0A=
  #include <fake-stdlib.h>=0A=
***************=0A=
*** 1534,1540 ****=0A=
--- 1537,1547 ----=0A=
  int krb5_seteuid  KRB5_PROTOTYPE((int));=0A=
  =0A=
  /* to keep lint happy */=0A=
+ #ifndef _WIN32=0A=
  #define krb5_xfree(val) free((char FAR *)(val))=0A=
+ #else=0A=
+ #define krb5_xfree(val) free((void *)(val))=0A=
+ #endif=0A=
  =0A=
  #if KRB5_CCACHE_ACCESSOR_FUNCTIONS=0A=
  /* temporary -- this should be under lib/krb5/ccache somewhere */=0A=
*** src/include/krb5/kdb.h	Thu Feb 28 01:15:19 2002=0A=
--- /h/krb5-1.2.4/src/include/krb5/kdb.h	Wed Mar 20 17:35:40 2002=0A=
***************=0A=
*** 84,90 ****=0A=
  #define KRB5_KDB_CREATE_BTREE		0x00000001=0A=
  #define KRB5_KDB_CREATE_HASH		0x00000002=0A=
  =0A=
! #if !defined(macintosh) && !defined(_MSDOS) && !defined(_WIN32) && =
!defined(__MACH__)=0A=
  =0A=
  /*=0A=
   * Note --- these structures cannot be modified without changing =
the=0A=
--- 84,90 ----=0A=
  #define KRB5_KDB_CREATE_BTREE		0x00000001=0A=
  #define KRB5_KDB_CREATE_HASH		0x00000002=0A=
  =0A=
! #if !defined(macintosh) && !defined(_MSDOS) && !defined(__MACH__)=0A=
  =0A=
  /*=0A=
   * Note --- these structures cannot be modified without changing =
the=0A=
***************=0A=
*** 406,411 ****=0A=
--- 406,413 ----=0A=
   =0A=
  #define KRB5_KDB_DEF_FLAGS	0=0A=
  =0A=
+ #if !defined(_WIN32)=0A=
+ =0A=
  #ifdef KRB5_OLD_AND_KRUFTY=0A=
  /* this is the same structure as krb5_keyblock, but with a different =
name to=0A=
     enable compile-time catching of programmer confusion between =
encrypted &=0A=
***************=0A=
*** 450,455 ****=0A=
--- 452,458 ----=0A=
  } krb5_db_entry_OLD;=0A=
  =0A=
  #endif	/* OLD_AND_KRUFTY */=0A=
+ #endif /* _WIN32 */=0A=
  =0A=
  /* This is now a structure that is private to the database backend. =
*/=0A=
  #ifdef notdef=0A=
*** src/krb524/cnv_tkt_skey.c	Thu Feb 28 01:15:27 2002=0A=
--- /h/krb5-1.2.4/src/krb524/cnv_tkt_skey.c	Tue Mar 26 14:20:14 2002=0A=
***************=0A=
*** 22,33 ****=0A=
--- 22,48 ----=0A=
  =0A=
  #include "k5-int.h"		/* we need krb5_context::clockskew */=0A=
  #include <stdio.h>=0A=
+ #ifdef _WIN32=0A=
+ #include <ctype.h>=0A=
+ #include <time.h>=0A=
+ #include "com_err.h"=0A=
+ #else /* !_WIN32 */=0A=
  #include <sys/types.h>=0A=
  #include <sys/time.h>=0A=
  #include <netinet/in.h>=0A=
+ #endif /* _WIN32 */=0A=
  #include <krb.h>=0A=
  #include "krb524.h"=0A=
  =0A=
+ #ifdef _WIN32=0A=
+ int krb_create_ticket(KTEXT,unsigned char,char *,char *,=0A=
+ 		      char *,long,char *,short,long,char *,=0A=
+ 		      char *,C_Block);=0A=
+ int krb_cr_tkt_krb5(KTEXT,unsigned char,char *,char *,=0A=
+ 		    char *,long,char *,short,long,char *,=0A=
+ 		    char *,krb5_keyblock *);=0A=
+ #endif=0A=
+ =0A=
  /* rather than copying the cmu code, these values are derived from=0A=
     a calculation based on the table and comments found there.=0A=
     the expression (in elisp) is:=0A=
***************=0A=
*** 54,60 ****=0A=
   * Convert a v5 ticket for server to a v4 ticket, using service =
key=0A=
   * skey for both.=0A=
   */=0A=
! int krb524_convert_tkt_skey(context, v5tkt, v4tkt, v5_skey, =
v4_skey,=0A=
  			    saddr)=0A=
       krb5_context context;=0A=
       krb5_ticket *v5tkt;=0A=
--- 69,75 ----=0A=
   * Convert a v5 ticket for server to a v4 ticket, using service =
key=0A=
   * skey for both.=0A=
   */=0A=
! int KRB5_DLLIMP krb524_convert_tkt_skey(context, v5tkt, v4tkt, =
v5_skey, v4_skey,=0A=
  			    saddr)=0A=
       krb5_context context;=0A=
       krb5_ticket *v5tkt;=0A=
*** src/krb524/conv_creds.c	Thu Feb 28 01:15:27 2002=0A=
--- /h/krb5-1.2.4/src/krb524/conv_creds.c	Tue Mar 26 14:51:28 2002=0A=
***************=0A=
*** 20,35 ****=0A=
   * PERFORMANCE OF THIS SOFTWARE.=0A=
   */=0A=
  =0A=
  #include "krb5.h"=0A=
  #include <stdio.h>=0A=
  #include <string.h>=0A=
  #include <sys/types.h>=0A=
  #include <netinet/in.h>=0A=
  #include <krb.h>=0A=
  =0A=
  #include "krb524.h"=0A=
  =0A=
! krb5_error_code krb524_convert_creds_plain=0A=
  KRB5_PROTOTYPE((krb5_context context, krb5_creds *v5creds, =0A=
  		   CREDENTIALS *v4creds));=0A=
  =0A=
--- 20,45 ----=0A=
   * PERFORMANCE OF THIS SOFTWARE.=0A=
   */=0A=
  =0A=
+ #ifdef _WIN32=0A=
+ #include <winsock2.h>=0A=
+ #include <com_err.h>=0A=
+ #endif /* _WIN32 */=0A=
  #include "krb5.h"=0A=
  #include <stdio.h>=0A=
+ #ifndef _WIN32=0A=
  #include <string.h>=0A=
  #include <sys/types.h>=0A=
  #include <netinet/in.h>=0A=
+ #endif /* _WIN32 */=0A=
  #include <krb.h>=0A=
  =0A=
  #include "krb524.h"=0A=
  =0A=
! #ifdef _WIN32=0A=
! #include <k5-int.h>=0A=
! #endif /* _WIN32 */=0A=
! =0A=
! krb5_error_code KRB5_DLLIMP krb524_convert_creds_plain=0A=
  KRB5_PROTOTYPE((krb5_context context, krb5_creds *v5creds, =0A=
  		   CREDENTIALS *v4creds));=0A=
  =0A=
***************=0A=
*** 37,43 ****=0A=
  KRB5_PROTOTYPE((krb5_context context, const krb5_data *message,=0A=
  		krb5_data *realm, krb5_data *reply));=0A=
  =0A=
! krb5_error_code=0A=
  krb524_convert_creds_kdc(context, v5creds, v4creds)=0A=
       krb5_context context;=0A=
       krb5_creds *v5creds;=0A=
--- 47,53 ----=0A=
  KRB5_PROTOTYPE((krb5_context context, const krb5_data *message,=0A=
  		krb5_data *realm, krb5_data *reply));=0A=
  =0A=
! krb5_error_code KRB5_DLLIMP=0A=
  krb524_convert_creds_kdc(context, v5creds, v4creds)=0A=
       krb5_context context;=0A=
       krb5_creds *v5creds;=0A=
***************=0A=
*** 113,119 ****=0A=
  }=0A=
  #endif=0A=
  =0A=
! krb5_error_code=0A=
  krb524_convert_creds_plain(context, v5creds, v4creds)=0A=
       krb5_context context;=0A=
       krb5_creds *v5creds;=0A=
--- 123,129 ----=0A=
  }=0A=
  #endif=0A=
  =0A=
! krb5_error_code KRB5_DLLIMP=0A=
  krb524_convert_creds_plain(context, v5creds, v4creds)=0A=
       krb5_context context;=0A=
       krb5_creds *v5creds;=0A=
*** src/krb524/conv_princ.c	Thu Feb 28 01:15:27 2002=0A=
--- /h/krb5-1.2.4/src/krb524/conv_princ.c	Wed Mar 20 17:00:55 2002=0A=
***************=0A=
*** 22,31 ****=0A=
--- 22,33 ----=0A=
  =0A=
  #include "krb5.h"=0A=
  #include <stdio.h>=0A=
+ #ifndef _WIN32=0A=
  #include <sys/types.h>=0A=
  #include <sys/time.h>=0A=
  #include <sys/signal.h>=0A=
  #include <netinet/in.h>=0A=
+ #endif /* _WIN32 */=0A=
  =0A=
  #include <krb.h>=0A=
  =0A=
Only in /h/krb5-1.2.4/src/krb524: conv_princ.obj=0A=
diff -r -c src/krb524/encode.c /h/krb5-1.2.4/src/krb524/encode.c=0A=
*** src/krb524/encode.c	Thu Feb 28 01:15:27 2002=0A=
--- /h/krb5-1.2.4/src/krb524/encode.c	Tue Mar 26 14:21:46 2002=0A=
***************=0A=
*** 24,33 ****=0A=
--- 24,35 ----=0A=
  #include <stdio.h>=0A=
  #include <string.h>=0A=
  #include <signal.h>=0A=
+ #ifndef _WIN32=0A=
  #include <sys/types.h>=0A=
  #include <sys/time.h>=0A=
  #include <sys/signal.h>=0A=
  #include <netinet/in.h>=0A=
+ #endif /* _WIN32 */=0A=
  =0A=
  #include <krb.h>=0A=
  #include "krb524.h"=0A=
***************=0A=
*** 72,78 ****=0A=
       return encode_bytes(out, outlen, (char *) &nv, sizeof(nv));=0A=
  }=0A=
  =0A=
! int encode_v4tkt(v4tkt, buf, encoded_len)=0A=
       KTEXT_ST *v4tkt;=0A=
       char *buf;=0A=
       int *encoded_len;=0A=
--- 74,80 ----=0A=
       return encode_bytes(out, outlen, (char *) &nv, sizeof(nv));=0A=
  }=0A=
  =0A=
! int KRB5_DLLIMP encode_v4tkt(v4tkt, buf, encoded_len)=0A=
       KTEXT_ST *v4tkt;=0A=
       char *buf;=0A=
       int *encoded_len;=0A=
*** src/krb524/k524init.c	Thu Feb 28 01:15:27 2002=0A=
--- /h/krb5-1.2.4/src/krb524/k524init.c	Mon Mar 25 12:00:12 2002=0A=
***************=0A=
*** 25,41 ****=0A=
--- 25,51 ----=0A=
  =0A=
  #include <stdio.h>=0A=
  #include <string.h>=0A=
+ #ifndef _WIN32=0A=
  #include <signal.h>=0A=
+ #endif /* _WIN32 */=0A=
  #include <sys/types.h>=0A=
+ #ifndef _WIN32=0A=
  #include <sys/time.h>=0A=
  #include <sys/signal.h>=0A=
  #include <netinet/in.h>=0A=
+ #else=0A=
+ #include <time.h>=0A=
+ #endif /* _WIN32 */=0A=
  =0A=
  #include <krb.h>=0A=
  #include "krb524.h"=0A=
  =0A=
+ #ifndef _WIN32=0A=
  extern int optind;=0A=
  extern char *optarg;=0A=
+ #else=0A=
+ #include <getopt.h>=0A=
+ #endif=0A=
  =0A=
  int main(argc, argv)=0A=
       int argc;=0A=
*** src/krb524/krb524.h	Thu Feb 28 01:15:27 2002=0A=
--- /h/krb5-1.2.4/src/krb524/krb524.h	Tue Mar 26 14:32:24 2002=0A=
***************=0A=
*** 26,43 ****=0A=
  #define KRB524_SERVICE "krb524"=0A=
  #define KRB524_PORT 4444=0A=
  =0A=
  #include "krb524_err.h"=0A=
  =0A=
  extern int krb524_debug;=0A=
  =0A=
! int krb524_convert_tkt_skey=0A=
  	KRB5_PROTOTYPE((krb5_context context, krb5_ticket *v5tkt, KTEXT_ST =
*v4tkt, =0A=
  		   krb5_keyblock *v5_skey, krb5_keyblock *v4_skey,=0A=
  			struct sockaddr_in *saddr));=0A=
  =0A=
  /* conv_princ.c */=0A=
  =0A=
! int krb524_convert_princs=0A=
  	KRB5_PROTOTYPE((krb5_context context, krb5_principal client, =0A=
  		   krb5_principal server, char *pname, =0A=
  		   char *pinst, char *prealm, char *sname, char *sinst));=0A=
--- 26,47 ----=0A=
  #define KRB524_SERVICE "krb524"=0A=
  #define KRB524_PORT 4444=0A=
  =0A=
+ #ifndef _WIN32=0A=
+ #include <win-mac.h>=0A=
+ #endif=0A=
+ =0A=
  #include "krb524_err.h"=0A=
  =0A=
  extern int krb524_debug;=0A=
  =0A=
! int KRB5_DLLIMP krb524_convert_tkt_skey=0A=
  	KRB5_PROTOTYPE((krb5_context context, krb5_ticket *v5tkt, KTEXT_ST =
*v4tkt, =0A=
  		   krb5_keyblock *v5_skey, krb5_keyblock *v4_skey,=0A=
  			struct sockaddr_in *saddr));=0A=
  =0A=
  /* conv_princ.c */=0A=
  =0A=
! int KRB5_DLLIMP krb524_convert_princs=0A=
  	KRB5_PROTOTYPE((krb5_context context, krb5_principal client, =0A=
  		   krb5_principal server, char *pname, =0A=
  		   char *pinst, char *prealm, char *sname, char *sinst));=0A=
***************=0A=
*** 48,54 ****=0A=
  	KRB5_PROTOTYPE((krb5_context context, krb5_creds *v5creds, =0A=
  		   CREDENTIALS *v4creds, struct sockaddr *saddr));=0A=
  =0A=
! int krb524_convert_creds_kdc=0A=
  	KRB5_PROTOTYPE((krb5_context context, krb5_creds *v5creds, =0A=
  		   CREDENTIALS *v4creds));=0A=
  =0A=
--- 52,58 ----=0A=
  	KRB5_PROTOTYPE((krb5_context context, krb5_creds *v5creds, =0A=
  		   CREDENTIALS *v4creds, struct sockaddr *saddr));=0A=
  =0A=
! int KRB5_DLLIMP krb524_convert_creds_kdc=0A=
  	KRB5_PROTOTYPE((krb5_context context, krb5_creds *v5creds, =0A=
  		   CREDENTIALS *v4creds));=0A=
  =0A=
***************=0A=
*** 60,66 ****=0A=
  =0A=
  /* encode.c */=0A=
  =0A=
! int encode_v4tkt=0A=
  	KRB5_PROTOTYPE((KTEXT_ST *v4tkt, char *buf, int *encoded_len));=0A=
  =0A=
  int decode_v4tkt=0A=
--- 64,70 ----=0A=
  =0A=
  /* encode.c */=0A=
  =0A=
! int KRB5_DLLIMP encode_v4tkt=0A=
  	KRB5_PROTOTYPE((KTEXT_ST *v4tkt, char *buf, int *encoded_len));=0A=
  =0A=
  int decode_v4tkt=0A=
***************=0A=
*** 69,75 ****=0A=
  =0A=
  /* misc.c */=0A=
  =0A=
! void krb524_init_ets=0A=
  	KRB5_PROTOTYPE((krb5_context context));=0A=
  =0A=
  /* sendmsg.c */=0A=
--- 73,79 ----=0A=
  =0A=
  /* misc.c */=0A=
  =0A=
! void KRB5_DLLIMP krb524_init_ets=0A=
  	KRB5_PROTOTYPE((krb5_context context));=0A=
  =0A=
  /* sendmsg.c */=0A=
*** src/krb524/krb524d.c	Thu Feb 28 01:15:27 2002=0A=
--- /h/krb5-1.2.4/src/krb524/krb524d.c	Wed Apr  3 14:53:51 2002=0A=
***************=0A=
*** 29,39 ****=0A=
--- 29,44 ----=0A=
  #include <sys/select.h>=0A=
  #endif=0A=
  #include <string.h>=0A=
+ #ifndef _WIN32=0A=
  #include <signal.h>=0A=
  #include <sys/types.h>=0A=
  #include <sys/time.h>=0A=
  #include <sys/signal.h>=0A=
  #include <netinet/in.h>=0A=
+ #else=0A=
+ #include <stdlib.h>=0A=
+ #include <malloc.h>=0A=
+ #endif=0A=
  =0A=
  #include <krb.h>=0A=
  #include "krb524.h"=0A=
***************=0A=
*** 51,56 ****=0A=
--- 56,71 ----=0A=
  char *keytab =3D NULL;=0A=
  krb5_keytab kt;=0A=
  =0A=
+ #if defined(_WIN32) && defined(WIN32SVC)=0A=
+ SERVICE_STATUS        ssServiceStatus;=0A=
+ SERVICE_STATUS_HANDLE sshServiceStatus;=0A=
+ VOID ServiceCtrlHandler(DWORD);=0A=
+ #define WIN32SVCRTN return;=0A=
+ #endif=0A=
+ #ifndef WIN32SVCRTN=0A=
+ #define WIN32SVCRTN=0A=
+ #endif=0A=
+ =0A=
  void init_keytab(), init_master(), cleanup_and_exit();=0A=
  krb5_error_code do_connection(), lookup_service_key(), =
kdc_get_server_key();=0A=
  =0A=
***************=0A=
*** 61,70 ****=0A=
--- 76,112 ----=0A=
       cleanup_and_exit(1, context);=0A=
  }=0A=
  =0A=
+ #ifndef _WIN32=0A=
  RETSIGTYPE request_exit(signo)=0A=
       int signo;=0A=
+ #else=0A=
+ #ifndef WIN32SVC=0A=
+ BOOL WINAPI request_exit(DWORD signo)=0A=
+ #else=0A=
+ void request_exit(void)=0A=
+ #endif=0A=
+ #endif=0A=
  {=0A=
+ #ifdef _WIN32=0A=
+ #ifndef WIN32SVC=0A=
+      switch (signo)=0A=
+      {=0A=
+        case CTRL_CLOSE_EVENT:=0A=
+        case CTRL_C_EVENT:=0A=
+ #endif=0A=
+ #endif=0A=
       signalled =3D 1;=0A=
+ #ifdef _WIN32=0A=
+ #ifndef WIN32SVC=0A=
+          return(TRUE);=0A=
+          break;=0A=
+        default:=0A=
+ 	 return(FALSE);=0A=
+      }=0A=
+ #else=0A=
+      Sleep(TIMEOUT*1000);=0A=
+ #endif=0A=
+ #endif=0A=
  }=0A=
  =0A=
  #if 0=0A=
***************=0A=
*** 79,87 ****=0A=
--- 121,133 ----=0A=
  }=0A=
  #endif=0A=
  =0A=
+ #ifndef WIN32SVC=0A=
  int main(argc, argv)=0A=
       int argc;=0A=
       char **argv;=0A=
+ #else=0A=
+ VOID ServiceMain(DWORD argc, LPTSTR *argv)=0A=
+ #endif=0A=
  {=0A=
       struct servent *serv;=0A=
       struct sockaddr_in saddr;=0A=
***************=0A=
*** 92,101 ****=0A=
--- 138,171 ----=0A=
       krb5_error_code retval;=0A=
       kadm5_config_params config_params;=0A=
  =0A=
+ #if defined(_WIN32) && defined(WIN32SVC)=0A=
+      ssServiceStatus.dwServiceType        =3D =
SERVICE_WIN32_OWN_PROCESS; =0A=
+      ssServiceStatus.dwCurrentState       =3D SERVICE_START_PENDING; =
=0A=
+      ssServiceStatus.dwControlsAccepted   =3D SERVICE_ACCEPT_STOP; =
=0A=
+      ssServiceStatus.dwWin32ExitCode      =3D 0; =0A=
+      ssServiceStatus.dwServiceSpecificExitCode =3D 0; =0A=
+      ssServiceStatus.dwCheckPoint         =3D 0; =0A=
+      ssServiceStatus.dwWaitHint           =3D 0;=0A=
+ =0A=
+      hssServiceStatus =3D RegisterServiceCtrlHandler("krb524",=0A=
+ 						   ServiceCtrlHandler);=0A=
+      if (hssServiceStatus =3D=3D (SERVICE_STATUS_HANDLE)0) return;=0A=
+ #endif=0A=
+ =0A=
       retval =3D krb5_init_context(&context);=0A=
       if (retval) {=0A=
+ #ifndef WIN32SVC=0A=
  	     com_err(argv[0], retval, "while initializing krb5");=0A=
  	     exit(1);=0A=
+ #else=0A=
+ 	     ssServiceStatus.dwCurrentState       =3D SERVICE_STOPPED; =0A=
+ 	     ssServiceStatus.dwCheckPoint         =3D 0; =0A=
+ 	     ssServiceStatus.dwWaitHint           =3D 0; =0A=
+ 	     ssServiceStatus.dwWin32ExitCode      =3D retval; =0A=
+ 	     ssServiceStatus.dwServiceSpecificExitCode =3D retval; =0A=
+ 	     SetServiceStatus (sshServiceStatus, &ssServiceStatus); =0A=
+ 	     return;=0A=
+ #endif=0A=
       }=0A=
  =0A=
       whoami =3D ((whoami =3D strrchr(argv[0], '/')) ? whoami + 1 : =
argv[0]);=0A=
***************=0A=
*** 103,110 ****=0A=
       argv++; argc--;=0A=
       use_master =3D use_keytab =3D nofork =3D 0;=0A=
       config_params.mask =3D 0;=0A=
!      =0A=
       while (argc) {=0A=
  	  if (strncmp(*argv, "-k", 2) =3D=3D 0)=0A=
  	       use_keytab =3D 1;=0A=
  	  else if (strncmp(*argv, "-m", 2) =3D=3D 0)=0A=
--- 173,181 ----=0A=
       argv++; argc--;=0A=
       use_master =3D use_keytab =3D nofork =3D 0;=0A=
       config_params.mask =3D 0;=0A=
! =0A=
       while (argc) {=0A=
+ #ifndef _WIN32     =0A=
  	  if (strncmp(*argv, "-k", 2) =3D=3D 0)=0A=
  	       use_keytab =3D 1;=0A=
  	  else if (strncmp(*argv, "-m", 2) =3D=3D 0)=0A=
***************=0A=
*** 120,137 ****=0A=
  	  }=0A=
  	  else=0A=
  	       break;=0A=
  	  argv++; argc--;=0A=
       }=0A=
       if (argc || use_keytab + use_master > 1 ||=0A=
  	 use_keytab + use_master =3D=3D 0) {=0A=
  	  use_keytab =3D use_master =3D 0;=0A=
  	  usage(context);=0A=
       }=0A=
!      =0A=
       signal(SIGINT, request_exit);=0A=
       signal(SIGHUP, SIG_IGN);=0A=
       signal(SIGTERM, request_exit);=0A=
! =0A=
       if (use_keytab)=0A=
  	  init_keytab(context);=0A=
       if (use_master)=0A=
--- 191,219 ----=0A=
  	  }=0A=
  	  else=0A=
  	       break;=0A=
+ #endif=0A=
  	  argv++; argc--;=0A=
       }=0A=
+ #ifdef _WIN32=0A=
+      use_keytab =3D 1;=0A=
+      use_master =3D 0;=0A=
+      nofork     =3D 1;=0A=
+ #endif=0A=
+ =0A=
       if (argc || use_keytab + use_master > 1 ||=0A=
  	 use_keytab + use_master =3D=3D 0) {=0A=
  	  use_keytab =3D use_master =3D 0;=0A=
  	  usage(context);=0A=
       }=0A=
! #ifndef _WIN32     =0A=
       signal(SIGINT, request_exit);=0A=
       signal(SIGHUP, SIG_IGN);=0A=
       signal(SIGTERM, request_exit);=0A=
! #else=0A=
! #ifndef WIN32SVC=0A=
!      SetConsoleCtrlHandler(request_exit,TRUE);=0A=
! #endif=0A=
! #endif=0A=
       if (use_keytab)=0A=
  	  init_keytab(context);=0A=
       if (use_master)=0A=
***************=0A=
*** 142,165 ****=0A=
--- 224,269 ----=0A=
       saddr.sin_addr.s_addr =3D INADDR_ANY;=0A=
       serv =3D getservbyname(KRB524_SERVICE, "udp");=0A=
       if (serv =3D=3D NULL) {=0A=
+ #ifndef WIN32SVC=0A=
  	  com_err(whoami, 0, "service entry not found, using %d", =
KRB524_PORT);=0A=
+ #endif=0A=
  	  saddr.sin_port =3D htons(KRB524_PORT);=0A=
       } else=0A=
  	  saddr.sin_port =3D serv->s_port;=0A=
  	  =0A=
       if ((s =3D socket(AF_INET, SOCK_DGRAM, 0)) < 0) {=0A=
+ #ifndef WIN32SVC=0A=
  	  com_err(whoami, errno, "creating main socket");=0A=
+ #endif=0A=
  	  cleanup_and_exit(1, context);=0A=
+ 	  WIN32SVCRTN=0A=
       }=0A=
       if ((ret =3D bind(s, (struct sockaddr *) &saddr,=0A=
  		     sizeof(struct sockaddr_in))) < 0) {=0A=
+ #ifndef WIN32SVC=0A=
  	  com_err(whoami, errno, "binding main socket");=0A=
+ #endif=0A=
  	  cleanup_and_exit(1, context);=0A=
+ 	  WIN32SVCRTN=0A=
       }=0A=
+ #ifndef _WIN32=0A=
       if (!nofork && daemon(0, 0)) {=0A=
  	  com_err(whoami, errno, "while detaching from tty");=0A=
  	  cleanup_and_exit(1, context);=0A=
+ 	  WIN32SVCRTN=0A=
       }=0A=
+ #else=0A=
+ #ifdef WIN32SVC=0A=
+     ssServiceStatus.dwCurrentState       =3D SERVICE_RUNNING; =0A=
+     ssServiceStatus.dwCheckPoint         =3D 0; =0A=
+     ssServiceStatus.dwWaitHint           =3D 0; =0A=
+  =0A=
+     if (!SetServiceStatus (MyServiceStatusHandle, &MyServiceStatus)) =
=0A=
+     { =0A=
+       return;=0A=
+     }=0A=
+ #endif=0A=
+ #endif=0A=
       =0A=
       while (1) {=0A=
  	  FD_ZERO(&rfds);=0A=
***************=0A=
*** 168,197 ****=0A=
  	  timeout.tv_usec =3D 0;=0A=
  =0A=
  	  ret =3D select(s+1, &rfds, NULL, NULL, &timeout);=0A=
! 	  if (signalled)=0A=
  	       cleanup_and_exit(0, context);=0A=
  	  else if (ret =3D=3D 0) {=0A=
  	       if (use_master) {=0A=
  		    ret =3D kadm5_flush(handle);=0A=
  		    if (ret && ret !=3D KRB5_KDB_DBNOTINITED) {=0A=
  			 com_err(whoami, ret, "closing kerberos database");=0A=
  			 cleanup_and_exit(1, context);=0A=
  		    }=0A=
  	       }=0A=
  	  } else if (ret < 0 && errno !=3D EINTR) {=0A=
  	       com_err(whoami, errno, "in select");=0A=
  	       cleanup_and_exit(1, context);=0A=
  	  } else if (FD_ISSET(s, &rfds)) {=0A=
  	       if (debug)=0A=
  		    printf("received packet\n");=0A=
  	       if ((ret =3D do_connection(s, context))) {=0A=
  		    com_err(whoami, ret, "handling packet");=0A=
  	       }=0A=
  	  } else=0A=
  	       com_err(whoami, 0, "impossible situation occurred!");=0A=
       }=0A=
  =0A=
       cleanup_and_exit(0, context);=0A=
  }=0A=
  =0A=
  void cleanup_and_exit(ret, context)=0A=
--- 272,318 ----=0A=
  	  timeout.tv_usec =3D 0;=0A=
  =0A=
  	  ret =3D select(s+1, &rfds, NULL, NULL, &timeout);=0A=
! 	  if (signalled) {=0A=
  	       cleanup_and_exit(0, context);=0A=
+ 	       WIN32SVCRTN=0A=
+ 		 }=0A=
  	  else if (ret =3D=3D 0) {=0A=
  	       if (use_master) {=0A=
+ #ifndef _WIN32=0A=
  		    ret =3D kadm5_flush(handle);=0A=
  		    if (ret && ret !=3D KRB5_KDB_DBNOTINITED) {=0A=
  			 com_err(whoami, ret, "closing kerberos database");=0A=
  			 cleanup_and_exit(1, context);=0A=
+ 			 WIN32SVCRTN=0A=
  		    }=0A=
+ #endif=0A=
  	       }=0A=
+ #ifndef _WIN32=0A=
  	  } else if (ret < 0 && errno !=3D EINTR) {=0A=
+ #else=0A=
+ 	  } else if (ret =3D=3D SOCKET_ERROR && WSAGetLastError() !=3D =
WSAEINTR) {=0A=
+ #endif=0A=
+ #ifndef WIN32SVC=0A=
  	       com_err(whoami, errno, "in select");=0A=
+ #endif=0A=
  	       cleanup_and_exit(1, context);=0A=
+ 	       WIN32SVCRTN=0A=
  	  } else if (FD_ISSET(s, &rfds)) {=0A=
  	       if (debug)=0A=
  		    printf("received packet\n");=0A=
  	       if ((ret =3D do_connection(s, context))) {=0A=
+ #ifndef WIN32SVC=0A=
  		    com_err(whoami, ret, "handling packet");=0A=
+ #endif=0A=
  	       }=0A=
  	  } else=0A=
+ #ifndef WIN32SVC=0A=
  	       com_err(whoami, 0, "impossible situation occurred!");=0A=
+ #endif=0A=
       }=0A=
  =0A=
       cleanup_and_exit(0, context);=0A=
+      WIN32SVCRTN=0A=
  }=0A=
  =0A=
  void cleanup_and_exit(ret, context)=0A=
***************=0A=
*** 199,209 ****=0A=
--- 320,334 ----=0A=
       krb5_context context;=0A=
  {=0A=
       if (use_master) {=0A=
+ #ifndef _WIN32=0A=
  	  (void) kadm5_destroy(handle);=0A=
+ #endif=0A=
       }=0A=
       if (use_keytab && kt) krb5_kt_close(context, kt);=0A=
       krb5_free_context(context);=0A=
+ #ifndef WIN32SVC=0A=
       exit(ret);=0A=
+ #endif=0A=
  }=0A=
  =0A=
  void init_keytab(context)=0A=
***************=0A=
*** 213,220 ****=0A=
--- 338,348 ----=0A=
       use_keytab =3D 0;=0A=
       if (keytab =3D=3D NULL) {=0A=
  	  if ((ret =3D krb5_kt_default(context, &kt))) {=0A=
+ #ifndef WIN32SVC=0A=
  	       com_err(whoami, ret, "while opening default keytab");=0A=
+ #endif=0A=
  	       cleanup_and_exit(1, context);=0A=
+ 	       WIN32SVCRTN=0A=
  	  }=0A=
       } else {=0A=
  	  if ((ret =3D krb5_kt_resolve(context, keytab, &kt))) {=0A=
***************=0A=
*** 230,238 ****=0A=
       krb5_context context;=0A=
       kadm5_config_params *params;=0A=
  {=0A=
       int ret;=0A=
! =0A=
       use_master =3D 0;=0A=
       if ((ret =3D kadm5_init(whoami, NULL, KADM5_ADMIN_SERVICE, =
params,=0A=
  			   KADM5_STRUCT_VERSION, KADM5_API_VERSION_2,=0A=
  			   &handle))) {=0A=
--- 358,368 ----=0A=
       krb5_context context;=0A=
       kadm5_config_params *params;=0A=
  {=0A=
+ #ifndef _WIN32=0A=
       int ret;=0A=
! #endif=0A=
       use_master =3D 0;=0A=
+ #ifndef _WIN32=0A=
       if ((ret =3D kadm5_init(whoami, NULL, KADM5_ADMIN_SERVICE, =
params,=0A=
  			   KADM5_STRUCT_VERSION, KADM5_API_VERSION_2,=0A=
  			   &handle))) {=0A=
***************=0A=
*** 240,249 ****=0A=
--- 370,384 ----=0A=
  	  cleanup_and_exit(1, context);=0A=
       }=0A=
       use_master =3D 1;		/* now safe to close kadm5 */=0A=
+ #endif=0A=
  }=0A=
  =0A=
  krb5_error_code do_connection(s, context)=0A=
+ #ifndef _WIN32=0A=
       int s;=0A=
+ #else=0A=
+      SOCKET s;=0A=
+ #endif=0A=
       krb5_context context;=0A=
  {=0A=
       struct sockaddr saddr;=0A=
***************=0A=
*** 261,277 ****=0A=
--- 396,429 ----=0A=
       msgdata.data =3D msgbuf;=0A=
       msgdata.length =3D MSGSIZE;=0A=
  =0A=
+      memset(msgbuf,0,MSGSIZE);=0A=
+ =0A=
       saddrlen =3D sizeof(struct sockaddr);=0A=
       ret =3D recvfrom(s, msgdata.data, msgdata.length, 0, &saddr, =
&saddrlen);=0A=
+ #ifndef _WIN32=0A=
       if (ret < 0) {=0A=
+ #else=0A=
+      if (ret =3D=3D SOCKET_ERROR) {=0A=
+ #endif=0A=
         /* if recvfrom fails, we probably don't have a valid saddr to =
=0A=
  	  use for the reply, so don't even try to respond. */=0A=
+ #ifndef _WIN32=0A=
         return errno;=0A=
+ #else=0A=
+        if (debug)=0A=
+ 	 printf("recvfrom failed. Error %d\n",WSAGetLastError());=0A=
+        return WSAGetLastError();=0A=
+ #endif=0A=
       }=0A=
       if (debug)=0A=
+        {=0A=
  	  printf("message received\n");=0A=
+ 	  printf("Data size is %d\n",ret);=0A=
+        }=0A=
  =0A=
       if ((ret =3D decode_krb5_ticket(&msgdata, &v5tkt))) {=0A=
+           if (debug)=0A=
+ 	    printf("ret is %d\n",ret);=0A=
            switch (ret) {=0A=
  	  case KRB5KDC_ERR_BAD_PVNO:=0A=
  	  case ASN1_MISPLACED_FIELD:=0A=
***************=0A=
*** 279,291 ****=0A=
  	  case ASN1_BAD_ID:=0A=
  	  case KRB5_BADMSGTYPE:=0A=
  	    /* don't even answer parse errors */=0A=
  	    return ret;=0A=
  	    break;=0A=
  	  default:=0A=
  	    /* try and recognize our own error packet */=0A=
  	    if (msgdata.length =3D=3D sizeof(int))=0A=
! 	      return KRB5_BADMSGTYPE;=0A=
  	    else=0A=
  	      goto error;=0A=
  	  }=0A=
       }=0A=
--- 431,451 ----=0A=
  	  case ASN1_BAD_ID:=0A=
  	  case KRB5_BADMSGTYPE:=0A=
  	    /* don't even answer parse errors */=0A=
+ 	    if (debug)=0A=
+ 	      printf("decode_krb5_ticket error\n");=0A=
  	    return ret;=0A=
  	    break;=0A=
  	  default:=0A=
  	    /* try and recognize our own error packet */=0A=
  	    if (msgdata.length =3D=3D sizeof(int))=0A=
! 	      {=0A=
! 		if (debug)=0A=
! 		  printf("msgdata.length error\n");=0A=
! 		return KRB5_BADMSGTYPE;=0A=
! 	      }=0A=
  	    else=0A=
+ 	      if (debug)=0A=
+ 		printf("Going to error\n");=0A=
  	      goto error;=0A=
  	  }=0A=
       }=0A=
***************=0A=
*** 337,342 ****=0A=
--- 497,506 ----=0A=
  	  printf("v4 credentials encoded\n");=0A=
  =0A=
  error:=0A=
+ =0A=
+      if (debug)=0A=
+        printf("Creating reply\n");=0A=
+ =0A=
       /* create the reply */=0A=
       p =3D msgdata.data;=0A=
       msgdata.length =3D 0;=0A=
***************=0A=
*** 347,353 ****=0A=
--- 511,521 ----=0A=
       msgdata.length +=3D sizeof(int);=0A=
  =0A=
       if (ret)=0A=
+        {=0A=
+ 	  if (debug)=0A=
+ 	    printf("Jumping to write_msg\n");=0A=
  	  goto write_msg;=0A=
+        }=0A=
  =0A=
       n =3D htonl(v4kvno);=0A=
       memcpy(p, (char *) &n, sizeof(int));=0A=
***************=0A=
*** 359,369 ****=0A=
--- 527,545 ----=0A=
       msgdata.length +=3D tktdata.length;=0A=
  =0A=
  write_msg:=0A=
+ =0A=
+      if (debug)=0A=
+        printf("Sending reply\n");=0A=
+ =0A=
       if (ret)=0A=
  	  (void) sendto(s, msgdata.data, msgdata.length, 0, &saddr, =
saddrlen);=0A=
       else=0A=
  	  if (sendto(s, msgdata.data, msgdata.length, 0, &saddr, =
saddrlen)<0)=0A=
+ #ifndef _WIN32=0A=
  	       ret =3D errno;=0A=
+ #else=0A=
+                ret =3D WSAGetLastError();=0A=
+ #endif=0A=
       if (debug)=0A=
  	  printf("reply written\n");=0A=
  /* If we have keys to clean up, do so.*/=0A=
***************=0A=
*** 372,378 ****=0A=
       if (v4_service_key.contents)=0A=
         krb5_free_keyblock_contents(context, &v4_service_key);=0A=
       if (v5tkt)=0A=
!        krb5_free_ticket(context, v5tkt);=0A=
       =0A=
  	       =0A=
       return ret;=0A=
--- 548,557 ----=0A=
       if (v4_service_key.contents)=0A=
         krb5_free_keyblock_contents(context, &v4_service_key);=0A=
       if (v5tkt)=0A=
!        {=0A=
! 	 krb5_free_ticket(context, v5tkt);=0A=
! 	 v5tkt =3D 0;=0A=
!        }=0A=
       =0A=
  	       =0A=
       return ret;=0A=
***************=0A=
*** 406,416 ****=0A=
--- 585,598 ----=0A=
  	  krb5_kt_free_entry(context, &entry);=0A=
  	  return 0;=0A=
       } else if (use_master) {=0A=
+ #ifndef _WIN32=0A=
  	  return kdc_get_server_key(context, p, key, kvnop, ktype, kvno);=0A=
+ #endif=0A=
       }=0A=
       return 0;=0A=
  }=0A=
  =0A=
+ #ifndef _WIN32=0A=
  krb5_error_code kdc_get_server_key(context, service, key, kvnop, =
ktype, kvno)=0A=
      krb5_context context;=0A=
      krb5_principal service;=0A=
***************=0A=
*** 453,455 ****=0A=
--- 635,682 ----=0A=
      kadm5_free_principal_ent(handle, &server);=0A=
      return ret;=0A=
  }=0A=
+ #else=0A=
+ #ifdef WIN32SVC=0A=
+ void main(void) {=0A=
+ =0A=
+   SERVICE_TABLE_ENTRY steDispatchTable[] =3D=0A=
+   {=0A=
+     { "krb524", ServiceMain },=0A=
+     { NULL, NULL }=0A=
+   };=0A=
+ =0A=
+   StartServiceCtrlDispatcher(steDispatchTable);=0A=
+ }=0A=
+ =0A=
+ VOID ServiceCtrlHandler(DWORD dwOpCode) {=0A=
+ =0A=
+   switch (dwOpCode) {=0A=
+   case SERVICE_CONTROL_STOP:=0A=
+ =0A=
+     ssServiceStatus.dwWin32ExitCode =3D 0; =0A=
+     ssServiceStatus.dwCurrentState  =3D SERVICE_STOP_PENDING;=0A=
+     ssServiceStatus.dwCheckPoint    =3D 0; =0A=
+     ssServiceStatus.dwWaitHint      =3D 60000; =0A=
+  =0A=
+     SetServiceStatus(sshServiceStatus, =0A=
+ 		     &ServiceStatus);=0A=
+ =0A=
+     request_exit();=0A=
+ =0A=
+     ssServiceStatus.dwWin32ExitCode =3D 0; =0A=
+     ssServiceStatus.dwCurrentState  =3D SERVICE_STOPPED; =0A=
+     ssServiceStatus.dwCheckPoint    =3D 0; =0A=
+     ssServiceStatus.dwWaitHint      =3D 0; =0A=
+  =0A=
+     SetServiceStatus(sshServiceStatus, =0A=
+ 		     &ServiceStatus);=0A=
+     return;=0A=
+   case SERVICE_CONTROL_INTERROGATE:=0A=
+   default:=0A=
+   }=0A=
+ =0A=
+   SetServiceStatus(sshServiceStatus,&ssServiceStatus);=0A=
+   return;=0A=
+ }=0A=
+ #endif=0A=
+ #endif=0A=
*** src/krb524/misc.c	Thu Feb 28 01:15:27 2002=0A=
--- /h/krb5-1.2.4/src/krb524/misc.c	Tue Mar 26 14:22:31 2002=0A=
***************=0A=
*** 23,36 ****=0A=
  #include <krb5.h>=0A=
  #include <stdio.h>=0A=
  #include <sys/types.h>=0A=
  #include <sys/time.h>=0A=
  #include <sys/signal.h>=0A=
  #include <netinet/in.h>=0A=
  =0A=
  #include <krb.h>=0A=
  #include "krb524.h"=0A=
  =0A=
! void krb524_init_ets(context)=0A=
       krb5_context context;=0A=
  {=0A=
       initialize_k524_error_table();=0A=
--- 23,38 ----=0A=
  #include <krb5.h>=0A=
  #include <stdio.h>=0A=
  #include <sys/types.h>=0A=
+ #ifndef _WIN32=0A=
  #include <sys/time.h>=0A=
  #include <sys/signal.h>=0A=
  #include <netinet/in.h>=0A=
+ #endif=0A=
  =0A=
  #include <krb.h>=0A=
  #include "krb524.h"=0A=
  =0A=
! void KRB5_DLLIMP krb524_init_ets(context)=0A=
       krb5_context context;=0A=
  {=0A=
       initialize_k524_error_table();=0A=
*** src/krb524/sendmsg.c	Thu Feb 28 01:15:27 2002=0A=
--- /h/krb5-1.2.4/src/krb524/sendmsg.c	Wed Mar 20 17:00:55 2002=0A=
***************=0A=
*** 30,40 ****=0A=
--- 30,51 ----=0A=
  #define NEED_LOWLEVEL_IO=0A=
  #include "k5-int.h"=0A=
  =0A=
+ #ifndef _WIN32=0A=
  #include <unistd.h>=0A=
+ #endif /* _WIN32 */=0A=
  #include <stdlib.h>=0A=
  #include <string.h>=0A=
  =0A=
+ #ifndef _WIN32=0A=
  #include <sys/time.h>=0A=
+ #else=0A=
+ krb5_error_code krb5_locate_kdc=0A=
+     PROTOTYPE((krb5_context,=0A=
+ 	       const krb5_data *,=0A=
+ 	       struct sockaddr **,=0A=
+ 	       int *,=0A=
+ 	       int));=0A=
+ #endif=0A=
  =0A=
  #ifdef _AIX=0A=
  #include <sys/select.h>=0A=
***************=0A=
*** 88,94 ****=0A=
       * find KDC location(s) for realm=0A=
       */=0A=
  =0A=
!     if ((retval =3D krb5_locate_kdc(context, realm, &addr, &naddr, =
NULL, NULL)))=0A=
  	return retval;=0A=
      if (naddr =3D=3D 0)=0A=
  	return KRB5_REALM_UNKNOWN;=0A=
--- 99,105 ----=0A=
       * find KDC location(s) for realm=0A=
       */=0A=
  =0A=
!     if ((retval =3D krb5_locate_kdc(context, realm, &addr, &naddr, =
0)))=0A=
  	return retval;=0A=
      if (naddr =3D=3D 0)=0A=
  	return KRB5_REALM_UNKNOWN;=0A=
*** src/lib/kadm5/admin.h	Thu Feb 28 01:15:33 2002=0A=
--- /h/krb5-1.2.4/src/lib/kadm5/admin.h	Wed Mar 20 17:00:56 2002=0A=
***************=0A=
*** 38,44 ****=0A=
--- 38,46 ----=0A=
  #endif=0A=
       =0A=
  #include	<sys/types.h>=0A=
+ #ifndef _WIN32=0A=
  #include	<gssrpc/rpc.h>=0A=
+ #endif=0A=
  #include	<krb5.h>=0A=
  #include	<k5-int.h>=0A=
  #include	<com_err.h>=0A=

------_=_NextPart_000_01C1DB1B.C8C5A300
Content-Type: application/octet-stream;
	name="make.win"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="make.win"

# -*- Mode: Makefile -*-=0A=
######################################################################=0A=
#=0A=
# makefile for krb524.dll=0A=
#=0A=
# $Id$=0A=
#=0A=
######################################################################=0A=
# Figure out the CPU=0A=
#=0A=
!if !defined(CPU) || "$(CPU)" =3D=3D ""=0A=
CPU=3D$(PROCESSOR_ARCHITECTURE)=0A=
!endif # CPU=0A=
=0A=
!if "$(CPU)" =3D=3D ""=0A=
CPU=3Di386=0A=
!endif=0A=
=0A=
# Change x86 or X86 to i386=0A=
!if ( "$(CPU)" =3D=3D "X86" ) || ( "$(CPU)" =3D=3D "x86" )=0A=
CPU=3Di386=0A=
!endif # CPU =3D=3D X86=0A=
=0A=
!if ( "$(CPU)" !=3D "i386" ) && ( "$(CPU)" !=3D "ALPHA" )=0A=
!error Must specify CPU environment variable ( CPU=3Di386, =
CPU=3DALPHA)=0A=
!endif=0A=
#=0A=
# End of figuring out CPU=0A=
#=0A=
=0A=
# NOTE: ^ is an escape char for NMAKE.=0A=
=0A=
!ifdef NODEBUG=0A=
OUTPRE_DBG=3Drel=0A=
!else=0A=
OUTPRE_DBG=3Ddbg=0A=
!endif=0A=
OUTPRE1=3Dobj=0A=
OUTPRE2=3D$(OUTPRE1)\$(CPU)=0A=
OUTPRE3=3D$(OUTPRE2)\$(OUTPRE_DBG)=0A=
OUTPRE=3D$(OUTPRE3)^\=0A=
=0A=
KRB5DIR               =3D       ..=0A=
=0A=
KRB5INCS      =3D       /I$(KRB5DIR)\include /I$(KRB5DIR)\include\krb5 =
\=0A=
                       /I$(KRB5DIR)\include\kerberosIV \=0A=
                      /I$(KRB5DIR)\lib=0A=
=0A=
INCLUDES      =3D       $(KRB5INCS)=0A=
=0A=
CC    =3D       cl /nologo=0A=
CFLAGS        =3D       /MD /W3 /O2 $(INCLUDES) $(DEFINES)=0A=
=0A=
LINK  =3D       link.exe /nologo=0A=
=0A=
SRCS  =3D conv_creds.c conv_princ.c cnv_tkt_skey.c \=0A=
        encode.c misc.c globals.c sendmsg.c krb524_err.c=0A=
=0A=
OBJS  =3D conv_creds.obj conv_princ.obj cnv_tkt_skey.obj \=0A=
       encode.obj misc.obj globals.obj sendmsg.obj krb524_err.obj=0A=
=0A=
DEF_FILE      =3D       .\krb524.def=0A=
=0A=
K5LIBS        =3D       $(KRB5DIR)\lib\$(OUTPRE)krb5_32.lib =
$(KRB5DIR)\lib\krb5\$(OUTPRE)krb5.lib \=0A=
                      $(KRB5DIR)\lib\$(OUTPRE)krb4_32.lib =
$(KRB5DIR)\lib\krb4\$(OUTPRE)krb4.lib \=0A=
                      $(KRB5DIR)\lib\$(OUTPRE)comerr32.lib=0A=
=0A=
SYSLIBS       =3D       shell32.lib ws2_32.lib=0A=
LIBS  =3D       $(SYSLIBS) $(K5LIBS)=0A=
=0A=
GETOPTINC        =3D $(KRB5DIR)\util\windows=0A=
GETOPTLIB        =3D $(KRB5DIR)\util\windows\$(OUTPRE)getopt.lib=0A=
=0A=
CFLAGS =3D $(CFLAGS) /I$(GETOPTINC)=0A=
=0A=
######################################################################=0A=
=0A=
all:  krb524.dll=0A=
=0A=
krb524.dll:   $(OBJS)=0A=
	$(LINK) $(LIBS) /subsystem:windows /dll /incremental:no \=0A=
		/pdb:"krb524.pdb" /machine:I386 \=0A=
		/nodefaultlib:"LIBC.lib" \=0A=
		/out:"krb524.dll" \=0A=
		/implib:"krb524.lib" $(OBJS)=0A=
=0A=
krb524d.exe: krb524.dll krb524d.obj=0A=
	$(LINK) /subsystem:console /out:$@ \=0A=
		/nodefaultlib:libc.lib /INCREMENTAL:NO \=0A=
		krb524d.obj $(LIBS) krb524.lib=0A=
=0A=
!ifdef KRB5_DLL_FILE=0A=
.c.obj:=0A=
	$(CC) $(CFLAGS) /c /DKRB5_DLL_FILE $*.c=0A=
!else=0A=
.c.obj:=0A=
	$(CC) $(CFLAGS) /c $*.c=0A=
!endif
------_=_NextPart_000_01C1DB1B.C8C5A300--



More information about the krb5-bugs mailing list