[opensuse] why can I not rename/mv a file when copy+remove works ?
This is mind boggling, to me anyway - on a very stable system, quite backlevel, I have some procedures/Makefiles that are run daily. I'm pretty certain noone has changed anything there for months or even years. A week ago, the following started complaining about lack of permissions: create tempfile in /tmp fill up tempfile with stuff move tempfile to destination (same filesystem, matching uids) - permission denied. Using strace, I see that it is a call to rename() that fails. Then I tried this instead: create tempfile in /tmp fill up tempfile with stuff copy tempfile to destination (same filesystem) remove tempfile Works fine. Does that make any sense to anyone? -- Per Jessen, Zürich (13.8°C) http://www.hostsuisse.com/ - dedicated server rental in Switzerland. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On Thu, Nov 19, 2015 at 10:49:34AM +0100, Per Jessen wrote:
This is mind boggling, to me anyway - on a very stable system, quite backlevel, I have some procedures/Makefiles that are run daily. I'm pretty certain noone has changed anything there for months or even years. A week ago, the following started complaining about lack of permissions:
create tempfile in /tmp fill up tempfile with stuff move tempfile to destination (same filesystem, matching uids) - permission denied.
Using strace, I see that it is a call to rename() that fails. Then I tried this instead:
create tempfile in /tmp fill up tempfile with stuff copy tempfile to destination (same filesystem) remove tempfile
Works fine. Does that make any sense to anyone?
Is this really the same filesystem? Do the permissions of both /tmp and target directory look good? Ciao, Marcus -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On Thu, Nov 19, 2015 at 12:49 PM, Per Jessen
This is mind boggling, to me anyway - on a very stable system, quite backlevel, I have some procedures/Makefiles that are run daily. I'm pretty certain noone has changed anything there for months or even years. A week ago, the following started complaining about lack of permissions:
create tempfile in /tmp fill up tempfile with stuff move tempfile to destination (same filesystem, matching uids) - permission denied.
Using strace, I see that it is a call to rename() that fails. Then I tried this instead:
create tempfile in /tmp fill up tempfile with stuff copy tempfile to destination (same filesystem) remove tempfile
What are exact permissions and owners of /tmp (ls -ld /tmp) tempfile (ls -l /tmp/temfile) destination (ls -l /tmp/destination)? And yes, rename and copy require different permissions, so one may succeed when other fails. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
Andrei Borzenkov wrote:
On Thu, Nov 19, 2015 at 12:49 PM, Per Jessen
wrote: This is mind boggling, to me anyway - on a very stable system, quite backlevel, I have some procedures/Makefiles that are run daily. I'm pretty certain noone has changed anything there for months or even years. A week ago, the following started complaining about lack of permissions:
create tempfile in /tmp fill up tempfile with stuff move tempfile to destination (same filesystem, matching uids) - permission denied.
Using strace, I see that it is a call to rename() that fails. Then I tried this instead:
create tempfile in /tmp fill up tempfile with stuff copy tempfile to destination (same filesystem) remove tempfile
What are exact permissions and owners of
/tmp (ls -ld /tmp)
# ls -ld /tmp drwxrwxrwt 12 root root 19750912 2015-11-19 11:45 /tmp
tempfile (ls -l /tmp/temfile)
# ls -l /tmp/tempfile.lFucmE -rw------- 1 bulwark daemon 237891 2015-11-19 10:26 /tmp/tempfile.lFucmE
destination (ls -l /tmp/destination)?
# ls -l ./bulwark_recipient_map -rw-r--r-- 1 bulwark daemon 237891 2015-11-19 10:42 ./bulwark_recipient_map
And yes, rename and copy require different permissions, so one may succeed when other fails.
Yes, that is clearly the case, although functionally "mv" would seem to be exactly the same "cp src dst && rm src". Marcus Meissner wrote:
Is this really the same filesystem?
Yep, definitely. All on root.
Do the permissions of both /tmp and target directory look good?
See above. The Makefile is run from cron under userid "bulwark". -- Per Jessen, Zürich (15.1°C) http://www.hostsuisse.com/ - dedicated server rental in Switzerland. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On Thu, Nov 19, 2015 at 2:05 PM, Per Jessen
Andrei Borzenkov wrote:
On Thu, Nov 19, 2015 at 12:49 PM, Per Jessen
wrote: This is mind boggling, to me anyway - on a very stable system, quite backlevel, I have some procedures/Makefiles that are run daily. I'm pretty certain noone has changed anything there for months or even years. A week ago, the following started complaining about lack of permissions:
create tempfile in /tmp fill up tempfile with stuff move tempfile to destination (same filesystem, matching uids) - permission denied.
Using strace, I see that it is a call to rename() that fails. Then I tried this instead:
create tempfile in /tmp fill up tempfile with stuff copy tempfile to destination (same filesystem) remove tempfile
What are exact permissions and owners of
/tmp (ls -ld /tmp)
# ls -ld /tmp drwxrwxrwt 12 root root 19750912 2015-11-19 11:45 /tmp
tempfile (ls -l /tmp/temfile)
# ls -l /tmp/tempfile.lFucmE -rw------- 1 bulwark daemon 237891 2015-11-19 10:26 /tmp/tempfile.lFucmE
destination (ls -l /tmp/destination)?
# ls -l ./bulwark_recipient_map -rw-r--r-- 1 bulwark daemon 237891 2015-11-19 10:42 ./bulwark_recipient_map
You show relative name - it is intentional? Then please "pwd -P" as well :) I cannot easily reproduce it. Do you have anything in dmesg around this time? Can you reproduce it on command line (su bulwark -c "mv /tmp/tempfile.lFucmE /tmp/bulwark_recipient_map")? Assuming destination is indeed in /tmp :) -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
Andrei Borzenkov wrote:
On Thu, Nov 19, 2015 at 2:05 PM, Per Jessen
wrote: Andrei Borzenkov wrote:
On Thu, Nov 19, 2015 at 12:49 PM, Per Jessen
wrote: This is mind boggling, to me anyway - on a very stable system, quite backlevel, I have some procedures/Makefiles that are run daily. I'm pretty certain noone has changed anything there for months or even years. A week ago, the following started complaining about lack of permissions:
create tempfile in /tmp fill up tempfile with stuff move tempfile to destination (same filesystem, matching uids) - permission denied.
Using strace, I see that it is a call to rename() that fails. Then I tried this instead:
create tempfile in /tmp fill up tempfile with stuff copy tempfile to destination (same filesystem) remove tempfile
What are exact permissions and owners of
/tmp (ls -ld /tmp)
# ls -ld /tmp drwxrwxrwt 12 root root 19750912 2015-11-19 11:45 /tmp
tempfile (ls -l /tmp/temfile)
# ls -l /tmp/tempfile.lFucmE -rw------- 1 bulwark daemon 237891 2015-11-19 10:26 /tmp/tempfile.lFucmE
destination (ls -l /tmp/destination)?
# ls -l ./bulwark_recipient_map -rw-r--r-- 1 bulwark daemon 237891 2015-11-19 10:42 ./bulwark_recipient_map
You show relative name - it is intentional? Then please "pwd -P" as well :)
Sorry, that wasn't intentional: # ls -l $PWD/bulwark_recipient_map -rw-r--r-- 1 bulwark daemon 237891 2015-11-19 10:42 /var/lib/bulwark/postfix/bulwark_recipient_map # ls -ld /var/lib/bulwark/postfix drwxr-xr-x 3 root root 45056 2015-11-19 12:02 /var/lib/bulwark/postfix
I cannot easily reproduce it. Do you have anything in dmesg around this time?
Nope, nothing relevant in dmesg.
Can you reproduce it on command line (su bulwark -c "mv /tmp/tempfile.lFucmE /tmp/bulwark_recipient_map")? Assuming destination is indeed in /tmp :)
The destination is /var/lib/bulwark/postfix/bulwark_recipient_map Yes, I can reproduce on the command line : sudo -u bulwark mv /tmp/tempfile.lFucmE /var/lib/bulwark/postfix/bulwark_recipient_map # sudo -u bulwark mv /tmp/bulwark_recipient_map.P0H1A3 /var/lib/bulwark/postfix/bulwark_recipient_map mv: cannot move `/tmp/bulwark_recipient_map.P0H1A3' to `/var/lib/bulwark/postfix/bulwark_recipient_map': Permission denied I've put the strace here: http://files.jessen.ch/strace-move-file.txt -- Per Jessen, Zürich (15.0°C) http://www.hostsuisse.com/ - virtual servers, made in Switzerland. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
Per, et al --
...and then Per Jessen said...
%
% Andrei Borzenkov wrote:
%
% > On Thu, Nov 19, 2015 at 2:05 PM, Per Jessen
On Thu, Nov 19, 2015 at 3:44 PM, Per Jessen
The destination is
/var/lib/bulwark/postfix/bulwark_recipient_map
And you needed the whole day and over dozen mails to finally tell us that source and destination are in different directories? Now please re-read your original question - for all purposes it sounded like you attempted to rename files INSIDE OF /tmp. You get just as good answer as good your question is. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
Andrei Borzenkov wrote:
On Thu, Nov 19, 2015 at 3:44 PM, Per Jessen
wrote: The destination is
/var/lib/bulwark/postfix/bulwark_recipient_map
And you needed the whole day and over dozen mails to finally tell us that source and destination are in different directories? Now please re-read your original question - for all purposes it sounded like you attempted to rename files INSIDE OF /tmp.
You get just as good answer as good your question is.
Hah, you're right - I didn't actually specify it was from one directory to another. Sorry about leaving that very important bit out. -- Per Jessen, Zürich (15.7°C) http://www.dns24.ch/ - your free DNS host, made in Switzerland. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 11/19/2015 12:05 PM, Per Jessen wrote:
Andrei Borzenkov wrote:
What are exact permissions and owners of
/tmp (ls -ld /tmp)
# ls -ld /tmp drwxrwxrwt 12 root root 19750912 2015-11-19 11:45 /tmp
tempfile (ls -l /tmp/temfile)
# ls -l /tmp/tempfile.lFucmE -rw------- 1 bulwark daemon 237891 2015-11-19 10:26 /tmp/tempfile.lFucmE
destination (ls -l /tmp/destination)?
# ls -l ./bulwark_recipient_map -rw-r--r-- 1 bulwark daemon 237891 2015-11-19 10:42 ./bulwark_recipient_map
As the destination is an existing file, rename(2) would fail if the user doesn't have write access to the target directory: $ ls -ldog /tmp/src /tmp /tmp/d/dest /tmp/d drwxrwxrwt 9 300 Nov 19 12:54 /tmp dr-x------ 2 60 Nov 19 12:53 /tmp/d -rw-r--r-- 1 1638 Nov 19 12:52 /tmp/d/dest -rw-r--r-- 1 1638 Nov 19 12:53 /tmp/src $ mv /tmp/src /tmp/d/dest mv: cannot move ‘/tmp/src’ to ‘/tmp/d/dest’: Permission denied Have a nice day, Berny -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
Bernhard Voelker wrote:
On 11/19/2015 12:05 PM, Per Jessen wrote:
Andrei Borzenkov wrote:
What are exact permissions and owners of
/tmp (ls -ld /tmp)
# ls -ld /tmp drwxrwxrwt 12 root root 19750912 2015-11-19 11:45 /tmp
tempfile (ls -l /tmp/temfile)
# ls -l /tmp/tempfile.lFucmE -rw------- 1 bulwark daemon 237891 2015-11-19 10:26 /tmp/tempfile.lFucmE
destination (ls -l /tmp/destination)?
# ls -l ./bulwark_recipient_map -rw-r--r-- 1 bulwark daemon 237891 2015-11-19 10:42 ./bulwark_recipient_map
As the destination is an existing file, rename(2) would fail if the user doesn't have write access to the target directory:
I think you've hit the nail on the head, Berny - someone _did_ change a "cp" to a "mv" last week because the Makefile kept leaving those tempfiles in /tmp. Thanks! And yes, user "bulwark" does not have write access to that dir, only some of the files, all existing. /Per -- Per Jessen, Zürich (15.2°C) http://www.hostsuisse.com/ - virtual servers, made in Switzerland. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
Per, et al -- ...and then Per Jessen said... % % Bernhard Voelker wrote: % ... % > As the destination is an existing file, rename(2) would fail if the % > user doesn't have write access to the target directory: % % I think you've hit the nail on the head, Berny - someone _did_ change % a "cp" to a "mv" last week because the Makefile kept leaving those % tempfiles in /tmp. Thanks! [snip] Darn it -- I was just a tad too slow! :-) HAND :-D -- David T-G See http://justpickone.org/davidtg/email/ See http://justpickone.org/davidtg/tofu.txt -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
David T-G wrote:
Per, et al --
...and then Per Jessen said... % % Bernhard Voelker wrote: % ... % > As the destination is an existing file, rename(2) would fail if the % > user doesn't have write access to the target directory: % % I think you've hit the nail on the head, Berny - someone _did_ change % a "cp" to a "mv" last week because the Makefile kept leaving those % tempfiles in /tmp. Thanks! [snip]
Darn it -- I was just a tad too slow! :-)
Not to worry David, I'll come up with a new puzzle next week. For Andrei, I might even include all the clues too :-) Thanks all, as always it's great with a few extra pairs of eyes! -- Per Jessen, Zürich (15.5°C) http://www.dns24.ch/ - your free DNS host, made in Switzerland. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
Am Donnerstag, 19. November 2015 10:49 CET, Per Jessen
This is mind boggling, to me anyway - on a very stable system, quite
backlevel, I have some procedures/Makefiles that are run daily. I'm
pretty certain noone has changed anything there for months or even years. A week ago, the following started complaining about lack of permissions:
create tempfile in /tmp
How do you do this step *exactly*? There are tools to create temporary files which are locked and can't be renamed until they are unlocked. Regards, -- Aaron "Optimizer" Digulla a.k.a. Philmann Dark "It's not the universe that's limited, it's our imagination. Follow me and I'll show you something beyond the limits." http://blog.pdark.de/ -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
Aaron Digulla wrote:
Am Donnerstag, 19. November 2015 10:49 CET, Per Jessen
schrieb: This is mind boggling, to me anyway - on a very stable system, quite
backlevel, I have some procedures/Makefiles that are run daily. I'm
pretty certain noone has changed anything there for months or even years. A week ago, the following started complaining about lack of permissions:
create tempfile in /tmp
How do you do this step *exactly*?
In the Makefile: tmpfile:=$(shell mktemp /tmp/tempfile.XXXXXX) -- Per Jessen, Zürich (15.3°C) http://www.dns24.ch/ - free dynamic DNS, made in Switzerland. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
participants (6)
-
Aaron Digulla
-
Andrei Borzenkov
-
Bernhard Voelker
-
David T-G
-
Marcus Meissner
-
Per Jessen