selftest: test listing directories inside snapshots
authorUri Simchoni <uri@samba.org>
Tue, 23 Aug 2016 11:29:39 +0000 (14:29 +0300)
committerJeremy Allison <jra@samba.org>
Wed, 24 Aug 2016 23:38:28 +0000 (01:38 +0200)
Verify that directories are also listable.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=12172

Signed-off-by: Uri Simchoni <uri@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
selftest/knownfail
source3/script/tests/test_shadow_copy.sh

index 97538f498e7fcd5cddd854fa7084aeb6c5dafd3d..a2b93b441f9a612bac498c8166f9f12e35332346 100644 (file)
 ^samba4.smb2.read.access
 #ntvfs server blocks copychunk with execute access on read handle
 ^samba4.smb2.ioctl.copy_chunk_bad_access
+#new snapshot dir listing test fails on SMB1
+^samba3.blackbox.shadow_copy2 NT1(?!.*wide links).*- list directory
index 2b72f06b14613c3566b194546796d7b354523a37..783e7f324a6c504ed29013f5bf8b16036c579c4f 100755 (executable)
@@ -144,6 +144,7 @@ test_count_versions()
     local tstamps
     local tstamp
     local content
+    local is_dir
 
     share=$1
     path=$2
@@ -155,13 +156,28 @@ test_count_versions()
         return 1
     fi
 
+    is_dir=0
+    $SMBCLIENT -U$USERNAME%$PASSWORD "//$SERVER/$share" -I $SERVER_IP -c "allinfo $path" | grep "^attributes:.*D" && is_dir=1
+    if [ $is_dir = 1 ] ; then
+        skip_content=1
+    fi
+
     #readable snapshots
     tstamps=`$SMBCLIENT -U$USERNAME%$PASSWORD "//$SERVER/$share" -I $SERVER_IP -c "allinfo $path" | awk '/^@GMT-/ {snapshot=$1} /^create_time:/ {printf "%s\n", snapshot}'`
     for tstamp in $tstamps ; do
-        if ! $SMBCLIENT -U$USERNAME%$PASSWORD "//$SERVER/$share" -I $SERVER_IP -c "get $tstamp\\$path $WORKDIR/foo" ; then
-            echo "Failed getting \\\\$SERVER\\$share\\$tstamp\\$path"
-            return 1
+        if [ $is_dir = 0 ] ;
+        then
+            if ! $SMBCLIENT -U$USERNAME%$PASSWORD "//$SERVER/$share" -I $SERVER_IP -c "get $tstamp\\$path $WORKDIR/foo" ; then
+                echo "Failed getting \\\\$SERVER\\$share\\$tstamp\\$path"
+                return 1
+            fi
+        else
+            if ! $SMBCLIENT -U$USERNAME%$PASSWORD "//$SERVER/$share" -I $SERVER_IP -c "ls $tstamp\\$path\\*" ; then
+                echo "Failed listing \\\\$SERVER\\$share\\$tstamp\\$path"
+                return 1
+            fi
         fi
+
         #also check the content, but not for wide links
         if [ "x$skip_content" != "x1" ] ; then
             content=`cat $WORKDIR/foo`
@@ -176,9 +192,17 @@ test_count_versions()
     tstamps=`$SMBCLIENT -U$USERNAME%$PASSWORD "//$SERVER/$share" -I $SERVER_IP -c "allinfo $path" | \
         awk '/^@GMT-/ {if (snapshot!=""){printf "%s\n", snapshot} ; snapshot=$1} /^create_time:/ {snapshot=""} END {if (snapshot!=""){printf "%s\n", snapshot}}'`
     for tstamp in $tstamps ; do
-        if $SMBCLIENT -U$USERNAME%$PASSWORD "//$SERVER/$share" -I $SERVER_IP -c "get $tstamp\\$path $WORKDIR/foo" ; then
-            echo "Unexpected success getting \\\\$SERVER\\$share\\$tstamp\\$path"
-            return 1
+        if [ $is_dir = 0 ] ;
+        then
+            if $SMBCLIENT -U$USERNAME%$PASSWORD "//$SERVER/$share" -I $SERVER_IP -c "get $tstamp\\$path $WORKDIR/foo" ; then
+                echo "Unexpected success getting \\\\$SERVER\\$share\\$tstamp\\$path"
+                return 1
+            fi
+        else
+            if $SMBCLIENT -U$USERNAME%$PASSWORD "//$SERVER/$share" -I $SERVER_IP -c "ls $tstamp\\$path\\*" ; then
+                echo "Unexpected success listing \\\\$SERVER\\$share\\$tstamp\\$path"
+                return 1
+            fi
         fi
     done
 }
@@ -242,6 +266,10 @@ test_shadow_copy_fixed()
     testit "$msg - rel symlink outside" \
         test_count_versions $share bar/loutside $ncopies_blocked 1 || \
         failed=`expr $failed + 1`
+
+    testit "$msg - list directory" \
+        test_count_versions $share bar $ncopies_allowed || \
+        failed=`expr $failed + 1`
 }
 
 test_shadow_copy_everywhere()