]> gitweb.michael.orlitzky.com - apply-default-acl.git/blobdiff - src/apply-default-acl.c
Eliminate the apply_default_acl_ex() function.
[apply-default-acl.git] / src / apply-default-acl.c
index bebb27c9907cb43f4bfb43599b483b5c568c189d..d83e428756cadbe4d94d666bdee739e6a7c46a76 100644 (file)
@@ -74,9 +74,9 @@ void usage(const char* program_name) {
   }
 
   printf("Apply any applicable default ACLs to the given files or "
-        "directories.\n\n");
+         "directories.\n\n");
   printf("Usage: %s [flags] <target1> [<target2> [ <target3>...]]\n\n",
-        program_name);
+         program_name);
   printf("Flags:\n");
   printf(" -h, --help         Print this help message\n");
   printf(" -r, --recursive    Act on any given directories recursively\n");
@@ -98,9 +98,9 @@ void usage(const char* program_name) {
  *
  */
 int apply_default_acl_nftw(const char *target,
-                          const struct stat *sp,
-                          int info,
-                          struct FTW *ftw) {
+                           const struct stat *sp,
+                           int info,
+                           struct FTW *ftw) {
 
   if (target == NULL) {
     errno = EINVAL;
@@ -109,7 +109,10 @@ int apply_default_acl_nftw(const char *target,
   }
 
 
-  if (apply_default_acl_ex(target, sp, false) == ACL_ERROR) {
+  /* The apply_default_acl() function could make use of the stat
+     struct pointer sp, but for safety we choose to stat the result of
+     safe_open() ourselves. */
+  if (apply_default_acl(target, false) == ACL_ERROR) {
     /* I guess we do want to bail out for serious/unexpected errors? */
     return ACL_ERROR;
   }
@@ -128,9 +131,9 @@ int apply_default_acl_nftw(const char *target,
  *
  */
 int apply_default_acl_nftw_x(const char *target,
-                            const struct stat *sp,
-                            int info,
-                            struct FTW *ftw) {
+                             const struct stat *sp,
+                             int info,
+                             struct FTW *ftw) {
 
   if (target == NULL) {
     errno = EINVAL;
@@ -138,7 +141,10 @@ int apply_default_acl_nftw_x(const char *target,
     return ACL_ERROR;
   }
 
-  if (apply_default_acl_ex(target, sp, true) == ACL_ERROR) {
+  /* The apply_default_acl() function could make use of the stat
+     struct pointer sp, but for safety we choose to stat the result of
+     safe_open() ourselves. */
+  if (apply_default_acl(target, true) == ACL_ERROR) {
     /* I guess we do want to bail out for serious/unexpected errors? */
     return ACL_ERROR;
   }
@@ -257,7 +263,7 @@ int main(int argc, char* argv[]) {
      * typos, too.
      */
     if (!path_accessible(target)) {
-      fprintf(stderr, "%s: %s: No such file or directory\n", argv[0], target);
+      perror(target);
       result = EXIT_FAILURE;
       continue;
     }