now only strip '/dev/' off of a tty if it starts with '/dev/'

This commit is contained in:
Todd C. Miller
1995-09-03 18:12:24 +00:00
parent 1f0b6dbfd5
commit 33de10d52d

4
sudo.c
View File

@@ -372,8 +372,8 @@ static void load_globals(sudo_mode)
* Need to get tty early since it's used for logging * Need to get tty early since it's used for logging
*/ */
if ((tty = (char *) ttyname(0)) || (tty = (char *) ttyname(0))) { if ((tty = (char *) ttyname(0)) || (tty = (char *) ttyname(0))) {
if ((p = strrchr(tty, '/'))) if (strncmp(tty, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0)
tty = p + 1; tty += sizeof(_PATH_DEV) - 1;
if ((tty = strdup(tty)) == NULL) { if ((tty = strdup(tty)) == NULL) {
perror("malloc"); perror("malloc");
(void) fprintf(stderr, "%s: cannot allocate memory!\n", Argv[0]); (void) fprintf(stderr, "%s: cannot allocate memory!\n", Argv[0]);