test: Gracefully handle running within user namespace with single user
Unprivileged users often make themselves root by unsharing a user namespace and then mapping their current user to root which does not require privileges. Let's make sure our tests don't fail in such an environment by adding checks where required to see if we're not running in a user namespace with only a single user.
This commit is contained in:
@@ -170,7 +170,7 @@ TEST(getpeercred_getpeergroups) {
|
||||
struct ucred ucred;
|
||||
int pair[2] = EBADF_PAIR;
|
||||
|
||||
if (geteuid() == 0) {
|
||||
if (geteuid() == 0 && !userns_has_single_user()) {
|
||||
test_uid = 1;
|
||||
test_gid = 2;
|
||||
test_gids = (gid_t*) gids;
|
||||
|
||||
Reference in New Issue
Block a user