|
|
531551 |
diff -up util-linux-2.23.2/include/pathnames.h.kzak util-linux-2.23.2/include/pathnames.h
|
|
|
531551 |
--- util-linux-2.23.2/include/pathnames.h.kzak 2013-07-30 10:39:26.201738190 +0200
|
|
|
531551 |
+++ util-linux-2.23.2/include/pathnames.h 2013-09-12 13:05:35.928359383 +0200
|
|
|
531551 |
@@ -63,6 +63,7 @@
|
|
|
531551 |
|
|
|
531551 |
/* used in term-utils/agetty.c */
|
|
|
531551 |
#define _PATH_ISSUE "/etc/issue"
|
|
|
531551 |
+#define _PATH_OS_RELEASE "/etc/os-release"
|
|
|
531551 |
#define _PATH_NUMLOCK_ON _PATH_LOCALSTATEDIR "/numlock-on"
|
|
|
531551 |
|
|
|
531551 |
#define _PATH_LOGINDEFS "/etc/login.defs"
|
|
|
531551 |
diff -up util-linux-2.23.2/term-utils/agetty.8.kzak util-linux-2.23.2/term-utils/agetty.8
|
|
|
531551 |
--- util-linux-2.23.2/term-utils/agetty.8.kzak 2013-07-30 10:58:20.889261333 +0200
|
|
|
531551 |
+++ util-linux-2.23.2/term-utils/agetty.8 2013-09-12 13:05:35.928359383 +0200
|
|
|
531551 |
@@ -310,6 +310,14 @@ Insert the current date.
|
|
|
531551 |
.TP
|
|
|
531551 |
s
|
|
|
531551 |
Insert the system name, the name of the operating system. Same as `uname \-s'.
|
|
|
531551 |
+See also \\S escape code.
|
|
|
531551 |
+.TP
|
|
|
531551 |
+S or S{VARIABLE}
|
|
|
531551 |
+Insert the VARIABLE data from \fI/etc/os-release\fP. If the VARIABLE argument
|
|
|
531551 |
+is not specified then use PRETTY_NAME from the file or the system name (see \\s).
|
|
|
531551 |
+This escape code allows to keep \fI/etc/issue\fP distribution and release
|
|
|
531551 |
+independent. Note that \\S{ANSI_COLOR} is converted to the real terminal
|
|
|
531551 |
+escape sequence.
|
|
|
531551 |
.TP
|
|
|
531551 |
l
|
|
|
531551 |
Insert the name of the current tty line.
|
|
|
531551 |
@@ -368,11 +376,14 @@ the system status file.
|
|
|
531551 |
.B /etc/issue
|
|
|
531551 |
printed before the login prompt.
|
|
|
531551 |
.TP
|
|
|
531551 |
+.B /etc/os-release
|
|
|
531551 |
+operating system identification data.
|
|
|
531551 |
+.TP
|
|
|
531551 |
.B /dev/console
|
|
|
531551 |
problem reports (if syslog(3) is not used).
|
|
|
531551 |
.TP
|
|
|
531551 |
.B /etc/inittab
|
|
|
531551 |
-\fIinit\fP(8) configuration file.
|
|
|
531551 |
+\fIinit\fP(8) configuration file for SysV-style init daemon.
|
|
|
531551 |
.SH BUGS
|
|
|
531551 |
.ad
|
|
|
531551 |
.fi
|
|
|
531551 |
diff -up util-linux-2.23.2/term-utils/agetty.c.kzak util-linux-2.23.2/term-utils/agetty.c
|
|
|
531551 |
--- util-linux-2.23.2/term-utils/agetty.c.kzak 2013-09-12 13:05:35.927359379 +0200
|
|
|
531551 |
+++ util-linux-2.23.2/term-utils/agetty.c 2013-09-12 13:05:35.929359388 +0200
|
|
|
531551 |
@@ -129,6 +129,7 @@ struct options {
|
|
|
531551 |
char *issue; /* alternative issue file */
|
|
|
531551 |
char *erasechars; /* string with erase chars */
|
|
|
531551 |
char *killchars; /* string with kill chars */
|
|
|
531551 |
+ char *osrelease; /* /etc/os-release data */
|
|
|
531551 |
int delay; /* Sleep seconds before prompt */
|
|
|
531551 |
int nice; /* Run login with this priority */
|
|
|
531551 |
int numspeed; /* number of baud rates to try */
|
|
|
531551 |
@@ -431,7 +432,8 @@ int main(int argc, char **argv)
|
|
|
531551 |
log_warn(_("%s: can't change process priority: %m"),
|
|
|
531551 |
options.tty);
|
|
|
531551 |
}
|
|
|
531551 |
-
|
|
|
531551 |
+ if (options.osrelease)
|
|
|
531551 |
+ free(options.osrelease);
|
|
|
531551 |
#ifdef DEBUGGING
|
|
|
531551 |
fprintf(dbf, "read %c\n", ch);
|
|
|
531551 |
if (close_stream(dbf) != 0)
|
|
|
531551 |
@@ -1279,6 +1281,84 @@ static char *xgetdomainname(void)
|
|
|
531551 |
return NULL;
|
|
|
531551 |
}
|
|
|
531551 |
|
|
|
531551 |
+static char *read_os_release(struct options *op, const char *varname)
|
|
|
531551 |
+{
|
|
|
531551 |
+ int fd = -1;
|
|
|
531551 |
+ struct stat st;
|
|
|
531551 |
+ size_t varsz = strlen(varname);
|
|
|
531551 |
+ char *p, *buf = NULL, *ret = NULL;
|
|
|
531551 |
+
|
|
|
531551 |
+ /* read the file only once */
|
|
|
531551 |
+ if (!op->osrelease) {
|
|
|
531551 |
+ fd = open(_PATH_OS_RELEASE, O_RDONLY);
|
|
|
531551 |
+ if (fd == -1) {
|
|
|
531551 |
+ log_warn(_("cannot open: %s: %m"), _PATH_OS_RELEASE);
|
|
|
531551 |
+ return NULL;
|
|
|
531551 |
+ }
|
|
|
531551 |
+
|
|
|
531551 |
+ if (fstat(fd, &st) < 0 || st.st_size > 4 * 1024 * 1024)
|
|
|
531551 |
+ goto done;
|
|
|
531551 |
+
|
|
|
531551 |
+ op->osrelease = malloc(st.st_size + 1);
|
|
|
531551 |
+ if (!op->osrelease)
|
|
|
531551 |
+ log_err(_("failed to allocate memory: %m"));
|
|
|
531551 |
+ if (read_all(fd, op->osrelease, st.st_size) != (ssize_t) st.st_size) {
|
|
|
531551 |
+ free(op->osrelease);
|
|
|
531551 |
+ op->osrelease = NULL;
|
|
|
531551 |
+ goto done;
|
|
|
531551 |
+ }
|
|
|
531551 |
+ op->osrelease[st.st_size] = 0;
|
|
|
531551 |
+ }
|
|
|
531551 |
+ buf = strdup(op->osrelease);
|
|
|
531551 |
+ if (!buf)
|
|
|
531551 |
+ log_err(_("failed to allocate memory: %m"));
|
|
|
531551 |
+ p = buf;
|
|
|
531551 |
+
|
|
|
531551 |
+ for (;;) {
|
|
|
531551 |
+ char *eol, *eon;
|
|
|
531551 |
+
|
|
|
531551 |
+ p += strspn(p, "\n\r");
|
|
|
531551 |
+ p += strspn(p, " \t\n\r");
|
|
|
531551 |
+ if (!*p)
|
|
|
531551 |
+ break;
|
|
|
531551 |
+ if (strspn(p, "#;\n") != 0) {
|
|
|
531551 |
+ p += strcspn(p, "\n\r");
|
|
|
531551 |
+ continue;
|
|
|
531551 |
+ }
|
|
|
531551 |
+ if (strncmp(p, varname, varsz) != 0) {
|
|
|
531551 |
+ p += strcspn(p, "\n\r");
|
|
|
531551 |
+ continue;
|
|
|
531551 |
+ }
|
|
|
531551 |
+ p += varsz;
|
|
|
531551 |
+ p += strspn(p, " \t\n\r=\"");
|
|
|
531551 |
+ eol = p + strcspn(p, "\n\r");
|
|
|
531551 |
+ *eol = '\0';
|
|
|
531551 |
+ eon = eol-1;
|
|
|
531551 |
+ while (eon > p) {
|
|
|
531551 |
+ if (*eon == '\t' || *eon == ' ') {
|
|
|
531551 |
+ eon--;
|
|
|
531551 |
+ continue;
|
|
|
531551 |
+ }
|
|
|
531551 |
+ if (*eon == '"') {
|
|
|
531551 |
+ *eon = '\0';
|
|
|
531551 |
+ break;
|
|
|
531551 |
+ }
|
|
|
531551 |
+ break;
|
|
|
531551 |
+ }
|
|
|
531551 |
+ if (ret)
|
|
|
531551 |
+ free(ret);
|
|
|
531551 |
+ ret = strdup(p);
|
|
|
531551 |
+ if (!ret)
|
|
|
531551 |
+ log_err(_("failed to allocate memory: %m"));
|
|
|
531551 |
+ p = eol + 1;
|
|
|
531551 |
+ }
|
|
|
531551 |
+done:
|
|
|
531551 |
+ free(buf);
|
|
|
531551 |
+ if (fd >= 0)
|
|
|
531551 |
+ close(fd);
|
|
|
531551 |
+ return ret;
|
|
|
531551 |
+}
|
|
|
531551 |
+
|
|
|
531551 |
/* Show login prompt, optionally preceded by /etc/issue contents. */
|
|
|
531551 |
static void do_prompt(struct options *op, struct termios *tp)
|
|
|
531551 |
{
|
|
|
531551 |
@@ -1968,6 +2048,24 @@ static void output_special_char(unsigned
|
|
|
531551 |
}
|
|
|
531551 |
break;
|
|
|
531551 |
}
|
|
|
531551 |
+ case 'S':
|
|
|
531551 |
+ {
|
|
|
531551 |
+ char *var = NULL, varname[64];
|
|
|
531551 |
+
|
|
|
531551 |
+ if (get_escape_argument(fp, varname, sizeof(varname)))
|
|
|
531551 |
+ var = read_os_release(op, varname);
|
|
|
531551 |
+ else if (!(var = read_os_release(op, "PRETTY_NAME")))
|
|
|
531551 |
+ var = uts.sysname;
|
|
|
531551 |
+ if (var) {
|
|
|
531551 |
+ if (strcmp(varname, "ANSI_COLOR") == 0)
|
|
|
531551 |
+ printf("\033[%sm", var);
|
|
|
531551 |
+ else
|
|
|
531551 |
+ printf("%s", var);
|
|
|
531551 |
+ if (var != uts.sysname)
|
|
|
531551 |
+ free(var);
|
|
|
531551 |
+ }
|
|
|
531551 |
+ break;
|
|
|
531551 |
+ }
|
|
|
531551 |
case 'u':
|
|
|
531551 |
case 'U':
|
|
|
531551 |
{
|