]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
sulogin: find a suitable console device
authorWerner Fink <werner@suse.de>
Thu, 8 May 2014 10:09:23 +0000 (12:09 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 13 May 2014 08:38:06 +0000 (10:38 +0200)
Enable sulogin to find a suitable console device even if the first line
in /proc/consoles does not have any major and minor number.

Signed-off-by: Werner Fink <werner@suse.de>
login-utils/sulogin-consoles.c

index 6ceea6ba79885ddbad3ceadfa05930b22c5b8190..817a882cf73c1891bad622fe12206c1e19421f88 100644 (file)
@@ -324,7 +324,7 @@ static int detect_consoles_from_proc(struct list_head *consoles)
        char fbuf[16 + 1];
        DIR *dir = NULL;
        FILE *fc = NULL;
-       int maj, min, rc = 1;
+       int maj, min, rc = 1, matches;
 
        DBG(dbgprint("trying /proc"));
 
@@ -337,10 +337,12 @@ static int detect_consoles_from_proc(struct list_head *consoles)
        if (!dir)
                goto done;
 
-       while (fscanf(fc, "%*s %*s (%16[^)]) %d:%d", fbuf, &maj, &min) == 3) {
+       while ((matches = fscanf(fc, "%*s %*s (%16[^)]) %d:%d", fbuf, &maj, &min)) >= 1) {
                char *name;
                dev_t comparedev;
 
+               if (matches != 3)
+                       continue;
                if (!strchr(fbuf, 'E'))
                        continue;
                comparedev = makedev(maj, min);