diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-03-29 16:19:33 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-04-05 08:13:53 +0200 |
commit | bb9947be2fa308d198b63b30e494ade5d68e5109 (patch) | |
tree | 4ed9fd6fdfe824d5bad256639eff2514957dd7f4 /src/tmpfiles/tmpfiles.c | |
parent | c75436067f4b392ecf161e123279720dc5c3b33a (diff) | |
download | systemd-bb9947be2fa308d198b63b30e494ade5d68e5109.tar.gz |
tmpfiles: add a new return code for "operational failure" when processing
Things can fail, and we have no control over it:
- file system issues (immutable bits, file system errors, MAC refusals, etc)
- kernel refusing certain arguments when writing to /proc/sys or /sys
Let's add a new code for the case where we parsed configuration but failed
to execute it because of external errors.
Diffstat (limited to 'src/tmpfiles/tmpfiles.c')
-rw-r--r-- | src/tmpfiles/tmpfiles.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c index 61e76570b1..9bb6a4f7e6 100644 --- a/src/tmpfiles/tmpfiles.c +++ b/src/tmpfiles/tmpfiles.c @@ -1292,7 +1292,7 @@ static int write_one_file(Item *i, const char *path) { fd = safe_close(fd); -done: + done: if (stat(path, &st) < 0) return log_error_errno(errno, "stat(%s) failed: %m", path); @@ -2728,7 +2728,7 @@ static int read_config_files(char **config_dirs, char **args, bool *invalid_conf } int main(int argc, char *argv[]) { - int r, k; + int r, k, r_process = 0; ItemArray *a; Iterator iterator; _cleanup_strv_free_ char **config_dirs = NULL; @@ -2775,7 +2775,7 @@ int main(int argc, char *argv[]) { t = strv_join(config_dirs, "\n\t"); if (t) - log_debug("Looking for configuration files in (higher priority first:\n\t%s", t); + log_debug("Looking for configuration files in (higher priority first):\n\t%s", t); } /* If command line arguments are specified along with --replace, read all @@ -2791,22 +2791,20 @@ int main(int argc, char *argv[]) { if (r < 0) goto finish; - - /* The non-globbing ones usually create things, hence we apply * them first */ ORDERED_HASHMAP_FOREACH(a, items, iterator) { k = process_item_array(a); - if (k < 0 && r == 0) - r = k; + if (k < 0 && r_process == 0) + r_process = k; } /* The globbing ones usually alter things, hence we apply them * second. */ ORDERED_HASHMAP_FOREACH(a, globs, iterator) { k = process_item_array(a); - if (k < 0 && r == 0) - r = k; + if (k < 0 && r_process == 0) + r_process = k; } finish: @@ -2821,10 +2819,12 @@ finish: mac_selinux_finish(); - if (r < 0) + if (r < 0 || ERRNO_IS_RESOURCE(-r_process)) return EXIT_FAILURE; else if (invalid_config) return EX_DATAERR; + else if (r_process < 0) + return EX_CANTCREAT; else return EXIT_SUCCESS; } |