diff options
author | Zac Medico <zmedico@gentoo.org> | 2011-12-14 01:11:07 -0800 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2011-12-14 01:11:07 -0800 |
commit | 2dbb9bb3bdb826a7da41ba1ccd89f4f8c8ee529c (patch) | |
tree | 9e07925c0a9c2113b5e56b6736919da6bdadefdb | |
parent | 29315ffe4d5c0d4030252ed25ecd81905654d534 (diff) | |
download | portage-2dbb9bb3bdb826a7da41ba1ccd89f4f8c8ee529c.tar.gz portage-2dbb9bb3bdb826a7da41ba1ccd89f4f8c8ee529c.tar.bz2 portage-2dbb9bb3bdb826a7da41ba1ccd89f4f8c8ee529c.zip |
hardlink_lockfile: preserve existing permissions
-rw-r--r-- | pym/portage/locks.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/pym/portage/locks.py b/pym/portage/locks.py index 297609c27..a645e255f 100644 --- a/pym/portage/locks.py +++ b/pym/portage/locks.py @@ -316,6 +316,7 @@ def hardlink_lockfile(lockfilename, max_wait=DeprecationWarning, global _quiet out = None displayed_waiting_msg = False + preexisting = os.path.exists(lockfilename) myhardlock = hardlock_name(lockfilename) # myhardlock must not exist prior to our link() call, and we can @@ -350,8 +351,11 @@ def hardlink_lockfile(lockfilename, max_wait=DeprecationWarning, myfd_st = None try: myfd_st = os.fstat(myfd) - if myfd_st.st_gid != portage_gid: - os.fchown(myfd, -1, portage_gid) + if not preexisting: + # Don't chown the file if it is preexisting, since we + # want to preserve existing permissions in that case. + if myfd_st.st_gid != portage_gid: + os.fchown(myfd, -1, portage_gid) except OSError as e: if e.errno not in (errno.ENOENT, errno.ESTALE): writemsg("%s: fchown('%s', -1, %d)\n" % \ |