Skip to content

Commit

Permalink
caps: skip file capability checks on android
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
  • Loading branch information
Christian Brauner authored and stgraber committed Apr 18, 2017
1 parent 99e54f0 commit 723935d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/lxc/caps.c
Expand Up @@ -225,6 +225,10 @@ static bool lxc_cap_is_set(cap_t caps, cap_value_t cap, cap_flag_t flag)

bool lxc_file_cap_is_set(const char *path, cap_value_t cap, cap_flag_t flag)
{
/* Android's bionic currently seems to lack support for cap_get_file(). */
#if IS_BIONIC
return true;
#else
bool cap_is_set;
cap_t caps;

Expand All @@ -243,6 +247,7 @@ bool lxc_file_cap_is_set(const char *path, cap_value_t cap, cap_flag_t flag)
cap_is_set = lxc_cap_is_set(caps, cap, flag);
cap_free(caps);
return cap_is_set;
#endif
}

bool lxc_proc_cap_is_set(cap_value_t cap, cap_flag_t flag)
Expand Down
6 changes: 5 additions & 1 deletion src/lxc/conf.c
Expand Up @@ -3254,7 +3254,7 @@ static int idmaptool_on_path_and_privileged(const char *binary, cap_value_t cap)
goto cleanup;
}

#if HAVE_LIBCAP
#if HAVE_LIBCAP && !IS_BIONIC
/* Check if it has the CAP_SETUID capability. */
if ((cap & CAP_SETUID) &&
lxc_file_cap_is_set(path, CAP_SETUID, CAP_EFFECTIVE) &&
Expand All @@ -3274,6 +3274,10 @@ static int idmaptool_on_path_and_privileged(const char *binary, cap_value_t cap)
fret = 1;
goto cleanup;
}
#else
DEBUG("Cannot check for file capabilites as full capability support is "
"missing. Manual intervention needed.");
fret = 1;
#endif

cleanup:
Expand Down

0 comments on commit 723935d

Please sign in to comment.