diff options
Diffstat (limited to 'tools/testing/selftests/capabilities/test_execve.c')
| -rw-r--r-- | tools/testing/selftests/capabilities/test_execve.c | 12 | 
1 files changed, 9 insertions, 3 deletions
diff --git a/tools/testing/selftests/capabilities/test_execve.c b/tools/testing/selftests/capabilities/test_execve.c index 7cde07a5df78..47bad7ddc5bc 100644 --- a/tools/testing/selftests/capabilities/test_execve.c +++ b/tools/testing/selftests/capabilities/test_execve.c @@ -82,7 +82,7 @@ static bool create_and_enter_ns(uid_t inner_uid)  {  	uid_t outer_uid;  	gid_t outer_gid; -	int i; +	int i, ret;  	bool have_outer_privilege;  	outer_uid = getuid(); @@ -97,7 +97,10 @@ static bool create_and_enter_ns(uid_t inner_uid)  			ksft_exit_fail_msg("setresuid - %s\n", strerror(errno));  		// Re-enable effective caps -		capng_get_caps_process(); +		ret = capng_get_caps_process(); +		if (ret == -1) +			ksft_exit_fail_msg("capng_get_caps_process failed\n"); +  		for (i = 0; i < CAP_LAST_CAP; i++)  			if (capng_have_capability(CAPNG_PERMITTED, i))  				capng_update(CAPNG_ADD, CAPNG_EFFECTIVE, i); @@ -207,6 +210,7 @@ static void exec_validate_cap(bool eff, bool perm, bool inh, bool ambient)  static int do_tests(int uid, const char *our_path)  { +	int ret;  	bool have_outer_privilege = create_and_enter_ns(uid);  	int ourpath_fd = open(our_path, O_RDONLY | O_DIRECTORY); @@ -250,7 +254,9 @@ static int do_tests(int uid, const char *our_path)  			ksft_exit_fail_msg("chmod - %s\n", strerror(errno));  	} -	capng_get_caps_process(); +	ret = capng_get_caps_process(); +	if (ret == -1) +		ksft_exit_fail_msg("capng_get_caps_process failed\n");  	/* Make sure that i starts out clear */  	capng_update(CAPNG_DROP, CAPNG_INHERITABLE, CAP_NET_BIND_SERVICE);  |