summaryrefslogtreecommitdiff
path: root/src/test/test-capability.c
Commit message (Collapse)AuthorAgeFilesLines
* capability-util: add new capability_get_ambient() helperLennart Poettering2023-02-221-1/+54
|
* tree-wide: have_effective_cap() may return negative errnoYu Watanabe2022-12-231-5/+5
|
* test: use assert_se() instead of assert()Yu Watanabe2021-10-121-1/+1
|
* test-capability: drop work-around initializationZbigniew Jędrzejewski-Szmek2021-06-091-1/+1
| | | | | | Since those workarounds have been added, work has been done to tighten up log_*() return values. Seems we get no warning with gcc-11.1.1-1.fc34.x86_64 and -O0/-O2.
* test-capability: skip tests that need CAP_NET_RAW if cap is not passedLennart Poettering2021-06-031-1/+7
| | | | See: #19746
* tree-wide: use the same comment for work-around initializationsZbigniew Jędrzejewski-Szmek2021-04-071-1/+1
| | | | | | | | This should make it easier to remove those warnings when the compiler gets smarter. Not sure if I got them all... Double space before the comment start to make it easier to separate from the preceding line.
* test-capability: silence gcc warningZbigniew Jędrzejewski-Szmek2021-03-311-12/+5
| | | | | | | | | | [2/3] Compiling C object test-capability.p/src_test_test-capability.c.o ../src/test/test-capability.c: In function ‘main’: ../src/test/test-capability.c:270:12: warning: ‘run_ambient’ may be used uninitialized in this function [-Wmaybe-uninitialized] 270 | if (run_ambient) | ^ gcc-11.0.1-0.3.fc34.x86_64
* license: LGPL-2.1+ -> LGPL-2.1-or-laterYu Watanabe2020-11-091-1/+1
|
* basic/missing_capability: clean up our defines and check that our fallback ↵Zbigniew Jędrzejewski-Szmek2020-08-271-0/+2
| | | | | | | | | is up-to-date There is little point in #defining and #undefining CAP_LAST_CAP multiple times. The check is only done in developer mode. After all, it's not an error to compile on a newer kernel, and we shouldn't even warn in that case.
* basic/capability-util: let cap_last_cap() return unsigned integerZbigniew Jędrzejewski-Szmek2020-07-101-1/+1
| | | | | | We never return anything higher than 63, so using "long unsigned" as the type only confused the reader. (We can still use "long unsigned" and safe_atolu() to parse the kernel file.)
* tests: various small fixes for strict systemsTopi Miettinen2020-04-261-1/+4
| | | | | | | | | | | | | | | | | | | | | | Don't assume that 4MB can be allocated from stack since there could be smaller DefaultLimitSTACK= in force, so let's use malloc(). NUL terminate the huge strings by hand, also ensure termination in test_lz4_decompress_partial() and optimize the memset() for the string. Some items in /proc and /etc may not be accessible to poor unprivileged users due to e.g. SELinux, BOFH or both, so check for EACCES and EPERM. /var/tmp may be a symlink to /tmp and then path_compare() will always fail, so let's stick to /tmp like elsewhere. /tmp may be mounted with noexec option and then trying to execute scripts from there would fail. Detect and warn if seccomp is already in use, which could make seccomp test fail if the syscalls are already blocked. Unset $TMPDIR so it will not break specifier tests where %T is assumed to be /tmp and %V /var/tmp.
* test-capability: Modify ambient capability tests to test clearing capsKevin Kuehler2019-11-271-3/+13
| | | | | | | Change test_set_ambient_caps() to test_apply_ambient_caps(), since the function capability_ambient_set_apply() not only sets ambient capabilities, but clears inherited capabilities that are not explicitly requested by the caller.
* tree-wide: drop capability.h when capability-util.h is includedYu Watanabe2019-11-041-1/+0
|
* util-lib: move yes_no() and friends to string-util.hZbigniew Jędrzejewski-Szmek2019-09-161-1/+1
|
* test: return a non-zero return code when 'nobody' user doesn't existFrantisek Sumsal2019-05-061-1/+1
| | | | | | | Lookup of a non-existing user using getpwnam() is not considered an error, thus the `errno` is not set appropriately, causing unexpected fails on systems, where 'nobody' user doesn't exist by default
* capability: add a test that fails if we ever enter > 64bit capability territoryLennart Poettering2019-03-211-0/+21
|
* capability: fix build without PR_CAP_AMBIENTFabrice Fontaine2019-01-111-0/+1
| | | | | | | | | | | | | systemd fails to build on kernel without PR_CAP_AMBIENT (< 4.3) since https://github.com/systemd/systemd/commit/2a03bb3e65327c73008f1db485ffc75c432dc6b2 To fix this error, include missing_prctl.h in all files using PR_CAP_AMBIENT Fixes: - http://autobuild.buildroot.org/results/699c078aa078240c6741da4dbd0871450ceeca92 Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
* tree-wide: use new macro HAS_FEATURE_ADDRESS_SANITIZER everywhereLennart Poettering2018-12-031-1/+1
|
* tests: keep SYS_PTRACE when running under ASanFrantisek Sumsal2018-11-091-1/+6
|
* tests: drop the precondition check for inherited flagFrantisek Sumsal2018-11-081-8/+0
| | | | | | | | Docker's default capability set has the inherited flag already set - that breaks tests which expect otherwise. Let's just drop the check and run the test anyway. Fixes #10663
* tests: use a helper function to parse environment and open loggingZbigniew Jędrzejewski-Szmek2018-09-141-3/+2
| | | | | The advantages are that we save a few lines, and that we can override logging using environment variables in more test executables.
* tests: add helper to unify skipping a test and exitingZbigniew Jędrzejewski-Szmek2018-09-141-10/+5
|
* test: when skipping tests, always print somethingZbigniew Jędrzejewski-Szmek2018-09-131-7/+10
| | | | | | It is quite confusing if the test "fails" without printing anything at all. A typo in an 'if' statement is also fixed.
* tree-wide: drop copyright headers from frequent contributorsZbigniew Jędrzejewski-Szmek2018-06-201-3/+0
| | | | | | | | Fixes #9320. for p in Shapovalov Chevalier Rozhkov Sievers Mack Herrmann Schmidt Rudenberg Sahani Landden Andersen Watanabe; do git grep -e 'Copyright.*'$p -l|xargs perl -i -0pe 's|/([*][*])?[*]\s+([*#]\s+)?Copyright[^\n]*'$p'[^\n]*\s*[*]([*][*])?/\n*|\n|gms; s|\s+([*#]\s+)?Copyright[^\n]*'$p'[^\n]*\n*|\n|gms' done
* 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: 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.
* tree-wide: use EXIT_SUCCESS/EXIT_FAILURE in exit() where we canLennart Poettering2017-12-251-1/+1
|
* test: use NOBODY_USER_NAME instead of hard-coded string "noody"Yu Watanabe2017-12-071-1/+1
|
* test: move tests about cap_list_cap() from test-cap-list to test-capabilityYu Watanabe2017-11-281-0/+39
|
* 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.
* capability: add new ambient_capabilities_supported() helperLennart Poettering2017-08-101-0/+2
| | | | | This new function reports whether ambient caps are available, and should be quick because the result is cached.
* tests: test ambient capabilities.Ismo Puustinen2016-01-121-2/+66
| | | | | The ambient capability tests are only run if the kernel has support for ambient capabilities.
* 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 out fd-related operations into fd-util.[ch]Lennart Poettering2015-10-251-5/+7
| | | | | There are more than enough to deserve their own .c file, hence move them over.
* remove unused includesThomas Hindoe Paaboel Andersen2015-02-231-1/+0
| | | | | | This patch removes includes that are not used. The removals were found with include-what-you-use which checks if any of the symbols from a header is in use.
* treewide: use log_*_errno whenever %m is in the format stringMichal Schmidt2014-11-281-1/+1
| | | | | | | | | | | If the format string contains %m, clearly errno must have a meaningful value, so we might as well use log_*_errno to have ERRNO= logged. Using: find . -name '*.[ch]' | xargs sed -r -i -e \ 's/log_(debug|info|notice|warning|error|emergency)\((".*%m.*")/log_\1_errno(errno, \2/' Plus some whitespace, linewrap, and indent adjustments.
* tests: add test-capabilityRonny Chevalier2014-06-221-0/+161