Unverified Commit d32dcd01 by Stéphane Graber Committed by GitHub

Merge pull request #3778 from brauner/2021-04-12/fixes

conf: idmaptool fixes
parents 965502a0 a864a2e1
...@@ -2789,18 +2789,16 @@ static int idmaptool_on_path_and_privileged(const char *binary, cap_value_t cap) ...@@ -2789,18 +2789,16 @@ static int idmaptool_on_path_and_privileged(const char *binary, cap_value_t cap)
int ret; int ret;
struct stat st; struct stat st;
errno = EINVAL;
if (cap != CAP_SETUID && cap != CAP_SETGID) if (cap != CAP_SETUID && cap != CAP_SETGID)
return -1; return ret_errno(EINVAL);
errno = ENOENT;
path = on_path(binary, NULL); path = on_path(binary, NULL);
if (!path) if (!path)
return -1; return ret_errno(ENOENT);
ret = stat(path, &st); ret = stat(path, &st);
if (ret < 0) if (ret < 0)
return -1; return -errno;
/* Check if the binary is setuid. */ /* Check if the binary is setuid. */
if (st.st_mode & S_ISUID) if (st.st_mode & S_ISUID)
...@@ -2818,15 +2816,17 @@ static int idmaptool_on_path_and_privileged(const char *binary, cap_value_t cap) ...@@ -2818,15 +2816,17 @@ static int idmaptool_on_path_and_privileged(const char *binary, cap_value_t cap)
lxc_file_cap_is_set(path, CAP_SETGID, CAP_EFFECTIVE) && lxc_file_cap_is_set(path, CAP_SETGID, CAP_EFFECTIVE) &&
lxc_file_cap_is_set(path, CAP_SETGID, CAP_PERMITTED)) lxc_file_cap_is_set(path, CAP_SETGID, CAP_PERMITTED))
return log_debug(1, "The binary \"%s\" has CAP_SETGID in its CAP_EFFECTIVE and CAP_PERMITTED sets", path); return log_debug(1, "The binary \"%s\" has CAP_SETGID in its CAP_EFFECTIVE and CAP_PERMITTED sets", path);
return 0;
#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
* of the doubt. Otherwise we might fail even though all the necessary * of the doubt. Otherwise we might fail even though all the necessary
* file capabilities are set. * file capabilities are set.
*/ */
DEBUG("Cannot check for file capabilities as full capability support is missing. Manual intervention needed"); DEBUG("Cannot check for file capabilities as full capability support is missing. Manual intervention needed");
#endif
return 1; return 1;
#endif
} }
static int lxc_map_ids_exec_wrapper(void *args) static 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