summaryrefslogtreecommitdiff
path: root/src/shared/path-util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-06-13 19:45:52 +0200
committerLennart Poettering <lennart@poettering.net>2014-06-13 20:11:59 +0200
commit5ae4d543cb9b45ad6c6b82b78da1d6abc2291cdb (patch)
treecf4d8817660f9a2a828c16ce42392703a5ccd690 /src/shared/path-util.c
parentb0284aba93e8ccd415da5bbee86d84c12b1b9856 (diff)
os-release: define /usr/lib/os-release as fallback for /etc/os-release
The file should have been in /usr/lib/ in the first place, since it describes the OS container in /usr (and not the configuration in /etc), hence, let's support os-release files in /usr/lib as fallback if no version in /etc exists, following the usual override logic. A prior commit already enabled tmpfiles to create /etc/os-release as a symlink to /usr/lib/os-release should it be missing, thus providing nice compatibility with applications only checking in /etc. While it's probably a good idea if all apps check both locations via a fallback logic, it is only necessary in the early boot process, as long as the /etc/os-release symlink has not been restored, in case we boot with an empty /etc.
Diffstat (limited to 'src/shared/path-util.c')
-rw-r--r--src/shared/path-util.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/shared/path-util.c b/src/shared/path-util.c
index 5863429c3..efe464d70 100644
--- a/src/shared/path-util.c
+++ b/src/shared/path-util.c
@@ -526,12 +526,18 @@ int path_is_os_tree(const char *path) {
char *p;
int r;
- /* We use /etc/os-release as flag file if something is an OS */
+ /* We use /usr/lib/os-release as flag file if something is an OS */
+ p = strappenda(path, "/usr/lib/os-release");
+ r = access(p, F_OK);
+
+ if (r >= 0)
+ return 1;
+ /* Also check for the old location in /etc, just in case. */
p = strappenda(path, "/etc/os-release");
r = access(p, F_OK);
- return r < 0 ? 0 : 1;
+ return r >= 0;
}
int find_binary(const char *name, char **filename) {