summaryrefslogtreecommitdiff
path: root/src/basic/cgroup-util.c
Commit message (Collapse)AuthorAge
* basic/cgroup-util: simplify cg_get_keyed_attribute(), add testZbigniew Jędrzejewski-Szmek2018-05-30
| | | | | I didn't like the nested loop where we'd count what we have acquired already, since we should always know that.
* cgroup-util: rework cg_get_keyed_attribute() a bitLennart Poettering2018-05-30
| | | | | | | | | | | | | Let's make sure we don't clobber the return parameter on failure, to follow our coding style. Also, break the loop early if we have all attributes we need. This also changes the keys parameter to a simple char**, so that we can use STRV_MAKE() for passing the list of attributes to read. This also makes it possible to distuingish the case when the whole attribute file doesn't exist from one key in it missing. In the former case we return -ENOENT, in the latter we now return -ENXIO.
* basic: shorten the code a bit in two placesZbigniew Jędrzejewski-Szmek2018-05-30
| | | | gcc complains that len might be used unitialized, but afaict, this is not true.
* Add mkdir_errno_wrapper() and use instead of mkdir() in various placesZbigniew Jędrzejewski-Szmek2018-05-30
| | | | | We'd pass pointers to mkdir and mkdir_label to call in various places. mkdir returns the error in errno while mkdir_label returns the error directly.
* tree-wide: make use of new STRLEN() macro everywhere (#7639)Lennart Poettering2018-05-30
| | | | | | Let's employ coccinelle to do this for us. Follow-up for #7625.
* basic: turn off stdio locking for a couple of helper callsLennart Poettering2018-05-30
| | | | | | These helper calls are potentially called often, and allocate FILE* objects internally for a very short period of time, let's turn off locking for them too.
* Prep v236 : Add missing SPDX-License-Identifier (2/9) src/basicSven Eden2018-03-26
|
* Replace free and nullify by mfreeDaniel Lockyer2017-11-24
|
* cgroup: properly determine cgroups zombie processes belong toLennart Poettering2017-11-17
| | | | | | When a process becomes a zombie its cgroup might be deleted. Let's add some minimal code to detect cases like this, so that we can still attribute this back to the original cgroup.
* Some minor cleanupsSven Eden2018-03-07
|
* Prep v235.3 : Fix cgroup hierarchy detection codeSven Eden2018-01-18
| | | | | | | There is no sub-grouping with elogind, so /sys/fs/cgroup/elogind is not needed to be mounted as cgroup fs in legacy mode. Fixes Bug https://bugs.gentoo.org/644834
* If elogind is just started, /sys/fs/cgroup/elogind might not exist, yet on ↵Sven Eden2018-01-15
| | | | legacy and hybrid systems.
* Prep 235: Make cgroups2 available, hybrid mode already works.Sven Eden2018-01-10
|
* Prep 235: Enabled sd_bus_creds_get_slice(), sd_bus_creds_get_user_slice(), ↵Sven Eden2018-01-09
| | | | sd_peer_get_user_slice() and sd_pid_get_user_slice() to try to work with eloginds session id to user mapping.
* Prep 235: Enabled sd_peer_get_slice() and sd_pid_get_slice() to at least try ↵Sven Eden2018-01-09
| | | | to work. This is considered experimental.
* Prep 235: Although systemd slices are unsupported, make cg_path_get_slice() ↵Sven Eden2018-01-09
| | | | available, but in 'elogind jargon'
* Prep 235: Implement an alternative approach for sd_pid_get_owner_uid(), ↵Sven Eden2017-12-13
| | | | making test-login to no longer fail.
* Fix various build failures with the latest systemd updates.Sven Eden2017-12-08
|
* tree-wide: use IN_SET macro (#6977)Yu Watanabe2017-12-08
|
* 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
* 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.
* 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
|
* cgroup-util: replace one use of fgets() by read_line()Lennart Poettering2017-09-25
|
* 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.
* Prep v235: Add missing includes and dependencies.Sven Eden2017-08-14
|
* Prep v235: Apply upstream fixes (3/10) [src/basic]Sven Eden2017-08-14
|
* Prep v234: Eventually fix the cgroup stuff. elogind is not init.Sven Eden2017-07-27
|
* Prep v234: Apply missing upstream fixes in src/basic (1/6)Sven Eden2017-07-25
|
* Be slightly more verbose in error messageZbigniew Jędrzejewski-Szmek2017-07-25
| | | | | | Including the full path is always useful. Also use PID_FMT in one more place.
* core: introduce cg_mask_from_string()/cg_mask_to_string()Franck Bui2017-07-25
|
* Prep v233.3: Unmask various functions for future coverage tests.Sven Eden2017-07-19
| | | | | These functions, although not used by elogind itself, are mostly tiny and crucial for important tests to work.
* Prep v233: Add missing updates from upstream in src/basicSven Eden2017-07-17
|
* cgroup: rework cg_all_unified()Lennart Poettering2017-07-17
| | | | | | | | Let's just check the unified level, directly. There's really no value in wrapping cg_unified_controllers() with this, i.e. potentially do string comparison when there's no reason to. Also, this makes the clal more alike cg_hybrid_unified().
* cgroup: rename cg_update_unified() → cg_unified_update()Lennart Poettering2017-07-17
| | | | | We usually put the noun first, the verb (i.e. method) secont, for example in cg_unified_flush(), let's follow the logic here...
* cgroup: rename cg_unified() → cg_unified_controller()Lennart Poettering2017-07-17
| | | | | cg_unified() is a bit generic a name, let's make clear that it checks whether a specified controller is in unified mode.
* cgroup: change cg_unified() to possibly return errors againLennart Poettering2017-07-17
| | | | | | | | | We use our cgroup APIs in various contexts, including from our libraries sd-login, sd-bus. As we don#t control those environments we can't rely that the unified cgroup setup logic succeeds, and hence really shouldn't assert on it. This more or less reverts 415fc41ceaeada2e32639f24f134b1c248b9e43f.
* cgroup-util: check unified_cache before invoking streq()Lennart Poettering2017-07-17
| | | | Just a minor optimization.
* cgroup-util: fix the case of default=unified, unified-cgroup-hierarchy=0Zbigniew Jędrzejewski-Szmek2017-07-17
| | | | | We should mount the hybrid hierarchy if the user disabled the unified hierarchy on the kernel command line.
* cgroup-util: cache all cg_is_*_wanted answers, disable ↵Zbigniew Jędrzejewski-Szmek2017-07-17
| | | | | | | | | | | | | /sys/fs/cgroups/unified on unified If we encounter an error in proc cmdline parsing, just treat that as permanent, i.e. the same as if the option was not specified. Realistically, it is better to use the same condition for all related mounts, then to have e.g. /sys/fs/cgroup mounted and /sys/fs/cgroup/unified not. If we find something is mounted and base our answer on that, cache that result too. Fix the conditions so that if "unified" is used, make sure any "hybrid" mounts are not mounted.
* cgroup-util: fix the reversed return value of ↵Zbigniew Jędrzejewski-Szmek2017-07-17
| | | | | | | | cg_is_unified_elogind_contoller_wanted 1d84ad944520fc3e062ef518c4db4e1 reversed the meaning of the option. The kernel command line option has the opposite meaning to the function, i.e. specifying "legacy=yes" means "unifed elogind controller=no".
* core/mount-setup: if unified hierarchy is not supported, fall back to legacyZbigniew Jędrzejewski-Szmek2017-07-17
| | | | | | | | | | | We need this to gracefully support older or strangely configured kernels. v2: - do not install a callback handler, just embed the right conditions into cg_is_*_wanted() v3: - fix bug in cg_is_legacy_wanted()
* Rename cg_is_unified_elogind_controller_wanted to cg_is_hybrid_wantedZbigniew Jędrzejewski-Szmek2017-07-17
| | | | Less typing and doesn't make the table so incredibly wide.
* pid1: add ./configure switch to select default cgroup hierarchyZbigniew Jędrzejewski-Szmek2017-07-17
| | | | | | | | | | | | | | | | The default default is set to "legacy", with "hybrid" and "unified" being the other two alternatives. There invert the behaviour for elogind.legacy_elogind_cgroup_controller: if it is not specified on the kernel command line, "hybrid" is used if selected as the default. If this option is specified, "hybrid" is used if false, and full "legacy" if true. Also make all fields in the configure summary lowercase (unless they are capitalized names) for consistency. v2: - update for the fixed interpreation of elogind.legacy_elogind_cgroup_controller
* fs-util: unify code we use to check if dirent's d_name is "." or ".."Lennart Poettering2017-07-17
| | | | | We use different idioms at different places. Let's replace this is the one true new idiom, that is even a bit faster...