> That does not sound so odd to me. cp likely has different code paths to > open > an existing file for writing vs a new file. > > If the directory is 755, or some other mode, did this not happen?
When I copy a file (NetBSD) with 644 perms and owner 1000:0 into a dir (Linux) with 700 perms and owner 1000:1000 I get: $ ls -al total 36028797018963967 drwx------ 2 carsten carsten 60 Aug 7 17:38 ./ drwxrwxrwt 8 root wheel 180 Aug 7 17:36 ../ -rw-r--r-- 1 4294967295 4294967295 6 Aug 7 17:43 a This scares me... (the number after "total" and the senseless owner ids) When I now change the local file to 400 I get: $ cp /tmp/a . cp: ./a: Operation not permitted But the file is created *empty* (dir had been empty): $ ls -la total 0 drwx------ 2 carsten carsten 60 Aug 7 17:43 ./ drwxrwxrwt 8 root wheel 180 Aug 7 17:36 ../ -r-------- 1 carsten carsten 0 Aug 7 17:44 a If the dir has 755 it is the same. The problem is the 400 of the source file. If the source file is 600 it works. After some tests also the owner ids are ok. Not very reliable...
