Subject: bug#55344: ftw thinks readable directories are unreadable if "other" don't have read permission

From: SeerLite <[email-masked]>
Date: Mon, 9 May 2022 20:25:17 -0400

ftw incorrectly thinks that if other users don't have the read 
permission then the owner can't read it either. This also affects ntfw.

Guile version: 3.0.8
Machine type: x86_64-pc-linux-gnu
[email-masked] from Guix

To reproduce: Create 2 directories, one with rwxrwxrwx permissions and 
another with rwxrwx---. Then pass them to ftw and notice it won't 
recurse because it thinks they're directory-not-readable.

scheme@(guile-user)> (passwd:uid (getpw (getlogin)))
$1 = 1001
scheme@(guile-user)> (stat:uid (stat "readable-dir"))
$2 = 1001
scheme@(guile-user)> (stat:uid (stat "also-readable-dir"))
$3 = 1001
scheme@(guile-user)> (format #f "~o" (stat:perms (stat "readable-dir")))
$4 = "777"
scheme@(guile-user)> (format #f "~o" (stat:perms (stat 
"also-readable-dir")))
$5 = "770"
scheme@(guile-user)> (stat "readable-dir")
$6 = #(24 61374845 16895 1 1001 998 0 0 1652140343 1652140343 1652141421 
4096 0 directory 511 216530924 216530924 1652141421)
scheme@(guile-user)> (stat "also-readable-dir")
$7 = #(24 61374847 16888 1 1001 998 0 0 1652140345 1652140345 1652141426 
4096 0 directory 504 20542871 20542871 1652141426)
scheme@(guile-user)> (ftw "readable-dir" (lambda (filename statinfo 
flag) (display flag) (newline) #t))
directory
$8 = #t
scheme@(guile-user)> (ftw "also-readable-dir" (lambda (filename statinfo 
flag) (display flag) (newline) #t))directory-not-readable
$9 = #t