]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
login: allow TTYGROUP name begin by number
authorSami Kerola <kerolasa@iki.fi>
Sat, 2 Jun 2012 10:11:25 +0000 (12:11 +0200)
committerSami Kerola <kerolasa@iki.fi>
Sat, 2 Jun 2012 13:10:28 +0000 (15:10 +0200)
Assuming someone is using a TTYGROUP name beginnign by a digit the
login was misbehaving with 'contains invalid numerical value: %s'
message(s) in syslog.  Please notice that group names that consist
only digits as characters are valid (but likely to cause confusion,
and chaos).

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
login-utils/login.c

index 9db4f0fe6da1915f39520a8785b6bf13b16dbbc0..db3a93345e6454c466113091bedb0b1a6c7cf6a4 100644 (file)
@@ -319,15 +319,12 @@ static void chown_tty(struct login_context *cxt)
 
        grname = getlogindefs_str("TTYGROUP", TTYGRPNAME);
        if (grname && *grname) {
-               if (*grname >= 0 && *grname <= 9)               /* group by ID */
-                       gid = (gid_t)getlogindefs_num("TTYGROUP", gid);
-               else {                                          /* group by name */
-                       struct group *gr = getgrnam(grname);
-                       if (gr)
-                               gid = gr->gr_gid;
-               }
+               struct group *gr = getgrnam(grname);
+               if (gr) /* group by name */
+                       gid = gr->gr_gid;
+               else    /* group by ID */
+                       gid = (gid_t) getlogindefs_num("TTYGROUP", gid);
        }
-
        if (fchown(0, uid, gid))                                /* tty */
                chown_err(cxt->tty_name, uid, gid);
        if (fchmod(0, cxt->tty_mode))