#define _XOPEN_SOURCE 500
#define _GNU_SOURCE
+#include <errno.h> /* EINVAL */
#include <fcntl.h> /* AT_FOO constants */
#include <ftw.h> /* nftw() et al. */
#include <getopt.h> /* getopt_long() */
*
*/
void usage(const char* program_name) {
+ if (program_name == NULL) {
+ /* ??? */
+ return;
+ }
+
printf("Apply any applicable default ACLs to the given files or "
"directories.\n\n");
printf("Usage: %s [flags] <target1> [<target2> [ <target3>...]]\n\n",
int info,
struct FTW *ftw) {
+ if (target == NULL) {
+ errno = EINVAL;
+ perror("apply_default_acl_nftw (args)");
+ return ACL_ERROR;
+ }
+
+
if (apply_default_acl_ex(target, sp, false) == ACL_ERROR) {
/* I guess we do want to bail out for serious/unexpected errors? */
return ACL_ERROR;
int info,
struct FTW *ftw) {
+ if (target == NULL) {
+ errno = EINVAL;
+ perror("apply_default_acl_nftw_x (args)");
+ return ACL_ERROR;
+ }
+
if (apply_default_acl_ex(target, sp, true) == ACL_ERROR) {
/* I guess we do want to bail out for serious/unexpected errors? */
return ACL_ERROR;
* then we return @c ACL_ERROR. Otherwise, we return @c ACL_SUCCESS.
*/
int apply_default_acl_recursive(const char *target, bool no_exec_mask) {
+ if (target == NULL) {
+ errno = EINVAL;
+ perror("apply_default_acl_recursive (args)");
+ return ACL_ERROR;
+ }
+
int max_levels = 256;
int flags = FTW_MOUNT | FTW_PHYS;
* and @c OPEN_ERROR if not.
*/
int safe_open_ex(int at_fd, char* pathname, int flags) {
- /* We're only called by safe_open(), so pathname is guaranteed to be
- non-NULL */
+ if (pathname == NULL) {
+ errno = EINVAL;
+ perror("safe_open_ex (args)");
+ return OPEN_ERROR;
+ }
+
if (strlen(pathname) == 0) {
/* Oops, went one level to deep with nothing to do. */
return at_fd;
*
*/
int acl_set_entry(acl_t* aclp, acl_entry_t entry) {
+ if (aclp == NULL || entry == NULL) {
+ errno = EINVAL;
+ perror("acl_set_entry (args)");
+ return ACL_ERROR;
+ }
acl_tag_t entry_tag;
if (acl_get_tag_type(entry, &entry_tag) == ACL_ERROR) {
* - @c ACL_ERROR - Unexpected library error
*/
int acl_is_minimal(acl_t acl) {
+ if (acl == NULL) {
+ errno = EINVAL;
+ perror("acl_is_minimal (args)");
+ return ACL_ERROR;
+ }
int ec = acl_entry_count(acl);
* - @c ACL_ERROR - Unexpected library error.
*/
int acl_execute_masked(acl_t acl) {
+ if (acl == NULL) {
+ errno = EINVAL;
+ perror("acl_execute_masked (args)");
+ return ACL_ERROR;
+ }
acl_entry_t entry;
int ge_result = acl_get_entry(acl, ACL_FIRST_ENTRY, &entry);
* - @c ACL_ERROR - Unexpected library error.
*/
int any_can_execute(int fd, const struct stat* sp) {
+ if (sp == NULL) {
+ errno = EINVAL;
+ perror("any_can_execute (args)");
+ return ACL_ERROR;
+ }
+
acl_t acl = acl_get_fd(fd);
if (acl == (acl_t)NULL) {
* - @c ACL_ERROR - Unexpected library error.
*/
int assign_default_acl(const char* path, acl_t acl) {
-
- if (path == NULL) {
+ if (path == NULL || acl == NULL) {
errno = EINVAL;
perror("assign_default_acl (args)");
return ACL_ERROR;