<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "http://bugs.gentoo.org/bugzilla.dtd">

<bugzilla version="2.22.7"
          urlbase="http://bugs.gentoo.org/"
          maintainer="bugzilla@gentoo.org"
>

    <bug>
          <bug_id>162664</bug_id>
          
          <creation_ts>2007-01-18 14:47 0000</creation_ts>
          <short_desc>sys-apps/acl-2.2.39-r1 broken on jfs with nfs use-flag</short_desc>
          <delta_ts>2007-09-20 06:17:09 0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>Gentoo Linux</product>
          <component>Core system</component>
          <version>unspecified</version>
          <rep_platform>All</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>green@msu.ru</reporter>
          <assigned_to>base-system@gentoo.org</assigned_to>
          <cc>bfields@fieldses.org</cc>
    
    <cc>charlie.page@gmail.com</cc>
    
    <cc>eva@gentoo.org</cc>
    
    <cc>Fred@Familie-Roehner.de</cc>
    
    <cc>heath@nozzala.net</cc>
    
    <cc>jakub@gentoo.org</cc>
    
    <cc>wschlich@gentoo.org</cc>

      

      
          <long_desc isprivate="0">
            <who>green@msu.ru</who>
            <bug_when>2007-01-18 14:47:14 0000</bug_when>
            <thetext>When sys-apps/acl-2.2.39-r1 is compiled with nfs use-flag, there is problems with acl&apos;s on jfs filesystem.
Bug tested on stable (x86) with 2.6.18-gentoo-r6 kernel and on unstable (~x86) with 2.6.19-gentoo-r4 kernel.
To reproduce this bug:
# dd if=/dev/zero of=img bs=1M count=16
# mkdir mnt
# mkfs.jfs img
# mount -o loop img mnt
# touch mnt/test
# setfacl -m u:&lt;user&gt;:rw mnt/test
(where &lt;user&gt; is some valid user)
The result will be:
&quot;setfacl: mnt/test: No data available&quot;

Here is strace cut of this call:
...
readlink(&quot;mnt/test&quot;, 0x804d3c0, 4095)   = -1 EINVAL (Invalid argument)
lstat64(&quot;mnt/test&quot;, {st_mode=S_IFREG|0664, st_size=0, ...}) = 0
getxattr(&quot;mnt/test&quot;, &quot;system.nfs4_acl&quot;, 0xbfaa8870, 132) = -1 ENODATA (No data available)
getxattr(&quot;mnt/test&quot;, &quot;system.posix_acl_access&quot;, 0xbfaa8870, 132) = -1 ENODATA (No data available)
stat64(&quot;mnt/test&quot;, {st_mode=S_IFREG|0664, st_size=0, ...}) = 0
getxattr(&quot;mnt/test&quot;, &quot;system.nfs4_acl&quot;, 0x0, 0) = -1 ENODATA (No data available)
setxattr(&quot;mnt/test&quot;, &quot;system.posix_acl_access&quot;, &quot;\x02\x00\x00\x00\x01\x00\x06\x00\xff\xff\xff\xff\x02\x00\x06\x00\xe8\x03\x00\x00\x04\x00\x06\x00\xff\xff\xff\xff\x10\x00\x06\x00\xff\xff\xff\xff \x00\x04\x00\xff\xff\xff\xff&quot;, 44, XATTR_REPLACE) = -1 ENODATA (No data available)
...

Here is ltrace cut of this call:
...
acl_copy_entry(0x8052cf4, 0x8052c80)             = 0
acl_set_tag_type(0x8052cf4, 16)                  = 0
acl_calc_mask(0xbfadc250)                        = 0
acl_check(0x8052c3c, 0xbfadc240)                 = 0
acl_cmp(0x8052bac, 0x8052c3c)                    = 1
acl_set_file(&quot;mnt/test&quot;, 32768, 0x8052c3c)       = -1
__errno_location()                               = 0xb7fd8690
strerror(61)                                     = &quot;No data available&quot;
...

