]> err.no Git - systemd/commitdiff
container: skip a few things when we are run in a container such as accessing /proc...
authorLennart Poettering <lennart@poettering.net>
Mon, 14 Mar 2011 22:41:47 +0000 (23:41 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 14 Mar 2011 22:41:47 +0000 (23:41 +0100)
src/condition.c
src/fsck.c
src/locale-setup.c
src/quotacheck.c
src/target.c
src/vconsole-setup.c

index 1d6cf12ad4b71c46086d5791cd45d5bebd4d4de0..1dce276c00575004f48ecde1ff40de576a8ed771 100644 (file)
@@ -67,6 +67,9 @@ static bool test_kernel_command_line(const char *parameter) {
 
         assert(parameter);
 
+        if (detect_virtualization(NULL) > 0)
+                return false;
+
         if ((r = read_one_line_file("/proc/cmdline", &line)) < 0) {
                 log_warning("Failed to read /proc/cmdline, ignoring: %s", strerror(-r));
                 return false;
index b5d8764e00fb5e828293980125f0b0afad899861..a3c83c3c2428000e5bddc9d0d76b0f1d4730d451 100644 (file)
@@ -106,6 +106,9 @@ static int parse_proc_cmdline(void) {
         int r;
         size_t l;
 
+        if (detect_virtualization(NULL) > 0)
+                return 0;
+
         if ((r = read_one_line_file("/proc/cmdline", &line)) < 0) {
                 log_warning("Failed to read /proc/cmdline, ignoring: %s", strerror(-r));
                 return 0;
index 7684681cca64c926d600f3c2252d9a715ef21c61..055c1fa3f31b03104b5da17bd28734bdc6e97845 100644 (file)
@@ -69,28 +69,29 @@ int locale_setup(void) {
 
         zero(variables);
 
-        if ((r = parse_env_file("/proc/cmdline", WHITESPACE,
+        if (detect_virtualization(NULL) <= 0)
+                if ((r = parse_env_file("/proc/cmdline", WHITESPACE,
 #ifdef TARGET_FEDORA
-                                "LANG",                     &variables[VARIABLE_LANG],
+                                        "LANG",                     &variables[VARIABLE_LANG],
 #endif
-                                "locale.LANG",              &variables[VARIABLE_LANG],
-                                "locale.LC_CTYPE",          &variables[VARIABLE_LC_CTYPE],
-                                "locale.LC_NUMERIC",        &variables[VARIABLE_LC_NUMERIC],
-                                "locale.LC_TIME",           &variables[VARIABLE_LC_TIME],
-                                "locale.LC_COLLATE",        &variables[VARIABLE_LC_COLLATE],
-                                "locale.LC_MONETARY",       &variables[VARIABLE_LC_MONETARY],
-                                "locale.LC_MESSAGES",       &variables[VARIABLE_LC_MESSAGES],
-                                "locale.LC_PAPER",          &variables[VARIABLE_LC_PAPER],
-                                "locale.LC_NAME",           &variables[VARIABLE_LC_NAME],
-                                "locale.LC_ADDRESS",        &variables[VARIABLE_LC_ADDRESS],
-                                "locale.LC_TELEPHONE",      &variables[VARIABLE_LC_TELEPHONE],
-                                "locale.LC_MEASUREMENT",    &variables[VARIABLE_LC_MEASUREMENT],
-                                "locale.LC_IDENTIFICATION", &variables[VARIABLE_LC_IDENTIFICATION],
-                                NULL)) < 0) {
-
-                if (r != -ENOENT)
-                        log_warning("Failed to read /proc/cmdline: %s", strerror(-r));
-        }
+                                        "locale.LANG",              &variables[VARIABLE_LANG],
+                                        "locale.LC_CTYPE",          &variables[VARIABLE_LC_CTYPE],
+                                        "locale.LC_NUMERIC",        &variables[VARIABLE_LC_NUMERIC],
+                                        "locale.LC_TIME",           &variables[VARIABLE_LC_TIME],
+                                        "locale.LC_COLLATE",        &variables[VARIABLE_LC_COLLATE],
+                                        "locale.LC_MONETARY",       &variables[VARIABLE_LC_MONETARY],
+                                        "locale.LC_MESSAGES",       &variables[VARIABLE_LC_MESSAGES],
+                                        "locale.LC_PAPER",          &variables[VARIABLE_LC_PAPER],
+                                        "locale.LC_NAME",           &variables[VARIABLE_LC_NAME],
+                                        "locale.LC_ADDRESS",        &variables[VARIABLE_LC_ADDRESS],
+                                        "locale.LC_TELEPHONE",      &variables[VARIABLE_LC_TELEPHONE],
+                                        "locale.LC_MEASUREMENT",    &variables[VARIABLE_LC_MEASUREMENT],
+                                        "locale.LC_IDENTIFICATION", &variables[VARIABLE_LC_IDENTIFICATION],
+                                        NULL)) < 0) {
+
+                        if (r != -ENOENT)
+                                log_warning("Failed to read /proc/cmdline: %s", strerror(-r));
+                }
 
         /* Hmm, nothing set on the kernel cmd line? Then let's
          * try /etc/locale.conf */
index da2da3b2e05adca5ddcc79ec6452ab0d0e444e51..057d8617c2290172170771cbebb1b7580df43919 100644 (file)
@@ -35,6 +35,9 @@ static int parse_proc_cmdline(void) {
         int r;
         size_t l;
 
+        if (detect_virtualization(NULL) > 0)
+                return 0;
+
         if ((r = read_one_line_file("/proc/cmdline", &line)) < 0) {
                 log_warning("Failed to read /proc/cmdline, ignoring: %s", strerror(-r));
                 return 0;
index e61255c12311f9adc443f385d0d135ed614f1efb..b8d4a01b6448e37aefd5ae6c44f673097ccc9807 100644 (file)
@@ -92,6 +92,9 @@ static int target_add_getty_dependencies(Target *t) {
         if (!unit_has_name(UNIT(t), SPECIAL_GETTY_TARGET))
                 return 0;
 
+        if (detect_container(NULL) > 0)
+                return 1;
+
         if (read_one_line_file("/sys/class/tty/console/active", &active) >= 0) {
                 const char *tty;
 
index 5b977126faefb352601ca892cb256efd4f676c55..29ce7be77e776e3dbe8c5a07bd801b492bf0ca23 100644 (file)
@@ -176,21 +176,22 @@ int main(int argc, char **argv) {
 
         utf8 = is_locale_utf8();
 
-        if ((r = parse_env_file("/proc/cmdline", WHITESPACE,
+        if (detect_virtualization(NULL) <= 0)
+                if ((r = parse_env_file("/proc/cmdline", WHITESPACE,
 #ifdef TARGET_FEDORA
-                                "SYSFONT", &vc_font,
-                                "KEYTABLE", &vc_keymap,
+                                        "SYSFONT", &vc_font,
+                                        "KEYTABLE", &vc_keymap,
 #endif
-                                "vconsole.keymap", &vc_keymap,
-                                "vconsole.keymap.toggle", &vc_keymap_toggle,
-                                "vconsole.font", &vc_font,
-                                "vconsole.font.map", &vc_font_map,
-                                "vconsole.font.unimap", &vc_font_unimap,
-                                NULL)) < 0) {
+                                        "vconsole.keymap", &vc_keymap,
+                                        "vconsole.keymap.toggle", &vc_keymap_toggle,
+                                        "vconsole.font", &vc_font,
+                                        "vconsole.font.map", &vc_font_map,
+                                        "vconsole.font.unimap", &vc_font_unimap,
+                                        NULL)) < 0) {
 
-                if (r != -ENOENT)
-                        log_warning("Failed to read /proc/cmdline: %s", strerror(-r));
-        }
+                        if (r != -ENOENT)
+                                log_warning("Failed to read /proc/cmdline: %s", strerror(-r));
+                }
 
         /* Hmm, nothing set on the kernel cmd line? Then let's
          * try /etc/vconsole.conf */