summaryrefslogtreecommitdiff
path: root/kerberosIV/kauth
diff options
context:
space:
mode:
authorArtur Grabowski <art@cvs.openbsd.org>1998-08-12 23:55:58 +0000
committerArtur Grabowski <art@cvs.openbsd.org>1998-08-12 23:55:58 +0000
commit36f98f8347f986ee192477e3c971047962571fb1 (patch)
tree06fdabf5f2094c5fe81997d161a4fbbc0b327f4a /kerberosIV/kauth
parentdd73b6049dc191cf93c774efbd41854b073e4285 (diff)
kauth from kth-krb 0.9.9. Fixes the problem with return values from executed programs.
Diffstat (limited to 'kerberosIV/kauth')
-rw-r--r--kerberosIV/kauth/Makefile15
-rw-r--r--kerberosIV/kauth/kauth.c65
2 files changed, 43 insertions, 37 deletions
diff --git a/kerberosIV/kauth/Makefile b/kerberosIV/kauth/Makefile
index ae45686de6b..2fbefa16160 100644
--- a/kerberosIV/kauth/Makefile
+++ b/kerberosIV/kauth/Makefile
@@ -1,12 +1,15 @@
-# $OpenBSD: Makefile,v 1.2 1998/01/23 08:29:58 art Exp $
+# $OpenBSD: Makefile,v 1.3 1998/08/12 23:55:56 art Exp $
.include <bsd.obj.mk>
-SRCS= encdata.c rkinit.c kauth.c marshall.c
-PROG= kauth
-LDADD+= -lkrb -lkafs -ldes
+SRCS= encdata.c rkinit.c kauth.c marshall.c
+.PATH: ${.CURDIR}/../roken
+SRCS+= simple_exec.c
+CFLAGS+= -I${.CURDIR}/../roken
+PROG= kauth
+LDADD+= -lkrb -lkafs -ldes
DPADD+= ${LIBKRB} ${LIBKAFS}
-BINDIR=/usr/bin
-MAN= kauth.1
+BINDIR= /usr/bin
+MAN= kauth.1
.include <bsd.prog.mk>
diff --git a/kerberosIV/kauth/kauth.c b/kerberosIV/kauth/kauth.c
index 4126ebdef92..dd12d0fc943 100644
--- a/kerberosIV/kauth/kauth.c
+++ b/kerberosIV/kauth/kauth.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: kauth.c,v 1.1 1997/12/18 22:28:03 art Exp $ */
-/* $KTH: kauth.c,v 1.81 1997/12/09 10:36:33 joda Exp $ */
+/* $OpenBSD: kauth.c,v 1.2 1998/08/12 23:55:57 art Exp $ */
+/* $KTH: kauth.c,v 1.81 1997/12/09 10:36:33 joda Exp $ */
/*
* Copyright (c) 1995, 1996, 1997 Kungliga Tekniska Högskolan
@@ -48,6 +48,7 @@
*/
#include "kauth.h"
+#include <simple_exec.h>
krb_principal princ;
static char srvtab[MAXPATHLEN + 1];
@@ -79,36 +80,26 @@ usage(void)
exit(1);
}
-static void
+#define EX_NOEXEC 126
+#define EX_NOTFOUND 127
+
+static int
doexec(int argc, char **argv)
{
- int status;
- pid_t ret;
-
- switch (fork()) {
- case -1:
- err (1, "fork");
- break;
- case 0:
- /* in child */
- execvp(argv[0], argv);
- err (1, "Can't exec program ``%s''", argv[0]);
- break;
- default:
- /* in parent */
- do {
- ret = wait(&status);
- } while ((ret > 0 && !WIFEXITED(status)) || (ret < 0 && errno == EINTR));
+ int ret = simple_execvp(argv[0], argv);
+ if(ret == -2)
+ warn ("fork");
+ if(ret == -3)
+ warn("waitpid");
if (ret < 0)
- perror("wait");
- dest_tkt();
- if (k_hasafs())
- k_unlog();
- break;
- }
+ return EX_NOEXEC;
+ if(ret == EX_NOEXEC || ret == EX_NOTFOUND)
+ warnx("Can't exec program ``%s''", argv[0]);
+
+ return ret;
}
-void
+static void
renew(int sig)
{
int code;
@@ -178,6 +169,7 @@ main(int argc, char **argv)
memset(srvtab, 0, sizeof(srvtab));
*remoteuser = '\0';
nhost = 0;
+ host = NULL;
/* Look for kerberos name */
if (argc > 1 &&
@@ -188,8 +180,12 @@ main(int argc, char **argv)
strupr(princ.realm);
}
- while ((c = getopt(argc, argv, "r:t:f:hl:n:c:")) != EOF)
+ while ((c = getopt(argc, argv, "r:t:f:hdl:n:c:")) != EOF)
switch (c) {
+ case 'd':
+ krb_enable_debug();
+ _kafs_debug = 1;
+ break;
case 'f':
strncpy(srvtab, optarg, sizeof(srvtab));
break;
@@ -308,7 +304,10 @@ main(int argc, char **argv)
if (more_args)
k_setpag();
if ((code = krb_afslog(cell, NULL)) != 0 && code != KDC_PR_UNKNOWN)
+ if(code > 0)
warnx ("%s", krb_get_err_text(code));
+ else
+ warnx ("failed to store AFS token");
}
for(ret = 0; nhost-- > 0; host++)
@@ -317,10 +316,14 @@ main(int argc, char **argv)
if (ret)
return ret;
- if (more_args)
- doexec(more_args, &argv[optind]);
+ if (more_args) {
+ ret = doexec(more_args, &argv[optind]);
+ dest_tkt();
+ if (k_hasafs())
+ k_unlog();
+ }
else
zrefresh();
- return 0;
+ return ret;
}