diff options
author | Craig Small <csmall@enc.com.au> | 2013-09-20 22:34:32 +1000 |
---|---|---|
committer | Craig Small <csmall@enc.com.au> | 2013-09-20 22:34:32 +1000 |
commit | cdca71e94506fbb921ab2c626be3ad05c4287498 (patch) | |
tree | c3f10ee8ce6da5119dae5ee61101843ff3be293f | |
parent | 4141efaf13254564f0377289bcf5a1a1389f60af (diff) | |
download | procps-ng-cdca71e94506fbb921ab2c626be3ad05c4287498.tar.gz |
sysctl --system ignores missing /etc/sysctl.conf
sysctl --system would not correctly return the RC for files in
subdirectories and would insist on having /etc/sysctl.conf
This update makes two changes when using sysctl --system:
- The RC status is ORed for each config file, meaning an error in
any file is propated to the RC
- If /etc/sysctl.conf doesn't exist we just don't load it
References:
https://bbs.archlinux.org/viewtopic.php?id=170005
http://www.freelists.org/post/procps/wrong-defaults-for-sysctl-on-arch-linux
-rw-r--r-- | sysctl.c | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -578,6 +578,8 @@ static int PreloadSystem(void) }; struct pair **cfgs = NULL; unsigned ncfgs = 0; + int rc = 0; + struct stat ts; enum { nprealloc = 16 }; for (di = 0; di < sizeof(dirs) / sizeof(dirs[0]); ++di) { @@ -634,12 +636,16 @@ static int PreloadSystem(void) for (i = 0; i < ncfgs; ++i) { if (!Quiet) printf(_("* Applying %s ...\n"), cfgs[i]->value); - Preload(cfgs[i]->value); + rc |= Preload(cfgs[i]->value); } - if (!Quiet) - printf(_("* Applying %s ...\n"), DEFAULT_PRELOAD); - return Preload(DEFAULT_PRELOAD); + + if (stat(DEFAULT_PRELOAD, &ts) < 0 && S_ISREG(ts.st_mode)) { + if (!Quiet) + printf(_("* Applying %s ...\n"), DEFAULT_PRELOAD); + rc |= Preload(DEFAULT_PRELOAD); + } + return rc; } /* |