krb524.dll for windows

David Bailey D.Bailey at Bristol.ac.uk
Wed Mar 20 13:15:30 EST 2002


Hi,

Here is a patch for MIT kerberos 5 release 1.2.4 that enables building
krb524.dll. The patch is really just a re-hash of the original NCSA patch
but updated to 1.2.4. I've also attempted to make it build krb524d.exe  -
this has to be a cut down beast on windows as the kadm5 stuff isn't
available. I'm still in the process of testing it, but I thought folks out
there might find it useful.

To apply the patch, unpack a vanilla krb5-1.2.4 distribution. Then:

cd <krb5 top level dir>
patch -p3 < krb5.patch

It will create two new files in the top level directory, make.win and
krb524.def. Just move them into src\krb524 and then build the kit. I've been
using cygwin, so I have all the unix tools available for a full build. The
makefile isn't very clever (and is not properly integrated into the standard
build environment) but the build should work. It's set up to look for the
release versions of the libraries, so if you don't have NODEBUG=1 set for
your build you'll need to edit the paths in make.win for now.

Enjoy,
    Dave

krb5.patch:
*** /h/krb5-1.2.4/src/krb524/cnv_tkt_skey.c Thu Feb 28 01:15:27 2002
--- src/krb524/cnv_tkt_skey.c Thu Mar 14 11:52:30 2002
***************
*** 22,32 ****
--- 22,47 ----

  #include "k5-int.h"  /* we need krb5_context::clockskew */
  #include <stdio.h>
+ #ifdef _WIN32
+ #include <ctype.h>
+ #include <time.h>
+ #include "com_err.h"
+ #else /* !_WIN32 */
  #include <sys/types.h>
  #include <sys/time.h>
  #include <netinet/in.h>
+ #endif /* _WIN32 */
  #include <krb.h>
  #include "krb524.h"
+
+ #ifdef _WIN32
+ int krb_create_ticket(KTEXT,unsigned char,char *,char *,
+         char *,long,char *,short,long,char *,
+         char *,C_Block);
+ int krb_cr_tkt_krb5(KTEXT,unsigned char,char *,char *,
+       char *,long,char *,short,long,char *,
+       char *,krb5_keyblock *);
+ #endif

  /* rather than copying the cmu code, these values are derived from
     a calculation based on the table and comments found there.
*** /h/krb5-1.2.4/src/krb524/conv_creds.c Thu Feb 28 01:15:27 2002
--- src/krb524/conv_creds.c Thu Mar 14 11:33:51 2002
***************
*** 20,33 ****
--- 20,43 ----
   * PERFORMANCE OF THIS SOFTWARE.
   */

+ #ifdef _WIN32
+ #include <winsock2.h>
+ #include <com_err.h>
+ #endif /* _WIN32 */
  #include "krb5.h"
  #include <stdio.h>
+ #ifndef _WIN32
  #include <string.h>
  #include <sys/types.h>
  #include <netinet/in.h>
+ #endif /* _WIN32 */
  #include <krb.h>

  #include "krb524.h"
