summaryrefslogtreecommitdiff
path: root/src/basic/sysctl-util.c
Commit message (Collapse)AuthorAgeFilesLines
* sysctl-util: minimize side-effects when running `systemd-sysctl`Antony Deepak Thomas2021-09-291-1/+1
| | | | | | | | | | | | | | | Currently `systemd-sysctl` binary is used in `systemd-sysctl.service` which is mostly configured as `oneshot`. There are situations where one would like to use systemd to maintain Sysctl configurations on a host, using a configuration managers such as Chef or Puppet, by apply configurations every X duration. The problem with using `systemd-sysctl` is that it writes all the Sysctl settings, even if the values for those settings have not changed. From experience, we have observed that some Sysctl settings cause actions in the kernel upon writing(like dropping caches) which in turn cause undesired side effects. This patch tries to minimize such side effects by comparing values before writing.
* sysctl-util: per coding style, compare chars explicit against 0.Lennart Poettering2021-09-151-1/+1
|
* sysctl-util: make sysctl_read_ip_property() a wrapper around sysctl_read()Lennart Poettering2021-09-151-13/+9
| | | | | | let's do what we did for sysctl_write()/sysctl_write_ip_property() also for the read paths: i.e. make one a wrapper of the other, and add more careful input validation.
* sysctl-util: modernize sysctl_read() a bitLennart Poettering2021-09-151-2/+13
| | | | | | | | | | Let's add similar path validation to sysctl_read() as we already have in sysctl_write(). Let's also drop the trailing newline from the returned string, like sysctl_read_ip_property() already does it. (I checked all users of this, they don't care)
* sysctl-util: make sysctl_write_ip_property() a wrapper around sysctl_write()Lennart Poettering2021-09-151-6/+12
| | | | | | | | It does the same stuff, let's use the same codepaths as much as we can. And while we are at it, let's generate good error codes in case we are called with unsupported parameters/let's validate stuff more that might originate from user input.
* sysctl-util: rework sysctl_write() to wrap write_string_file()Lennart Poettering2021-09-151-11/+5
| | | | | | | | | The sysctl_write_ip_property() call already uses write_string_file(), so let's do so here, too, to make the codepaths more uniform. While we are at it, let's also validate the passed path a bit, since we shouldn't allow sysctls with /../ or such in the name. Hence simplify the path first, and then check if it is normalized, and refuse if not.
* tree-wide: always drop unnecessary dot in pathYu Watanabe2021-05-281-1/+1
|
* basic: move shared/sysctl-util.[ch] → basic/Lennart Poettering2021-03-051-0/+130
This is self-contained ans allows us later to use the provided APIs from other code in src/basic/