If sys-apps/acl is compiled with USE=&quot;-nfs&quot; than this command is working properly.
Cut of strace:
...
readlink(&quot;mnt/test&quot;, 0x804d380, 4095)   = -1 EINVAL (Invalid argument)
lstat64(&quot;mnt/test&quot;, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
getxattr(&quot;mnt/test&quot;, &quot;system.posix_acl_access&quot;, 0xbfdd7690, 132) = -1 ENODATA (No data available)
stat64(&quot;mnt/test&quot;, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
setxattr(&quot;mnt/test&quot;, &quot;system.posix_acl_access&quot;, &quot;\x02\x00\x00\x00\x01\x00\x06\x00\xff\xff\xff\xff\x02\x00\x06\x00\x00\x00\x00\x00\x04\x00\x04\x00\xff\xff\xff\xff\x10\x00\x06\x00\xff\xff\xff\xff \x00\x04\x00\xff\xff\xff\xff&quot;, 44, 0) = 0
...

Cut of ltrace:
...
acl_get_entry(0x80518d4, 1, 0xbfd31ee8)          = 1
acl_get_tag_type(0x8051918, 0xbfd31ee4)          = 0
acl_create_entry(0xbfd31f90, 0xbfd31f20)         = 0
acl_copy_entry(0x805198c, 0x8051918)             = 0
acl_set_tag_type(0x805198c, 16)                  = 0
acl_calc_mask(0xbfd31f90)                        = 0
acl_check(0x80518d4, 0xbfd31f80)                 = 0
acl_cmp(0x8051844, 0x80518d4)                    = 1
acl_set_file(&quot;mnt/test&quot;, 32768, 0x80518d4)       = 0
acl_free(0x80518d4)                              = 0
acl_free(0x8051844)                              = 0
...

There is no such problem with reiserfs, at least. Do not tested other filesystems.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>tkrah@fachschaft.imn.htwk-leipzig.de</who>
            <bug_when>2007-01-19 12:47:53 0000</bug_when>
            <thetext>I got these problems too compiling acl with nfs flag on xfs FS.

Torsten</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>heath@nozzala.net</who>
            <bug_when>2007-03-21 22:10:25 0000</bug_when>
            <thetext>Created an attachment (id=114019)
acl_set_file: Don&apos;t use XATTR_REPLACE on non-NFS files

This must be applied after acl-2.2.29-CITI_NFS4_ALL-3.dif</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>heath@nozzala.net</who>
            <bug_when>2007-03-21 22:10:45 0000</bug_when>
            <thetext>I ran into this issue as well, but in cp -Rp.

The difference is in the USE=nfs build, the setxattr call has XATTR_REPLACE; where in the non-nfs build, it doesn&apos;t.  (The NFS patch adds the XATTR_REPLACE).

The breakage is because setxattr is supposed to fail (errno=ENOATTR) if XATTR_REPLACE is specified and the file doesn&apos;t have the attr to begin with; which means that acl_set_file() will never be able to add an acl to a file that lacks an acl to begin with.

I see two ways to fix this:

1) only use XATTR_REPLACE if the target file is NFS

2) test the return value of setxattr(..., XATTR_REPLACE). If -1 and errno == ENOATTR, do the setxattr() again without XATTR_REPLACE.

I prefer the first option, because the second adds the extra syscall.  Attached is the patch I used on my system, which has fixed the problem for me.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>jakub@gentoo.org</who>
            <bug_when>2007-05-04 20:03:54 0000</bug_when>
            <thetext>*** Bug 167290 has been marked as a duplicate of this bug. ***</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>jakub@gentoo.org</who>
            <bug_when>2007-05-04 20:04:28 0000</bug_when>
            <thetext>*** Bug 177083 has been marked as a duplicate of this bug. ***</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>Fred@Familie-Roehner.de</who>
            <bug_when>2007-05-05 13:50:26 0000</bug_when>
            <thetext>Upgrading to sys-libs/glibc-2.5-r2 failed on jfs:
