summaryrefslogtreecommitdiffstats
path: root/src/test/test-capability.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2019-03-21 12:38:18 +0100
committerLennart Poettering <lennart@poettering.net>2019-03-21 12:38:18 +0100
commit74b6ce90a0f2c2c0f824fc7e89f5433758d44914 (patch)
tree74be304b538fe1812cf1f46c4985369d039f1221 /src/test/test-capability.c
parentcapability: also cap CAP_LAST_CAP at 63 (diff)
downloadsystemd-74b6ce90a0f2c2c0f824fc7e89f5433758d44914.tar.xz
systemd-74b6ce90a0f2c2c0f824fc7e89f5433758d44914.zip
capability: add a test that fails if we ever enter > 64bit capability territory
Diffstat (limited to 'src/test/test-capability.c')
-rw-r--r--src/test/test-capability.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/test/test-capability.c b/src/test/test-capability.c
index 325d7c8cc2..6b2de66bb7 100644
--- a/src/test/test-capability.c
+++ b/src/test/test-capability.c
@@ -215,11 +215,32 @@ static void test_set_ambient_caps(void) {
assert_se(prctl(PR_CAP_AMBIENT, PR_CAP_AMBIENT_IS_SET, CAP_CHOWN, 0, 0) == 1);
}
+static void test_ensure_cap_64bit(void) {
+ _cleanup_free_ char *content = NULL;
+ unsigned long p = 0;
+ int r;
+
+ r = read_one_line_file("/proc/sys/kernel/cap_last_cap", &content);
+ if (r == -ENOENT) /* kernel pre 3.2 */
+ return;
+ assert_se(r >= 0);
+
+ assert_se(safe_atolu(content, &p) >= 0);
+
+ /* If caps don't fit into 64bit anymore, we have a problem, fail the test. */
+ assert_se(p <= 63);
+
+ /* Also check for the header definition */
+ assert_se(CAP_LAST_CAP <= 63);
+}
+
int main(int argc, char *argv[]) {
bool run_ambient;
test_setup_logging(LOG_INFO);
+ test_ensure_cap_64bit();
+
test_last_cap_file();
test_last_cap_probe();