summaryrefslogtreecommitdiffstats
path: root/src/test/test-condition.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* tree-wide: beautify remaining copyright statementsLennart Poettering2018-06-141-1/+1
| | | | | | Let's unify an beautify our remaining copyright statements, with a unicode ©. This means our copyright statements are now always formatted the same way. Yay.
* 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.
* tree-wide: use newa() rather than alloca() where we canLennart Poettering2018-04-271-1/+1
|
* 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.
* test: fix condition test if there are no controllersLennart Poettering2018-01-051-3/+3
| | | | | As an optimization cg_mask_to_string() returns NULL if there are no controllers available. We need to handle that.
* condition: extend ConditionKernelVersion= with relative version checksLennart Poettering2017-12-261-0/+85
| | | | | Now that we have str_verscmp() in our source tree anyway, let's make it generic and reuse it for ConditionKernelVersion=.
* core,udev,networkd: add ConditionKernelVersion=Lennart Poettering2017-12-261-2/+40
| | | | | | | | | | This adds a simple condition/assert/match to the service manager, to udev's .link handling and to networkd, for matching the kernel version string. In this version we only do fnmatch() based globbing, but we might want to extend that to version comparisons later on, if we like, by slightly extending the syntax with ">=", "<=", ">", "<" and "==" expressions.
* condition: Create AssertControlGroupController (#7630)Chris Down2017-12-181-0/+74
| | | | | | | | | | | | | | | | | | Up until now, the behaviour in systemd has (mostly) been to silently ignore failures to action unit directives that refer to an unavailble controller. The addition of AssertControlGroupController and its conditional counterpart allow explicit specification of the desired behaviour when such a situation occurs. As for how this can happen, it is possible that a particular controller is not available in the cgroup hierarchy. One possible reason for this is that, in the running kernel, the controller simply doesn't exist -- for example, the CPU controller in cgroup v2 has only recently been merged and was out of tree until then. Another possibility is that the controller exists, but has been forcibly disabled by `cgroup_disable=` on the kernel command line. In future this will also support whatever comes out of issue #7624, `DefaultXAccounting=never`, or similar.
* user-util: add new uid_is_system() helperLennart Poettering2017-12-061-1/+1
| | | | | | | This adds uid_is_system() and gid_is_system(), similar in style to uid_is_dynamic(). That a helper like this is useful is illustrated by the fact that test-condition.c didn't get the check right so far, which this patch fixes.
* 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.
* test-condition: fix test_condition_test_group() (#6531)Alan Jenkins2017-08-061-4/+4
| | | | | | | | | | | | | | | | I hit a test failure with the `max_gid+1` test. Problem is that we loop over 0..r, but set `r` again within the loop (to 1). So max_gid is only set based on the first supplementary GID. ConditionGroup=1000 → 1 ConditionGroup=4 → 1 ConditionGroup=adm → 1 ConditionGroup=1001 → 1 Assertion 'r == 0' failed at ../src/test/test-condition.c:462, function test_condition_test_group(). Aborting. $ id uid=1000(alan-sysop) gid=1000(alan-sysop) groups=1000(alan-sysop),4(adm), 10(wheel),1001(sshlogin)
* test-condition: don't assume that all non-root users are normal users (#6409)Felipe Sateler2017-07-201-1/+1
| | | | | Automated builders may run under a dedicated system user, and this test would fail that Fixes #6366
* Merge pull request #5926 from fsateler/condition-uidLennart Poettering2017-05-291-0/+151
|\ | | | | core: add ConditionUID and ConditionGID
| * core: add @system special value to ConditionUser=Felipe Sateler2017-05-261-0/+10
| | | | | | | | It allows checking if the user is a system user or a normal user
| * core: add ConditionUser and ConditionGroupFelipe Sateler2017-05-261-0/+141
| | | | | | | | | | | | | | This adds two options that are useful for user units. In particular, it is useful to check ConditionUser=!0 to not start for the root user. Closes: #5187
* | Revert "selinux: split up mac_selinux_have() from mac_selinux_use()"Gary Tierney2017-05-121-1/+1
|/ | | | | | | | | | | | | | | This reverts commit 6355e75610a8d47fc3ba5ab8bd442172a2cfe574. The previously mentioned commit inadvertently broke a lot of SELinux related functionality for both unprivileged users and systemd instances running as MANAGER_USER. In particular, setting the correct SELinux context after a User= directive is used would fail to work since we attempt to set the security context after changing UID. Additionally, it causes activated socket units to be mislabeled for systemd --user processes since setsockcreatecon() would never be called. Reverting this fixes the issues with labeling outlined above, and reinstates SELinux access checks on unprivileged user services.
* shared/condition: add ConditionVirtualization=[!]private-usersZbigniew Jędrzejewski-Szmek2016-10-271-0/+60
| | | | | This can be useful to silence warnings about units which fail in userns container.
* test: always check whether condition allocation workedLennart Poettering2016-08-191-3/+38
| | | | Our tests should test for OOM too explicitly, hence fix the test accordingly
* Merge pull request 3821 from davide125/fix-testsZbigniew Jędrzejewski-Szmek2016-08-011-3/+9
|\
| * tests: don't test hostname if it looks like an id128Steve Muir2016-07-291-3/+9
|/ | | | | | | | | The condition tests for hostname will fail if hostname looks like an id128. The test function attempts to convert hostname to an id128, and if that succeeds compare it to the machine ID (presumably because the 'hostname' condition test is overloaded to also test machine ID). That will typically fail, and unfortunately the 'mock' utility generates a random hostname that happens to have the same format as an id128, thus causing a test failure.
* Fix #3236 (#3633)Lennart Poettering2016-07-011-3/+3
| | | | | | | | | | | | | | | | | | | | | * networkd: condition_test() can return a negative error, handle that If a condition check fails with an error we should not consider the check successful. Fix that. We should probably also improve logging in this case, but for now, let's just unbreak this breakage. Fixes: #3236 * condition: handle unrecognized architectures nicer When we encounter a check for an architecture we don't know we should not let the condition check fail with an error code, but instead simply return false. After all the architecture might just be newer than the ones we know, in which case it's certainly not our local one. Fixes: #3236
* selinux: split up mac_selinux_have() from mac_selinux_use()Lennart Poettering2015-11-271-1/+1
| | | | | | | | | | | | | Let's distuingish the cases where our code takes an active role in selinux management, or just passively reports whatever selinux properties are set. mac_selinux_have() now checks whether selinux is around for the passive stuff, and mac_selinux_use() for the active stuff. The latter checks the former, plus also checks UID == 0, under the assumption that only when we run priviliged selinux management really makes sense. Fixes: #1941
* util-lib: split out allocation calls into alloc-util.[ch]Lennart Poettering2015-10-271-0/+1
|
* src/basic: rename audit.[ch] → audit-util.[ch] and capability.[ch] → ↵Lennart Poettering2015-10-271-1/+1
| | | | | | | | | capability-util.[ch] The files are named too generically, so that they might conflict with the upstream project headers. Hence, let's add a "-util" suffix, to clarify that this are just our utility headers and not any official upstream headers.
* util-lib: split our string related calls from util.[ch] into its own file ↵Lennart Poettering2015-10-241-8/+9
| | | | | | | | | | | | | | string-util.[ch] There are more than enough calls doing string manipulations to deserve its own files, hence do something about it. This patch also sorts the #include blocks of all files that needed to be updated, according to the sorting suggestions from CODING_STYLE. Since pretty much every file needs our string manipulation functions this effectively means that most files have sorted #include blocks now. Also touches a few unrelated include files.
* util: split all hostname related calls into hostname-util.cLennart Poettering2015-05-181-0/+1
|
* test-condition: add more test casesRonny Chevalier2014-12-111-2/+45
|
* shared: rename condition-util.[ch] to condition.[ch]Lennart Poettering2014-11-061-0/+194
Now that we only have one file with condition implementations around, we can drop the -util suffix and simplify things a bit.