#endif
#include "alloc-util.h"
+#include "capability-util.h"
#include "fd-util.h"
#include "fileio.h"
#include "macro.h"
# define SECCOMP_RESTRICT_ADDRESS_FAMILIES_BROKEN 0
#endif
+static bool have_seccomp_privs(void) {
+ return geteuid() == 0 && have_effective_cap(CAP_SYS_ADMIN) > 0; /* If we are root but CAP_SYS_ADMIN we can't do caps (unless we also do NNP) */
+}
+
static void test_parse_syscall_and_errno(void) {
_cleanup_free_ char *n = NULL;
int e;
log_notice("Seccomp not available, skipping %s", __func__);
return;
}
- if (geteuid() != 0) {
- log_notice("Not root, skipping %s", __func__);
+ if (!have_seccomp_privs()) {
+ log_notice("Not privileged, skipping %s", __func__);
return;
}
log_notice("Seccomp not available, skipping remaining tests in %s", __func__);
return;
}
- if (geteuid() != 0) {
- log_notice("Not root, skipping remaining tests in %s", __func__);
+ if (!have_seccomp_privs()) {
+ log_notice("Not privileged, skipping remaining tests in %s", __func__);
return;
}
log_notice("Seccomp not available, skipping %s", __func__);
return;
}
- if (geteuid() != 0) {
- log_notice("Not root, skipping %s", __func__);
+ if (!have_seccomp_privs()) {
+ log_notice("Not privileged, skipping %s", __func__);
return;
}
log_notice("Seccomp not available, skipping %s", __func__);
return;
}
- if (geteuid() != 0) {
- log_notice("Not root, skipping %s", __func__);
+ if (!have_seccomp_privs()) {
+ log_notice("Not privileged, skipping %s", __func__);
return;
}
log_notice("Seccomp not available, skipping %s", __func__);
return;
}
- if (geteuid() != 0) {
- log_notice("Not root, skipping %s", __func__);
+ if (!have_seccomp_privs()) {
+ log_notice("Not privileged, skipping %s", __func__);
return;
}
log_notice("Seccomp not available, skipping %s", __func__);
return;
}
- if (geteuid() != 0) {
- log_notice("Not root, skipping %s", __func__);
+ if (!have_seccomp_privs()) {
+ log_notice("Not privileged, skipping %s", __func__);
return;
}
log_notice("Seccomp not available, skipping %s", __func__);
return;
}
- if (geteuid() != 0) {
- log_notice("Not root, skipping %s", __func__);
+ if (!have_seccomp_privs()) {
+ log_notice("Not privileged, skipping %s", __func__);
return;
}
#if HAVE_VALGRIND_VALGRIND_H
log_notice("Seccomp not available, skipping %s", __func__);
return;
}
- if (geteuid() != 0) {
- log_notice("Not root, skipping %s", __func__);
+ if (!have_seccomp_privs()) {
+ log_notice("Not privileged, skipping %s", __func__);
return;
}
#if HAVE_VALGRIND_VALGRIND_H
log_notice("Seccomp not available, skipping %s", __func__);
return;
}
- if (geteuid() != 0) {
- log_notice("Not root, skipping %s", __func__);
+ if (!have_seccomp_privs()) {
+ log_notice("Not privileged, skipping %s", __func__);
return;
}
log_notice("Seccomp not available, skipping %s", __func__);
return;
}
- if (geteuid() != 0) {
- log_notice("Not root, skipping %s", __func__);
+ if (!have_seccomp_privs()) {
+ log_notice("Not privileged, skipping %s", __func__);
return;
}
log_notice("Seccomp not available, skipping %s", __func__);
return;
}
- if (geteuid() != 0) {
- log_notice("Not root, skipping %s", __func__);
+ if (!have_seccomp_privs()) {
+ log_notice("Not privileged, skipping %s", __func__);
return;
}
log_notice("Seccomp not available, skipping %s", __func__);
return;
}
- if (geteuid() != 0) {
- log_notice("Not root, skipping %s", __func__);
+ if (!have_seccomp_privs()) {
+ log_notice("Not privileged, skipping %s", __func__);
return;
}