diff options
author | ed <ed@FreeBSD.org> | 2009-03-27 19:13:36 +0000 |
---|---|---|
committer | ed <ed@FreeBSD.org> | 2009-03-27 19:13:36 +0000 |
commit | 66aaf53891e707b20d78eef7a3347a3af25a63e1 (patch) | |
tree | a5e8ebab3f502f2a66bbd86af700adec8e70d280 /usr.bin/login/login.c | |
parent | ebbff345acb1f73f7f224c0d2c455c8f60fbc856 (diff) | |
download | FreeBSD-src-66aaf53891e707b20d78eef7a3347a3af25a63e1.zip FreeBSD-src-66aaf53891e707b20d78eef7a3347a3af25a63e1.tar.gz |
Don't strip TTY device name to the last '/'.
We've seen this bug in other applications before: we have some
applications that use strrchr(tty, '/') on the TTY device name. This
isn't valid when using pts(4), because the device name will be stripped
to "0" instead of "pts/0".
This fixes issues with login(1) ignoring /etc/ttys and missing utmp
records.
Reported by: Barney Cordoba <barney_cordoba yahoo com>
Reviewed by: rwatson
Diffstat (limited to 'usr.bin/login/login.c')
-rw-r--r-- | usr.bin/login/login.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/usr.bin/login/login.c b/usr.bin/login/login.c index 549e015..2a42924 100644 --- a/usr.bin/login/login.c +++ b/usr.bin/login/login.c @@ -245,8 +245,8 @@ main(int argc, char *argv[]) (void)snprintf(tname, sizeof(tname), "%s??", _PATH_TTY); ttyn = tname; } - if ((tty = strrchr(ttyn, '/')) != NULL) - ++tty; + if (strncmp(ttyn, _PATH_DEV, sizeof _PATH_DEV - 1) == 0) + tty = ttyn + sizeof _PATH_DEV - 1; else tty = ttyn; |