summaryrefslogtreecommitdiffstats
path: root/usr.bin/login
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>1999-08-21 18:19:49 +0000
committerimp <imp@FreeBSD.org>1999-08-21 18:19:49 +0000
commitb725db36e2d825e10e8f80edf484563f437ba0bb (patch)
tree7b8883039e538c6f36872b2670bce79eb32f4e09 /usr.bin/login
parent6d45c2c683e3e1c9e85a4ba66a92407a95d44ee4 (diff)
downloadFreeBSD-src-b725db36e2d825e10e8f80edf484563f437ba0bb.zip
FreeBSD-src-b725db36e2d825e10e8f80edf484563f437ba0bb.tar.gz
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.
Diffstat (limited to 'usr.bin/login')
-rw-r--r--usr.bin/login/login.c16
-rw-r--r--usr.bin/login/login_fbtab.c3
2 files changed, 16 insertions, 3 deletions
diff --git a/usr.bin/login/login.c b/usr.bin/login/login.c
index 2024a43..94a463d 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.
diff --git a/usr.bin/login/login_fbtab.c b/usr.bin/login/login_fbtab.c
index 66e9fb0..e747850 100644
--- a/usr.bin/login/login_fbtab.c
+++ b/usr.bin/login/login_fbtab.c
@@ -132,6 +132,9 @@ gid_t gid;
DIR *dir;
if (strcmp("/*", path + pathlen - 2) != 0) {
+ /* clear flags of the device */
+ if (chflags(path, 0) && errno != ENOENT)
+ syslog(LOG_ERR, "%s: chflags(%s): %m", table, path);
if (chmod(path, mask) && errno != ENOENT)
syslog(LOG_ERR, "%s: chmod(%s): %m", table, path);
if (chown(path, uid, gid) && errno != ENOENT)
OpenPOWER on IntegriCloud