chmod -h 000x against symlink has bizarre results on ZFS
Andriy Gapon
avg at FreeBSD.org
Tue Aug 28 14:26:11 UTC 2012
on 24/08/2012 04:15 Trent Nelson said the following:
> Hi folks,
>
> I recently set up a FreeBSD build slave for the Python project,
> and noticed some symlink tests were failing in a very strange way
> (http://bugs.python.org/issue15748).
>
> When chmod -h 000x is done against a file/link of length less than
> 24, the target seems to get padded out to 24 with 0s. If it's
> longer than 24, it'll get truncated. 'x' can be 7, 6, 5 or 4 and
> the behaviour is the same.
>
> Here's the output from the attached test_readlink.sh, also available
> at http://bugs.python.org/file26979/test_readlink.sh:
>
> % ./test_readlink.sh
>
> ****** TEST 1: link/target length less than 24 ******
> before chmod -h 0007:
> -rw-r----- /tmp/lt24
> lrwxr-x--- /tmp/lt24.lnk->/tmp/lt24
> python os.readlink(/tmp/lt24.lnk):
> '/tmp/lt24'
> after chmod -h 0007:
> -rw-r----- /tmp/lt24
> l------rwx /tmp/lt24.lnk->/tmp/lt24
> python os.readlink(/tmp/lt24.lnk):
> '/tmp/lt24\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> target is padded out with NULLs to 24
>
>
>
>
> ****** TEST 2: link/target length longer than 24 ******
> before chmod -h 0007:
> -rw-r----- /tmp/definitelywaylongerthantwentyfour
> lrwxr-x---
> /tmp/definitelywaylongerthantwentyfour.lnk->/tmp/definitelywaylongerthantwentyfour
> python os.readlink(/tmp/definitelywaylongerthantwentyfour.lnk):
> '/tmp/definitelywaylongerthantwentyfour'
> after chmod -h 0007:
> -rw-r----- /tmp/definitelywaylongerthantwentyfour
> l------rwx
> /tmp/definitelywaylongerthantwentyfour.lnk->/tmp/definitelywaylonger
> python os.readlink(/tmp/definitelywaylongerthantwentyfour.lnk):
> '/tmp/definitelywaylonger'
> ^^^^^^^^^^^^^^^^^^^^^^^^
> target gets truncated to 24
>
>
>
> ****** Other modes... ******
> after chmod -h 0006:
> l------rw-
> /tmp/definitelywaylongerthantwentyfour.lnk->/tmp/definitelywaylonger
> after chmod -h 0005:
> l------r-x
> /tmp/definitelywaylongerthantwentyfour.lnk->/tmp/definitelywaylonger
> after chmod -h 0004:
> l------r--
> /tmp/definitelywaylongerthantwentyfour.lnk->/tmp/definitelywaylonger
> after chmod -h 0000:
> l---------
> /tmp/definitelywaylongerthantwentyfour.lnk->/tmp/definitelywaylongerthantwentyfour
>
>
> This only happens on ZFS. I'm on v28, don't have any v15s lying
> around.
>
> I'm perplexed. Can others reproduce it?
>
I can reproduce this problem
I can also provide some additional bits of information using a modified version of
zdb:
$ ln -fs definitelywaylongerthantwentyfour definitelywaylongerthantwentyfour.lnk
$ stat -s definitelywaylongerthantwentyfour.lnk
st_dev=3895460379 st_ino=27165 st_mode=0120755 st_nlink=1 st_uid=0 st_gid=0
st_rdev=4294967295 st_size=33 st_atime=1346161009 st_mtime=1346161009
st_ctime=1346161009 st_birthtime=1346161009 st_blksize=131072 st_blocks=1 st_flags=0
$ zdb -ddddddd tank/tmp 27165
Dataset tank/tmp [ZPL], ID 69, cr_txg 31, 4.57G, 24910 objects, rootbp
DVA[0]=<0:5c5375e000:200> DVA[1]=<0:4c1a80ce00:200> [L0 DMU objset] fletcher4 lzjb
LE contiguous unique double size=800L/200P birth=70882769L/70882769P fill=24910
cksum=1c72e8f065:89bbdf9d575:1732432c541ff:2d672d98b0ff66
Object lvl iblk dblk dsize lsize %full type
27165 1 16K 512 0 512 0.00 ZFS plain file (K=inherit)
(Z=inherit)
209 bonus System attributes
dnode flags: USERUSED_ACCOUNTED
dnode maxblkid: 0
path /definitelywaylongerthantwentyfour.lnk
uid 0
gid 0
atime Tue Aug 28 16:36:49 2012
mtime Tue Aug 28 16:36:49 2012
ctime Tue Aug 28 16:36:49 2012
crtime Tue Aug 28 16:36:49 2012
gen 70882769
mode 120755
size 33
parent 3
links 1
pflags 40800000104
symlink definitelywaylongerthantwentyfour
symlink size 33
Indirect blocks:
$ chmod -h 0007 definitelywaylongerthantwentyfour.lnk
$ stat -s definitelywaylongerthantwentyfour.lnk
st_dev=3895460379 st_ino=27165 st_mode=0120007 st_nlink=1 st_uid=0 st_gid=0
st_rdev=4294967295 st_size=33 st_atime=1346161009 st_mtime=1346161009
st_ctime=1346161227 st_birthtime=1346161227 st_blksize=131072 st_blocks=1 st_flags=0
$ zdb -ddddddd tank/tmp 27165
Dataset tank/tmp [ZPL], ID 69, cr_txg 31, 4.57G, 24910 objects, rootbp
DVA[0]=<0:5c556b4400:200> DVA[1]=<0:4c1a989600:200> [L0 DMU objset] fletcher4 lzjb
LE contiguous unique double size=800L/200P birth=70882812L/70882812P fill=24910
cksum=170e778d58:737e87307d3:140a45f4106a6:283187f7da9de7
Object lvl iblk dblk dsize lsize %full type
27165 1 16K 512 0 512 0.00 ZFS plain file (K=inherit)
(Z=inherit)
216 bonus System attributes
dnode flags: USERUSED_ACCOUNTED
dnode maxblkid: 0
path /definitelywaylongerthantwentyfour.lnk
uid 0
gid 0
atime Tue Aug 28 16:36:49 2012
mtime Tue Aug 28 16:36:49 2012
ctime Tue Aug 28 16:40:27 2012
crtime Tue Aug 28 16:36:49 2012
gen 70882769
mode 120007
size 33
parent 3
links 1
pflags 40800000004
symlink definitelywaylongerthant
symlink size 24
Indirect blocks:
Note how the file/object size remains 33, but size of ZPL_SYMLINK attribute is
changed to 24.
--
Andriy Gapon
More information about the zfs-devel
mailing list