MCPcopy Create free account
hub / github.com/coreutils/coreutils / has_capability

Function has_capability

src/ls.c:3167–3187  ·  view source on GitHub ↗

Return true if NAME has a capability (see linux/capability.h) */

Source from the content-addressed store, hash-verified

3165#ifdef HAVE_CAP
3166/* Return true if NAME has a capability (see linux/capability.h) */
3167static bool
3168has_capability (char const *name)
3169{
3170 char *result;
3171 bool has_cap;
3172
3173 cap_t cap_d = cap_get_file (name);
3174 if (cap_d == NULL)
3175 return false;
3176
3177 result = cap_to_text (cap_d, NULL);
3178 cap_free (cap_d);
3179 if (!result)
3180 return false;
3181
3182 /* check if human-readable capability string is empty */
3183 has_cap = !!*result;
3184
3185 cap_free (result);
3186 return has_cap;
3187}
3188#else
3189static bool
3190has_capability (MAYBE_UNUSED char const *name)

Callers 1

has_capability_cacheFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected