Bug 972292

Summary: lgetxattrs can't show the file attribute list with ntfs FS in rhel7
Product: Red Hat Enterprise Linux 7 Reporter: bfan
Component: libguestfsAssignee: Richard W.M. Jones <rjones>
Status: CLOSED NOTABUG QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.0CC: leiwang, wshi
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-04-25 09:21:14 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description bfan 2013-06-08 07:52:46 UTC
Description of problem:
lgetxattrs can't show the file attribute list with ntfs FS though execute no error


Version-Release number of selected component (if applicable):
libguestfs-1.22.2-1.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
# guestfish -N fs:ntfs

Welcome to guestfish, the guest filesystem shell for
editing virtual machine filesystems and disk images.

Type: 'help' for help on commands
      'man' to read the manual
      'quit' to quit the shell

><fs> trace 1
><fs> mount-options user_xattr /dev/sda1 /
libguestfs: trace: mount_options "user_xattr" "/dev/sda1" "/"
libguestfs: trace: mount_options = 0
><fs> touch /test.txt
libguestfs: trace: touch "/test.txt"
libguestfs: trace: touch = 0
><fs> lsetxattr security.name "hello" 5 /test.txt
libguestfs: trace: lsetxattr "security.name" "hello" 5 "/test.txt"
libguestfs: trace: lsetxattr = 0
><fs> lsetxattr security.type "ascii file" 10 /test.txt
libguestfs: trace: lsetxattr "security.type" "ascii file" 10 "/test.txt"
libguestfs: trace: lsetxattr = 0
><fs> lgetxattrs /test.txt
libguestfs: trace: lgetxattrs "/test.txt"
libguestfs: trace: lgetxattrs = <struct guestfs_xattr_list *>
><fs>


Actual results:
lgetxattrs don't have output


Expected results:
lgetxattrs can show the attribute list
><fs> lgetxattrs /test.txt
[0] = {
  attrname: security.name
  attrval: hello
}
[1] = {
  attrname: security.type
  attrval: ascii file
}


Additional info:
1. lgetxattrs work with ext FS
2. has same issue with libguestfs-1.20.8-4.el6.x86_64 in rhel6

Comment 1 Richard W.M. Jones 2013-06-10 15:24:57 UTC
I'm pretty sure I've seen the same bug in ntfs-3g itself.
The problem was that ntfs-3g wouldn't return all the xattrs
when you use listxattr(2).

Comment 2 Richard W.M. Jones 2013-07-18 22:09:45 UTC
Should we expect that security.* xattrs can be set arbitrarily?
The security.* namespace is reserved by kernel security modules.
From attr(5):

   Extended security attributes
       The  security  attribute  namespace is used by kernel security modules,
       such as Security Enhanced Linux.  Read and write access permissions  to
       security  attributes depend on the policy implemented for each security
       attribute by the security module.  When no security module  is  loaded,
       all  processes  have  read  access to extended security attributes, and
       write access is limited to processes that have the CAP_SYS_ADMIN  capa‐
       bility.

So the fact this worked for ext4 is just luck.

If you use the user.* namespace instead, then everything works
fine even on NTFS:

$ guestfish -N fs:ntfs -m /dev/sda1:/:user_xattr <<EOF
touch /test.txt
lsetxattr user.name "hello" 5 /test.txt
lsetxattr user.type "ascii file" 10 /test.txt
lgetxattr /test.txt user.name
echo
lgetxattrs /test.txt
EOF
hello
[0] = {
  attrname: user.name
  attrval: hello
}
[1] = {
  attrname: user.type
  attrval: ascii file
}

So I would say this is not a bug.

Comment 4 Richard W.M. Jones 2014-04-25 09:21:14 UTC
I looked at the description again, and it's not expected that
you should be able to set arbitrary security.* xattrs.  That
namespace is reserved for the kernel.  Try setting user.* xattrs
instead -- those should work.