Build kpasswd under windows
authorDanilo Almeida <dalmeida@mit.edu>
Tue, 10 Aug 1999 00:19:25 +0000 (00:19 +0000)
committerDanilo Almeida <dalmeida@mit.edu>
Tue, 10 Aug 1999 00:19:25 +0000 (00:19 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@11636 dc483132-0cff-0310-8789-dd5450dbe970

src/ChangeLog
src/Makefile.in
src/clients/ChangeLog
src/clients/Makefile.in
src/clients/kpasswd/ChangeLog
src/clients/kpasswd/Makefile.in
src/clients/kpasswd/kpasswd.c

index 2eab397b1b16ccd6c3e5687370a36fd92e7ff955..05ab21b14119dbccec2c20bf89b1541bea3de4b7 100644 (file)
@@ -1,3 +1,7 @@
+1999-08-09  Danilo Almeida  <dalmeida@mit.edu>
+
+       * Makefile.in: Build kpasswd under windows.
+
 1999-07-22  Tom Yu  <tlyu@mit.edu>
 
        * Makefile.in (install-mkdirs): Use mkinstalldirs rather than
index d4aba1439232aa95cce1f470a8748e9c07e3714b..664a99acf8432d4546d2f6a907f3092d175222f1 100644 (file)
@@ -131,6 +131,7 @@ config-windows:: Makefile-windows
 WINMAKEFILES=Makefile \
        clients\Makefile clients\kdestroy\Makefile \
        clients\kinit\Makefile clients\klist\Makefile \
+       clients\kpasswd\Makefile \
        include\Makefile include\krb5\Makefile \
        lib\Makefile lib\crypto\Makefile \
        lib\crypto\crc32\Makefile lib\crypto\des\Makefile \
@@ -175,6 +176,8 @@ WINMAKEFILES=Makefile \
 ##DOS##        $(WCONFIG) config < $@.in > $@
 ##DOS##clients\klist\Makefile: clients\klist\Makefile.in $(MKFDEP)
 ##DOS##        $(WCONFIG) config < $@.in > $@
+##DOS##clients\kpasswd\Makefile: clients\kpasswd\Makefile.in $(MKFDEP)
+##DOS##        $(WCONFIG) config < $@.in > $@
 ##DOS##include\Makefile: include\Makefile.in $(MKFDEP)
 ##DOS##        $(WCONFIG) config < $@.in > $@
 ##DOS##include\krb5\Makefile: include\krb5\Makefile.in $(MKFDEP)
@@ -300,6 +303,7 @@ ren2long:
 ZIP=zip
 FILES= ./* \
        clients/* clients/kdestroy/* clients/kinit/* clients/klist/* \
+       clients/kpasswd/* \
        config/* include/* include/kerberosIV/* \
        include/krb5/* include/krb5/stock/* include/sys/* lib/* \
        lib/crypto/* lib/crypto/crc32/* lib/crypto/des/* lib/crypto/dk/* \
@@ -520,3 +524,4 @@ mkbin:
        $(CP) clients\klist\$(OUTPRE)klist.exe $(KBINDIR)\.
        $(CP) clients\kinit\$(OUTPRE)kinit.exe $(KBINDIR)\.
        $(CP) clients\kdestroy\$(OUTPRE)kdestroy.exe $(KBINDIR)\.
+       $(CP) clients\kpasswd\$(OUTPRE)kpasswd.exe $(KBINDIR)\.
index 7aa79e60a3ee0c2df52eb06ff065c3b71e286719..84c16224b04c6feb0e6fa3719f150273c064c7e9 100644 (file)
@@ -1,3 +1,7 @@
+1999-08-09  Danilo Almeida  <dalmeida@mit.edu>
+
+       * Makefile.in: Build kpasswd under windows.
+
 Tue May 18 19:52:56 1999  Danilo Almeida  <dalmeida@mit.edu>
 
        * Makefile.in: Remove - from recursive Win32 make invocation.
index ada6fd0c1f038929faa2e0acbe63ad15703b94a6..931bdc0c9327fae7cd10d89340265d903ed8930b 100644 (file)
@@ -16,6 +16,9 @@ all-windows::
        @echo Making all in clients\kinit
        cd ..\kinit
        $(MAKE) -$(MFLAGS)
+       @echo Making all in clients\kpasswd
+       cd ..\kpasswd
+       $(MAKE) -$(MFLAGS)
        cd ..
 
 clean-windows::
index 46f98c5546d699a555649bfbd60c170bd2128b4e..c61e6889820914f022ca4215ca116068e2022aef 100644 (file)
@@ -1,3 +1,8 @@
+1999-08-09  Danilo Almeida  <dalmeida@mit.edu>
+
+       * kpasswd.c: 
+       * Makefile.in: Build kpasswd under windows.
+
 1998-11-13  Theodore Ts'o  <tytso@rsts-11.mit.edu>
 
        * Makefile.in: Set the myfulldir and mydir variables (which are
index 2b749082058a37389fdb0e2f0f05980cec47407b..dddc05b9542bc81731ee0b32cbb93cc1cc66890c 100644 (file)
@@ -14,17 +14,17 @@ kpasswd: kpasswd.o $(KRB5_BASE_DEPLIBS)
 kpasswd.o:     $(srcdir)/kpasswd.c
 
 all-unix:: kpasswd
-all-windows:: kpasswd.exe
 
 clean-unix::
        $(RM) kpasswd.o kpasswd
 
-clean-windows::
-       $(RM) kpasswd.obj kpasswd.exe
-
 install-all install-kdc install-server install-client install-unix::
        $(INSTALL_PROGRAM) kpasswd $(DESTDIR)$(CLIENT_BINDIR)/`echo kpasswd|sed '$(transform)'`
        $(INSTALL_DATA) $(srcdir)/kpasswd.M $(DESTDIR)$(CLIENT_MANDIR)/`echo kpasswd|sed '$(transform)'`.1;
 
-kpasswd.exe: kpasswd.obj
-       link /out:kpasswd.exe kpasswd.obj $(BUILDTOP)\lib\libkrb5.lib
+##WIN32##INCLUDES = /I$(BUILDTOP)\include /I$(BUILDTOP)\include\krb5
+##WIN32##CFLAGS        = $(CCOPTS2) $(INCLUDES)
+
+##WIN32##all-windows:: $(OUTPRE)kpasswd.exe
+##WIN32##$(OUTPRE)kpasswd.exe: $(OUTPRE)kpasswd.obj $(KLIB) $(CLIB)
+##WIN32##      link $(LINKOPTS2) -out:$@ $**
index 711c4ecd64003450f1b6c23239780c6af1b760da..2e719d6de7ae14312ae3e8531a2ba26817c66778 100644 (file)
@@ -1,20 +1,51 @@
 #include <stdio.h>
 #include <sys/types.h>
-#include <pwd.h>
+
+#ifndef _WIN32
 #include <unistd.h>
+#endif
 
 #include <krb5.h>
 
 #define P1 "Enter new password: "
 #define P2 "Enter it again: "
 
+#ifdef HAVE_PWD_H
+#include <pwd.h>
+
+void get_name_from_passwd_file(program_name, kcontext, me)
+    char * program_name;
+    krb5_context kcontext;
+    krb5_principal * me;
+{
+    struct passwd *pw;
+    krb5_error_code code;
+    if (pw = getpwuid((int) getuid())) {
+       if ((code = krb5_parse_name(kcontext, pw->pw_name, me))) {
+           com_err (program_name, code, "when parsing name %s", pw->pw_name);
+           exit(1);
+       }
+    } else {
+       fprintf(stderr, "Unable to identify user from password file\n");
+       exit(1);
+    }
+}
+#else /* HAVE_PWD_H */
+void get_name_from_passwd_file(kcontext, me)
+    krb5_context kcontext;
+    krb5_principal * me;
+{
+    fprintf(stderr, "Unable to identify user\n");
+    exit(1);
+}
+#endif /* HAVE_PWD_H */
+
 int main(int argc, char *argv[])
 {
    krb5_error_code ret;
    krb5_context context;
    krb5_principal princ;
    char *pname;
-   struct passwd *pwd;
    krb5_ccache ccache;
    krb5_get_init_creds_opt opts;
    krb5_creds creds;
@@ -40,7 +71,9 @@ int main(int argc, char *argv[])
       exit(1);
    }
 
+#if 0
    krb5_init_ets(context);
+#endif
 
    /* in order, use the first of:
       - a name specified on the command line
@@ -70,15 +103,8 @@ int main(int argc, char *argv[])
         com_err(argv[0], ret, "closing ccache");
         exit(1);
       }
-   } else if (pwd = getpwuid(getuid())) {
-      if (ret = krb5_parse_name(context, pwd->pw_name, &princ)) {
-        com_err(argv[0], ret, "parsing client name");
-        exit(1);
-      }
    } else {
-      com_err(argv[0], 0,
-             "no matching password entry while looking for username");
-      exit(1);
+       get_name_from_passwd_file(argv[0], context, &princ);
    }
 
    krb5_get_init_creds_opt_init(&opts);