| Ticket UUID: | 731062 | ||
| Title: | file copy reports "not owner" although rights suffice | ||
| Type: | Bug | Created on: | 2003-05-01 23:06:55 |
| Submitter: | nobody | Assigned to: | jan.nijtmans |
| Subsystem: | 37. File System | Severity: | Minor |
| Priority: | 5 Medium | Last modified: | 2026-11-11 14:34:40 |
| Status: | Closed | Closed by: | jan.nijtmans |
| Resolution: | Duplicate | Closed on: | 2026-11-11 14:34:40 |
| Version: | obsolete: 8.4.4 | ||
| Description: | ||||
I cannot copy a file to a directory I do not own, although I am a member of a group having the necessary rights to do so. Even using the option "-force" of "file copy" does not help. The error reportes is "not owner", which corresponds to EPERM. Copying from the command line using cp works fine. I use Tcl/Tk 8.4.1 on Linux (version 8.3.3 behaves same way) Maybe this report belongs in the category "file system", but since it shows when using the command "file", I put it here. [email protected] | ||||
| User Comments: | ||||
vincentdarley added on 2003-05-02 15:23:08:
Logged In: YES user_id=32170 I'm afraid I'm not really in a position to debug this. A few notes though: "-force" won't help --- that's to do with files already existing If you are able to do some debugging, the function you should look at is DoCopyFile in tclUnixFCmd.c. Maybe you could give a bit more info about the actual permissions of the file and directory in question. nobody added on 2003-10-24 23:27:06:
Logged In: NO
I am user hj, primary group membership in group 100, users.
Proof:
hj > who am i
hj pts/0 Oct 24 17:54
hj > grep hj /etc/passwd
hj:x:500:100:Holger:/home/hj:/bin/bash
hj > grep 100 /etc/group
users:x:100:
The current directory is open open for writing for members
of group users.
Proof:
hj > ll -d .
drwxrwx--- 44 nobody users 12288 Okt 24 18:22 .
Now, let's copy a file to the current directory. Works fine.
hj > cp /tmp/x .
hj > ll x
-rwxrwx--- 1 nobody users 4344 Okt 24 18:22 x
Yes, the file is there!
Remove the file and try the same with Tcl.
hj > rm x
hj > tclsh
% file copy /tmp/x .
error copying "/tmp/x" to "./x": not owner
%
Oops, Tcl doesn't allow this, although the rights suffice.
dgp added on 2003-11-13 05:23:30:
Logged In: YES user_id=80530 pass on to someone else if not sutiable for you, but don't leave it assigned to "nobody" holgerjakobs added on 2003-11-16 21:40:45:
Logged In: YES user_id=110058 The directory where no file could be copied to happens to be an FAT drive mounted under Linux. /dev/hda8 on /d type vfat (rw,nosuid,nodev,umask=007,uid=65534,gid=100) It only gives trouble with Tcl, not with normal Unix-cp. Does this give a hint for the programmers how to get rid of this error? vincentdarley asked: >Maybe you could give a bit more info about the actual >permissions of the file and directory in question. Actually, my description written 2003-10-24 18:27 includes all information I could think of. If you believe there is anything missing I would like to know what you are looking for. Holger holgerjakobs added on 2003-11-16 21:43:58:
Logged In: YES user_id=110058 The directory where no file could be copied to happens to be an FAT drive mounted under Linux. /dev/hda8 on /d type vfat (rw,nosuid,nodev,umask=007,uid=65534,gid=100) It only gives trouble with Tcl, not with normal Unix-cp. Does this give a hint for the programmers how to get rid of this error? vincentdarley asked: >Maybe you could give a bit more info about the actual >permissions of the file and directory in question. Actually, my description written 2003-10-24 18:27 includes all information I could think of. If you believe there is anything missing I would like to know what you are looking for. Holger ctasada added on 2010-06-01 17:33:56:
Hi guys, I just got the same error using Tcl/Tk 8.5.4 and Ubuntu 10.04 As already said in the case the replication steps are: have a destination path with writing permissions (in fact I have 777) but owned by a different user (in my case root) Do: file copy $from_file $to_file Results: error: "not owner" Workaround: Right now I'm doing an "exec cp" but then I need to have specific code for every OS :( Cheers. ferrieux added on 2010-06-01 18:32:19:
Cannot repro in Fedora 12, with any of the three branches 8.[456] HEAD. Is upgrading to 8.5.8 an option for you ? ctasada added on 2010-06-01 19:30:55:
I have just tested with 8.5.8 from ActiveState and I've the same problem carlos@carlos-desktop:~/ActiveTcl-8.5/bin$ ./base-tcl8.5-thread-linux-ix86 % file copy /home/carlos/bookmarks.xml /media/borat/Users/carlos/BackUps/bookmarks.xml error copying "/home/carlos/bookmarks.xml" to "/media/borat/Users/carlos/BackUps/bookmarks.xml": not owner % puts $tcl_version 8.5 % puts $tcl_patchLevel 8.5.8 % file owned /media/borat/Users/carlos/BackUps 0 % file writable /media/borat/Users/carlos/BackUps 1 The /media/borat is mounted from a Windows computer with the next fstab line: //borat/fileserver/media/boratcifsnounix,rw,file_mode=0777,dir_mode=0777,username=Administrator,password=********00 Is there any other info that can help fixing this problem? Thanks. ferrieux added on 2010-06-01 19:48:18:
Ah, a Windows share.... It would have been cool to mention that earlier. flatworm added on 2010-06-01 19:57:14:
ctasada, note that "writable" on a directory in Unix means that you have rights to manipulate directory contents which is a list of its entries, that is, you can delete and create files and directories; this does not mean you can, say, truncate an existing file and replace its contents with another data as this means modifying the file's data and this is controlled by the access rights set for that specific file. In other words, it would be cool if you posted the output of `id` command run as the user executing the script being discussed as well as the output of `stat /media/borat/Users/carlos/BackUps/` and `stat /media/borat/Users/carlos/BackUps/bookmarks.xml`. ctasada added on 2010-06-01 20:32:18:
Hi Konstantin, The requested results are: carlos@carlos-desktop:~$ stat /media/borat/Users/carlos/BackUps/ File: `/media/borat/Users/carlos/BackUps/' Size: 0 Blocks: 0 IO Block: 16384 directory Device: 15h/21dInode: 1970324837205476 Links: 1 Access: (0777/drwxrwxrwx) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2010-06-01 14:26:58.124250000 +0200 Modify: 2010-06-01 14:26:58.124250000 +0200 Change: 2010-06-01 14:26:58.124250000 +0200 carlos@carlos-desktop:~$ stat /media/borat/Users/carlos/BackUps/bookmarks.xml stat: cannot stat `/media/borat/Users/carlos/BackUps/bookmarks.xml': No such file or directory So as you can see there's no file with this name in the destination path. If I'm understanding you properly, that means that should work, right? holgerjakobs added on 2010-06-01 22:37:10:
Hi, its me, the original creator of this bug report. I cannot confirm this error any more, because I don't have Tcl 8.4.4 at hand. This bug may be closed, it was solved by the passing of time. Regards Holger Jakobs flatworm added on 2010-06-02 05:05:48:
Carlos, from the point of view of Unix permissions, all is OK. But you know that mount.cifs is actually lying to you about these permissions as the Windows part has no idea about them. So let's try to change file copy $from_file $to_file in your script to exec cp $from_file $to_file and see it it errors out. If it doesn't, we really have a bug. flatworm added on 2010-06-02 05:28:42:
And to not make you think I'm trolling you with my questions, Carlos, I should say that I'm using CIFS from one of my scripts. That machine has Tcl 8.5.3 (Debian Lenny). All works OK with the only difference that my script uses [open $filename w] instead of [file copy]. Of course, [file copy] might have a different execution path when creating the target file, so [open] works in this case but [file copy] is not. So we should check this. The relevant bit of my script (for reference) is at http://pastebin.com/46Vzxbaw ferrieux added on 2010-06-02 14:26:42:
Konstantin, he already said he was doing [exec cp] as a workaround... Carlos, can you do an 'strace -f' of the tclsh for both the [file copy] and [exec cp] cases ? I'd like to see the difference in syscalls between the working and nonworking cases. ctasada added on 2010-06-03 18:37:23:
Ummm, I've the requested result from "strace -f", but I don't see how to attach files :( What's the best option to attach those results here? simply copy & paste? Thanks. ferrieux added on 2010-06-03 19:38:19:
Yes, I wish SF allowed logged-in, non-submitter users to attach files too :} In the meantime, please send it to ferrieux at users dot sourceforge dot net. ferrieux added on 2010-06-03 20:51:30:
Thanks Carlos for the files. Bug spotted :)
What happens is that Tcl's [file copy] does the copy, which succeeds, then tries (twice!!) to alter the permission bits of the just created file with chmod(), which fails in this case:
[pid 29862] open("/home/carlos/bookmarks.xml", O_RDONLY|O_LARGEFILE) = 5
[pid 29862] open("/media/borat/Users/carlos/BackUps/bookmarks.xml", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0100644) = 6
[pid 29862] read(5, "<?xml version=\"1.0\" encoding=\"UT"..., 4096) = 3528
[pid 29862] write(6, "<?xml version=\"1.0\" encoding=\"UT"..., 3528) = 3528
[pid 29862] read(5, "", 4096) = 0
[pid 29862] close(5) = 0
[pid 29862] close(6) = 0
[pid 29862] chmod("/media/borat/Users/carlos/BackUps/bookmarks.xml", 0644) = -1 EPERM (Operation not permitted)
[pid 29862] chmod("/media/borat/Users/carlos/BackUps/bookmarks.xml", 0644) = -1 EPERM (Operation not permitted)
[pid 29862] unlink("/media/borat/Users/carlos/BackUps/bookmarks.xml") = 0
[pid 29862] write(2, "error copying \"/home/carlos/book"..., 106error copying "/home/carlos/bookmarks.xml" to "/media/borat/Users/c
In contrast, /bin/cp trusts the perm bits passed to the initial open(), and does not try that strange chmod(), so it succeeds:
open("/home/carlos/bookmarks.xml", O_RDONLY|O_LARGEFILE) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=3528, ...}) = 0
open("/media/borat/Users/carlos/BackUps/bookmarks.xml", O_WRONLY|O_CREAT|O_EXCL|O_LARGEFILE, 0644) = 4
fstat64(4, {st_mode=S_IFREG|0777, st_size=0, ...}) = 0
read(3, "<?xml version=\"1.0\" encoding=\"UT"..., 32768) = 3528
write(4, "<?xml version=\"1.0\" encoding=\"UT"..., 3528) = 3528
read(3, "", 32768) = 0
close(4) = 0
close(3) = 0
Jeff, any idea why we're insisting on chmod here ?
serhiy.storchaka added on 2026-10-20 21:33:41:
Still present in 8.6, 9.0 and 9.1, as ferrieux's strace showed: the data is copied, but chmod() or utime() of the new file fails with EPERM when the filesystem has a fixed owner (vfat mounted with uid=, CIFS), and then the copy is removed. Proposed fix in branch copy-eperm-attrs, together with [1523045fff]: ignore EPERM there and keep the copy, as cp does. jan.nijtmans added on 2026-11-11 14:34:40:
So, mark this as duplicate to [1523045] Thanks for the analysis and fix! | ||||
