2 * @file apply-default-acl.c
4 * @brief The entire implementation.
8 /* On Linux, ftw.h needs this special voodoo to work. */
9 #define _XOPEN_SOURCE 500
13 #include <fcntl.h> /* AT_FOO constants */
14 #include <ftw.h> /* nftw() et al. */
16 #include <libgen.h> /* dirname() */
17 #include <limits.h> /* PATH_MAX */
26 #include <acl/libacl.h> /* acl_get_perm, not portable */
27 #include <sys/types.h>
30 /* Most of the libacl functions return 1 for success, 0 for failure,
39 * @brief Get the mode bits from the given path.
42 * The path (file or directory) whose mode we want.
44 * @return A mode_t (st_mode) structure containing the mode bits.
45 * See sys/stat.h for details.
47 mode_t
get_mode(const char* path
) {
54 int result
= lstat(path
, &s
);
60 /* errno will be set already by lstat() */
68 * @brief Determine if the given path might refer to an (unsafe) hard link.
73 * @return true if we are certain that @c path does not refer to a hard
74 * link, and false otherwise. In case of error, false is returned,
75 * because we are not sure that @c path is not a hard link.
77 bool is_hardlink_safe(const char* path
) {
82 int result
= lstat(path
, &s
);
84 return (s
.st_nlink
== 1 || S_ISDIR(s
.st_mode
));
93 * @brief Determine whether or not the given path is a regular file.
98 * @return true if @c path is a regular file, false otherwise.
100 bool is_regular_file(const char* path
) {
106 int result
= lstat(path
, &s
);
108 return S_ISREG(s
.st_mode
);
118 * @brief Determine whether or not the given path is accessible.
123 * @return true if @c path is accessible to the current effective
124 * user/group, false otherwise.
126 bool path_accessible(const char* path
) {
131 /* Test for access using the effective user and group rather than
133 int flags
= AT_EACCESS
;
135 /* Don't follow symlinks when checking for a path's existence,
136 since we won't follow them to set its ACLs either. */
137 flags
|= AT_SYMLINK_NOFOLLOW
;
139 /* If the path is relative, interpret it relative to the current
140 working directory (just like the access() system call). */
141 int result
= faccessat(AT_FDCWD
, path
, F_OK
, flags
);
154 * @brief Determine whether or not the given path is a directory.
159 * @return true if @c path is a directory, false otherwise.
161 bool is_directory(const char* path
) {
167 int result
= lstat(path
, &s
);
169 return S_ISDIR(s
.st_mode
);
179 * @brief Update (or create) an entry in an @b minimal ACL.
181 * This function will not work if @c aclp contains extended
182 * entries. This is fine for our purposes, since we call @c wipe_acls
183 * on each path before applying the default to it.
185 * The assumption that there are no extended entries makes things much
186 * simpler. For example, we only have to update the @c ACL_USER_OBJ,
187 * @c ACL_GROUP_OBJ, and @c ACL_OTHER entries -- all others can simply
188 * be created anew. This means we don't have to fool around comparing
189 * named-user/group entries.
192 * A pointer to the acl_t structure whose entry we want to modify.
195 * The new entry. If @c entry contains a user/group/other entry, we
196 * update the existing one. Otherwise we create a new entry.
198 * @return If there is an unexpected library error, @c ACL_ERROR is
199 * returned. Otherwise, @c ACL_SUCCESS.
202 int acl_set_entry(acl_t
* aclp
,
206 int gt_result
= acl_get_tag_type(entry
, &entry_tag
);
207 if (gt_result
== ACL_ERROR
) {
208 perror("acl_set_entry (acl_get_tag_type)");
212 acl_permset_t entry_permset
;
213 int ps_result
= acl_get_permset(entry
, &entry_permset
);
214 if (ps_result
== ACL_ERROR
) {
215 perror("acl_set_entry (acl_get_permset)");
219 acl_entry_t existing_entry
;
220 /* Loop through the given ACL looking for matching entries. */
221 int result
= acl_get_entry(*aclp
, ACL_FIRST_ENTRY
, &existing_entry
);
223 while (result
== ACL_SUCCESS
) {
224 acl_tag_t existing_tag
= ACL_UNDEFINED_TAG
;
225 int tag_result
= acl_get_tag_type(existing_entry
, &existing_tag
);
227 if (tag_result
== ACL_ERROR
) {
228 perror("set_acl_tag_permset (acl_get_tag_type)");
232 if (existing_tag
== entry_tag
) {
233 if (entry_tag
== ACL_USER_OBJ
||
234 entry_tag
== ACL_GROUP_OBJ
||
235 entry_tag
== ACL_OTHER
) {
236 /* Only update for these three since all other tags will have
237 been wiped. These three are guaranteed to exist, so if we
238 match one of them, we're allowed to return ACL_SUCCESS
239 below and bypass the rest of the function. */
240 acl_permset_t existing_permset
;
241 int gep_result
= acl_get_permset(existing_entry
, &existing_permset
);
242 if (gep_result
== ACL_ERROR
) {
243 perror("acl_set_entry (acl_get_permset)");
247 int s_result
= acl_set_permset(existing_entry
, entry_permset
);
248 if (s_result
== ACL_ERROR
) {
249 perror("acl_set_entry (acl_set_permset)");
258 result
= acl_get_entry(*aclp
, ACL_NEXT_ENTRY
, &existing_entry
);
261 /* This catches both the initial acl_get_entry and the ones at the
263 if (result
== ACL_ERROR
) {
264 perror("acl_set_entry (acl_get_entry)");
268 /* If we've made it this far, we need to add a new entry to the
270 acl_entry_t new_entry
;
272 /* We allocate memory here that we should release! */
273 int c_result
= acl_create_entry(aclp
, &new_entry
);
274 if (c_result
== ACL_ERROR
) {
275 perror("acl_set_entry (acl_create_entry)");
279 int st_result
= acl_set_tag_type(new_entry
, entry_tag
);
280 if (st_result
== ACL_ERROR
) {
281 perror("acl_set_entry (acl_set_tag_type)");
285 int s_result
= acl_set_permset(new_entry
, entry_permset
);
286 if (s_result
== ACL_ERROR
) {
287 perror("acl_set_entry (acl_set_permset)");
291 if (entry_tag
== ACL_USER
|| entry_tag
== ACL_GROUP
) {
292 /* We need to set the qualifier too. */
293 void* entry_qual
= acl_get_qualifier(entry
);
294 if (entry_qual
== (void*)NULL
) {
295 perror("acl_set_entry (acl_get_qualifier)");
299 int sq_result
= acl_set_qualifier(new_entry
, entry_qual
);
300 if (sq_result
== ACL_ERROR
) {
301 perror("acl_set_entry (acl_set_qualifier)");
312 * @brief Determine the number of entries in the given ACL.
315 * A pointer to an @c acl_t structure.
317 * @return Either the non-negative number of entries in @c acl, or
318 * @c ACL_ERROR on error.
320 int acl_entry_count(acl_t
* acl
) {
324 int result
= acl_get_entry(*acl
, ACL_FIRST_ENTRY
, &entry
);
326 while (result
== ACL_SUCCESS
) {
328 result
= acl_get_entry(*acl
, ACL_NEXT_ENTRY
, &entry
);
331 if (result
== ACL_ERROR
) {
332 perror("acl_entry_count (acl_get_entry)");
342 * @brief Determine whether or not the given ACL is minimal.
344 * An ACL is minimal if it has fewer than four entries.
347 * A pointer to an acl_t structure.
350 * - @c ACL_SUCCESS - @c acl is minimal
351 * - @c ACL_FAILURE - @c acl is not minimal
352 * - @c ACL_ERROR - Unexpected library error
354 int acl_is_minimal(acl_t
* acl
) {
356 int ec
= acl_entry_count(acl
);
358 if (ec
== ACL_ERROR
) {
359 perror("acl_is_minimal (acl_entry_count)");
374 * @brief Determine whether the given path has an ACL whose mask
381 * - @c ACL_SUCCESS - @c path has a mask which denies execute.
382 * - @c ACL_FAILURE - The ACL for @c path does not deny execute,
383 * or @c path has no extended ACL at all.
384 * - @c ACL_ERROR - Unexpected library error.
386 int acl_execute_masked(const char* path
) {
388 acl_t acl
= acl_get_file(path
, ACL_TYPE_ACCESS
);
390 if (acl
== (acl_t
)NULL
) {
391 perror("acl_execute_masked (acl_get_file)");
395 /* Our return value. */
396 int result
= ACL_FAILURE
;
399 int ge_result
= acl_get_entry(acl
, ACL_FIRST_ENTRY
, &entry
);
401 while (ge_result
== ACL_SUCCESS
) {
402 acl_tag_t tag
= ACL_UNDEFINED_TAG
;
403 int tag_result
= acl_get_tag_type(entry
, &tag
);
405 if (tag_result
== ACL_ERROR
) {
406 perror("acl_execute_masked (acl_get_tag_type)");
411 if (tag
== ACL_MASK
) {
412 /* This is the mask entry, get its permissions, and see if
413 execute is specified. */
414 acl_permset_t permset
;
416 int ps_result
= acl_get_permset(entry
, &permset
);
417 if (ps_result
== ACL_ERROR
) {
418 perror("acl_execute_masked (acl_get_permset)");
423 int gp_result
= acl_get_perm(permset
, ACL_EXECUTE
);
424 if (gp_result
== ACL_ERROR
) {
425 perror("acl_execute_masked (acl_get_perm)");
430 if (gp_result
== ACL_FAILURE
) {
431 /* No execute bit set in the mask; execute not allowed. */
436 ge_result
= acl_get_entry(acl
, ACL_NEXT_ENTRY
, &entry
);
447 * @brief Determine whether @c path is executable (by anyone) or a
450 * This is used as part of the heuristic to determine whether or not
451 * we should mask the execute bit when inheriting an ACL. If @c path
452 * is a directory, the answer is a clear-cut yes. This behavior is
453 * modeled after the capital 'X' perms of setfacl.
455 * If @c path is a file, we check the @a effective permissions,
456 * contrary to what setfacl does.
462 * - @c ACL_SUCCESS - @c path is a directory, or someone has effective
464 * - @c ACL_FAILURE - @c path is a regular file and nobody can execute
466 * - @c ACL_ERROR - Unexpected library error.
468 int any_can_execute_or_dir(const char* path
) {
470 if (is_directory(path
)) {
471 /* That was easy... */
475 acl_t acl
= acl_get_file(path
, ACL_TYPE_ACCESS
);
477 if (acl
== (acl_t
)NULL
) {
478 perror("any_can_execute_or_dir (acl_get_file)");
482 /* Our return value. */
483 int result
= ACL_FAILURE
;
485 if (acl_is_minimal(&acl
)) {
486 mode_t mode
= get_mode(path
);
487 if (mode
& (S_IXUSR
| S_IXOTH
| S_IXGRP
)) {
488 result
= ACL_SUCCESS
;
492 result
= ACL_FAILURE
;
498 int ge_result
= acl_get_entry(acl
, ACL_FIRST_ENTRY
, &entry
);
500 while (ge_result
== ACL_SUCCESS
) {
501 /* The first thing we do is check to see if this is a mask
502 entry. If it is, we skip it entirely. */
503 acl_tag_t tag
= ACL_UNDEFINED_TAG
;
504 int tag_result
= acl_get_tag_type(entry
, &tag
);
506 if (tag_result
== ACL_ERROR
) {
507 perror("any_can_execute_or_dir (acl_get_tag_type)");
512 if (tag
== ACL_MASK
) {
513 ge_result
= acl_get_entry(acl
, ACL_NEXT_ENTRY
, &entry
);
517 /* Ok, so it's not a mask entry. Check the execute perms. */
518 acl_permset_t permset
;
520 int ps_result
= acl_get_permset(entry
, &permset
);
521 if (ps_result
== ACL_ERROR
) {
522 perror("any_can_execute_or_dir (acl_get_permset)");
527 int gp_result
= acl_get_perm(permset
, ACL_EXECUTE
);
528 if (gp_result
== ACL_ERROR
) {
529 perror("any_can_execute_or_dir (acl_get_perm)");
534 if (gp_result
== ACL_SUCCESS
) {
535 /* Only return ACL_SUCCESS if this execute bit is not masked. */
536 if (acl_execute_masked(path
) != ACL_SUCCESS
) {
537 result
= ACL_SUCCESS
;
542 ge_result
= acl_get_entry(acl
, ACL_NEXT_ENTRY
, &entry
);
545 if (ge_result
== ACL_ERROR
) {
546 perror("any_can_execute_or_dir (acl_get_entry)");
559 * @brief Set @c acl as the default ACL on @c path if it's a directory.
561 * This overwrites any existing default ACL on @c path. If no default
562 * ACL exists, then one is created. If @c path is not a directory, we
563 * return ACL_FAILURE but no error is raised.
566 * The target directory whose ACL we wish to replace or create.
569 * The ACL to set as default on @c path.
572 * - @c ACL_SUCCESS - The default ACL was assigned successfully.
573 * - @c ACL_FAILURE - If @c path is not a directory.
574 * - @c ACL_ERROR - Unexpected library error.
576 int assign_default_acl(const char* path
, acl_t acl
) {
583 if (!is_directory(path
)) {
587 /* Our return value; success unless something bad happens. */
588 int result
= ACL_SUCCESS
;
589 acl_t path_acl
= acl_dup(acl
);
591 if (path_acl
== (acl_t
)NULL
) {
592 perror("inherit_default_acl (acl_dup)");
593 return ACL_ERROR
; /* Nothing to clean up in this case. */
596 int sf_result
= acl_set_file(path
, ACL_TYPE_DEFAULT
, path_acl
);
597 if (sf_result
== -1) {
598 perror("inherit_default_acl (acl_set_file)");
609 * @brief Remove @c ACL_USER, @c ACL_GROUP, and @c ACL_MASK entries
610 * from the given path.
613 * The path whose ACLs we want to wipe.
616 * - @c ACL_SUCCESS - The ACLs were wiped successfully, or none
617 * existed in the first place.
618 * - @c ACL_ERROR - Unexpected library error.
620 int wipe_acls(const char* path
) {
627 acl_t acl
= acl_get_file(path
, ACL_TYPE_ACCESS
);
628 if (acl
== (acl_t
)NULL
) {
629 perror("wipe_acls (acl_get_file)");
633 /* Our return value. */
634 int result
= ACL_SUCCESS
;
637 int ge_result
= acl_get_entry(acl
, ACL_FIRST_ENTRY
, &entry
);
639 while (ge_result
== ACL_SUCCESS
) {
640 int d_result
= acl_delete_entry(acl
, entry
);
641 if (d_result
== ACL_ERROR
) {
642 perror("wipe_acls (acl_delete_entry)");
647 ge_result
= acl_get_entry(acl
, ACL_NEXT_ENTRY
, &entry
);
650 /* Catches the first acl_get_entry as well as the ones at the end of
652 if (ge_result
== ACL_ERROR
) {
653 perror("wipe_acls (acl_get_entry)");
658 int sf_result
= acl_set_file(path
, ACL_TYPE_ACCESS
, acl
);
659 if (sf_result
== ACL_ERROR
) {
660 perror("wipe_acls (acl_set_file)");
673 * @brief Apply parent default ACL to a path.
675 * This overwrites any existing ACLs on @c path.
678 * The path whose ACL we would like to reset to its default.
680 * @param no_exec_mask
681 * The value (either true or false) of the --no-exec-mask flag.
684 * - @c ACL_SUCCESS - The parent default ACL was inherited successfully.
685 * - @c ACL_FAILURE - The target path is not a regular file/directory,
686 * or the parent of @c path is not a directory.
687 * - @c ACL_ERROR - Unexpected library error.
689 int apply_default_acl(const char* path
, bool no_exec_mask
) {
696 /* Refuse to operate on hard links, which can be abused by an
697 * attacker to trick us into changing the ACL on a file we didn't
698 * intend to; namely the "target" of the hard link. To truly prevent
699 * that sort of mischief, we should be using file descriptors for
700 * the target and its parent directory. Then modulo a tiny race
701 * condition, we would be sure that "path" and "parent" don't change
702 * their nature between the time that we test them and when we
703 * utilize them. For contrast, the same attacker is free to replace
704 * "path" with a hard link after is_hardlink_safe() has returned
707 * Unfortunately, our API is lacking in this area. For example,
708 * acl_set_fd() is only capable of setting the ACL_TYPE_ACCESS list,
709 * and not the ACL_TYPE_DEFAULT. Apparently the only way to operate
710 * on default ACLs is through the path name, which is inherently
711 * unreliable since the acl_*_file() calls themselves might follow
712 * links (both hard and symbolic).
714 * Some improvement could still be made by using descriptors where
715 * possible -- this would shrink the exploit window -- but for now
716 * we use a naive implementation that only keeps honest men honest.
718 if (!is_hardlink_safe(path
)) {
722 if (!is_regular_file(path
) && !is_directory(path
)) {
726 /* dirname mangles its argument */
727 char path_copy
[PATH_MAX
];
728 strncpy(path_copy
, path
, PATH_MAX
-1);
729 path_copy
[PATH_MAX
-1] = 0;
731 char* parent
= dirname(path_copy
);
732 if (!is_directory(parent
)) {
733 /* Make sure dirname() did what we think it did. */
737 /* Default to not masking the exec bit; i.e. applying the default
738 ACL literally. If --no-exec-mask was not specified, then we try
739 to "guess" whether or not to mask the exec bit. */
740 bool allow_exec
= true;
743 int ace_result
= any_can_execute_or_dir(path
);
745 if (ace_result
== ACL_ERROR
) {
746 perror("apply_default_acl (any_can_execute_or_dir)");
750 allow_exec
= (bool)ace_result
;
753 acl_t defacl
= acl_get_file(parent
, ACL_TYPE_DEFAULT
);
755 if (defacl
== (acl_t
)NULL
) {
756 perror("apply_default_acl (acl_get_file)");
760 /* Our return value. */
761 int result
= ACL_SUCCESS
;
763 int wipe_result
= wipe_acls(path
);
764 if (wipe_result
== ACL_ERROR
) {
765 perror("apply_default_acl (wipe_acls)");
770 /* Do this after wipe_acls(), otherwise we'll overwrite the wiped
771 ACL with this one. */
772 acl_t acl
= acl_get_file(path
, ACL_TYPE_ACCESS
);
773 if (acl
== (acl_t
)NULL
) {
774 perror("apply_default_acl (acl_get_file)");
778 /* If it's a directory, inherit the parent's default. */
779 int inherit_result
= assign_default_acl(path
, defacl
);
780 if (inherit_result
== ACL_ERROR
) {
781 perror("apply_default_acl (inherit_acls)");
787 int ge_result
= acl_get_entry(defacl
, ACL_FIRST_ENTRY
, &entry
);
789 while (ge_result
== ACL_SUCCESS
) {
790 acl_tag_t tag
= ACL_UNDEFINED_TAG
;
791 int tag_result
= acl_get_tag_type(entry
, &tag
);
793 if (tag_result
== ACL_ERROR
) {
794 perror("apply_default_acl (acl_get_tag_type)");
800 /* We've got an entry/tag from the default ACL. Get its permset. */
801 acl_permset_t permset
;
802 int ps_result
= acl_get_permset(entry
, &permset
);
803 if (ps_result
== ACL_ERROR
) {
804 perror("apply_default_acl (acl_get_permset)");
809 /* If this is a default mask, fix it up. */
810 if (tag
== ACL_MASK
||
811 tag
== ACL_USER_OBJ
||
812 tag
== ACL_GROUP_OBJ
||
816 /* The mask doesn't affect acl_user_obj, acl_group_obj (in
817 minimal ACLs) or acl_other entries, so if execute should be
818 masked, we have to do it manually. */
819 int d_result
= acl_delete_perm(permset
, ACL_EXECUTE
);
820 if (d_result
== ACL_ERROR
) {
821 perror("apply_default_acl (acl_delete_perm)");
826 int sp_result
= acl_set_permset(entry
, permset
);
827 if (sp_result
== ACL_ERROR
) {
828 perror("apply_default_acl (acl_set_permset)");
835 /* Finally, add the permset to the access ACL. */
836 int set_result
= acl_set_entry(&acl
, entry
);
837 if (set_result
== ACL_ERROR
) {
838 perror("apply_default_acl (acl_set_entry)");
843 ge_result
= acl_get_entry(defacl
, ACL_NEXT_ENTRY
, &entry
);
846 /* Catches the first acl_get_entry as well as the ones at the end of
848 if (ge_result
== ACL_ERROR
) {
849 perror("apply_default_acl (acl_get_entry)");
854 int sf_result
= acl_set_file(path
, ACL_TYPE_ACCESS
, acl
);
855 if (sf_result
== ACL_ERROR
) {
856 perror("apply_default_acl (acl_set_file)");
869 * @brief Display program usage information.
871 * @param program_name
872 * The program name to use in the output.
875 void usage(const char* program_name
) {
876 printf("Apply any applicable default ACLs to the given files or "
878 printf("Usage: %s [flags] <target1> [<target2> [ <target3>...]]\n\n",
881 printf(" -h, --help Print this help message\n");
882 printf(" -r, --recursive Act on any given directories recursively\n");
883 printf(" -x, --no-exec-mask Apply execute permissions unconditionally\n");
890 * @brief Wrapper around @c apply_default_acl() for use with @c nftw().
892 * For parameter information, see the @c nftw man page.
894 * @return If the ACL was applied to @c target successfully, we return
895 * @c FTW_CONTINUE to signal to @ nftw() that we should proceed onto
896 * the next file or directory. Otherwise, we return @c FTW_STOP to
900 int apply_default_acl_nftw(const char *target
,
901 const struct stat
*s
,
905 bool app_result
= apply_default_acl(target
, false);
917 * @brief Wrapper around @c apply_default_acl() for use with @c nftw().
919 * This is identical to @c apply_default_acl_nftw(), except it passes
920 * @c true to @c apply_default_acl() as its no_exec_mask argument.
923 int apply_default_acl_nftw_x(const char *target
,
924 const struct stat
*s
,
928 bool app_result
= apply_default_acl(target
, true);
940 * @brief Recursive version of @c apply_default_acl().
942 * If @c target is a directory, we use @c nftw() to call @c
943 * apply_default_acl() recursively on all of its children. Otherwise,
944 * we just delegate to @c apply_default_acl().
946 * We ignore symlinks for consistency with chmod -r.
949 * The root (path) of the recursive application.
951 * @param no_exec_mask
952 * The value (either true or false) of the --no-exec-mask flag.
955 * If @c target is not a directory, we return the result of
956 * calling @c apply_default_acl() on @c target. Otherwise, we convert
957 * the return value of @c nftw(). If @c nftw() succeeds (returns 0),
958 * then we return @c true. Otherwise, we return @c false.
960 * If there is an error, it will be reported via @c perror, but
961 * we still return @c false.
963 bool apply_default_acl_recursive(const char *target
, bool no_exec_mask
) {
965 if (!is_directory(target
)) {
966 return apply_default_acl(target
, no_exec_mask
);
969 int max_levels
= 256;
970 int flags
= FTW_PHYS
; /* Don't follow links. */
972 /* There are two separate functions that could be passed to
973 nftw(). One passes no_exec_mask = true to apply_default_acl(),
974 and the other passes no_exec_mask = false. Since the function we
975 pass to nftw() cannot have parameters, we have to create separate
976 options and make the decision here. */
977 int (*fn
)(const char *, const struct stat
*, int, struct FTW
*) = NULL
;
978 fn
= no_exec_mask
? apply_default_acl_nftw_x
: apply_default_acl_nftw
;
980 int nftw_result
= nftw(target
, fn
, max_levels
, flags
);
982 if (nftw_result
== 0) {
987 /* nftw will return -1 on error, or if the supplied function
988 * (apply_default_acl_nftw) returns a non-zero result, nftw will
991 if (nftw_result
== -1) {
992 perror("apply_default_acl_recursive (nftw)");
1001 * @brief Call apply_default_acl (possibly recursively) on each
1002 * command-line argument.
1004 * @return Either @c EXIT_FAILURE or @c EXIT_SUCCESS. If everything
1005 * goes as expected, we return @c EXIT_SUCCESS. Otherwise, we return
1008 int main(int argc
, char* argv
[]) {
1012 return EXIT_FAILURE
;
1015 bool recursive
= false;
1016 bool no_exec_mask
= false;
1018 struct option long_options
[] = {
1019 /* These options set a flag. */
1020 {"help", no_argument
, NULL
, 'h'},
1021 {"recursive", no_argument
, NULL
, 'r'},
1022 {"no-exec-mask", no_argument
, NULL
, 'x'},
1028 while ((opt
= getopt_long(argc
, argv
, "hrx", long_options
, NULL
)) != -1) {
1032 return EXIT_SUCCESS
;
1037 no_exec_mask
= true;
1041 return EXIT_FAILURE
;
1045 int result
= EXIT_SUCCESS
;
1048 for (arg_index
= optind
; arg_index
< argc
; arg_index
++) {
1049 const char* target
= argv
[arg_index
];
1050 bool reapp_result
= false;
1052 /* Make sure we can access the given path before we go out of our
1053 * way to please it. Doing this check outside of
1054 * apply_default_acl() lets us spit out a better error message for
1057 if (!path_accessible(target
)) {
1058 fprintf(stderr
, "%s: %s: No such file or directory\n", argv
[0], target
);
1059 result
= EXIT_FAILURE
;
1064 reapp_result
= apply_default_acl_recursive(target
, no_exec_mask
);
1067 /* It's either a normal file, or we're not operating recursively. */
1068 reapp_result
= apply_default_acl(target
, no_exec_mask
);
1071 if (!reapp_result
) {
1072 result
= EXIT_FAILURE
;