aboutsummaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin')
-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 2024a43cf290f..94a463d90ffa4 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 66e9fb0a4bb49..e7478501b28f0 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)