summaryrefslogtreecommitdiff
path: root/src/sysctl
AgeCommit message (Collapse)Author
2016-11-02sysctl: minor simplificationLennart Poettering
Let's place only one ternary operator.
2016-11-02sysctl: no need to check for eof twiceLennart Poettering
Let's only check for eof once after the fgets(). There's no point in checking EOF before the first read, and twice in each loop.
2016-11-02sysctl: when failing to process a config line, show line nrLennart Poettering
2016-11-02sysctl: split out condition check into its own functionLennart Poettering
This way, we can get rid of a label/goto.
2016-11-02sysctl: do not fail systemd-sysctl.service if /proc/sys is mounted read-onlyLennart Poettering
Let's make missing write access to /proc/sys non-fatal to the sysctl service. This is a follow-up to 411e869f497c7c7bd0688f1e3500f9043bc56e48 which altered the condition for running the sysctl service to check for /proc/sys/net being writable, accepting that /proc/sys might be read-only. In order to ensure the boot-up stays clean in containers lower the log level for the EROFS errors generated due to this.
2016-09-24sysctl: configure kernel parameters in the order they occur in each sysctl ↵HATAYAMA Daisuke
configuration files (#4205) Currently, systemd-sysctl command configures kernel parameters in each sysctl configuration files in random order due to characteristics of iterator of Hashmap. However, kernel parameters need to be configured in the order they occur in each sysctl configuration files. - For example, consider fs.suid_coredump and kernel.core_pattern. If fs.suid_coredump=2 is configured before kernel.core_pattern= whose default value is "core", then kernel outputs the following message: Unsafe core_pattern used with suid_dumpable=2. Pipe handler or fully qualified core dump path required. Note that the security issue mentioned in this message has already been fixed on recent kernels, so this is just a warning message on such kernels. But it's still confusing to users that this message is output on some boot and not output on another boot. - I don't know but there could be other kernel parameters that are significant in the order they are configured. - The legacy sysctl command configures kernel parameters in the order they occur in each sysctl configuration files. Although I didn't find any official specification explaining this behavior of sysctl command, I don't think there is any meaningful reason to change this behavior, in particular, to the random one. This commit does the change by simply using OrderedHashmap instead of Hashmap.
2016-02-10tree-wide: remove Emacs lines from all filesDaniel Mack
This should be handled fine now by .dir-locals.el, so need to carry that stuff in every file.
2015-11-10defs: rework CONF_DIRS_NULSTR() macroLennart Poettering
The macro is generically useful for putting together search paths, hence let's make it truly generic, by dropping the implicit ".d" appending it does, and leave that to the caller. Also rename it from CONF_DIRS_NULSTR() to CONF_PATHS_NULSTR(), since it's not strictly about dirs that way, but any kind of file system path. Also, mark CONF_DIR_SPLIT_USR() as internal macro by renaming it to _CONF_PATHS_SPLIT_USR() so that the leading underscore indicates that it's internal.
2015-11-09treewide: apply errno.cocciMichal Schmidt
with small manual cleanups for style.
2015-11-03util-lib: move CONF_DIRS_NULSTR definition to def.hLennart Poettering
After all, this is not some compiler or C magic, but something very specific to how systemd works, hence let's move it into def.h, and out of macro.h
2015-10-25util-lib: split out fd-related operations into fd-util.[ch]Lennart Poettering
There are more than enough to deserve their own .c file, hence move them over.
2015-10-24util-lib: split our string related calls from util.[ch] into its own file ↵Lennart Poettering
string-util.[ch] There are more than enough calls doing string manipulations to deserve its own files, hence do something about it. This patch also sorts the #include blocks of all files that needed to be updated, according to the sorting suggestions from CODING_STYLE. Since pretty much every file needs our string manipulation functions this effectively means that most files have sorted #include blocks now. Also touches a few unrelated include files.
2015-09-29util: introduce common version() implementation and use it everywhereLennart Poettering
This also allows us to drop build.h from a ton of files, hence do so. Since we touched the #includes of those files, let's order them properly according to CODING_STYLE.
2015-08-05sysctl: reword warning message a bitLennart Poettering
Let's make this less dramatic, in order to not confuse people too much making them think that this was something to actually fix.
2015-08-05sysctl: bump loglevel when attempting to write invalid valuesJan Synacek
2015-04-24sysctl: don't propagate ENOENT sysctl optionsLennart Poettering
We shouldn't fail the sysctl service if an option is missing. Previously the warning about this was already downgraded to LOG_DEBUG, but we really shouldn't propagate such errors either.
2015-03-14sysctl: tweak debug messageZbigniew Jędrzejewski-Szmek
2015-03-11sysctl: move property handling to shared/Kay Sievers
2015-02-26sysctl: downgrade message about sysctl overrides to debugZbigniew Jędrzejewski-Szmek
Printing it at info level was tedious. We don't do that for any other overrides.
2015-02-07sysctl: consider --prefix while parsing the filesUmut Tezduyar Lindskog
not while applying the parsed sysctl values. Otherwise info "Overwriting earlier assignment of %s in file %s" is visible many times even though the given --prefix doesn't try to set the overridden value. This also optimizes the startup tiny bit since we have udev rules running on network devices and setting sysctl through the rules.
2014-11-28treewide: use log_*_errno whenever %m is in the format stringMichal Schmidt
If the format string contains %m, clearly errno must have a meaningful value, so we might as well use log_*_errno to have ERRNO= logged. Using: find . -name '*.[ch]' | xargs sed -r -i -e \ 's/log_(debug|info|notice|warning|error|emergency)\((".*%m.*")/log_\1_errno(errno, \2/' Plus some whitespace, linewrap, and indent adjustments.
2014-11-28treewide: a few more log_*_errno + return simplificationsMichal Schmidt
The one in tmpfiles.c:create_item() even looks like it fixes a bug.
2014-11-28treewide: no need to negate errno for log_*_errno()Michal Schmidt
It corrrectly handles both positive and negative errno values.
2014-11-28treewide: auto-convert the simple cases to log_*_errno()Michal Schmidt
As a followup to 086891e5c1 "log: add an "error" parameter to all low-level logging calls and intrdouce log_error_errno() as log calls that take error numbers", use sed to convert the simple cases to use the new macros: find . -name '*.[ch]' | xargs sed -r -i -e \ 's/log_(debug|info|notice|warning|error|emergency)\("(.*)%s"(.*), strerror\(-([a-zA-Z_]+)\)\);/log_\1_errno(-\4, "\2%m"\3);/' Multi-line log_*() invocations are not covered. And we also should add log_unit_*_errno().
2014-11-26Introduce CONF_DIRS_NULSTR helper to define standard conf dirsJosh Triplett
Several different systemd tools define a nulstr containing a standard series of configuration file directories, in /etc, /run, /usr/local/lib, /usr/lib, and (#ifdef HAVE_SPLIT_USR) /lib. Factor that logic out into a new helper macro, CONF_DIRS_NULSTR.
2014-09-17sysctl: make --prefix allow all kinds of sysctl pathsDavid Herrmann
Currently, we save arguments passed as --prefix directly and compare them later to absolute sysctl file-system paths. That is, you are required to specify arguments to --prefix with leading /proc/sys/. This is kinda uselesss. Furthermore, we replace dots by slashes in the name, which makes it impossible to match on specific sysfs paths that have dots in their name (like netdev names). The intention of this argument is clear, but it never worked as expected. This patch modifies --prefix to accept any kind of sysctl paths. It supports paths prefixed with /proc/sys for compatibility (but drops the erroneous dot->slash conversion), but instead applies normalize_sysctl() which turns any name or path into a proper path. It then appends /proc/sys/ so we can properly use it in matches. Thanks to Jan Synacek <jsynacek@redhat.com> for catching this!
2014-09-15hashmap: introduce hash_ops to make struct Hashmap smallerMichal Schmidt
It is redundant to store 'hash' and 'compare' function pointers in struct Hashmap separately. The functions always comprise a pair. Store a single pointer to struct hash_ops instead. systemd keeps hundreds of hashmaps, so this saves a little bit of memory.
2014-08-03Unify parse_argv styleZbigniew Jędrzejewski-Szmek
getopt is usually good at printing out a nice error message when commandline options are invalid. It distinguishes between an unknown option and a known option with a missing arg. It is better to let it do its job and not use opterr=0 unless we actually want to suppress messages. So remove opterr=0 in the few places where it wasn't really useful. When an error in options is encountered, we should not print a lengthy help() and overwhelm the user, when we know precisely what is wrong with the commandline. In addition, since help() prints to stdout, it should not be used except when requested with -h or --help. Also, simplify things here and there.
2014-04-16sysctl: replaces some slashes with dotsZbigniew Jędrzejewski-Szmek
It turns out that plain sysctl understands a.b/c syntax to write to /proc/sys/a/b.c. Support this for compatibility. https://bugs.freedesktop.org/show_bug.cgi?id=77466
2014-03-16Use strlen even for constant stringsJosh Triplett
GCC optimizes strlen("string constant") to a constant, even with -O0. Thus, replace patterns like sizeof("string constant")-1 with strlen("string constant") where possible, for clarity. In particular, for expressions intended to add up the lengths of components going into a string, this often makes it clearer that the expression counts the trailing '\0' exactly once, by putting the +1 for the '\0' at the end of the expression, rather than hidden in a sizeof in the middle of the expression.
2014-03-14shared: add root argument to search_and_fopenMichael Marineau
This adds the same root argument to search_and_fopen that conf_files_list already has. Tools that use those two functions as a pair can now be easily modified to load configuration files from an alternate root filesystem tree.
2014-01-05Remove unused variablesZbigniew Jędrzejewski-Szmek
2014-01-05strv: multiple cleanupsSimon Peeters
- turn strv_merge into strv_extend_strv. appending strv b to the end of strv a instead of creating a new strv - strv_append: remove in favor of strv_extend and strv_push. - strv_remove: write slightly more elegant - strv_remove_prefix: remove unused function - strv_overlap: use strv_contains - strv_printf: STRV_FOREACH handles NULL correctly
2013-12-24log: log_error() and friends add a newline after each line anyway, so avoid ↵Lennart Poettering
including it in the log strings
2013-11-18Remove duplicate includesKarel Zak
2013-11-06clients: unify how we invoke getopt_long()Lennart Poettering
Among other things this makes sure we always expose a --version command and show it in the help texts.
2013-08-15sysctl: allow overwriting of values specified in "later" filesKay Sievers
2013-04-13fileio: in envfiles, do not skip lines following empty linesZbigniew Jędrzejewski-Szmek
https://bugs.freedesktop.org/show_bug.cgi?id=63477
2013-04-03util: rename write_one_line_file() to write_string_file()Lennart Poettering
You can write much more than just one line with this call (and we frequently do), so let's correct the naming.
2013-03-27systemd-sysctl: Handle missing /etc/sysctl.conf properlyEelco Dolstra
Since fabe5c0e5fce730aa66e10a9c4f9fdd443d7aeda, systemd-sysctl returns a non-zero exit code if /etc/sysctl.conf does not exist, due to a broken ENOENT check.
2013-02-14honor SELinux labels, when creating and writing config filesHarald Hoyer
Also split out some fileio functions to fileio.c and provide a SELinux aware pendant in fileio-label.c see https://bugzilla.redhat.com/show_bug.cgi?id=881577
2013-02-13sysctl: fix uninitalized memory access in error pathZbigniew Jędrzejewski-Szmek
src/sysctl/sysctl.c: In function ‘parse_file’: src/sysctl/sysctl.c:172:41: warning: ‘property’ may be used uninitialized in this function [-Wmaybe-uninitialized]
2013-02-11binfmt,tmpfiles,modules-load,sysctl: rework the various early-boot services ↵Lennart Poettering
that work on .d/ directories This unifies much of the logic behind them: - All four will now ofllow the rule that the earlier file and earlier assignment in the .d/ directories wins. Before, sysctl was the only outlier, where the later setting always won. - All four now support getopt() and --help on the command line. - All four can now handle specification of configuration file names on the command line to apply. The tools will automatically find them, and apply them. Previously only tmpfiles could do that. This is useful for %post scripts in RPMs and suchlike. - This fixes various error path issues in conf_files_list()
2013-02-08shared: conf-files - add root parameterKay Sievers
2012-10-26sysctl: parse all keys in a config fileMichal Sekletar
https://bugzilla.redhat.com/show_bug.cgi?id=869779
2012-10-06sysctl: avoiding exiting with error on -EEXISTDave Reisner
If the final key in any sysctl.d file is a duplicate, systemd-sysctl will exit with an error (and no explaination why). Ignore this, as duplicate keys are to be expected when overriding settings in the directory hierarchy.
2012-09-21sysctl: always return the last error we encounteredLennart Poettering
2012-09-21sysctl: fix error code handlingLukas Nykryn
After if (r <= 0) r can't be 0 so if (k < 0 && r == 0) never happens.
2012-08-06sysctl: apply configuration at onceMichal Sekletar
https://bugzilla.redhat.com/show_bug.cgi?id=767795 [ Simplified by iterating the config files in the backwards order - no need for hashmap_update(). Other minor cleanups. -- michich ]
2012-07-26log.h: new log_oom() -> int -ENOMEM, use itShawn Landden
also a number of minor fixups and bug fixes: spelling, oom errors that didn't print errors, not properly forwarding error codes, few more consistency issues, et cetera