+
+ #ifdef _WIN32
+ #include <k5-int.h>
+ #endif /* _WIN32 */

  krb5_error_code krb524_convert_creds_plain
  KRB5_PROTOTYPE((krb5_context context, krb5_creds *v5creds,
*** /h/krb5-1.2.4/src/krb524/conv_princ.c Thu Feb 28 01:15:27 2002
--- src/krb524/conv_princ.c Thu Mar 14 10:47:20 2002
***************
*** 22,31 ****
--- 22,33 ----

  #include "krb5.h"
  #include <stdio.h>
+ #ifndef _WIN32
  #include <sys/types.h>
  #include <sys/time.h>
  #include <sys/signal.h>
  #include <netinet/in.h>
+ #endif /* _WIN32 */

  #include <krb.h>

*** /h/krb5-1.2.4/src/krb524/encode.c Thu Feb 28 01:15:27 2002
--- src/krb524/encode.c Thu Mar 14 10:48:52 2002
***************
*** 24,33 ****
--- 24,35 ----
  #include <stdio.h>
  #include <string.h>
  #include <signal.h>
+ #ifndef _WIN32
  #include <sys/types.h>
  #include <sys/time.h>
  #include <sys/signal.h>
  #include <netinet/in.h>
+ #endif /* _WIN32 */

  #include <krb.h>
  #include "krb524.h"
*** /h/krb5-1.2.4/src/krb524/krb524d.c Thu Feb 28 01:15:27 2002
--- src/krb524/krb524d.c Thu Mar 14 18:50:54 2002
***************
*** 29,39 ****
--- 29,41 ----
  #include <sys/select.h>
  #endif
  #include <string.h>
+ #ifndef _WIN32
  #include <signal.h>
  #include <sys/types.h>
  #include <sys/time.h>
  #include <sys/signal.h>
  #include <netinet/in.h>
+ #endif

  #include <krb.h>
  #include "krb524.h"
***************
*** 51,56 ****
--- 53,64 ----
  char *keytab = NULL;
  krb5_keytab kt;

+ #ifdef _WIN32
+ #ifndef RETSIGTYPE
+ #define RETSIGTYPE void
+ #endif
+ #endif
+
  void init_keytab(), init_master(), cleanup_and_exit();
  krb5_error_code do_connection(), lookup_service_key(),
kdc_get_server_key();

***************
*** 103,110 ****
       argv++; argc--;
       use_master = use_keytab = nofork = 0;
       config_params.mask = 0;
!
       while (argc) {
     if (strncmp(*argv, "-k", 2) == 0)
          use_keytab = 1;
     else if (strncmp(*argv, "-m", 2) == 0)
--- 111,119 ----
       argv++; argc--;
       use_master = use_keytab = nofork = 0;
       config_params.mask = 0;
!
       while (argc) {
+ #ifndef _WIN32
     if (strncmp(*argv, "-k", 2) == 0)
          use_keytab = 1;
     else if (strncmp(*argv, "-m", 2) == 0)
***************
*** 120,137 ****
     }
     else
          break;
     argv++; argc--;
       }
       if (argc || use_keytab + use_master > 1 ||
    use_keytab + use_master == 0) {
     use_keytab = use_master = 0;
     usage(context);
       }
!
       signal(SIGINT, request_exit);
       signal(SIGHUP, SIG_IGN);
       signal(SIGTERM, request_exit);
!
       if (use_keytab)
     init_keytab(context);
       if (use_master)
--- 129,153 ----
     }
     else
          break;
+ #endif
     argv++; argc--;
       }
+ #ifdef _WIN32
+      use_keytab = 1;
+      use_master = 0;
+      nofork     = 1;
+ #endif
+
       if (argc || use_keytab + use_master > 1 ||
    use_keytab + use_master == 0) {
     use_keytab = use_master = 0;
     usage(context);
       }
! #ifndef _WIN32
       signal(SIGINT, request_exit);
       signal(SIGHUP, SIG_IGN);
       signal(SIGTERM, request_exit);
! #endif
       if (use_keytab)
     init_keytab(context);
       if (use_master)
***************
*** 156,165 ****
--- 172,183 ----
     com_err(whoami, errno, "binding main socket");
     cleanup_and_exit(1, context);
       }
+ #ifndef _WIN32
       if (!nofork && daemon(0, 0)) {
     com_err(whoami, errno, "while detaching from tty");
     cleanup_and_exit(1, context);
       }
