From: Jason Stubbs Date: Fri, 30 Dec 2005 04:10:54 +0000 (-0000) Subject: Don't attempt to chmod/chown unless running as root when calling simple X-Git-Tag: v2.1_pre3~9 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=89d9943894fb32b7f9ed63017e9332367f4a5dc1;p=portage.git Don't attempt to chmod/chown unless running as root when calling simple ebuild functions. svn path=/main/trunk/; revision=2495 --- diff --git a/pym/portage.py b/pym/portage.py index eaa5c6e8d..aa99c1c1c 100644 --- a/pym/portage.py +++ b/pym/portage.py @@ -2584,8 +2584,9 @@ def doebuild(myebuild,mydo,myroot,mysettings,debug=0,listonly=0,fetchonly=0,clea logdir = mysettings["T"]+"/logging" if not os.path.exists(logdir): os.makedirs(logdir) - os.chown(logdir, portage_uid, portage_gid) - os.chmod(logdir, 0770) + if secpass == 2: + os.chown(logdir, portage_uid, portage_gid) + os.chmod(logdir, 0770) try: # XXX: negative RESTRICT if not (("nouserpriv" in string.split(mysettings["PORTAGE_RESTRICT"])) or \ @@ -2707,8 +2708,11 @@ def doebuild(myebuild,mydo,myroot,mysettings,debug=0,listonly=0,fetchonly=0,clea print "!!!",e if os.access(mysettings["PORT_LOGDIR"]+"/",os.W_OK): try: - os.chown(mysettings["PORT_LOGDIR"],portage_uid,portage_gid) - os.chmod(mysettings["PORT_LOGDIR"],02770) + perms = os.stat(mysettings["PORT_LOGDIR"]) + if perms[stat.ST_UID] != portage_uid or perms[stat.ST_GID] != portage_gid: + os.chown(mysettings["PORT_LOGDIR"],portage_uid,portage_gid) + if stat.S_IMODE(perms[stat.ST_MODE]) != 02770: + os.chmod(mysettings["PORT_LOGDIR"],02770) if not mysettings.has_key("LOG_PF") or (mysettings["LOG_PF"] != mysettings["PF"]): mysettings["LOG_PF"]=mysettings["PF"] mysettings["LOG_COUNTER"]=str(db[myroot]["vartree"].dbapi.get_counter_tick_core("/"))