help-tar
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Avoiding “Permission denied” as non-admin


From: Felipe Gasper
Subject: Avoiding “Permission denied” as non-admin
Date: Mon, 6 Apr 2020 21:53:53 -0400

Hello,

        When I extract a tar archive over existing contents, I’m seeing:

/usr/bin/gtar: mail/dovecot-uidvalidity.5e8a8de1: Cannot open: Permission denied

        The file in question has 0444 permissions but is owned by the same user 
as the one running tar. I guess tar doesn’t chmod() the file in order to 
overwrite it?

        Anyway, I then tried adding “--unlink-first”, but that produced a bunch 
of warnings about unlink()ing nonempty directories. (bug?)

        I next tried “--recursive-unlink”, and this seems to fix my problem, 
though I wonder about the disk I/O hit if it’s a large hierarchy being 
overwritten.

        What if tar were instead to overwrite files instead by writing to a 
temporary file in the same directory, then rename()ing the newly-written file 
into place? Then directory hierarchies could stay as they are during 
extraction, and the 0444-perms-as-user problem would be avoided as well. (It 
would assume, of course, that the user has write permission on the directories.)

        Thank you for your time!

-Felipe Gasper


reply via email to

[Prev in Thread] Current Thread [Next in Thread]