+ #endif

       while (1) {
     FD_ZERO(&rfds);
***************
*** 172,182 ****
--- 190,202 ----
          cleanup_and_exit(0, context);
     else if (ret == 0) {
          if (use_master) {
+ #ifndef _WIN32
        ret = kadm5_flush(handle);
        if (ret && ret != KRB5_KDB_DBNOTINITED) {
      com_err(whoami, ret, "closing kerberos database");
      cleanup_and_exit(1, context);
        }
+ #endif
          }
     } else if (ret < 0 && errno != EINTR) {
          com_err(whoami, errno, "in select");
***************
*** 199,205 ****
--- 219,227 ----
       krb5_context context;
  {
       if (use_master) {
+ #ifndef _WIN32
     (void) kadm5_destroy(handle);
+ #endif
       }
       if (use_keytab && kt) krb5_kt_close(context, kt);
       krb5_free_context(context);
***************
*** 233,238 ****
--- 255,261 ----
       int ret;

       use_master = 0;
+ #ifndef _WIN32
       if ((ret = kadm5_init(whoami, NULL, KADM5_ADMIN_SERVICE, params,
        KADM5_STRUCT_VERSION, KADM5_API_VERSION_2,
        &handle))) {
***************
*** 240,245 ****
--- 263,269 ----
     cleanup_and_exit(1, context);
       }
       use_master = 1;  /* now safe to close kadm5 */
+ #endif
  }

  krb5_error_code do_connection(s, context)
***************
*** 406,416 ****
--- 430,443 ----
     krb5_kt_free_entry(context, &entry);
     return 0;
       } else if (use_master) {
+ #ifndef _WIN32
     return kdc_get_server_key(context, p, key, kvnop, ktype, kvno);
+ #endif
       }
       return 0;
  }

+ #ifndef _WIN32
  krb5_error_code kdc_get_server_key(context, service, key, kvnop, ktype,
kvno)
      krb5_context context;
      krb5_principal service;
***************
*** 453,455 ****
--- 480,483 ----
      kadm5_free_principal_ent(handle, &server);
      return ret;
  }
+ #endif
*** /h/krb5-1.2.4/src/krb524/misc.c Thu Feb 28 01:15:27 2002
--- src/krb524/misc.c Thu Mar 14 11:54:29 2002
***************
*** 23,31 ****
--- 23,33 ----
  #include <krb5.h>
  #include <stdio.h>
  #include <sys/types.h>
+ #ifndef _WIN32
  #include <sys/time.h>
  #include <sys/signal.h>
  #include <netinet/in.h>
+ #endif

  #include <krb.h>
  #include "krb524.h"
*** /h/krb5-1.2.4/src/krb524/sendmsg.c Thu Feb 28 01:15:27 2002
--- src/krb524/sendmsg.c Thu Mar 14 12:04:49 2002
***************
*** 30,40 ****
--- 30,51 ----
  #define NEED_LOWLEVEL_IO
  #include "k5-int.h"

+ #ifndef _WIN32
  #include <unistd.h>
+ #endif /* _WIN32 */
  #include <stdlib.h>
  #include <string.h>

+ #ifndef _WIN32
  #include <sys/time.h>
+ #else
+ krb5_error_code krb5_locate_kdc
+     PROTOTYPE((krb5_context,
+         const krb5_data *,
+         struct sockaddr **,
+         int *,
+         int));
+ #endif

  #ifdef _AIX
  #include <sys/select.h>
***************
*** 88,94 ****
       * find KDC location(s) for realm
       */

!     if ((retval = krb5_locate_kdc(context, realm, &addr, &naddr, NULL,
NULL)))
   return retval;
      if (naddr == 0)
   return KRB5_REALM_UNKNOWN;
--- 99,105 ----
       * find KDC location(s) for realm
       */

!     if ((retval = krb5_locate_kdc(context, realm, &addr, &naddr, 0)))
   return retval;
      if (naddr == 0)
   return KRB5_REALM_UNKNOWN;
