Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Thu, 2 Apr 2015 22:15:16 -0400
From: Rich Felker <dalias@...c.org>
To: musl@...ts.openwall.com
Subject: Re: bug? in  musl libc failed to preserve ownership for

On Thu, Apr 02, 2015 at 09:18:49PM -0400, Jean-Marc Pigeon wrote:
> Hello.
> 
> Using cp (from native musl coreutils compilation, not busybox) I am
> getting a strange result when doing a copy
> (using musls-1.1.8)
> 
> test (user:group, no privilege 301:300, doing this as root is no problem):
> ;-------------------------------------------------------------
> mkdir d1
> cd d1
> touch p1
> ln -s p1 lp1
> cd ..
> cp -a d1 d2
> cp: failed to preserve ownership for d2/lp1: Not supported
> ;--------------------------------------------------------------
> Note: same cp from coreutils glibc working fine.
> 
> strace extract
> 
> getdents64(3, /* 4 entries */, 2048)    = 96
> getdents64(3, /* 0 entries */, 2048)    = 0
> close(3)                                = 0
> lstat("d1/lp1", {st_mode=S_IFLNK|0777, st_size=2, ...}) = 0
> readlink("d1/lp1", "p1", 3)             = 2
> symlink("p1", "d2/lp1")                 = 0
> lstat("d2/lp1", {st_mode=S_IFLNK|0777, st_size=2, ...}) = 0
> lchown("d2/lp1", 301, 300)              = 0
> newfstatat(AT_FDCWD, "d2/lp1", {st_mode=S_IFLNK|0777, st_size=2, ...},
> AT_SYMLINK_NOFOLLOW) = 0
> fcntl(1, F_GETFL)                       = 0x8002 (flags O_RDWR|O_LARGEFILE)
> writev(2, [{"cp: ", 4}, {NULL, 0}], 2cp: )  = 4
> writev(2, [{"", 0}, {"failed to preserve ownership for"..., 39}],
> 2failed to preserve ownership for d2/lp1) = 39
> writev(2, [{": Not supported", 15}, {NULL, 0}], 2: Not supported) = 15
> writev(2, [{"", 0}, {"\n", 1}], 2
> )      = 1
> lstat("d1/p1", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
> open("d1/p1", O_RDONLY|O_NOFOLLOW)      = 3
> ;----------------------------------------------------------------------
> 
> My understanding/feeling, could be within fcntl not
> reading symlink file status properly. possible?

fcntl is unrelated; it's not acting on the symlink.

I've tried to make sense of the above strace but I don't see anything
in the source that would be causing the newfstatat syscall. The only
code paths I can find in the source that print that message just check
for failure of lchown, and lchown is not failing. I checked current
git master and 8.19 which I had lying around. What specific version
are you using?

Rich

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.