summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2012-03-20 15:31:09 +0100
committerLennart Poettering <lennart@poettering.net>2012-03-20 15:31:09 +0100
commitde19ece73860e90a10029fbc4c4f6d3b296f1a1e (patch)
tree521bb04f22e9af1f5abd7716809c0c1f00d7b27b /src
parent4e2075ceea72b3e7e753bf5c6c0e8c4a3b68cdd9 (diff)
sysctl: accept multiple passed configuration files
Diffstat (limited to 'src')
-rw-r--r--src/sysctl.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/src/sysctl.c b/src/sysctl.c
index 852ec91c9c..17c6719841 100644
--- a/src/sysctl.c
+++ b/src/sysctl.c
@@ -219,28 +219,34 @@ int main(int argc, char *argv[]) {
if (r <= 0)
return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
- if (argc-optind > 1) {
- log_error("This program expects one or no arguments.");
- return EXIT_FAILURE;
- }
-
log_set_target(LOG_TARGET_AUTO);
log_parse_environment();
log_open();
umask(0022);
- if (argc > optind)
- r = apply_file(argv[optind], false);
- else {
+ if (argc > optind) {
+ int i;
+
+ for (i = optind; i < argc; i++) {
+ int k;
+
+ k = apply_file(argv[i], false);
+ if (k < 0 && r == 0)
+ r = k;
+ }
+ } else {
char **files, **f;
+ int k;
r = conf_files_list(&files, ".conf",
"/etc/sysctl.d",
"/run/sysctl.d",
"/usr/local/lib/sysctl.d",
"/usr/lib/sysctl.d",
+#ifdef HAVE_SPLIT_USR
"/lib/sysctl.d",
+#endif
NULL);
if (r < 0) {
log_error("Failed to enumerate sysctl.d files: %s", strerror(-r));
@@ -248,14 +254,14 @@ int main(int argc, char *argv[]) {
}
STRV_FOREACH(f, files) {
- int k;
-
k = apply_file(*f, true);
if (k < 0 && r == 0)
r = k;
}
- apply_file("/etc/sysctl.conf", true);
+ k = apply_file("/etc/sysctl.conf", true);
+ if (k < 0 && r == 0)
+ r = k;
strv_free(files);
}