*** /h/krb5-1.2.4/src/krb524/make.win Wed Mar 20 15:57:23 2002
--- src/krb524/make.win Thu Mar 14 18:30:34 2002
***************
*** 0 ****
--- 1,52 ----
+ # -*- Mode: Makefile -*-
+ ######################################################################
+ #
+ # makefile for krb524.dll
+ #
+ # $Id$
+ #
+ ######################################################################
+ KRB5DIR               =       ..
+
+ KRB5INCS      =       /I$(KRB5DIR)\include /I$(KRB5DIR)\include\krb5 \
+                        /I$(KRB5DIR)\include\kerberosIV \
+                       /I$(KRB5DIR)\lib
+
+ INCLUDES      =       $(KRB5INCS)
+
+ CC    =       cl /nologo
+ CFLAGS        =       /MT /W3 /GX /O2 /YX /FD $(INCLUDES) $(DEFINES)
+
+ LINK  =       link.exe
+
+ SRCS  = conv_creds.c conv_princ.c cnv_tkt_skey.c \
+         encode.c misc.c globals.c sendmsg.c krb524_err.c
+
+ OBJS  = conv_creds.obj conv_princ.obj cnv_tkt_skey.obj \
+        encode.obj misc.obj globals.obj sendmsg.obj krb524_err.obj
+
+ DEF_FILE      =       .\krb524.def
+
+ K5LIBS        =       $(KRB5DIR)\lib\obj\i386\rel\krb5_32.lib
$(KRB5DIR)\lib\krb5\obj\i386\rel\krb5.lib \
+                       $(KRB5DIR)\lib\obj\i386\rel\krb4_32.lib
$(KRB5DIR)\lib\krb4\obj\i386\rel\krb4.lib \
+                       $(KRB5DIR)\lib\obj\i386\rel\comerr32.lib
+ SYSLIBS       =       shell32.lib ws2_32.lib
+ LIBS  =       $(SYSLIBS) $(K5LIBS)
+
+ ######################################################################
+
+ ALL:  krb524.dll krb524d.exe
+
+ krb524.dll:   $(OBJS)
+  $(LINK) $(LIBS) /nologo /subsystem:windows /dll /incremental:no \
+   /pdb:"krb524.pdb" /machine:I386 \
+   /nodefaultlib:"LIBCMT.lib" \
+   /def:"$(DEF_FILE)" /out:"krb524.dll" \
+   /implib:"krb524.lib" $(OBJS)
+
+ krb524d.exe: krb524.dll krb524d.obj
+  $(LINK) krb524d.obj $(LIBS) /nologo /subsystem:console \
+   /NODEFAULTLIB:MSVCRT.lib krb524.lib /out:$@
+
+ .c.obj:
+  $(CC) $(CFLAGS) /c $*.c
*** /h/krb5-1.2.4/src/krb524/krb524.def Wed Mar 20 15:57:31 2002
--- src/krb524/krb524.def Thu Mar 14 18:19:57 2002
***************
*** 0 ****
--- 1,8 ----
+ DESCRIPTION 'KRB524 Library for Kerberos 5'
+ HEAPSIZE      8192
+
+ EXPORTS
+        krb524_convert_creds_kdc
+        krb524_convert_tkt_skey
+        encode_v4tkt
+        krb524_init_ets
*** /h/krb5-1.2.4/src/lib/kadm5/admin.h Thu Feb 28 01:15:33 2002
--- src/lib/kadm5/admin.h Thu Mar 14 16:37:57 2002
***************
*** 38,44 ****
--- 38,46 ----
  #endif

  #include <sys/types.h>
+ #ifndef _WIN32
  #include <gssrpc/rpc.h>
+ #endif
  #include <krb5.h>
  #include <k5-int.h>
  #include <com_err.h>
*** /h/krb5-1.2.4/src/Makefile.in Thu Feb 28 01:15:15 2002
--- src/Makefile.in Wed Mar 20 16:47:00 2002
***************
*** 31,36 ****
--- 31,39 ----
   @echo Making in clients
   cd ..\clients
   $(MAKE) -$(MFLAGS)
+  @echo Making in krb524
+  cd ..\krb524
+  $(MAKE) -f make.win -$(MFLAGS)
   @echo Making in appl\gss-sample
   cd ..\appl\gss-sample
   $(MAKE) -$(MFLAGS)
