MS_NOSUID|MS_NOEXEC|MS_NODEV, NULL);
if (ret < 0) {
ret = -errno;
- printf("error mount() %s :%d (%m)\n",
- kdbus_args->module, ret);
+ printf("error mount() %s :%d (%m)\n", kdbusfs, ret);
_exit(TEST_ERR);
}
ret = kdbus_conn_info(env->conn, 0, "non.existent.name", 0, NULL);
ASSERT_RETURN(ret == -ESRCH);
+ if (!all_uids_gids_are_mapped())
+ return TEST_SKIP;
+
/* Test for caps here, so we run the previous test */
have_caps = test_is_capable(CAP_SETUID, CAP_SETGID, -1);
ASSERT_RETURN(have_caps >= 0);
ret = test_is_capable(CAP_SETUID, CAP_SETGID, -1);
ASSERT_RETURN(ret >= 0);
- /* we can drop privileges */
- if (ret) {
+ /*
+ * All uids/gids are mapped and we have the necessary caps
+ */
+ if (ret && all_uids_gids_are_mapped()) {
ret = unpriv_test_custom_ep(env->buspath);
ASSERT_RETURN(ret == 0);
}
ret = kdbus_test_notify_kernel_quota(env);
ASSERT_RETURN(ret == 0);
- if (geteuid() == 0) {
+ if (geteuid() == 0 && all_uids_gids_are_mapped()) {
ret = kdbus_test_multi_users_quota(env);
ASSERT_RETURN(ret == 0);
#include <sys/ioctl.h>
#include <sys/eventfd.h>
#include <sys/syscall.h>
+#include <sys/capability.h>
#include <linux/sched.h>
#include "kdbus-test.h"
struct kdbus_conn *policy_holder = NULL;
char *bus = env->buspath;
- if (geteuid() > 0) {
- kdbus_printf("error geteuid() != 0, %s() needs root\n",
- __func__);
+ ret = test_is_capable(CAP_SETUID, CAP_SETGID, -1);
+ ASSERT_RETURN(ret >= 0);
+
+ /* no enough privileges, SKIP test */
+ if (!ret)
return TEST_SKIP;
- }
/* we require user-namespaces */
if (access("/proc/self/uid_map", F_OK) != 0)
return TEST_SKIP;
+ /* uids/gids must be mapped */
+ if (!all_uids_gids_are_mapped())
+ return TEST_SKIP;
+
conn_db = calloc(MAX_CONN, sizeof(struct kdbus_conn *));
ASSERT_RETURN(conn_db);
if (!ret)
return TEST_SKIP;
+ /* make sure that uids and gids are mapped */
+ if (!all_uids_gids_are_mapped())
+ return TEST_SKIP;
+
/*
* Setup:
* conn_a: policy holder for com.example.a