]> err.no Git - systemd/commitdiff
fragment: allow prefixing of the EnvironmentFile= path with - to ignore errors
authorLennart Poettering <lennart@poettering.net>
Thu, 6 Jan 2011 00:39:08 +0000 (01:39 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 6 Jan 2011 00:39:08 +0000 (01:39 +0100)
TODO
man/systemd.exec.xml
src/load-fragment.c

diff --git a/TODO b/TODO
index fb23de9096cce798b6dba1229f29bd47a55e7ddc..7f3ae5fabea05c1c4ba4bda652879ce034121b23 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,3 +1,5 @@
+* dbus should run with oom adjust set
+
 * support caching password questions in plymouth and on the console
   https://bugzilla.redhat.com/show_bug.cgi?id=655538
 
 
 * global defaults for StandardOuput=xxx
 
-* Make EnvironmentFile=-/fooobar/waldo ingnore errors while reading /foobar/waldo
-
 * mkswap/mke2fs is called on wrong devices in crypto devices.
 
 Fedora:
index b24792b0a088201d4a38d7ec5994479ee6083db3..d6ac5aed89d6828e6746facee8eda4c0e432a515 100644 (file)
                                 contain new-line separated variable
                                 assignments. Empty lines and lines
                                 starting with ; or # will be ignored,
-                                which may be used for
-                                commenting.</para></listitem>
+                                which may be used for commenting. The
+                                argument passed should be an absolute
+                                file name, optionally prefixed with
+                                "-", which indicates that if the file
+                                does not exist it won't be read and no
+                                error or warning message is
+                                logged.</para></listitem>
                         </varlistentry>
 
                         <varlistentry>
index 281863264e1ec212b6a0bc0eed68d14b27f6ab41..334dd68146c175e9121611af9bc4022bd03827db 100644 (file)
@@ -1348,14 +1348,26 @@ static int config_parse_env_file(
         FILE *f;
         int r;
         char ***env = data;
+        bool ignore = false;
 
         assert(filename);
         assert(lvalue);
         assert(rvalue);
         assert(data);
 
+        if (rvalue[0] == '-') {
+                ignore = true;
+                rvalue++;
+        }
+
+        if (!path_is_absolute(rvalue)) {
+                log_error("[%s:%u] Path '%s' is not absolute, ignoring.", filename, line, rvalue);
+                return 0;
+        }
+
         if (!(f = fopen(rvalue, "re"))) {
-                log_error("[%s:%u] Failed to open environment file '%s', ignoring: %m", filename, line, rvalue);
+                if (!ignore)
+                        log_error("[%s:%u] Failed to open environment file '%s', ignoring: %m", filename, line, rvalue);
                 return 0;
         }