Return true if NAME has a capability (see linux/capability.h) */
| 3165 | #ifdef HAVE_CAP |
| 3166 | /* Return true if NAME has a capability (see linux/capability.h) */ |
| 3167 | static bool |
| 3168 | has_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 |
| 3189 | static bool |
| 3190 | has_capability (MAYBE_UNUSED char const *name) |
no outgoing calls
no test coverage detected