summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarel Zak <kzak@redhat.com>2015-03-05 12:25:28 +0100
committerKarel Zak <kzak@redhat.com>2015-03-12 10:15:47 +0100
commit753f2807c9297d4226b7cfe44fd145f9e3e2b40b (patch)
treeb8c7eeec865ead0b407ae8b14911cc3c1c8a1287
parent32881ca22daba4bff0520d150ef64b8b55036e73 (diff)
downloadutil-linux-753f2807c9297d4226b7cfe44fd145f9e3e2b40b.tar.gz
agetty: support /usr/lib/os-release too
http://www.freedesktop.org/software/systemd/man/os-release.html The file /etc/os-release takes precedence over /usr/lib/os-release. Applications should check for the former, and exclusively use its data if it exists, and only fall back to /usr/lib/os-release if it is missing. Reported-by: Dimitri John Ledkov <dimitri.j.ledkov@intel.com> Signed-off-by: Karel Zak <kzak@redhat.com>
-rw-r--r--include/pathnames.h4
-rw-r--r--term-utils/agetty.87
-rw-r--r--term-utils/agetty.c9
3 files changed, 13 insertions, 7 deletions
diff --git a/include/pathnames.h b/include/pathnames.h
index cc01589cd..9d2c22b4e 100644
--- a/include/pathnames.h
+++ b/include/pathnames.h
@@ -69,7 +69,9 @@
/* used in term-utils/agetty.c */
#define _PATH_ISSUE "/etc/issue"
-#define _PATH_OS_RELEASE "/etc/os-release"
+#define _PATH_OS_RELEASE_ETC "/etc/os-release"
+#define _PATH_OS_RELEASE_USR "/usr/lib/os-release"
+
#define _PATH_NUMLOCK_ON _PATH_LOCALSTATEDIR "/numlock-on"
#define _PATH_LOGINDEFS "/etc/login.defs"
diff --git a/term-utils/agetty.8 b/term-utils/agetty.8
index c4b7f13e2..66f1a0389 100644
--- a/term-utils/agetty.8
+++ b/term-utils/agetty.8
@@ -338,8 +338,9 @@ Insert the system name, the name of the operating system. Same as `uname \-s'.
See also \\S escape code.
.TP
S or S{VARIABLE}
-Insert the VARIABLE data from \fI/etc/os-release\fP. If the VARIABLE argument
-is not specified then use PRETTY_NAME from the file or the system name (see \\s).
+Insert the VARIABLE data from \fI/etc/os-release\fP, if the file does not exist
+then fallback to \fI/usr/lib/os-release\fP. If the VARIABLE argument is not
+specified then use PRETTY_NAME from the file or the system name (see \\s).
This escape code allows to keep \fI/etc/issue\fP distribution and release
independent. Note that \\S{ANSI_COLOR} is converted to the real terminal
escape sequence.
@@ -401,7 +402,7 @@ the system status file.
.B /etc/issue
printed before the login prompt.
.TP
-.B /etc/os-release
+.B /etc/os-release /usr/lib/os-release
operating system identification data.
.TP
.B /dev/console
diff --git a/term-utils/agetty.c b/term-utils/agetty.c
index 7c97faffa..0d7bd1db7 100644
--- a/term-utils/agetty.c
+++ b/term-utils/agetty.c
@@ -1444,10 +1444,13 @@ static char *read_os_release(struct options *op, const char *varname)
/* read the file only once */
if (!op->osrelease) {
- fd = open(_PATH_OS_RELEASE, O_RDONLY);
+ fd = open(_PATH_OS_RELEASE_ETC, O_RDONLY);
if (fd == -1) {
- log_warn(_("cannot open %s: %m"), _PATH_OS_RELEASE);
- return NULL;
+ fd = open(_PATH_OS_RELEASE_USR, O_RDONLY);
+ if (fd == -1) {
+ log_warn(_("cannot open os-release file"));
+ return NULL;
+ }
}
if (fstat(fd, &st) < 0 || st.st_size > 4 * 1024 * 1024)