summaryrefslogtreecommitdiff
path: root/src/basic
Commit message (Collapse)AuthorAge
* tree-wide: use IN_SET macro (#6977)Yu Watanabe2017-12-08
|
* build-sys: s/HAVE_SMACK/ENABLE_SMACK/Zbigniew Jędrzejewski-Szmek2017-12-08
| | | | Same justification as for HAVE_UTMP.
* build-sys: s/HAVE_IMA/ENABLE_IMA/Zbigniew Jędrzejewski-Szmek2017-12-07
| | | | Same justification as for HAVE_UTMP.
* Apply updates from upstreamSven Eden2017-12-07
|
* build-sys: use #if Y instead of #ifdef Y everywhereZbigniew Jędrzejewski-Szmek2017-11-23
| | | | | | | | | | | | | | | The advantage is that is the name is mispellt, cpp will warn us. $ git grep -Ee "conf.set\('(HAVE|ENABLE)_" -l|xargs sed -r -i "s/conf.set\('(HAVE|ENABLE)_/conf.set10('\1_/" $ git grep -Ee '#ifn?def (HAVE|ENABLE)' -l|xargs sed -r -i 's/#ifdef (HAVE|ENABLE)/#if \1/; s/#ifndef (HAVE|ENABLE)/#if ! \1/;' $ git grep -Ee 'if.*defined\(HAVE' -l|xargs sed -i -r 's/defined\((HAVE_[A-Z0-9_]*)\)/\1/g' $ git grep -Ee 'if.*defined\(ENABLE' -l|xargs sed -i -r 's/defined\((ENABLE_[A-Z0-9_]*)\)/\1/g' + manual changes to meson.build squash! build-sys: use #if Y instead of #ifdef Y everywhere v2: - fix incorrect setting of HAVE_LIBIDN2
* Revert "tree-wide: use pid_is_valid() at more places"Alan Jenkins2017-10-03
| | | | | | | | | | | This reverts commit ee043777be58251e7441b4f04594e9e3792d7fb2. It broke almost everywhere it touched. The places that handn't been converted, were mostly followed by special handling for the invalid PID `0`. That explains why they tested for `pid < 0` instead of `pid <= 0`. I think that one was the first commit I reviewed, heh.
* build-sys: change all HAVE_DECL_ macros to HAVE_Zbigniew Jędrzejewski-Szmek2017-11-22
| | | | | | | This is a legacy of autotools, where one detection routine used a different prefix then the others. $ git grep -e HAVE_DECL_ -l|xargs sed -i s/HAVE_DECL_/HAVE_/g
* path-util: some updates to path_make_relative()Lennart Poettering2017-11-22
| | | | | | | | | | Don't miscount number of "../" to generate, if we "." is included in an input path. Also, refuse if we encounter "../" since we can't possibly follow that up properly, without file system access. Some other modernizations.
* tree-wide: use `!IN_SET(..)` for `a != b && a != c && …`Andreas Rammhold2017-09-29
| | | | | | The included cocci was used to generate the changes. Thanks to @flo-wer for pointing this case out.
* tree-wide: use IN_SET where possibleAndreas Rammhold2017-09-29
| | | | | In addition to the changes from #6933 this handles cases that could be matched with the included cocci file.
* mount-util: add fusectl to list of API VFSLennart Poettering2017-09-29
|
* dissect: split list of discard-supporting fs out into mount-util.cLennart Poettering2017-11-22
| | | | | | | Let's manage the list of file systems that do a specific thing at one place, following similar naming. No functional changes.
* dissect: automatically mark partitions read-only that have a read-only file ↵Lennart Poettering2017-11-22
| | | | | | | system Specifically, squashfs and iso9660 are always read-only, hence make sure we never even think about mounting them writable.
* fs-util: propagate EEXIST error in symlink_idempotent() as EEXISTLennart Poettering2017-11-22
| | | | | We really shouldn't silently translate the error code here for no reason.
* log: add a mode where we open the log fds for every single log messageLennart Poettering2017-11-22
| | | | | | This we can then make use in execute.c to make error logging a bit less special when preparing for process execution, as we can still log but don't have any fds open continously.
* log: let's make use of the fact that our functions return the negative error ↵Lennart Poettering2017-09-25
| | | | code for log_oom() too
* swap: adjust swap.c in a similar way to what we just did to mount.cLennart Poettering2017-09-25
| | | | | | Also drop the redundant states and make all similar changes too. Thankfully the swap.c state engine is much simpler than mount.c's, hence this should be easier to digest.
* mount: rework mount state engineLennart Poettering2017-09-25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This changes the mount unit state engine in the following ways: 1. The MOUNT_MOUNTING_SIGTERM and MOUNT_MOUNTING_SIGKILL are removed. They have been pretty much equivalent to MOUNT_UNMOUNTING_SIGTERM and MOUNT_UNMOUNTING_SIGKILL in what they do, and the outcome has been the same as well: the unit is stopped. Hence, let's simplify things a bit, and merge them. Note that we keep MOUNT_REMOUNTING_{SIGTERM|SIGKILL} however, as those states have a different outcome: the unit remains started. 2. mount_enter_signal() will now honour the SendSIGKILL= option of the mount unit if it was set. This was previously done already when we entered the signal states through a timeout, and was simply missing here. 3. A new helper function mount_enter_dead_or_mounted() is added that places the mount unit in either MOUNT_DEAD or MOUNT_MOUNTED, depending on what the kernel thinks about the mount's state. This function is called at various places now, wherever we finished an operation, and want to make sure our own state reflects again what the kernel thinks. Previously we had very similar code in a number of places and in other places didn't recheck the kernel state. Let's do that with the same logic and function at all relevant places now. 4. Rework mount_stop(): never forget about running control processes. Instead: when we have a start (i.e. a /bin/mount) process running, and are asked to stop, then enter the kill states for it, so that it gets cleaned up. This fixes #6048. Moreover, when we have a reload process running convert the possible states into the relevant unmounting states, so that we can properly execute the requested operation. Fixes #6048
* set: add new helper set_make() which is like set_new() + multiple set_put() ↵Lennart Poettering2017-11-22
| | | | in vararg
* basic/log: fix return value from log_struct_iovec_internal()Zbigniew Jędrzejewski-Szmek2017-09-26
| | | | | This returned value so far wasn't used anywhere, so there's no change in behaviour.
* string-util: use size_t for strjoina macro (#6914)Jonathan Lebon2017-09-25
| | | | `strlen` returns a `size_t` and `alloca` expects a `size_t`.
* basic/cap-list: report empty capability set as ""Zbigniew Jędrzejewski-Szmek2017-09-25
| | | | | | | | | | | | | | $ systemctl show elogind-journald -p CapabilityBoundingSet,AmbientCapabilities CapabilityBoundingSet=cap_chown cap_dac_override cap_dac_read_search cap_fowner cap_setgid ... AmbientCapabilities=(null) ↓ $ systemctl show elogind-journald -p CapabilityBoundingSet,AmbientCapabilities CapabilityBoundingSet=cap_chown cap_dac_override cap_dac_read_search cap_fowner cap_setgid ... AmbientCapabilities= Partially fixes #6511. Add some basic tests for the printing function.
* fileio: return 0 from read_one_line_file on successZbigniew Jędrzejewski-Szmek2017-11-22
| | | | Fixup for f4b51a2d09. Suggested by Evgeny Vereshchagin.
* fileio: initialize errno to zero before we do fread()Lennart Poettering2017-09-22
| | | | | if there was something in the read buffer already errno might not be set on error, let's detect that case.
* fileio: try to read one byte too much in read_full_stream()Lennart Poettering2017-09-22
| | | | | | | | Let's read one byte more than the file size we read from stat() on the first fread() invocation. That way, the first read() will already be short and indicate eof to fread(). This is a minor optimization, and replaces #3908.
* fileio: move fsync() logic into write_string_stream_ts()Lennart Poettering2017-09-22
| | | | | | That way, write_string_stream_ts() becomes more powerful, and we can remove duplicate code from write_string_file_atomic() and write_string_file_ts().
* fileio: make write_string_stream() accept flags parameterLennart Poettering2017-09-22
| | | | | | Let's make write_string_stream() and write_string_file() more alike, and pass the same flag set so that we can remove a number of boolean parameters.
* fileio: support writing atomic files with timestampLennart Poettering2017-09-22
| | | | | Let's make sure "ts" is taken into account when writing atomic files, too.
* cgroup: rework which files we chown() on delegationLennart Poettering2017-09-22
| | | | | | | | | | | | | | | | On cgroupsv2 we should also chown()/chmod() the subtree_control file, so that children can use controllers the way they like. On cgroupsv1 we should also chown()/chmod() cgroups.clone_children, as not setting this for new cgroups makes little sense, and hence delegated clients should be able to write to it. Note that error handling for both cases is different. subtree_control matters so we check for errors, but the clone_children/tasks stuff doesn't really, as it's legacy stuff. Hence we only log errors and proceed. Fixes: #6216
* cgroup-util: downgrade log messages from library code to LOG_DEBUGLennart Poettering2017-11-21
| | | | | | | These errors don't really matter, that's why we log and proceed in the current code. However, we currently log at LOG_WARNING, but we really shouldn't given that this is library code. Hence downgrade this to LOG_DEBUG.
* core: whenever a unit terminates, log its consumed resources to the journalLennart Poettering2017-09-21
| | | | | | | | | | | | This adds a new recognizable log message for each unit invocation that contains structured information about consumed resources of the unit as a whole after it terminated. This is particular useful for apps that want to figure out what the resource consumption of a unit given a specific invocation ID was. The log message is only generated for units that have at least one XyzAccounting= property turned on, and currently only covers IP traffic and CPU time metrics.
* io-util: add new IOVEC_INIT/IOVEC_MAKE macrosLennart Poettering2017-09-21
| | | | | | | | | | | | | | | | | | | | | | This adds IOVEC_INIT() and IOVEC_MAKE() for initializing iovec structures from a pointer and a size. On top of these IOVEC_INIT_STRING() and IOVEC_MAKE_STRING() are added which take a string and automatically determine the size of the string using strlen(). This patch removes the old IOVEC_SET_STRING() macro, given that IOVEC_MAKE_STRING() is now useful for similar purposes. Note that the old IOVEC_SET_STRING() invocations were two characters shorter than the new ones using IOVEC_MAKE_STRING(), but I think the new syntax is more readable and more generic as it simply resolves to a C99 literal structure initialization. Moreover, we can use very similar syntax now for initializing strings and pointer+size iovec entries. We canalso use the new macros to initialize function parameters on-the-fly or array definitions. And given that we shouldn't have so many ways to do the same stuff, let's just settle on the new macros. (This also converts some code to use _cleanup_ where dynamically allocated strings were using IOVEC_SET_STRING() before, to modernize things a bit)
* cgroup, unit, fragment parser: make use of new firewall functionsDaniel Mack2017-11-21
|
* Add abstraction model for BPF programsDaniel Mack2017-11-20
| | | | | This object takes a number of bpf_insn members and wraps them together with the in-kernel reference id. Will be needed by the firewall code.
* cgroup-util: minor coding style adjustmentLennart Poettering2017-09-04
|
* v235: Added missing updatesSven Eden2017-11-19
|
* Prep v235: Added cap-list, which is needed now.Sven Eden2017-11-19
|
* fileio: return 0 from read_one_line_file on successZbigniew Jędrzejewski-Szmek2017-09-24
| | | | Fixup for f4b51a2d09. Suggested by Evgeny Vereshchagin.
* fileio: use _cleanup_ for FILE unlockingZbigniew Jędrzejewski-Szmek2017-09-25
|
* fileio: initialize errno to zero before we do fread()Lennart Poettering2017-09-22
| | | | | if there was something in the read buffer already errno might not be set on error, let's detect that case.
* fileio: try to read one byte too much in read_full_stream()Lennart Poettering2017-09-22
| | | | | | | | Let's read one byte more than the file size we read from stat() on the first fread() invocation. That way, the first read() will already be short and indicate eof to fread(). This is a minor optimization, and replaces #3908.
* fileio: move fsync() logic into write_string_stream_ts()Lennart Poettering2017-09-22
| | | | | | That way, write_string_stream_ts() becomes more powerful, and we can remove duplicate code from write_string_file_atomic() and write_string_file_ts().
* fileio: make write_string_stream() accept flags parameterLennart Poettering2017-09-22
| | | | | | Let's make write_string_stream() and write_string_file() more alike, and pass the same flag set so that we can remove a number of boolean parameters.
* fileio: support writing atomic files with timestampLennart Poettering2017-09-22
| | | | | Let's make sure "ts" is taken into account when writing atomic files, too.
* cgroup-util: replace one use of fgets() by read_line()Lennart Poettering2017-09-25
|
* fileio: rework read_one_line_file() on top of read_line()Lennart Poettering2017-09-25
|
* def: add new constant LONG_LINE_MAXLennart Poettering2017-09-22
| | | | | | | | LONG_LINE_MAX is much like LINE_MAX, but longer. As it turns out LINE_MAX at 4096 is too short for many usecases. Since the general concept of having a common maximum line length limit makes sense let's add our own, and make it larger (1MB for now).
* fileio: add new helper call read_line() as bounded getline() replacementLennart Poettering2017-09-25
| | | | | | | read_line() is much like getline(), and returns a line read from a FILE*, of arbitrary sizes. In contrast to gets() it will grow the buffer dynamically, and in contrast to getline() it will place a user-specified boundary on the line.
* cgroup: rework which files we chown() on delegationLennart Poettering2017-09-22
| | | | | | | | | | | | | | | | On cgroupsv2 we should also chown()/chmod() the subtree_control file, so that children can use controllers the way they like. On cgroupsv1 we should also chown()/chmod() cgroups.clone_children, as not setting this for new cgroups makes little sense, and hence delegated clients should be able to write to it. Note that error handling for both cases is different. subtree_control matters so we check for errors, but the clone_children/tasks stuff doesn't really, as it's legacy stuff. Hence we only log errors and proceed. Fixes: #6216
* cgroup-util: downgrade log messages from library code to LOG_DEBUGLennart Poettering2017-09-25
| | | | | | | These errors don't really matter, that's why we log and proceed in the current code. However, we currently log at LOG_WARNING, but we really shouldn't given that this is library code. Hence downgrade this to LOG_DEBUG.