summaryrefslogtreecommitdiff
path: root/src/sysctl
Commit message (Collapse)AuthorAgeFilesLines
* Rename def.h to constants.hZbigniew Jędrzejewski-Szmek2022-11-081-1/+1
| | | | | | The name "def.h" originates from before the rule of "no needless abbreviations" was established. Let's rename the file to clarify that it contains a collection of various semi-related constants.
* basic: move version() to build.h+cZbigniew Jędrzejewski-Szmek2022-11-081-0/+1
|
* sysctl: apply prefix before calling glob()Yu Watanabe2022-08-171-9/+53
| | | | | | | Otherwise, if there exist million of network interfaces, calling glob() for network properties takes much time. Fixes #24031.
* sysctl: split out code for applying glob optionYu Watanabe2022-08-171-44/+50
|
* sysctl: drop /proc/sys/ in prefixYu Watanabe2022-08-171-16/+4
|
* sysctl: use ordered_hashmap_ensure_put()Yu Watanabe2022-08-171-4/+1
|
* sysctl: add --strict option to fail if sysctl does not existsQuentin Deslandes2022-07-251-6/+16
| | | | | | | | | | | | | | systemd-sysctl currently fails silently under any of these conditions: - Missing permission to write a sysctl. - Invalid sysctl (path doesn't exists). - Ignore failure flag ('-' in front of the sysctl name). Because of this behaviour, configuration issues can go unnoticed as there is no way to detect those unless going through the logs. --strict option forces systemd-sysctl to fail if a sysctl is invalid or if permission are insufficient. Errors on sysctl marked as "ignore failure" will still be ignored.
* sysctl: also process sysctl requests via the "sysctl.extra" credentialLennart Poettering2022-07-141-0/+24
|
* sysctl: increase log severity on failed writeChristian Göttsche2022-06-141-1/+1
| | | | | | | | | Increase the log severity in case of writing to a non existent sysctl parameter as this can either be caused by a misspelling or a kernel mis- configuration, e.g. in case YAMA does not get loaded due to a incomplete lsm= override: systemd-sysctl[354]: Couldn't write '1' to 'kernel/yama/ptrace_scope', ignoring: No such file or directory
* strv: make iterator in STRV_FOREACH() declaread in the loopYu Watanabe2022-03-191-4/+0
| | | | This also avoids multiple evaluations in STRV_FOREACH_BACKWARDS()
* Make pager_open() return voidZbigniew Jędrzejewski-Szmek2021-11-031-1/+1
|
* Drop the text argument from assert_not_reached()Zbigniew Jędrzejewski-Szmek2021-08-031-1/+1
| | | | | | | | | | | | | | | | | In general we almost never hit those asserts in production code, so users see them very rarely, if ever. But either way, we just need something that users can pass to the developers. We have quite a few of those asserts, and some have fairly nice messages, but many are like "WTF?" or "???" or "unexpected something". The error that is printed includes the file location, and function name. In almost all functions there's at most one assert, so the function name alone is enough to identify the failure for a developer. So we don't get much extra from the message, and we might just as well drop them. Dropping them makes our code a tiny bit smaller, and most importantly, improves development experience by making it easy to insert such an assert in the code without thinking how to phrase the argument.
* fileio: optionally, return discovered path of file in search_and_fopen()Lennart Poettering2021-05-071-5/+6
|
* sysctl: downgrade warning about excluded keysZbigniew Jędrzejewski-Szmek2021-02-171-1/+1
| | | | | | | | | | | | Our own config generates logs like this: systemd-sysctl[1280]: Not setting net/ipv4/conf/all/rp_filter (explicit setting exists). systemd-sysctl[1280]: Not setting net/ipv4/conf/default/rp_filter (explicit setting exists). systemd-sysctl[1280]: Not setting net/ipv4/conf/all/accept_source_route (explicit setting exists). systemd-sysctl[1280]: Not setting net/ipv4/conf/default/accept_source_route (explicit setting exists). systemd-sysctl[1280]: Not setting net/ipv4/conf/all/promote_secondaries (explicit setting exists). systemd-sysctl[1280]: Not setting net/ipv4/conf/default/promote_secondaries (explicit setting exists). There is no error and nothing really to see.
* tree-wide: enable colorized logging for daemons when run in consoleYu Watanabe2021-02-011-1/+1
| | | | It may be useful when debugging daemons.
* tree-wide: Drop custom formatting for print() help messagesDaan De Meyer2021-01-311-4/+3
| | | | | | | | | | | | I think this formatting was originally used because it simplified adding new options to the help messages. However, these days, most tools their help message end with "\nSee the %s for details.\n" so the final line almost never has to be edited which eliminates the benefit of the custom formatting used for printf() help messages. Let's make things more consistent and use the same formatting for printf() help messages that we use everywhere else. Prompted by https://github.com/systemd/systemd/pull/18355#discussion_r567241580
* license: LGPL-2.1+ -> LGPL-2.1-or-laterYu Watanabe2020-11-091-1/+1
|
* tree-wide: define iterator inside of the macroZbigniew Jędrzejewski-Szmek2020-09-081-2/+1
|
* journalctl,elsewhere: make sure --file=foo fails with sane error msg if foo ↵Lennart Poettering2020-05-191-1/+1
| | | | | | | | | | | | | is not readable It annoyed me for quite a while that running "journalctl --file=…" on a file that is not readable failed with a "File not found" error instead of a permission error. Let's fix that. We make this work by using the GLOB_NOCHECK flag for glob() which means that files are not accessible will be returned in the array as they are instead of being filtered away. This then means that our later attemps to open the files will fail cleanly with a good error message.
* sysctl: check correct error codeLennart Poettering2020-05-141-1/+1
|
* sysctl: fix segfaultYu Watanabe2020-02-061-1/+1
| | | | Fixes #14801.
* sysctl: add glob syntax to sysctl.d filesZbigniew Jędrzejewski-Szmek2020-02-041-51/+117
| | | | | | | | | This is intended for net.*.conf.*.foo files. Setting just "default" is not very useful because any interfaces present before systemd-sysctl is invoked are not affected. Setting "all" is too harsh, because the kernel takes the stronger of the device-specific setting and the "all" value, so effectively having a weaker setting for specific interfaces is not possible. Let's add a way in which can set "default" first and then all the others without "all".
* sysctl: downgrade message when we have no permissionZbigniew Jędrzejewski-Szmek2020-01-161-7/+10
| | | | | | | | | | | | | We need to run sysctl also in containers, because the network subtree is namespaces and may legitimately be writable. But logging all "errors" at notice level creates unwanted noise. Also downgrade message about missing sysctls to log_info. This might also be relatively common when configuration is targeted at different kernel versions. With log_debug it'll still end up in the logs, but isn't really worth of "notice" most of the time. https://bugzilla.redhat.com/show_bug.cgi?id=1609806
* sysctl: move hashmap allocation out of main functionZbigniew Jędrzejewski-Szmek2020-01-161-10/+9
| | | | | This allocation is a low level detail, and it seems nicer to keep it out of run().
* tree-wide: drop string.h when string-util.h or friends are includedYu Watanabe2019-11-041-1/+0
|
* sysctl: if options are prefixed with "-" ignore write errorsLennart Poettering2019-07-261-34/+80
|
* sysctl: reset 'r' only where neededLennart Poettering2019-07-261-2/+2
|
* sysctl: switch to log_syntax()Lennart Poettering2019-07-261-2/+1
| | | | | With @keszybz' recent work this will give us clickable links in the journalctl output.
* 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