summaryrefslogtreecommitdiff
path: root/src/basic/cgroup-util.c
Commit message (Collapse)AuthorAge
* Prep v239: Unmask cg_weight_parse()Sven Eden2018-08-24
|
* Prep v239: Add missing updates that evaded migration.Sven Eden2018-08-24
|
* tree-wide: remove Lennart's copyright linesLennart Poettering2018-08-24
| | | | | | | | | | | 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-08-24
| | | | | | | | | | | | | | | | 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.
* pid1: do not reset subtree_control on already-existing units with delegationZbigniew Jędrzejewski-Szmek2018-08-24
| | | | | | | | | | | | | | | | | Fixes #8364. Reproducer: $ sudo systemd-run -t -p Delegate=yes bash # mkdir /sys/fs/cgroup/system.slice/run-u6958.service/supervisor # echo $$ > /sys/fs/cgroup/system.slice/run-u6958.service/supervisor/cgroup.procs # echo +memory > /sys/fs/cgroup/system.slice/run-u6958.service/cgroup.subtree_control # cat /sys/fs/cgroup/system.slice/run-u6958.service/cgroup.subtree_control memory # systemctl daemon-reload # cat /sys/fs/cgroup/system.slice/run-u6958.service/cgroup.subtree_control (empty) With patch, the last command shows 'memory'.
* path-util: introduce path_simplify()Yu Watanabe2018-08-24
| | | | | | | | The function is similar to path_kill_slashes() but also removes initial './', trailing '/.', and '/./' in the path. When the second argument of path_simplify() is false, then it behaves as the same as path_kill_slashes(). Hence, this also replaces path_kill_slashes() with path_simplify().
* cgroup-util: fix enabling of controllers (#8816)Antique2018-08-24
| | | | | | | | | | | If enabling controller for some reason fails we need to clear error for the FILE stream. Enabling remaining controllers would otherwise fail because write_string_stream_ts() checks for ferror(f) and returns -EIO if there is one. Broken by commit <77fa610b22>. Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
* util-lib: introduce new empty_or_root() helper (#8746)Lennart Poettering2018-08-24
| | | | | | | | We check the same condition at various places. Let's add a trivial, common helper for this, and use it everywhere. It's not going to make things much faster or much shorter, but I think a lot more readable
* tree-wide: drop license boilerplateZbigniew Jędrzejewski-Szmek2018-08-24
| | | | | | | | | | 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 TAKE_PTR() and TAKE_FD() macrosYu Watanabe2018-08-24
|
* fuzz-unit-file: add __has_feature(memory_sanitizer) when skipping ListenNetlink=Zbigniew Jędrzejewski-Szmek2018-08-24
| | | | | | | | | | | | https://clang.llvm.org/docs/MemorySanitizer.html#id5 documents this check as the way to detect MemorySanitizer at compilation time. We only need to skip the test if MemorySanitizer is used. Also, use this condition in cg_slice_to_path(). There, the code that is conditionalized is not harmful in any way (it's just unnecessary), so remove the FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION condition. Fixes #8482.
* macro: introduce TAKE_PTR() macroLennart Poettering2018-08-24
| | | | | | | | | | | | | | | | This macro will read a pointer of any type, return it, and set the pointer to NULL. This is useful as an explicit concept of passing ownership of a memory area between pointers. This takes inspiration from Rust: https://doc.rust-lang.org/std/option/enum.Option.html#method.take and was suggested by Alan Jenkins (@sourcejedi). It drops ~160 lines of code from our codebase, which makes me like it. Also, I think it clarifies passing of ownership, and thus helps readability a bit (at least for the initiated who know the new macro)
* Fix cgroup directory mounting:Sven Eden2018-06-29
| | | | | | | | | | | | | A little misunderstanding has been fixed, and elogind now mounts the following directories, if (and only if) it has to act as its own cgroups controller. * -Ddefault-hierarchy=legacy : /sys/fs/cgroup as tmpfs /sys/fs/cgroup/elogind as cgroup * -Ddefault-hierarchy=hybrid : The same as with 'legacy', plus /sys/fs/cgroup/unified as cgroup2 * -Ddefault-hierarchy=unified : /sys/fs/cgroup2 as cgroup2
* cgroup-util: fix enabling of controllers (#8816)Antique2018-06-28
| | | | | | | | | | | | If enabling controller for some reason fails we need to clear error for the FILE stream. Enabling remaining controllers would otherwise fail because write_string_stream_ts() checks for ferror(f) and returns -EIO if there is one. Broken by commit <77fa610b22>. Signed-off-by: Pavel Hrdina <phrdina@redhat.com> (cherry picked from commit 96aa6591d1103b8cca9a4db80ba478a18bdf3e9a)
* basic/cgroup-util: remove unused variableZbigniew Jędrzejewski-Szmek2018-06-28
| | | | (cherry picked from commit eef03d70c1bedb3aabd4e2bcf10ab1f2678443bf)
* Prep v238: Fix cg_path_decode_unit() to understand elogind session naming.Sven Eden2018-06-11
| | | | (cherry picked from commit d8949c3072a4b984d6fa964178a2d8d945ecbcb6)
* Prep v238: Uncomment now needed headers and unmask now needed functions in ↵Sven Eden2018-06-05
| | | | src/basic (1/6)
* Prep v238: Applied some upstream updates to src/basic (3/5)Sven Eden2018-06-04
|
* 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
|