- applied recommended patch for &quot;XATTR_REPLACE on non-NFS files&quot; on sys-apps/acl
- emerge upgrade of sys-libs/glibc completed without any error!

sys-apps/acl-2.2.39-r1  USE=&quot;nfs nls&quot;
sys-fs/jfsutils-1.1.8
x86: 2.6.20-gentoo-r7

Please add patch to acl ebuild!</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>bfields@fieldses.org</who>
            <bug_when>2007-05-09 20:03:16 0000</bug_when>
            <thetext>I&apos;m not sure how that XATTR_REPLACE crept in there in the first place--it looks like a mistake.  Just remove it and make that argument a zero unconditionally.  I&apos;ve pushed out an updated version with that fix to

  git://linux-nfs.org/~bfields/acl.git

Browsable version at

  http://www.linux-nfs.org/cgi-bin/gitweb.cgi?p=bfields-acl.git;a=summary

(PS: Is there a way I could be cc:&apos;d on any bugs related to the citi nfsv4 acl stuff?)</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>vapier@gentoo.org</who>
            <bug_when>2007-09-20 06:17:09 0000</bug_when>
            <thetext>acl-2.2.45 has latest NFS patch

J. Bruce Fields: there is no way to filter specifically on the nfs patch, but i can add you as a cc when a new one comes up ...</thetext>
          </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>114019</attachid>
            <date>2007-03-21 22:10 0000</date>
            <desc>acl_set_file: Don&apos;t use XATTR_REPLACE on non-NFS files</desc>
            <filename>acl-2.2.29-nfs-setxattr.patch</filename>
            <type>text/plain</type>
            <data encoding="base64">LS0tIGxpYmFjbC9hY2xfc2V0X2ZpbGUuYy5kaXN0CTIwMDctMDMtMjEgMTY6NTU6MjcuMjU2ODU3
OTkxIC0wNTAwCisrKyBsaWJhY2wvYWNsX3NldF9maWxlLmMJMjAwNy0wMy0yMSAxNjo1NTowNy42
MjM3MzkxNjMgLTA1MDAKQEAgLTUwLDYgKzUwLDcgQEAKIAlzdHJ1Y3QgbmZzNF9hY2wgKiBuYWNs
OwogCWludCBpc19kaXIgPSBORlM0X0FDTF9JU0ZJTEU7CiAjZW5kaWYKKwlpbnQgaXNfbmZzID0g
MDsKIAogCWlmICghYWNsX29ial9wKQogCQlyZXR1cm4gLTE7CkBAIC0xMTEsNiArMTEyLDcgQEAK
IAogCQlzaXplID0gYWNsX25mczRfeGF0dHJfcGFjayhuYWNsLCAmZXh0X2FjbF9wKTsKIAkJbmFt
ZSA9IEFDTF9ORlM0X1hBVFRSOworCQlpc19uZnMgPSAxOwogCQlhY2xfbmZzNF9mcmVlKG5hY2wp
OwogCX0KICNlbHNlCkBAIC0xMzMsNyArMTM1LDcgQEAKIAlpZiAoIWV4dF9hY2xfcCkKIAkJcmV0
dXJuIC0xOwogCi0JZXJyb3IgPSBzZXR4YXR0cihwYXRoX3AsIG5hbWUsIChjaGFyICopZXh0X2Fj
bF9wLCBzaXplLCBYQVRUUl9SRVBMQUNFKTsKKwllcnJvciA9IHNldHhhdHRyKHBhdGhfcCwgbmFt
ZSwgKGNoYXIgKilleHRfYWNsX3AsIHNpemUsIGlzX25mcyA/IFhBVFRSX1JFUExBQ0UgOiAwKTsK
IAlmcmVlKGV4dF9hY2xfcCk7CiAJcmV0dXJuIGVycm9yOwogfQo=
</data>        

          </attachment>
    </bug>

</bugzilla>