bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

copy_acl on IRIX


From: Bruno Haible
Subject: copy_acl on IRIX
Date: Mon, 22 Oct 2007 00:30:28 +0200
User-agent: KMail/1.5.4

Hi Paul and Jim,

Since the ACL module is not advertised as unstable, I started to make use of
it in the copy-file module: The copy_file_preserving function calls copy_acl
in order to copy ACLs from the original to the destination file. And
copy_file_preserving, in turn, is used by "msgmerge --update", for creating
a backup file before it destructively modifies a PO file.

This leads to a test failure on IRIX:

  msgmerge: preserving permissions for `mm-p-2.po~': Invalid argument
  FAIL: msgmerge-properties-2

What's happening? The msgmerge-properties-2 test invokes

  ../src/msgmerge -q --properties-input --update mm-p-2.po mm-p-2.pot

and this tries to create a backup. It calls

  copy_file_preserving ("mm-p-2.po", "mm-p-2.po~");

This then calls copy_acl.

At this point the files look like this:

-rw-r--r--    1 haible   user          39 Oct 21 23:56 mm-p-2.po~
-rw-r--r--    1 haible   user          39 Oct 21 23:56 mm-p-2.po

More details:

$ man ls
...
     -M   Print the mandatory access control ( MAC ) label of each entry,
          enclosed in square brackets.  The -M option may be set automatically
          by setting the environment variable LABELFLAG to the (case
          insensitive) string "on", other values have no effect.  If MAC is
          not enabled, the square brackets will be empty.

     -D   Print the Access Control List ( ACL ) for the entry as an acl(4)
          string enclosed in square brackets.  If the ACL is empty or support
          for ACLs is not installed, the square brackets will be empty.

     -P   Print the capabilities for the entry as a capabilities(4) string
          enclosed in square brackets.

$ ls -lM mm-p-2.po*
-rw-r--r--    1 haible   user          39 Oct 21 23:56 mm-p-2.po []
-rw-r--r--    1 haible   user          39 Oct 21 23:56 mm-p-2.po~ []

$ ls -lD mm-p-2.po*
-rw-r--r--    1 haible   user          39 Oct 21 23:56 mm-p-2.po []
-rw-r--r--    1 haible   user          39 Oct 21 23:56 mm-p-2.po~ []

$ ls -lP mm-p-2.po*
-rw-r--r--    1 haible   user          39 Oct 21 23:56 mm-p-2.po []
-rw-r--r--    1 haible   user          39 Oct 21 23:56 mm-p-2.po~ []

This is on an XFS file system:

$ df -k .      
Filesystem             Type  kbytes     use     avail  %use Mounted on
/dev/root               xfs  1834010  1768884    65126  97  /

Inside copy_acl,
  - acl_get_fd (line 60) succeeds, returns a pointer to a struct like this:
    (gdb) print *acl
    $3 = {acl_cnt = -1, acl_entry = {{ae_tag = 0, ae_id = 0, 
          ae_perm = 0} <repeats 25 times>}}
  - acl_set_fd (line 75) returns -1 and sets errno to EINVAL,
  - ACL_NOT_WELL_SUPPORTED (errno) is true,
  - acl_entries (acl) (line 84) returns -1.
  - But since -1 is not 3, the code path falls through to the error()
    statement.

This proposed patch fixes it for me. One can put the "n < 0" test into the
function copy_acl. One could also create a function

   static bool acl_is_trivial (acl_t acl)

and define this function conditionally ('#ifdef __sgi' for the IRIX case).


2007-10-21  Bruno Haible  <address@hidden>

        * lib/acl.c (copy_acl): Consider an ACL with a negative number of
        entries as trivial. Needed on IRIX 6.5.

--- lib/acl.c.orig      2007-10-22 00:09:30.000000000 +0200
+++ lib/acl.c   2007-10-22 00:08:55.000000000 +0200
@@ -84,7 +84,11 @@
          int n = acl_entries (acl);
 
          acl_free (acl);
-         if (n == 3)
+         /* If the ACL is trivial, there is no point in complaining that
+            we cannot set it on DEST.
+            An ACL is trivial if it has only the user/group/other entries,
+            or (on IRIX 6.5) if acl_entries (acl) == -1.  */
+         if (n == 3 || n < 0)
            {
              if (chmod_or_fchmod (dst_name, dest_desc, mode) != 0)
                saved_errno = errno;





reply via email to

[Prev in Thread] Current Thread [Next in Thread]