[yum-cvs] yum-utils repoclosure.py,1.5,1.6
Seth Vidal
skvidal at login.linux.duke.edu
Tue Jun 21 05:09:22 UTC 2005
Update of /home/groups/yum/cvs/yum-utils
In directory login:/tmp/cvs-serv11382
Modified Files:
repoclosure.py
Log Message:
fix up the getCacheDir() dir test to exclude an extremely narrow race
condition
Index: repoclosure.py
===================================================================
RCS file: /home/groups/yum/cvs/yum-utils/repoclosure.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- repoclosure.py 20 Jun 2005 00:09:15 -0000 1.5
+++ repoclosure.py 21 Jun 2005 05:09:17 -0000 1.6
@@ -33,12 +33,13 @@
import tempfile
import rpmUtils.arch
from yum.constants import *
-tmpdir='/var/tmp'
+
def getCacheDir():
"""return a path to a valid and safe cachedir - only used when not running
as root or when --tempcache is set"""
+ tmpdir='/var/tmp'
uid = os.geteuid()
try:
usertup = pwd.getpwuid(uid)
@@ -52,25 +53,11 @@
cachedirs = glob.glob(dirpath)
for thisdir in cachedirs:
- # if one exists take the first one
- # check if it is:
- # 0. is a dir
- if not os.path.isdir(thisdir):
- continue
-
- stats = os.stat(thisdir)
- # 1. owned by the user
- if stats[4] != uid:
- continue
-
- # 2. 0700
- if S_IMODE(stats[0]) != 448:
- continue
-
- # it made it through the gauntlet!
- return thisdir
+ stats = os.stat(thisdir)
+ if S_ISDIR(stats[0]) and S_IMODE(stats[0]) == 448 and stats[4] == uid:
+ print thisdir
+ return thisdir
-
# make the dir (tempfile.mkdtemp())
cachedir = tempfile.mkdtemp(prefix=prefix, dir=tmpdir)
return cachedir
More information about the Yum-cvs-commits
mailing list