summaryrefslogtreecommitdiffstats
path: root/src/basic/util.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* util: move display_is_local() to pam_systemd.c, its only userLennart Poettering2019-03-141-9/+0
| | | | It's quite specific anyway, hence let's move this where it's used
* util: split out plymouth related stuffLennart Poettering2019-03-141-4/+0
|
* util: split out sorting related calls to new sort-util.[ch]Lennart Poettering2019-03-131-25/+0
|
* util: split out memcmp()/memset() related calls into memory-util.[ch]Lennart Poettering2019-03-131-36/+0
| | | | Just some source rearranging.
* util: split out some stuff into a new file limits-util.[ch]Lennart Poettering2019-03-131-148/+0
|
* util: split out namespace related stuff into a new namespace-util.[ch] pairLennart Poettering2019-03-131-115/+0
| | | | Just some minor reorganiztion.
* Print the systemd version in a format that dracut likesZbigniew Jędrzejewski-Szmek2019-01-061-1/+1
| | | | | | | | | - systemd 240-63-g4199f68+ + systemd 240 (240-63-g4199f68+) Sad, but easy. Fixes #11330.
* meson: generate version tag from gitZbigniew Jędrzejewski-Szmek2018-12-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | $ build/systemctl --version systemd 239-3555-g6178cbb5b5 +PAM +AUDIT +SELINUX +IMA -APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD -IDN2 +IDN +PCRE2 default-hierarchy=hybrid $ git tag v240 -m 'v240' $ ninja -C build ninja: Entering directory `build' [76/76] Linking target fuzz-unit-file. $ build/systemctl --version systemd 240 +PAM +AUDIT +SELINUX +IMA -APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD -IDN2 +IDN +PCRE2 default-hierarchy=hybrid This is very useful during development, because a precise version string is embedded in the build product and displayed during boot, so we don't have to guess answers for questions like "did I just boot the latest version or the one from before?". This change creates an overhead for "noop" builds. On my laptop, 'ninja -C build' that does nothing goes from 0.1 to 0.5 s. It would be nice to avoid this, but I think that <1 s is still acceptable. Fixes #7183. PACKAGE_VERSION is renamed to GIT_VERSION, to make it obvious that this is the more dynamically changing version string. Why save to a file? It would be easy to generate the version tag using run_command(), but we want to go through a file so that stuff gets rebuilt when this file changes. If we just defined an variable in meson, ninja wouldn't know it needs to rebuild things.
* Remove use of PACKAGE_STRINGZbigniew Jędrzejewski-Szmek2018-12-191-1/+1
| | | | | | | PACKAGE_VERSION is more explicit, and also, we don't pretend that changing the project name in meson.build has any real effect. "systemd" is embedded in a thousand different places, so let's just use the hardcoded string consistently. This is mostly in preparation for future changes.
* util-lib: split out env file parsing code into env-file.cLennart Poettering2018-12-021-0/+1
| | | | | | It's quite complex, let's split this out. No code changes, just some file rearranging.
* basic/util: import memeqzero from casyncZbigniew Jędrzejewski-Szmek2018-11-181-0/+22
|
* fileio: automatically add NULL sentinel to parse_env_file()Lennart Poettering2018-11-141-1/+3
| | | | Let's modernize things a bit.
* fileio: drop "newline" parameter for env file parsersLennart Poettering2018-11-141-1/+1
| | | | | | | Now that we don't (mis-)use the env file parser to parse kernel command lines there's no need anymore to override the used newline character set. Let's hence drop the argument and just "\n\r" always. This nicely simplifies our code.
* tree-wide: set WRITE_STRING_FILE_DISABLE_BUFFER flag when we write files ↵Yu Watanabe2018-11-061-1/+1
| | | | under /proc or /sys
* util: drop const_int_one/const_int_zero againLennart Poettering2018-10-181-3/+0
| | | | | | | There's only a single user remaining now that we have setsockopt_int(), let's define those variables locally. This more or less reverts 6d5e65f6454212cd400d0ebda34978a9f20cc26a.
* tree-wide: add a single version of "static const int one = 1"Lennart Poettering2018-10-151-0/+3
| | | | | | | | | | All over the place we define local variables for the various sockopts that take a bool-like "int" value. Sometimes they are const, sometimes static, sometimes both, sometimes neither. Let's clean this up, introduce a common const variable "const_int_one" (as well as one matching "const_int_zero") and use it everywhere, all acorss the codebase.
* Add $SYSTEMD_IN_INITRD=yes|no override for debuggingZbigniew Jędrzejewski-Szmek2018-10-081-3/+12
|
* util: introduce typesafe_bsearch() and typesafe_bsearch_r()Yu Watanabe2018-09-191-1/+1
|
* sd-bus: allow connecting to the pseudo-container ".host"Lennart Poettering2018-07-251-0/+5
| | | | | | | | machined exposes the pseudo-container ".host" as a reference to the host system, and this means "machinectl login .host" and "machinectl shell .host" get your a login/shell on the host. systemd-run currently doesn't allow that. Let's fix that, and make sd-bus understand ".host" as an alias for connecting to the host system.
* pam_systemd: move socket_from_display() from util.[ch] to pam_systemd.cLennart Poettering2018-07-251-25/+0
| | | | | | It's highly specific, kinda legacy (X11…) and only used at one place, let's move this out of the common code, and into pam_systemd.c where it is used.
* 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.
* fileio: accept FILE* in addition to path in parse_env_file()Lennart Poettering2018-05-241-1/+1
| | | | | | | Most our other parsing functions do this, let's do this here too, internally we accept that anyway. Also, the closely related load_env_file() and load_env_file_pairs() also do this, so let's be systematic.
* util: add debug logging to system_tasks_max()Lennart Poettering2018-05-241-4/+16
| | | | | We should always do debug logging when we eat up error conditions. Let's do so here too.
* util: fix physical_memory() to work correctly on cgroupsv2Lennart Poettering2018-05-241-3/+31
| | | | | | | Let's look into the right cgroupsv2 attribute. Also, while we are at it, add debug logging for all error conditions we eat up silently otherwise.
* 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.
* util: check for overflows in xbsearch_r()Lennart Poettering2018-03-281-1/+3
|
* basic: split out update_reboot_parameter_and_warn() into its own .c/.h filesLennart Poettering2018-02-221-23/+0
| | | | | | This is primarily preparation for a follow-up commit that adds a common implementation of the other side of the reboot parameter file, i.e. the code that reads the file and issues reboot() for it.
* util: rework system_tasks_max() to make use of procfs_tasks_max()Lennart Poettering2018-01-221-4/+4
| | | | Let's use our new code.
* util: introduce more accurate definitions of TASKS_MAXLennart Poettering2018-01-221-10/+2
| | | | | | | The maximum number of processes a tasks on the system is usually lower than what pid_t would allow, and is compiled into the kernel (and documented in proc(5)). Let's add proper defines for that, so that we can adjust the pid_max sysctl without fearing invalid accesses.
* util: minor tweaks to disable_core_dumps()Lennart Poettering2018-01-101-3/+9
| | | | | | | | | First, let's rename it to disable_coredumps(), as in the rest of our codebase we spell it "coredump" rather than "core_dump", so let's stick to that. However, also log about failures to turn off core dumpling on LOG_DEBUG, because debug logging is always a good idea.
* tree-wide: introduce disable_core_dumps helper and port existing usersJan Klötzke2018-01-101-0/+7
| | | | | | Changes the core_pattern to prevent any core dumps by the kernel. Does nothing if we're in a container environment as this is system wide setting.
* condition: extend ConditionKernelVersion= with relative version checksLennart Poettering2017-12-261-0/+62
| | | | | Now that we have str_verscmp() in our source tree anyway, let's make it generic and reuse it for ConditionKernelVersion=.
* basic: split out blockdev-util.[ch] from util.hLennart Poettering2017-12-251-168/+0
| | | | With three functions it makes sense to split this out now.
* process-util: move fork_agent() to process-util.[ch]Lennart Poettering2017-12-251-74/+0
| | | | | | It's a relatively small wrapper around safe_fork() now, hence let's move it over, and make its signature even more alike. Also, set a different process name for the polkit and askpw agents.
* tree-wide: introduce new safe_fork() helper and port everything overLennart Poettering2017-12-251-39/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | This adds a new safe_fork() wrapper around fork() and makes use of it everywhere. The new wrapper does a couple of things we previously did manually and separately in a safer, more correct and automatic way: 1. Optionally resets signal handlers/mask in the child 2. Sets a name on all processes we fork off right after forking off (and the patch assigns useful names for all processes we fork off now, following a systematic naming scheme: always enclosed in () – in order to indicate that these are not proper, exec()ed processes, but only forked off children, and if the process is long-running with only our own code, without execve()'ing something else, it gets am "sd-" prefix.) 3. Optionally closes all file descriptors in the child 4. Optionally sets a PR_SET_DEATHSIG to SIGTERM in the child, in a safe way so that the parent dying before this happens being handled safely. 5. Optionally reopens the logs 6. Optionally connects stdin/stdout/stderr to /dev/null 7. Debug logs about the forked off processes.
* tree-wide: make use of new STRLEN() macro everywhere (#7639)Lennart Poettering2017-12-141-1/+1
| | | | | Let's employ coccinelle to do this for us. Follow-up for #7625.
* Add a little helper to make /sys/dev/block/major:minor pathsZbigniew Jędrzejewski-Szmek2017-11-301-37/+16
|
* 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.
* util-lib: simplify kexec_loaded()Zbigniew Jędrzejewski-Szmek2017-10-181-9/+6
|
* tree-wide: use IN_SET where possibleAndreas Rammhold2017-10-021-1/+1
| | | | | In addition to the changes from #6933 this handles cases that could be matched with the included cocci file.
* util: make get_block_device() availableFranck Bui2017-09-131-0/+131
|
* tree-wide: make use of getpid_cached() wherever we canLennart Poettering2017-07-201-1/+1
| | | | | | | This moves pretty much all uses of getpid() over to getpid_raw(). I didn't specifically check whether the optimization is worth it for each replacement, but in order to keep things simple and systematic I switched over everything at once.
* basic/path-util: allow flags for path_equal_or_files_sameZbigniew Jędrzejewski-Szmek2017-06-171-1/+1
| | | | | No functional change, just a new parameters and the tests that AT_SYMLINK_NOFOLLOW works as expected.
* basic/util: move execute_directory() to separate fileZbigniew Jędrzejewski-Szmek2017-02-121-143/+0
| | | | It's a fairly specialized function. Let's make new files for it and the tests.
* Merge pull request #4771 from keszybz/udev-property-orderingMartin Pitt2016-12-121-1/+1
|\ | | | | Udev property ordering
| * Two small cleanupsZbigniew Jędrzejewski-Szmek2016-11-301-1/+1
| |
* | tree-wide: replace all readdir cycles with FOREACH_DIRENT{,_ALL} (#4853)Reverend Homer2016-12-091-14/+2
|/
* Rename formats-util.h to format-util.hZbigniew Jędrzejewski-Szmek2016-11-071-1/+1
| | | | | | We don't have plural in the name of any other -util files and this inconsistency trips me up every time I try to type this file name from memory. "formats-util" is even hard to pronounce.
* tree-wide: drop NULL sentinel from strjoinZbigniew Jędrzejewski-Szmek2016-10-231-1/+1
| | | | | | | | | | | | | This makes strjoin and strjoina more similar and avoids the useless final argument. spatch -I . -I ./src -I ./src/basic -I ./src/basic -I ./src/shared -I ./src/shared -I ./src/network -I ./src/locale -I ./src/login -I ./src/journal -I ./src/journal -I ./src/timedate -I ./src/timesync -I ./src/nspawn -I ./src/resolve -I ./src/resolve -I ./src/systemd -I ./src/core -I ./src/core -I ./src/libudev -I ./src/udev -I ./src/udev/net -I ./src/udev -I ./src/libsystemd/sd-bus -I ./src/libsystemd/sd-event -I ./src/libsystemd/sd-login -I ./src/libsystemd/sd-netlink -I ./src/libsystemd/sd-network -I ./src/libsystemd/sd-hwdb -I ./src/libsystemd/sd-device -I ./src/libsystemd/sd-id128 -I ./src/libsystemd-network --sp-file coccinelle/strjoin.cocci --in-place $(git ls-files src/*.c) git grep -e '\bstrjoin\b.*NULL' -l|xargs sed -i -r 's/strjoin\((.*), NULL\)/strjoin(\1)/' This might have missed a few cases (spatch has a really hard time dealing with _cleanup_ macros), but that's no big issue, they can always be fixed later.