diff options
author | Warner Losh <imp@FreeBSD.org> | 1999-08-21 18:19:49 +0000 |
---|---|---|
committer | Warner Losh <imp@FreeBSD.org> | 1999-08-21 18:19:49 +0000 |
commit | a761a4653a59927feed63d520cbf1f7516136768 (patch) | |
tree | a0d8927b08459ed604332f6b752ad01d9d9987b4 /usr.bin/login/login.c | |
parent | 15621e0d76c24fe3fa332defe514082bd01c87bc (diff) | |
download | src-a761a4653a59927feed63d520cbf1f7516136768.tar.gz src-a761a4653a59927feed63d520cbf1f7516136768.zip |
Clear all file flags when taking ownership of devices. Do not ignore
chown failures in some places, but instead log them like we do all
other errors.
Notes
Notes:
svn path=/head/; revision=50124
Diffstat (limited to 'usr.bin/login/login.c')
-rw-r--r-- | usr.bin/login/login.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/usr.bin/login/login.c b/usr.bin/login/login.c index 2024a43cf290..94a463d90ffa 100644 --- a/usr.bin/login/login.c +++ b/usr.bin/login/login.c @@ -42,7 +42,7 @@ static char copyright[] = static char sccsid[] = "@(#)login.c 8.4 (Berkeley) 4/2/94"; #endif static const char rcsid[] = - "$Id: login.c,v 1.46 1999/04/07 14:05:03 brian Exp $"; + "$Id: login.c,v 1.47 1999/04/24 17:26:32 ache Exp $"; #endif /* not lint */ /* @@ -460,8 +460,18 @@ main(argc, argv) */ login_fbtab(tty, pwd->pw_uid, pwd->pw_gid); - (void)chown(ttyn, pwd->pw_uid, - (gr = getgrnam(TTYGRPNAME)) ? gr->gr_gid : pwd->pw_gid); + /* + * Clear flags of the tty. None should be set, and when the + * user sets them otherwise, this can cause the chown to fail. + * Since it isn't clear that flags are useful on character + * devices, we just clear them. + */ + if (chflags(ttyn, 0)) + syslog(LOG_ERR, "chmod(%s): %m", ttyn); + if (chown(ttyn, pwd->pw_uid, + (gr = getgrnam(TTYGRPNAME)) ? gr->gr_gid : pwd->pw_gid)) + syslog(LOG_ERR, "chmod(%s): %m", ttyn); + /* * Preserve TERM if it happens to be already set. |