summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--kerberosV/lib/roken/Makefile3
-rw-r--r--kerberosV/src/kuser/kinit.c71
-rw-r--r--kerberosV/src/kuser/kuser_locl.h2
3 files changed, 60 insertions, 16 deletions
diff --git a/kerberosV/lib/roken/Makefile b/kerberosV/lib/roken/Makefile
index 8ba0ab1987a..46a3b16064f 100644
--- a/kerberosV/lib/roken/Makefile
+++ b/kerberosV/lib/roken/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.5 2001/07/11 09:36:05 hin Exp $
+# $OpenBSD: Makefile,v 1.6 2001/07/11 10:05:19 hin Exp $
LIB = roken
@@ -36,7 +36,6 @@ SRCS= base64.c \
resolve.c \
roken_gethostby.c \
rtbl.c \
- simple_exec.c \
tm2time.c \
verify.c \
strcollect.c \
diff --git a/kerberosV/src/kuser/kinit.c b/kerberosV/src/kuser/kinit.c
index 93ed1e46b88..8980882779e 100644
--- a/kerberosV/src/kuser/kinit.c
+++ b/kerberosV/src/kuser/kinit.c
@@ -32,7 +32,7 @@
*/
#include "kuser_locl.h"
-RCSID("$KTH: kinit.c,v 1.69 2001/01/05 16:32:55 joda Exp $");
+RCSID("$KTH: kinit.c,v 1.75 2001/05/07 21:08:15 assar Exp $");
#ifdef KRB4
/* for when the KDC tells us it's a v4 one, we try to talk that */
@@ -248,7 +248,7 @@ usage (int ret)
arg_printusage (args,
sizeof(args)/sizeof(*args),
NULL,
- "[principal]");
+ "[principal [command]]");
exit (ret);
}
@@ -290,9 +290,12 @@ renew_validate(krb5_context context,
flags.i = 0;
flags.b.renewable = flags.b.renew = renew;
flags.b.validate = validate;
- flags.b.forwardable = forwardable_flag;
- flags.b.proxiable = proxiable_flag;
- flags.b.request_anonymous = anonymous_flag;
+ if (forwardable_flag != -1)
+ flags.b.forwardable = forwardable_flag;
+ if (proxiable_flag != -1)
+ flags.b.proxiable = proxiable_flag;
+ if (anonymous_flag != -1)
+ flags.b.request_anonymous = anonymous_flag;
if(life)
in.times.endtime = time(NULL) + life;
@@ -339,7 +342,7 @@ main (int argc, char **argv)
krb5_addresses no_addrs;
char passwd[256];
- set_progname (argv[0]);
+ setprogname (argv[0]);
memset(&cred, 0, sizeof(cred));
ret = krb5_init_context (&context);
@@ -376,9 +379,6 @@ main (int argc, char **argv)
argc -= optind;
argv += optind;
- if (argc > 1)
- usage (1);
-
if (argv[0]) {
ret = krb5_parse_name (context, argv[0], &principal);
if (ret)
@@ -394,8 +394,26 @@ main (int argc, char **argv)
if(cred_cache)
ret = krb5_cc_resolve(context, cred_cache, &ccache);
- else
- ret = krb5_cc_default (context, &ccache);
+ else {
+ if(argc > 1) {
+ char s[1024];
+ ret = krb5_cc_gen_new(context, &krb5_fcc_ops, &ccache);
+ if(ret)
+ krb5_err(context, 1, ret, "creating cred cache");
+ snprintf(s, sizeof(s), "%s:%s",
+ krb5_cc_get_type(context, ccache),
+ krb5_cc_get_name(context, ccache));
+ setenv("KRB5CCNAME", s, 1);
+#ifdef KRB4
+ snprintf(s, sizeof(s), "%s_XXXXXX", TKT_ROOT);
+ close(mkstemp(s));
+ setenv("KRBTKFILE", s, 1);
+ if (k_hasafs ())
+ k_setpag();
+#endif
+ } else
+ ret = krb5_cc_default (context, &ccache);
+ }
if (ret)
krb5_err (context, 1, ret, "resolving credentials cache");
@@ -437,7 +455,7 @@ main (int argc, char **argv)
errx (1, "unparsable time: %s", renew_life);
krb5_get_init_creds_opt_set_renew_life (&opt, tmp);
- } else if (renewable_flag)
+ } else if (renewable_flag == 1)
krb5_get_init_creds_opt_set_renew_life (&opt, 1 << 30);
if(ticket_life != 0)
@@ -570,9 +588,34 @@ main (int argc, char **argv)
}
if(do_afslog && k_hasafs())
krb5_afslog(context, ccache, NULL, NULL);
-#endif
krb5_free_creds_contents (context, &cred);
- krb5_cc_close (context, ccache);
+#endif
+ if(argc > 1) {
+ pid_t pid = fork();
+ if(pid == 0) {
+ execvp(argv[1], argv+1);
+ exit(1);
+ }
+ while(1) {
+ int status;
+ while(waitpid(pid, &status, 0) < 0)
+ if(errno != EINTR)
+ break;
+ if(WIFSTOPPED(status))
+ continue;
+ if(WIFEXITED(status))
+ break;
+ if(WIFSIGNALED(status))
+ break;
+ }
+ krb5_cc_destroy(context, ccache);
+#ifdef KRB4
+ dest_tkt();
+ if(k_hasafs())
+ k_unlog();
+#endif
+ } else
+ krb5_cc_close (context, ccache);
krb5_free_context (context);
return 0;
}
diff --git a/kerberosV/src/kuser/kuser_locl.h b/kerberosV/src/kuser/kuser_locl.h
index e41095e6bd9..a6a69d3a76a 100644
--- a/kerberosV/src/kuser/kuser_locl.h
+++ b/kerberosV/src/kuser/kuser_locl.h
@@ -86,4 +86,6 @@
#endif
#include <kafs.h>
+#include <sys/wait.h>
+
#endif /* __KUSER_LOCL_H__ */