diff options
author | Karel Zak | 2012-03-05 16:48:38 +0100 |
---|---|---|
committer | Karel Zak | 2012-03-05 16:48:38 +0100 |
commit | 2f595c001b4528b3b9a4aea04d72b6918c434efb (patch) | |
tree | 8c0d5b57b2e55b6ed092702b65382e70186f53b2 /login-utils/login.c | |
parent | tests: search for "none" by findmnt (diff) | |
download | kernel-qcow2-util-linux-2f595c001b4528b3b9a4aea04d72b6918c434efb.tar.gz kernel-qcow2-util-linux-2f595c001b4528b3b9a4aea04d72b6918c434efb.tar.xz kernel-qcow2-util-linux-2f595c001b4528b3b9a4aea04d72b6918c434efb.zip |
login: fix LOGIN_CHOWN_VCS code
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'login-utils/login.c')
-rw-r--r-- | login-utils/login.c | 49 |
1 files changed, 25 insertions, 24 deletions
diff --git a/login-utils/login.c b/login-utils/login.c index bc0eaec26..4f448f860 100644 --- a/login-utils/login.c +++ b/login-utils/login.c @@ -128,6 +128,22 @@ static int timeout = LOGIN_TIMEOUT; static int child_pid = 0; static volatile int got_sig = 0; +#ifdef LOGIN_CHOWN_VCS +/* true if the filedescriptor fd is a console tty, very Linux specific */ +static int is_consoletty(int fd) +{ + struct stat stb; + + if ((fstat(fd, &stb) >= 0) + && (major(stb.st_rdev) == TTY_MAJOR) + && (minor(stb.st_rdev) < 64)) { + return 1; + } + return 0; +} +#endif + + /* * Robert Ambrose writes: * A couple of my users have a problem with login processes hanging around @@ -316,15 +332,15 @@ static void chown_tty(struct login_context *cxt) #ifdef LOGIN_CHOWN_VCS if (is_consoletty(0)) { - if (chown(cxt->vcs, uid, gid)) /* vcs */ - chown_err(cxt->vcs, uid, gid); - if (chmod(cxt->vcs, cxt->tty_mode)) - chmod_err(cxt->vcs, cxt->tty_mode); - - if (chown(cxt->vcsa, uid, gid)) /* vcsa */ - chown_err(cxt->vcsa, uid, gid); - if (chmod(cxt->vcsa, cxt->tty_mode)) - chmod_err(cxt->vcsa, cxt->tty_mode); + if (chown(cxt->vcsn, uid, gid)) /* vcs */ + chown_err(cxt->vcsn, uid, gid); + if (chmod(cxt->vcsn, cxt->tty_mode)) + chmod_err(cxt->vcsn, cxt->tty_mode); + + if (chown(cxt->vcsan, uid, gid)) /* vcsa */ + chown_err(cxt->vcsan, uid, gid); + if (chmod(cxt->vcsan, cxt->tty_mode)) + chmod_err(cxt->vcsan, cxt->tty_mode); } #endif } @@ -403,21 +419,6 @@ static void init_tty(struct login_context *cxt) } -#ifdef LOGIN_CHOWN_VCS -/* true if the filedescriptor fd is a console tty, very Linux specific */ -static int is_consoletty(int fd) -{ - struct stat stb; - - if ((fstat(fd, &stb) >= 0) - && (major(stb.st_rdev) == TTY_MAJOR) - && (minor(stb.st_rdev) < 64)) { - return 1; - } - return 0; -} -#endif - /* * Log failed login attempts in _PATH_BTMP if that exists. * Must be called only with username the name of an actual user. |