[Yum-devel] [PATCH] Do locking for non-root users, using cachedir. BZ 590675.
seth vidal
skvidal at fedoraproject.org
Thu Jan 6 23:21:54 UTC 2011
On Thu, 2011-01-06 at 11:00 -0500, James Antill wrote:
> ---
> yum/__init__.py | 18 +++++++++++++-----
> 1 files changed, 13 insertions(+), 5 deletions(-)
>
> diff --git a/yum/__init__.py b/yum/__init__.py
> index 6bb1614..39ed0db 100644
> --- a/yum/__init__.py
> +++ b/yum/__init__.py
> @@ -1674,11 +1674,13 @@ class YumBase(depsolve.Depsolve):
> def doLock(self, lockfile = YUM_PID_FILE):
> """perform the yum locking, raise yum-based exceptions, not OSErrors"""
>
> - # if we're not root then we don't lock - just return nicely
> + # if we're not root then lock the cache
> if self.conf.uid != 0:
> - return
> -
> - root = self.conf.installroot
> + root = self.conf.cachedir
> + # Don't want <cachedir>/var/run/yum.pid ... just: <cachedir>/yum.pid
> + lockfile = os.path.basename(lockfile)
> + else:
> + root = self.conf.installroot
> lockfile = root + '/' + lockfile # lock in the chroot
> lockfile = os.path.normpath(lockfile) # get rid of silly preceding extra /
>
> @@ -1720,8 +1722,14 @@ class YumBase(depsolve.Depsolve):
> # Note that we can get here from __del__, so if we haven't created
> # YumBase.conf we don't want to do so here as creating stuff inside
> # __del__ is bad.
> - if hasattr(self, 'preconf') or self.conf.uid != 0:
> + if hasattr(self, 'preconf'):
> return
> +
> + # Obviously, we can't lock random places as non-root, but we still want
> + # to get rid of our lock file. Given we now have _lockfile I'm pretty
> + # sure nothing should ever pass lockfile in here anyway.
> + if self.conf.uid != 0:
> + lockfile = None
>
> if lockfile is not None:
> root = self.conf.installroot
ACK
0-sv
More information about the Yum-devel
mailing list