Applied patch from Matthias Schiffer which allows bootlogd to read from

a wider range of consoles. The console name is already passed in from the
kernel command line using "console=". We no longer filter out names as strictly
but do now check to confirm the "console=" device points to a valid TTY.
This commit is contained in:
Jesse Smith 2021-08-03 18:21:16 -03:00
parent bb6d5dfcd6
commit 8a085ea9b7
2 changed files with 30 additions and 1 deletions

View File

@ -1,3 +1,9 @@
* Applied patch from Matthias Schiffer which allows bootlogd to read from
a wider range of consoles. The console name is already passed in from the
kernel command line using "console=". We no longer filter out names as strictly
but do now check to confirm the "console=" device points to a valid TTY.
sysvinit (2.99) released; urgency=low
* Fixed typos and missing underlines in shutdown manual page.

View File

@ -212,6 +212,22 @@ int findpty(int *master, int *slave, char *name)
return 0;
}
static int istty(const char *dev)
{
int fd, ret;
fd = open(dev, O_RDONLY|O_NONBLOCK);
if (fd < 0)
return 0;
ret = isatty(fd);
close(fd);
return ret;
}
/*
* See if a console taken from the kernel command line maps
* to a character device we know about, and if we can open it.
@ -228,7 +244,7 @@ int isconsole(char *s, char *res, int rlen)
l = strlen(c->cmdline);
if (sl <= l) continue;
p = s + l;
if (strncmp(s, c->cmdline, l) != 0 || !isdigit(*p))
if (strncmp(s, c->cmdline, l) != 0)
continue;
for (i = 0; i < 2; i++) {
snprintf(res, rlen, i ? c->dev1 : c->dev2, p);
@ -239,6 +255,13 @@ int isconsole(char *s, char *res, int rlen)
}
}
}
/* Fallback: accept any TTY device */
snprintf(res, rlen, "/dev/%s", s);
if ((q = strchr(res, ',')) != NULL) *q = 0;
if (istty(res))
return 1;
return 0;
}