]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
conf: simplify idmaptool_on_path_and_privileged()
authorChristian Brauner <christian.brauner@ubuntu.com>
Mon, 12 Apr 2021 07:44:40 +0000 (09:44 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Mon, 12 Apr 2021 07:44:40 +0000 (09:44 +0200)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/conf.c

index 11c177b865f363592566b1985e7abf04fffb5241..37918dac783aba2a9a7be65a2fab42912680b0a5 100644 (file)
@@ -2789,18 +2789,16 @@ static int idmaptool_on_path_and_privileged(const char *binary, cap_value_t cap)
        int ret;
        struct stat st;
 
-       errno = EINVAL;
        if (cap != CAP_SETUID && cap != CAP_SETGID)
-               return -1;
+               return ret_errno(EINVAL);
 
-       errno = ENOENT;
        path = on_path(binary, NULL);
        if (!path)
-               return -1;
+               return ret_errno(ENOENT);
 
        ret = stat(path, &st);
        if (ret < 0)
-               return -1;
+               return -errno;
 
        /* Check if the binary is setuid. */
        if (st.st_mode & S_ISUID)
@@ -2819,7 +2817,8 @@ static int idmaptool_on_path_and_privileged(const char *binary, cap_value_t cap)
            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);
 #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
         * file capabilities are set.
         */