***************
*** 162,168 ****
   windows\Makefile windows\lib\Makefile \
   windows\cns\Makefile windows\gina\Makefile \
   windows\gss\Makefile windows\ms2mit\Makefile \
!  windows\wintel\Makefile

  ##DOS##Makefile-windows:: $(MKFDEP) $(WINMAKEFILES)

--- 165,172 ----
   windows\Makefile windows\lib\Makefile \
   windows\cns\Makefile windows\gina\Makefile \
   windows\gss\Makefile windows\ms2mit\Makefile \
!  windows\wintel\Makefile \
!  krb524\make.win

  ##DOS##Makefile-windows:: $(MKFDEP) $(WINMAKEFILES)

***************
*** 276,281 ****
--- 280,287 ----
  ##DOS## $(WCONFIG) config < $@.in > $@
  ##DOS##windows\wintel\Makefile: windows\wintel\Makefile.in $(MKFDEP)
  ##DOS## $(WCONFIG) config < $@.in > $@
+ ##DOS##krb524\make.win:
+ ##DOS## @echo Making krb524 make.win

  clean-windows:: Makefile-windows
   @echo Making clean in util
***************
*** 327,333 ****
   lib/krb5/error_tables/* \
   lib/krb5/keytab/* lib/krb5/keytab/file/* lib/krb5/keytab/srvtab/* \
   lib/krb5/os/* lib/krb5/posix/* lib/krb5/rcache/* \
!  util/* util/et/* util/profile/*

  WINFILES= util/windows/* windows/* windows/lib/* windows/cns/* \
   windows/wintel/* windows/gss/* windows/gina/* windows/ms2mit/*
--- 333,340 ----
   lib/krb5/error_tables/* \
   lib/krb5/keytab/* lib/krb5/keytab/file/* lib/krb5/keytab/srvtab/* \
   lib/krb5/os/* lib/krb5/posix/* lib/krb5/rcache/* \
!  util/* util/et/* util/profile/* \
!  krb524/*

  WINFILES= util/windows/* windows/* windows/lib/* windows/cns/* \
   windows/wintel/* windows/gss/* windows/gina/* windows/ms2mit/*
***************
*** 351,356 ****
--- 358,365 ----
  GG  = lib/gssapi/generic/
  GK  = lib/gssapi/krb5/
  PR  = util/profile/
+ K524 = krb524/
+ KA5 = lib/kadm5/

  ETOUT = $(INC)asn1_err.h $(ET)asn1_err.c \
   $(INC)kdb5_err.h $(ET)kdb5_err.c \
***************
*** 360,366 ****
   $(INC)/kerberosIV/krb_err.h lib/krb4/krb_err.c \
   $(PR)prof_err.h $(PR)prof_err.c \
   $(GG)gssapi_err_generic.h $(GG)gssapi_err_generic.c \
!  $(GK)gssapi_err_krb5.h $(GK)gssapi_err_krb5.c

  HOUT = $(INC)krb5.h $(GG)gssapi.h $(PR)profile.h

--- 369,380 ----
   $(INC)/kerberosIV/krb_err.h lib/krb4/krb_err.c \
   $(PR)prof_err.h $(PR)prof_err.c \
   $(GG)gssapi_err_generic.h $(GG)gssapi_err_generic.c \
!  $(GK)gssapi_err_krb5.h $(GK)gssapi_err_krb5.c \
!  $(K524)krb524_err.h $(K524)krb524_err.c \
!  $(KA5)kadm_err.h $(KA5)kadm_err.c \
!  $(KA5)adb_err.h $(KA5)adb_err.c \
!  $(KA5)chpass_util_strings.h \
!  $(KA5)chpass_util_strings.c

  HOUT = $(INC)krb5.h $(GG)gssapi.h $(PR)profile.h

***************
*** 468,473 ****
--- 482,495 ----
   $(AWK) -f $(AH) outfile=$@ $(GG)gssapi_err_generic.et
  $(GK)gssapi_err_krb5.h: $(AH) $(GK)gssapi_err_krb5.et
   $(AWK) -f $(AH) outfile=$@ $(GK)gssapi_err_krb5.et
+ $(K524)krb524_err.h: $(AH) $(K524)krb524_err.et
+  $(AWK) -f $(AH) outfile=$@ $(K524)krb524_err.et
+ $(KA5)kadm_err.h: $(AH) $(KA5)kadm_err.et
+  $(AWK) -f $(AH) outfile=$@ $(KA5)kadm_err.et
+ $(KA5)adb_err.h: $(AH) $(KA5)adb_err.et
+  $(AWK) -f $(AH) outfile=$@ $(KA5)adb_err.et
+ $(KA5)chpass_util_strings.h: $(AH) $(KA5)chpass_util_strings.et
+  $(AWK) -f $(AH) outfile=$@ $(KA5)chpass_util_strings.et

  $(ET)asn1_err.c: $(AC) $(ET)asn1_err.et
   $(AWK) -f $(AC) outfile=$@ $(ET)asn1_err.et
***************
*** 487,492 ****
--- 509,522 ----
   $(AWK) -f $(AC) outfile=$@ $(GG)gssapi_err_generic.et
  $(GK)gssapi_err_krb5.c: $(AC) $(GK)gssapi_err_krb5.et
   $(AWK) -f $(AC) outfile=$@ $(GK)gssapi_err_krb5.et
+ $(K524)krb524_err.c: $(AC) $(K524)krb524_err.et
+  $(AWK) -f $(AC) outfile=$@ $(K524)krb524_err.et
+ $(KA5)kadm_err.c: $(AC) $(KA5)kadm_err.et
+  $(AWK) -f $(AC) outfile=$@ $(KA5)kadm_err.et
+ $(KA5)adb_err.c: $(AC) $(KA5)adb_err.et
+  $(AWK) -f $(AC) outfile=$@ $(KA5)adb_err.et
+ $(KA5)chpass_util_strings.c: $(AC) $(KA5)chpass_util_strings.et
+  $(AWK) -f $(AC) outfile=$@ $(KA5)chpass_util_strings.et

  KRBHDEP = $(INC)krb5.hin $(INC)krb5_err.h $(INC)kdb5_err.h \
   $(INC)kv5m_err.h $(INC)asn1_err.h
*** /h/krb5-1.2.4/src/include/krb5/kdb.h Thu Feb 28 01:15:19 2002
--- src/include/krb5/kdb.h Thu Mar 14 17:31:23 2002
***************
*** 84,90 ****
  #define KRB5_KDB_CREATE_BTREE  0x00000001
  #define KRB5_KDB_CREATE_HASH  0x00000002

! #if !defined(macintosh) && !defined(_MSDOS) && !defined(_WIN32) &&
!defined(__MACH__)

  /*
   * Note --- these structures cannot be modified without changing the
--- 84,90 ----
  #define KRB5_KDB_CREATE_BTREE  0x00000001
  #define KRB5_KDB_CREATE_HASH  0x00000002

! #if !defined(macintosh) && !defined(_MSDOS) && !defined(__MACH__)

  /*
   * Note --- these structures cannot be modified without changing the
***************
*** 406,411 ****
--- 406,413 ----

  #define KRB5_KDB_DEF_FLAGS 0

+ #if !defined(_WIN32)
+
  #ifdef KRB5_OLD_AND_KRUFTY
  /* this is the same structure as krb5_keyblock, but with a different name
to
     enable compile-time catching of programmer confusion between encrypted
&
***************
*** 450,455 ****
--- 452,458 ----
  } krb5_db_entry_OLD;

  #endif /* OLD_AND_KRUFTY */
+ #endif /* _WIN32 */

  /* This is now a structure that is private to the database backend. */
  #ifdef notdef






More information about the Kerberos mailing list