Skip to contentSkip to conversation

xfstests: filter selinux output in _acl_ls

PATCH Superseded Eric Sandeen 2 participants 5 messages Jan 28, 2010 – Feb 3, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfstests: filter selinux output in _acl_ls

When selinux is on, ls -l gives us a "." to indicate selinux attrs, which breaks some tests:

=== Test minimal ACE ===
Setup file
--rwxrw-r-- id1 id2 file1
+-rwxrw-r--. id1 id2 file1

so filter that out.

---

common.attr +4 -1
Index: xfstests/common.attr
===================================================================
@@ -58,7 +58,10 @@ _acl_filter_id()
 #
 _acl_ls()
 {
-    ls -ln $* | awk '{ print $1, $3, $4, $NF }' | _acl_filter_id
+    ls -ln $* |	\
+    sed "s/\(.*\)\. /\1 /" | \
+    awk '{ print $1, $3, $4, $NF }' | \
+    _acl_filter_id
 } 
 
 #

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#1 lore raw
Quoted 9 lines · Eric Sandeen

When selinux is on, ls -l gives us a "." to indicate selinux attrs, which breaks some tests:

=== Test minimal ACE ===
Setup file
--rwxrw-r-- id1 id2 file1
+-rwxrw-r--. id1 id2 file1

so filter that out.

Hmm NAK this one for now; there are more places that need this fixup, maybe an _ls_l() would be a good idea and put the filter in one spot.

-Eric

Quoted 20 lines

---

Index: xfstests/common.attr
===================================================================

common.attr +4 -1
@@ -58,7 +58,10 @@ _acl_filter_id()
 #
 _acl_ls()
 {
-    ls -ln $* | awk '{ print $1, $3, $4, $NF }' | _acl_filter_id
+    ls -ln $* |	\
+    sed "s/\(.*\)\. /\1 /" | \
+    awk '{ print $1, $3, $4, $NF }' | \
+    _acl_filter_id
 } 
 
 #
Quoted 5 lines

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#2 lore raw

PATCH v2 1/1 xfstests: filter selinux output in _acl_ls etc

In reply to Eric Sandeen

When selinux is on, ls -l gives us a "." to indicate selinux attrs, which breaks some tests:

=== Test minimal ACE ===
Setup file
--rwxrw-r-- id1 id2 file1
+-rwxrw-r--. id1 id2 file1

so make an _ls_l helper to filter that out.

---

105 +2 -2
index e3163fd..9544c66 100755
@@ -76,7 +76,7 @@ chown $acl1 subdir
 
 # put a file in the directory
 echo data > subdir/file
-ls -l subdir/file | awk '{ print $1, $3 }'
+_ls_l subdir/file | awk '{ print $1, $3 }'
 
 # add an ACL with a user ACE which has no exec permission 
 if [ "$HOSTOS" == "Linux" ]; then
@@ -91,7 +91,7 @@ fi
 # With the bug this gives: `ls: subdir/file: Permission denied'
 # because one needs at least an exec perm somewhere in acl
 # However, this should not hold true for directories.
-ls -l subdir/file | awk '{ print $1, $3 }'
+_ls_l subdir/file | awk '{ print $1, $3 }'
 
 # With the bug this gives: `subdir/file2: Permission denied'.
 echo data2 > subdir/file2
common.attr +1 -1
index a6b9b3b..d12cc02 100644
@@ -58,7 +58,7 @@ _acl_filter_id()
 #
 _acl_ls()
 {
-    ls -ln $* | awk '{ print $1, $3, $4, $NF }' | _acl_filter_id
+    _ls_l -n $* | awk '{ print $1, $3, $4, $NF }' | _acl_filter_id
 } 
 
 #
common.rc +8 -0
index cf2662a..237f3aa 100644
@@ -37,6 +37,14 @@ dd()
    fi
 }
 
+# ls -l w/ selinux sometimes puts a dot at the end:
+# -rwxrw-r--. id1 id2 file1
+
+_ls_l()
+{
+	ls -l $* | sed "s/\(.*\)\. /\1 /"
+}
+
 _mount_opts()
 {
     case $FSTYP in

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#3 lore raw

PATCH v3 1/1 xfstests: filter selinux output in _acl_ls etc

When selinux is on, ls -l gives us a "." to indicate selinux attrs, which breaks some tests:

=== Test minimal ACE ===
Setup file
--rwxrw-r-- id1 id2 file1
+-rwxrw-r--. id1 id2 file1

so make an _ls_l helper to filter that out.

---

V3: after talking to christoph, maybe a sed that looks just for the ls -l chars might be better.

105 +2 -2
index e3163fd..9544c66 100755
@@ -76,7 +76,7 @@ chown $acl1 subdir
 
 # put a file in the directory
 echo data > subdir/file
-ls -l subdir/file | awk '{ print $1, $3 }'
+_ls_l subdir/file | awk '{ print $1, $3 }'
 
 # add an ACL with a user ACE which has no exec permission 
 if [ "$HOSTOS" == "Linux" ]; then
@@ -91,7 +91,7 @@ fi
 # With the bug this gives: `ls: subdir/file: Permission denied'
 # because one needs at least an exec perm somewhere in acl
 # However, this should not hold true for directories.
-ls -l subdir/file | awk '{ print $1, $3 }'
+_ls_l subdir/file | awk '{ print $1, $3 }'
 
 # With the bug this gives: `subdir/file2: Permission denied'.
 echo data2 > subdir/file2
common.attr +1 -1
index a6b9b3b..d12cc02 100644
@@ -58,7 +58,7 @@ _acl_filter_id()
 #
 _acl_ls()
 {
-    ls -ln $* | awk '{ print $1, $3, $4, $NF }' | _acl_filter_id
+    _ls_l -n $* | awk '{ print $1, $3, $4, $NF }' | _acl_filter_id
 } 
 
 #
common.rc +8 -0
index 6424871..4425007 100644
@@ -37,6 +37,14 @@ dd()
    fi
 }
 
+# ls -l w/ selinux sometimes puts a dot at the end:
+# -rwxrw-r--. id1 id2 file1
+
+_ls_l()
+{
+	ls -l $* | sed "s/\(^[-rwxdlbcpsStT]*\)\. /\1 /"
+}
+
 _mount_opts()
 {
     case $FSTYP in

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

Reviewed-by on v3 1/1
#4 lore raw

Re: [PATCH V3] xfstests: filter selinux output in _acl_ls etc

Quoted 11 lines · Eric Sandeen

When selinux is on, ls -l gives us a "." to indicate selinux attrs, which breaks some tests:

=== Test minimal ACE ===
Setup file
--rwxrw-r-- id1 id2 file1
+-rwxrw-r--. id1 id2 file1

so make an _ls_l helper to filter that out.

Looks good,

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs