summaryrefslogtreecommitdiff
path: root/src/shared/util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-12-23 18:10:57 +0100
committerLennart Poettering <lennart@poettering.net>2013-12-23 18:13:12 +0100
commit02bb6cda87189ce0be10e8daba5c781f5eb90634 (patch)
treec730ef5f7cd2f16046900966cdfbbd4d01270ffd /src/shared/util.c
parentb8d0ffc21f9c237cdeef49b1873b47df1a0a1543 (diff)
util: when we try to read /proc/cmdline in a container, read /proc/1/cmdline instead
Diffstat (limited to 'src/shared/util.c')
-rw-r--r--src/shared/util.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/shared/util.c b/src/shared/util.c
index 5c9d0bb730..8d7cf5398f 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -5994,8 +5994,20 @@ int proc_cmdline(char **ret) {
int r;
if (detect_container(NULL) > 0) {
- *ret = NULL;
- return 0;
+ char *buf, *p;
+ size_t sz = 0;
+
+ r = read_full_file("/proc/1/cmdline", &buf, &sz);
+ if (r < 0)
+ return r;
+
+ for (p = buf; p + 1 < buf + sz; p++)
+ if (*p == 0)
+ *p = ' ';
+
+ *p = 0;
+ *ret = buf;
+ return 1;
}
r = read_one_line_file("/proc/cmdline", ret);