conf: simplify idmaptool_on_path_and_privileged

parent c4fb13e9
...@@ -2844,24 +2844,23 @@ static int idmaptool_on_path_and_privileged(const char *binary, cap_value_t cap) ...@@ -2844,24 +2844,23 @@ static int idmaptool_on_path_and_privileged(const char *binary, cap_value_t cap)
struct stat st; struct stat st;
int fret = 0; int fret = 0;
errno = EINVAL;
if (cap != CAP_SETUID && cap != CAP_SETGID) if (cap != CAP_SETUID && cap != CAP_SETGID)
return -EINVAL; return -1;
errno = ENOENT;
path = on_path(binary, NULL); path = on_path(binary, NULL);
if (!path) if (!path)
return -ENOENT; return -1;
ret = stat(path, &st); ret = stat(path, &st);
if (ret < 0) { if (ret < 0)
fret = -errno; return -1;
goto cleanup;
}
/* Check if the binary is setuid. */ /* Check if the binary is setuid. */
if (st.st_mode & S_ISUID) { if (st.st_mode & S_ISUID) {
DEBUG("The binary \"%s\" does have the setuid bit set", path); DEBUG("The binary \"%s\" does have the setuid bit set", path);
fret = 1; return 1;
goto cleanup;
} }
#if HAVE_LIBCAP && LIBCAP_SUPPORTS_FILE_CAPABILITIES #if HAVE_LIBCAP && LIBCAP_SUPPORTS_FILE_CAPABILITIES
...@@ -2871,8 +2870,7 @@ static int idmaptool_on_path_and_privileged(const char *binary, cap_value_t cap) ...@@ -2871,8 +2870,7 @@ static int idmaptool_on_path_and_privileged(const char *binary, cap_value_t cap)
lxc_file_cap_is_set(path, CAP_SETUID, CAP_PERMITTED)) { lxc_file_cap_is_set(path, CAP_SETUID, CAP_PERMITTED)) {
DEBUG("The binary \"%s\" has CAP_SETUID in its CAP_EFFECTIVE " DEBUG("The binary \"%s\" has CAP_SETUID in its CAP_EFFECTIVE "
"and CAP_PERMITTED sets", path); "and CAP_PERMITTED sets", path);
fret = 1; return 1;
goto cleanup;
} }
/* Check if it has the CAP_SETGID capability. */ /* Check if it has the CAP_SETGID capability. */
...@@ -2881,8 +2879,7 @@ static int idmaptool_on_path_and_privileged(const char *binary, cap_value_t cap) ...@@ -2881,8 +2879,7 @@ static int idmaptool_on_path_and_privileged(const char *binary, cap_value_t cap)
lxc_file_cap_is_set(path, CAP_SETGID, CAP_PERMITTED)) { lxc_file_cap_is_set(path, CAP_SETGID, CAP_PERMITTED)) {
DEBUG("The binary \"%s\" has CAP_SETGID in its CAP_EFFECTIVE " DEBUG("The binary \"%s\" has CAP_SETGID in its CAP_EFFECTIVE "
"and CAP_PERMITTED sets", path); "and CAP_PERMITTED sets", path);
fret = 1; return 1;
goto cleanup;
} }
#else #else
/* If we cannot check for file capabilities we need to give the benefit /* If we cannot check for file capabilities we need to give the benefit
...@@ -2891,11 +2888,9 @@ static int idmaptool_on_path_and_privileged(const char *binary, cap_value_t cap) ...@@ -2891,11 +2888,9 @@ static int idmaptool_on_path_and_privileged(const char *binary, cap_value_t cap)
*/ */
DEBUG("Cannot check for file capabilities as full capability support is " DEBUG("Cannot check for file capabilities as full capability support is "
"missing. Manual intervention needed"); "missing. Manual intervention needed");
fret = 1;
#endif #endif
cleanup: return 1;
return fret;
} }
int lxc_map_ids_exec_wrapper(void *args) int lxc_map_ids_exec_wrapper(void *args)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment