diff options
author | Zac Medico <zmedico@gentoo.org> | 2009-01-18 23:43:01 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2009-01-18 23:43:01 +0000 |
commit | 0e80f907e5d10bc2a0e9067c70e7ae53e097616f (patch) | |
tree | 469daf6978ab24d73c351d2210e67fba21f5d0e0 | |
parent | 51482d335f34090b81eb58647e1c8700415c96db (diff) | |
download | portage-0e80f907e5d10bc2a0e9067c70e7ae53e097616f.tar.gz portage-0e80f907e5d10bc2a0e9067c70e7ae53e097616f.tar.bz2 portage-0e80f907e5d10bc2a0e9067c70e7ae53e097616f.zip |
Revert chown behavior change from the previous commit, so that chown will
not be called on a pre-existing file. (trunk r12522)
svn path=/main/branches/2.1.6/; revision=12534
-rw-r--r-- | pym/portage/locks.py | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/pym/portage/locks.py b/pym/portage/locks.py index be7cdf07d..50fe317bf 100644 --- a/pym/portage/locks.py +++ b/pym/portage/locks.py @@ -55,6 +55,7 @@ def lockfile(mypath, wantnewlockfile=0, unlinkfile=0, if type(mypath) == types.StringType: if not os.path.exists(os.path.dirname(mypath)): raise DirectoryNotFound(os.path.dirname(mypath)) + preexisting = os.path.exists(lockfilename) old_mask = os.umask(000) try: try: @@ -67,17 +68,21 @@ def lockfile(mypath, wantnewlockfile=0, unlinkfile=0, raise PermissionDenied(func_call) else: raise - try: - if os.stat(lockfilename).st_gid != portage_gid: - os.chown(lockfilename, os.getuid(), portage_gid) - except OSError, e: - if e.errno == errno.ENOENT: # No such file or directory - return lockfile(mypath, wantnewlockfile=wantnewlockfile, - unlinkfile=unlinkfile, waiting_msg=waiting_msg, - flags=flags) - else: - writemsg("Cannot chown a lockfile. This could " + \ - "cause inconvenience later.\n") + + if not preexisting: + try: + if os.stat(lockfilename).st_gid != portage_gid: + os.chown(lockfilename, -1, portage_gid) + except OSError, e: + if e.errno == errno.ENOENT: # No such file or directory + return lockfile(mypath, + wantnewlockfile=wantnewlockfile, + unlinkfile=unlinkfile, waiting_msg=waiting_msg, + flags=flags) + else: + writemsg("Cannot chown a lockfile. This could " + \ + "cause inconvenience later.\n") + finally: os.umask(old_mask) |