summaryrefslogtreecommitdiff
path: root/src/sysctl
Commit message (Collapse)AuthorAgeFilesLines
* tree-wide: get rid of strappend()Lennart Poettering2019-07-121-1/+1
| | | | | It's a special case of strjoin(), so no need to keep both. In particular as typing strjoin() is even shoert than strappend().
* headers: remove unneeded includes from util.hZbigniew Jędrzejewski-Szmek2019-03-271-1/+2
| | | | | This means we need to include many more headers in various files that simply included util.h before, but it seems cleaner to do it this way.
* sysctl: Don't pass null directive argument to '%s'Khem Raj2018-12-161-1/+1
| | | | | | | | value pointer here is always NULL but subsequent use of that pointer with a %s format will always be NULL, printing p instead would be a valid string Signed-off-by: Khem Raj <raj.khem@gmail.com>
* coccinelle: make use of SYNTHETIC_ERRNOZbigniew Jędrzejewski-Szmek2018-11-221-4/+3
| | | | | | | | | | | Ideally, coccinelle would strip unnecessary braces too. But I do not see any option in coccinelle for this, so instead, I edited the patch text using search&replace to remove the braces. Unfortunately this is not fully automatic, in particular it didn't deal well with if-else-if-else blocks and ifdefs, so there is an increased likelikehood be some bugs in such spots. I also removed part of the patch that coccinelle generated for udev, where we returns -1 for failure. This should be fixed independently.
* Split out pretty-print.c and move pager.c and main-func.h to shared/Zbigniew Jędrzejewski-Szmek2018-11-201-1/+1
| | | | | This is high-level functionality, and fits better in shared/ (which is for our executables), than in basic/ (which is also for libraries).
* basic/main-func: also close the pager automaticallyZbigniew Jędrzejewski-Szmek2018-11-201-15/+7
| | | | | | We generally want to close the pager last. This patch closes the pager last, after the static destuctor calls. This means that they can do logging and such like during normal program runtime.
* sysctl: use STATIC_DESTRUCTOR_REGISTER() to free arg_prefixesLennart Poettering2018-11-201-2/+2
|
* sysctl: use _cleanup_ in one more occasionLennart Poettering2018-11-201-2/+1
|
* sysctl: port to use DEFINE_MAIN_FUNCTION()Lennart Poettering2018-11-201-2/+5
|
* log: introduce new helper call log_setup_service()Lennart Poettering2018-11-201-3/+1
| | | | | Let's reduce the common boilerplate and have a single setup function used by all service code to setup logging.
* basic/pager: convert the pager options to a flags argumentZbigniew Jędrzejewski-Szmek2018-11-141-3/+3
| | | | | Pretty much everything uses just the first argument, and this doesn't make this common pattern more complicated, but makes it simpler to pass multiple options.
* tree-wide: add clickable man page link to all --help textsLennart Poettering2018-08-201-4/+15
| | | | | | | | | | This is a bit like the info link in most of GNU's --help texts, but we don't do info but man pages, and we make them properly clickable on terminal supporting that, because awesome. I think it's generally advisable to link up our (brief) --help texts and our (more comprehensive) man pages a bit, so this should be an easy and straight-forward way to do it.
* tree-wide: remove Lennart's copyright linesLennart Poettering2018-06-141-3/+0
| | | | | | | | | | | These lines are generally out-of-date, incomplete and unnecessary. With SPDX and git repository much more accurate and fine grained information about licensing and authorship is available, hence let's drop the per-file copyright notice. Of course, removing copyright lines of others is problematic, hence this commit only removes my own lines and leaves all others untouched. It might be nicer if sooner or later those could go away too, making git the only and accurate source of authorship information.
* tree-wide: drop 'This file is part of systemd' blurbLennart Poettering2018-06-141-2/+0
| | | | | | | | | | | | | | | | This part of the copyright blurb stems from the GPL use recommendations: https://www.gnu.org/licenses/gpl-howto.en.html The concept appears to originate in times where version control was per file, instead of per tree, and was a way to glue the files together. Ultimately, we nowadays don't live in that world anymore, and this information is entirely useless anyway, as people are very welcome to copy these files into any projects they like, and they shouldn't have to change bits that are part of our copyright header for that. hence, let's just get rid of this old cruft, and shorten our codebase a bit.
* binfmt,sysctl,sysuers,tmpfiles: add auto-paging for --cat-config commandsLennart Poettering2018-06-131-0/+13
| | | | | The output of these commands is really long, and already enriched with color. Let's add auto-paging to make this easier to digest.
* Eliminate config_dirs vars which hold a static strvZbigniew Jędrzejewski-Szmek2018-05-071-4/+2
|
* sysctl: add --cat-configZbigniew Jędrzejewski-Szmek2018-04-271-7/+26
|
* tree-wide: drop license boilerplateZbigniew Jędrzejewski-Szmek2018-04-061-13/+0
| | | | | | | | | | Files which are installed as-is (any .service and other unit files, .conf files, .policy files, etc), are left as is. My assumption is that SPDX identifiers are not yet that well known, so it's better to retain the extended header to avoid any doubt. I also kept any copyright lines. We can probably remove them, but it'd nice to obtain explicit acks from all involved authors before doing that.
* tree-wide: use path_hash_ops instead of string_hash_ops whenever we key by a ↵Lennart Poettering2018-02-121-4/+4
| | | | | | path Let's make use of our new hash_ops!
* Use read_line() and LONG_LINE_MAX to read values configuration files.Tiago Salem Herrmann2017-12-131-7/+7
|
* Add SPDX license identifiers to source files under the LGPLZbigniew Jędrzejewski-Szmek2017-11-191-0/+1
| | | | | This follows what the kernel is doing, c.f. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5fd54ace4721fc5ce2bb5aef6318fcf17f421460.
* exec-util,conf-files: skip non-executable files in execute_directories()Lennart Poettering2017-09-131-1/+1
| | | | Fixes: #6787
* tree-wide: use path_startswith() rather than startswith() where ever that's ↵Lennart Poettering2017-08-091-1/+1
| | | | | | | appropriate When checking path prefixes we really should use the right APIs, just in case people add multiple slashes to their paths...
* build-sys: drop automake supportZbigniew Jędrzejewski-Szmek2017-07-181-1/+0
| | | | | v2: - also mention m4
* sysctl: minor simplificationLennart Poettering2016-11-021-2/+2
| | | | Let's place only one ternary operator.
* sysctl: no need to check for eof twiceLennart Poettering2016-11-021-1/+1
| | | | | 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.
* sysctl: when failing to process a config line, show line nrLennart Poettering2016-11-021-2/+5
|
* sysctl: split out condition check into its own functionLennart Poettering2016-11-021-12/+20
| | | | This way, we can get rid of a label/goto.
* sysctl: do not fail systemd-sysctl.service if /proc/sys is mounted read-onlyLennart Poettering2016-11-021-5/+12
| | | | | | | | | | 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.
* sysctl: configure kernel parameters in the order they occur in each sysctl ↵HATAYAMA Daisuke2016-09-241-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* tree-wide: remove Emacs lines from all filesDaniel Mack2016-02-101-2/+0
| | | | | This should be handled fine now by .dir-locals.el, so need to carry that stuff in every file.
* defs: rework CONF_DIRS_NULSTR() macroLennart Poettering2015-11-101-1/+1
| | | | | | | | | | | | 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.
* treewide: apply errno.cocciMichal Schmidt2015-11-091-2/+1
| | | | with small manual cleanups for style.
* util-lib: move CONF_DIRS_NULSTR definition to def.hLennart Poettering2015-11-031-0/+1
| | | | | | 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
* util-lib: split out fd-related operations into fd-util.[ch]Lennart Poettering2015-10-251-0/+1
| | | | | There are more than enough to deserve their own .c file, hence move them over.
* util-lib: split our string related calls from util.[ch] into its own file ↵Lennart Poettering2015-10-241-0/+1
| | | | | | | | | | | | | | 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.
* util: introduce common version() implementation and use it everywhereLennart Poettering2015-09-291-14/+11
| | | | | | 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.
* sysctl: reword warning message a bitLennart Poettering2015-08-051-1/+1
| | | | | Let's make this less dramatic, in order to not confuse people too much making them think that this was something to actually fix.
* sysctl: bump loglevel when attempting to write invalid valuesJan Synacek2015-08-051-1/+1
|
* sysctl: don't propagate ENOENT sysctl optionsLennart Poettering2015-04-241-7/+7
| | | | | | | 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.
* sysctl: tweak debug messageZbigniew Jędrzejewski-Szmek2015-03-141-1/+1
|
* sysctl: move property handling to shared/Kay Sievers2015-03-111-55/+11
|
* sysctl: downgrade message about sysctl overrides to debugZbigniew Jędrzejewski-Szmek2015-02-261-1/+1
| | | | | Printing it at info level was tedious. We don't do that for any other overrides.
* sysctl: consider --prefix while parsing the filesUmut Tezduyar Lindskog2015-02-071-16/+14
| | | | | | | | | | | 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.
* treewide: use log_*_errno whenever %m is in the format stringMichal Schmidt2014-11-281-1/+1
| | | | | | | | | | | 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.
* treewide: a few more log_*_errno + return simplificationsMichal Schmidt2014-11-281-2/+1
| | | | The one in tmpfiles.c:create_item() even looks like it fixes a bug.
* treewide: no need to negate errno for log_*_errno()Michal Schmidt2014-11-281-3/+3
| | | | It corrrectly handles both positive and negative errno values.
* treewide: auto-convert the simple cases to log_*_errno()Michal Schmidt2014-11-281-3/+3
| | | | | | | | | | | | | 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().
* Introduce CONF_DIRS_NULSTR helper to define standard conf dirsJosh Triplett2014-11-261-9/+1
| | | | | | | 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.
* sysctl: make --prefix allow all kinds of sysctl pathsDavid Herrmann2014-09-171-6/+14
| | | | | | | | | | | | | | | | | | 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!