F
F. Senault
Hi.
I have a windows share mounted on a FreeBSD box, and I see the
following :
| 12:39 fred@ardbeg:~/glenmorangie/misc/temp% uname -a
| FreeBSD ardbeg.lacave.local 8.1-STABLE FreeBSD 8.1-STABLE #1: Wed Oct 20 18:56:00 CEST 2010 (e-mail address removed):/usr/obj/usr/src/sys/ARDBEG amd64
| 12:39 fred@ardbeg:~/glenmorangie/misc/temp% mount
....
| //FRED@GLENMORANGIE/E$ on /data/glenmorangie/misc (smbfs)
| 12:39 fred@ardbeg:~/glenmorangie/misc/temp% touch test.txt
| 12:40 fred@ardbeg:~/glenmorangie/misc/temp% ls -la
| total 32
| drwxr-xr-x 1 fred wheel 16384 18 nov 12:40 .
| drwxr-xr-x 1 fred wheel 16384 1 jan 1970 ..
| -rwxr-xr-x 1 fred wheel 0 18 nov 12:40 test.txt
| 12:40 fred@ardbeg:~/glenmorangie/misc/temp% chmod a-w test.txt
| 12:40 fred@ardbeg:~/glenmorangie/misc/temp% ls -la
| total 32
| drwxr-xr-x 1 fred wheel 16384 18 nov 12:40 .
| drwxr-xr-x 1 fred wheel 16384 1 jan 1970 ..
| -r-xr-xr-x 1 fred wheel 0 18 nov 12:40 test.txt
| 12:40 fred@ardbeg:~/glenmorangie/misc/temp% echo "abc" > test.txt
| zsh: permission denied: test.txt
All set. (And Windows shows the file as read-only too, FWIW.)
| 12:40 fred@ardbeg:~/glenmorangie/misc/temp% ruby -v
| ruby 1.9.2p0 (2010-08-18 revision 29036) [amd64-freebsd8]
| 12:40 fred@ardbeg:~/glenmorangie/misc/temp% irb
| >> File.writable? "./test.txt"
| => true
Uh ?
| >> File.stat("./test.txt").writable?
| => false
Better.
| >> File.open("./test.txt", "w") {}
| Errno::EACCES: Permission denied - ./test.txt
| from (irb):3:in `initialize'
| from (irb):3:in `open'
| from (irb):3
| from /usr/local/bin/irb:12:in `<main>'
Ok.
And, from the Windows box itself :
| E:\temp>ruby -v
| ruby 1.9.1p429 (2010-07-02 revision 28523) [i386-mingw32]
| E:\temp>irb
| irb(main):001:0> File.writable?("./test.txt")
| => false
Good.
Is this to be expected ? Is it a bug from FreeBSD or from Ruby ?
TIA,
Fred
I have a windows share mounted on a FreeBSD box, and I see the
following :
| 12:39 fred@ardbeg:~/glenmorangie/misc/temp% uname -a
| FreeBSD ardbeg.lacave.local 8.1-STABLE FreeBSD 8.1-STABLE #1: Wed Oct 20 18:56:00 CEST 2010 (e-mail address removed):/usr/obj/usr/src/sys/ARDBEG amd64
| 12:39 fred@ardbeg:~/glenmorangie/misc/temp% mount
....
| //FRED@GLENMORANGIE/E$ on /data/glenmorangie/misc (smbfs)
| 12:39 fred@ardbeg:~/glenmorangie/misc/temp% touch test.txt
| 12:40 fred@ardbeg:~/glenmorangie/misc/temp% ls -la
| total 32
| drwxr-xr-x 1 fred wheel 16384 18 nov 12:40 .
| drwxr-xr-x 1 fred wheel 16384 1 jan 1970 ..
| -rwxr-xr-x 1 fred wheel 0 18 nov 12:40 test.txt
| 12:40 fred@ardbeg:~/glenmorangie/misc/temp% chmod a-w test.txt
| 12:40 fred@ardbeg:~/glenmorangie/misc/temp% ls -la
| total 32
| drwxr-xr-x 1 fred wheel 16384 18 nov 12:40 .
| drwxr-xr-x 1 fred wheel 16384 1 jan 1970 ..
| -r-xr-xr-x 1 fred wheel 0 18 nov 12:40 test.txt
| 12:40 fred@ardbeg:~/glenmorangie/misc/temp% echo "abc" > test.txt
| zsh: permission denied: test.txt
All set. (And Windows shows the file as read-only too, FWIW.)
| 12:40 fred@ardbeg:~/glenmorangie/misc/temp% ruby -v
| ruby 1.9.2p0 (2010-08-18 revision 29036) [amd64-freebsd8]
| 12:40 fred@ardbeg:~/glenmorangie/misc/temp% irb
| >> File.writable? "./test.txt"
| => true
Uh ?
| >> File.stat("./test.txt").writable?
| => false
Better.
| >> File.open("./test.txt", "w") {}
| Errno::EACCES: Permission denied - ./test.txt
| from (irb):3:in `initialize'
| from (irb):3:in `open'
| from (irb):3
| from /usr/local/bin/irb:12:in `<main>'
Ok.
And, from the Windows box itself :
| E:\temp>ruby -v
| ruby 1.9.1p429 (2010-07-02 revision 28523) [i386-mingw32]
| E:\temp>irb
| irb(main):001:0> File.writable?("./test.txt")
| => false
Good.
Is this to be expected ? Is it a bug from FreeBSD or from Ruby ?
TIA,
Fred