]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
login: use TTYGROUP from login.defs
authorKarel Zak <kzak@redhat.com>
Wed, 5 Oct 2011 21:07:45 +0000 (23:07 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 26 Oct 2011 21:17:17 +0000 (23:17 +0200)
Note that Suse login(1) does not use any default for TTYGROUP, it
means that TTYGROUP has to be explicitly defined otherwise user\'s
primary group is used.

The util-linux login(1) uses 'tty' group name as a default value.

Signed-off-by: Karel Zak <kzak@redhat.com>
login-utils/login.1
login-utils/login.c

index 1d3ae1a5dfdc3c9e7b2916c1c6d7dac631a20198..cce4672316ad13aa317f963d2ea0e6e67e97c555 100644 (file)
@@ -149,6 +149,15 @@ The default value is 5.
 .RS 4
 The terminal permissions. The default value is 0600.
 .RE
+.PP
+\fBTTYGROUP\fR (string)
+.RS 4
+The login tty will be owned by the
+\fBTTYGROUP\fR. The default value is 'tty'. If the \fBTTYGROUP\fR does not exist
+then the ownership of the terminal is set to the user\'s primary group.
+.SP
+The \fBTTYGROUP\fR can be either the name of a group or a numeric group identifier.
+.RE
 
 .SH FILES
 .nf
index 4ad962ae85841080324e01cf9b03d8b70e6b9fea..17a3137108a55dc1a3afd61e0e5578052e54a9be 100644 (file)
@@ -264,13 +264,20 @@ static void open_tty(const char *tty)
 
 static void chown_tty(struct login_context *cxt)
 {
-       struct group *gr;
+       const char *grname;
        uid_t uid = cxt->pwd->pw_uid;
        gid_t gid = cxt->pwd->pw_gid;
 
-       gr = getgrnam(TTYGRPNAME);
-       if (gr)
-               gid = gr->gr_gid;
+       grname = getlogindefs_str("TTYGROUP", TTYGRPNAME);
+       if (grname && *grname) {
+               if (*grname >= 0 && *grname <= 9)               /* group by ID */
+                       gid = getlogindefs_num("TTYGROUP", gid);
+               else {                                          /* group by name */
+                       struct group *gr = getgrnam(grname);
+                       if (gr)
+                               gid = gr->gr_gid;
+               }
+       }
 
        if (fchown(0, uid, gid))                                /* tty */
                chown_err(cxt->tty_name, uid, gid);