Uploaded image for project: 'RHEL'
  1. RHEL
  2. RHEL-3909

setfacl exits with rc 0 while it should fail

    • Icon: Bug Bug
    • Resolution: Done-Errata
    • Icon: Normal Normal
    • rhel-8.10
    • rhel-7.9, rhel-8.8.0, rhel-9.2.0
    • acl
    • None
    • acl-2.2.53-3.el8
    • None
    • Low
    • sst_cs_plumbers
    • ssg_core_services
    • 7
    • 26
    • 5
    • False
    • Hide

      None

      Show
      None
    • None
    • Red Hat Enterprise Linux
    • None
    • Approved Blocker
    • All
    • None

      What were you trying to do that didn't work?

      When setting an ACL for multiple files and some files do not exit, an error message shows up but rc code is still 0, which it should be 1.

      This complicates automation and error handling.

      Please provide the package NVR for which bug is seen:

      All acl releases, including Upstream

      How reproducible:

      Always

      Steps to reproduce

      1. Set an ACL on a file that doesn't exist and a file that does exist on some command
      $ mkdir FOO
      $ setfacl -m d:g:rmetrich:rwX -m g:rmetrich:rwX ./FOO/bar ./FOO

      Expected results

      setfacl: ./FOO/bar: No such file or directory
      $ echo $?
      1 

      Actual results

      setfacl: ./FOO/bar: No such file or directory
      $ echo $?
      0  

      The following patch fixes the issue:

      diff -up acl-2.3.1/tools/setfacl.c.rhcase03610571 acl-2.3.1/tools/setfacl.c
      --- acl-2.3.1/tools/setfacl.c.rhcase03610571    2023-09-14 16:49:52.436561413 +0200
      +++ acl-2.3.1/tools/setfacl.c    2023-09-14 17:08:07.448939043 +0200
      @@ -555,7 +555,7 @@ int main(int argc, char *argv[])
                           goto synopsis;
                       saw_files = 1;
       
      -                status = next_file(optarg, seq);
      +                status |= next_file(optarg, seq);
                       break;
       
                   case 'B':  /* restore ACL backup */
      @@ -642,7 +642,7 @@ int main(int argc, char *argv[])
                   goto synopsis;
               saw_files = 1;
       
      -        status = next_file(argv[optind++], seq);
      +        status |= next_file(argv[optind++], seq);
           }
           if (!saw_files)
               goto synopsis; 

      In a nutshell, the status of the previous files being processed has to be final status, not the status of the last file only.

            rskvaril@redhat.com Radka Brychtova
            rhn-support-rmetrich Renaud Métrich
            Lukáš Zaoral Lukáš Zaoral
            Radka Brychtova Radka Brychtova
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: