summaryrefslogtreecommitdiffstats
path: root/login-utils/login.c
diff options
context:
space:
mode:
authorYann Droneaud2010-01-25 23:12:09 +0100
committerKarel Zak2010-01-28 15:24:38 +0100
commit453b36147bcd58962fade1cac76ddebecfa2caf6 (patch)
treef86dd4de7fc34fe2ca34e9c91fdd5206ce7e8023 /login-utils/login.c
parentblkid: add newline when only one value is printed (diff)
downloadkernel-qcow2-util-linux-453b36147bcd58962fade1cac76ddebecfa2caf6.tar.gz
kernel-qcow2-util-linux-453b36147bcd58962fade1cac76ddebecfa2caf6.tar.xz
kernel-qcow2-util-linux-453b36147bcd58962fade1cac76ddebecfa2caf6.zip
login: use fd instead of pathname for update tty's owner and permissions
To avoid some nasty races, use the only true tty: the one already opened, don't use the path. Signed-off-by: Yann Droneaud <yann@droneaud.fr>
Diffstat (limited to 'login-utils/login.c')
-rw-r--r--login-utils/login.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/login-utils/login.c b/login-utils/login.c
index 486b30bf0..fdc8078dd 100644
--- a/login-utils/login.c
+++ b/login-utils/login.c
@@ -536,8 +536,8 @@ main(int argc, char **argv)
ttt.c_cflag &= ~HUPCL;
/* These can fail, e.g. with ttyn on a read-only filesystem */
- chown(ttyn, 0, 0);
- chmod(ttyn, TTY_MODE);
+ fchown(0, 0, 0);
+ fchmod(0, TTY_MODE);
/* Kill processes left on this tty */
tcsetattr(0,TCSAFLUSH,&ttt);
@@ -1009,9 +1009,9 @@ Michael Riepe <michael@stud.uni-hannover.de>
logaudit(tty_name, username, hostname, pwd, 1);
dolastlog(quietlog);
- chown(ttyn, pwd->pw_uid,
+ fchown(0, pwd->pw_uid,
(gr = getgrnam(TTYGRPNAME)) ? gr->gr_gid : pwd->pw_gid);
- chmod(ttyn, TTY_MODE);
+ fchmod(0, TTY_MODE);
#ifdef LOGIN_CHOWN_VCS
/* if tty is one of the VC's then change owner and mode of the