diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 1997-12-21 23:15:07 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 1997-12-21 23:15:07 +0000 |
commit | 67f003f63b9473a2f8912944a95d78f04eb96838 (patch) | |
tree | 63dbbd87d7db3ed294e3ffb28e2288f00832d699 /gnu/usr.bin/sudo | |
parent | 656cc4483f6c53826da4e0dc3418bb88e1656132 (diff) |
Don't set the tty variable to NULL when we lack a tty, leave it as
"unknown".
Diffstat (limited to 'gnu/usr.bin/sudo')
-rw-r--r-- | gnu/usr.bin/sudo/sudo/sudo.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/gnu/usr.bin/sudo/sudo/sudo.c b/gnu/usr.bin/sudo/sudo/sudo.c index c72c49d1674..dd272cc85ba 100644 --- a/gnu/usr.bin/sudo/sudo/sudo.c +++ b/gnu/usr.bin/sudo/sudo/sudo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sudo.c,v 1.5 1997/11/23 07:15:49 millert Exp $ */ +/* $OpenBSD: sudo.c,v 1.6 1997/12/21 23:15:06 millert Exp $ */ /* * CU sudo version 1.5.3 (based on Root Group sudo version 1.1) @@ -435,10 +435,10 @@ static void load_globals(sudo_mode) /* * Need to get tty early since it's used for logging */ - if ((tty = (char *) ttyname(0)) || (tty = (char *) ttyname(1))) { - if (strncmp(tty, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0) - tty += sizeof(_PATH_DEV) - 1; - if ((tty = (char *) strdup(tty)) == NULL) { + if ((p = (char *) ttyname(0)) || (p = (char *) ttyname(1))) { + if (strncmp(p, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0) + p += sizeof(_PATH_DEV) - 1; + if ((tty = (char *) strdup(p)) == NULL) { perror("malloc"); (void) fprintf(stderr, "%s: cannot allocate memory!\n", Argv[0]); exit(1); |