Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 60844 Details for
Bug 94661
Use python-provided st_flags to read flags instead of calling lgetflags
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
2.0.51.22-chflags.patch
2.0.51.22-chflags.patch (text/plain), 9.64 KB, created by
Diego Elio Pettenò (RETIRED)
on 2005-06-08 09:20:18 UTC
(
hide
)
Description:
2.0.51.22-chflags.patch
Filename:
MIME Type:
Creator:
Diego Elio Pettenò (RETIRED)
Created:
2005-06-08 09:20:18 UTC
Size:
9.64 KB
patch
obsolete
>diff -x '*~' -ur portage-2.0.51.22/pym/portage.py portage-2.0.51.22-chflags/pym/portage.py >--- portage-2.0.51.22/pym/portage.py 2005-05-15 12:20:58.000000000 +0200 >+++ portage-2.0.51.22-chflags/pym/portage.py 2005-06-08 18:00:46.099609992 +0200 >@@ -51,15 +51,13 @@ > sys.stderr.write("!!! gone wrong. The exception was non-standard and we were unable to catch it.\n\n") > sys.exit(127) > >+flagsNotWritable = 0x0160016 > try: >- # XXX: This should get renamed to bsd_chflags, I think. >- import chflags >- bsd_chflags = chflags >+ import freebsd > except SystemExit, e: > raise > except: >- # XXX: This should get renamed to bsd_chflags, I think. >- bsd_chflags = None >+ freebsd = None > > try: > import cvstree >@@ -594,16 +592,22 @@ > mtimedb["ldpath"][x]=newldpathtime > ld_cache_update=True > >- if (ld_cache_update or makelinks): >- # We can't update links if we haven't cleaned other versions first, as >- # an older package installed ON TOP of a newer version will cause ldconfig >- # to overwrite the symlinks we just made. -X means no links. After 'clean' >- # we can safely create links. >- writemsg(">>> Regenerating "+str(root)+"etc/ld.so.cache...\n") >- if makelinks: >- commands.getstatusoutput("cd / ; /sbin/ldconfig -r "+root) >- else: >- commands.getstatusoutput("cd / ; /sbin/ldconfig -X -r "+root) >+ # ldconfig has very different behaviour between FreeBSD and Linux >+ if ostype=="Linux" or ostype.lower().endswith("gnu"): >+ if (ld_cache_update or makelinks): >+ # We can't update links if we haven't cleaned other versions first, as >+ # an older package installed ON TOP of a newer version will cause ldconfig >+ # to overwrite the symlinks we just made. -X means no links. After 'clean' >+ # we can safely create links. >+ writemsg(">>> Regenerating "+str(root)+"etc/ld.so.cache...\n") >+ if makelinks: >+ commands.getstatusoutput("cd / ; /sbin/ldconfig -r "+root) >+ else: >+ commands.getstatusoutput("cd / ; /sbin/ldconfig -X -r "+root) >+ elif ostype == "FreeBSD": >+ if (ld_cache_update): >+ writemsg(">>> Regenerating "+str(root)+"var/run/ld-elf.so.hints...\n") >+ commands.getstatusoutput("cd / ; /sbin/ldconfig -elf -f "+str(root)+"var/run/ld-elf.so.hints "+str(root)+"etc/ld.so.conf") > > del specials["LDPATH"] > >@@ -1588,7 +1592,7 @@ > (("nouserpriv" in string.split(mysettings["RESTRICT"])) or \ > ("userpriv" in string.split(mysettings["RESTRICT"])))) > >- if droppriv and portage_gid and portage_uid: >+ if droppriv and not uid and portage_gid and portage_uid: > keywords.update({"uid":portage_uid,"gid":portage_gid,"groups":[portage_gid],"umask":002}) > > if not free: >@@ -1902,10 +1906,10 @@ > con=selinux.getcontext() > con=string.replace(con,mysettings["PORTAGE_T"],mysettings["PORTAGE_FETCH_T"]) > selinux.setexec(con) >- myret=spawn(myfetch,mysettings,free=1, droppriv=("userpriv" in mysettings.features)) >+ myret=spawn(myfetch,mysettings,free=1, droppriv=("userfetch" in mysettings.features)) > selinux.setexec(None) > else: >- myret=spawn(myfetch,mysettings,free=1, droppriv=("userpriv" in mysettings.features)) >+ myret=spawn(myfetch,mysettings,free=1, droppriv=("userfetch" in mysettings.features)) > finally: > #if root, -always- set the perms. > if os.path.exists(mysettings["DISTDIR"]+"/"+myfile) and (fetched != 1 or os.getuid() == 0) \ >@@ -2661,7 +2665,7 @@ > except: > pass > >- if not fetch(fetchme, mysettings, listonly=listonly, fetchonly=fetchonly): >+ if mydo!="manifest" and not fetch(fetchme, mysettings, listonly=listonly, fetchonly=fetchonly): > return 1 > > if mydo=="fetch" and listonly: >@@ -2738,12 +2742,6 @@ > try: > if not sstat: > sstat=os.lstat(src) >- if bsd_chflags: >- sflags=bsd_chflags.lgetflags(src) >- if sflags < 0: >- # Problem getting flags... >- writemsg("!!! Couldn't get flags for "+dest+"\n") >- return None > > except SystemExit, e: > raise >@@ -2761,20 +2759,27 @@ > dstat=os.lstat(os.path.dirname(dest)) > destexists=0 > >- if bsd_chflags: >- # Check that we can actually unset schg etc flags... >- # Clear the flags on source and destination; we'll reinstate them after merging >- if(destexists): >- if bsd_chflags.lchflags(dest, 0) < 0: >- writemsg("!!! Couldn't clear flags on file being merged: \n ") >- # We might have an immutable flag on the parent dir; save and clear. >- pflags=bsd_chflags.lgetflags(os.path.dirname(dest)) >- bsd_chflags.lchflags(os.path.dirname(dest), 0) >- >- # Don't bother checking the return value here; if it fails then the next line will catch it. >- bsd_chflags.lchflags(src, 0) >+ if freebsd: >+ if destexists: >+ # We might have an immutable flag on the parent dir; >+ # save and clear. >+ pflags=os.lstat(os.path.dirname(dest)).st_flags >+ >+ try: >+ if destexists: >+ freebsd.lchflags(os.path.dirname(dest), 0) >+ freebsd.lchflags(dest, 0) >+ >+ freebsd.lchflags(src, 0) >+ except OSError, e: >+ import errno >+ if e[0] == errno.EOPNOTSUPP: >+ writemsg("Operation not supported on destination\n") >+ else: >+ writemsg("!!! Unable to reset flags.\n") >+ return None > >- if bsd_chflags.lhasproblems(src)>0 or (destexists and bsd_chflags.lhasproblems(dest)>0) or bsd_chflags.lhasproblems(os.path.dirname(dest))>0: >+ if os.lstat(src).st_flags & flagsNotWritable != 0 or ( destexists and os.lstat(dest).st_flags & flagsNotWritable != 0 or os.lstat(os.path.dirname(dest)).st_flags & flagsNotWritable != 0 ): > # This is bad: we can't merge the file with these flags set. > writemsg("!!! Can't merge file "+dest+" because of flags set\n") > return None >@@ -2803,12 +2808,20 @@ > else: > os.symlink(target,dest) > lchown(dest,sstat[stat.ST_UID],sstat[stat.ST_GID]) >- if bsd_chflags: >- # Restore the flags we saved before moving >- if bsd_chflags.lchflags(dest, sflags) < 0 or bsd_chflags.lchflags(os.path.dirname(dest), pflags) < 0: >- writemsg("!!! Couldn't restore flags ("+str(flags)+") on " + dest+":\n") >- writemsg("!!! %s\n" % str(e)) >- return None >+ if freebsd: >+ try: >+ # Restore the flags we saved before moving >+ freebsd.lchflags(dest, sstat.st_flags) >+ if destexists: >+ freebsd.lchflags(os.path.dirname(dest), pflags) >+ except OSError, e: >+ import errno >+ if e[0] == errno.EOPNOTSUPP: >+ writemsg("Operation not supported on destination\n") >+ else: >+ writemsg("!!! Couldn't restore flags ("+str(sstat.st_flags)+") on " + dest+":\n") >+ writemsg("!!! %s\n" % str(e)) >+ return None > return os.lstat(dest)[stat.ST_MTIME] > except SystemExit, e: > raise >@@ -2883,11 +2896,19 @@ > os.utime(dest, (sstat[stat.ST_ATIME], sstat[stat.ST_MTIME])) > newmtime=sstat[stat.ST_MTIME] > >- if bsd_chflags: >- # Restore the flags we saved before moving >- if bsd_chflags.lchflags(dest, sflags) < 0 or bsd_chflags.lchflags(os.path.dirname(dest), pflags) < 0: >- writemsg("!!! Couldn't restore flags ("+str(sflags)+") on " + dest+":\n") >- return None >+ if freebsd: >+ try: >+ # Restore the flags we saved before moving >+ freebsd.lchflags(dest, sstat.st_flags) >+ if destexists: >+ freebsd.lchflags(os.path.dirname(dest), pflags) >+ except OSError, e: >+ import errno >+ if e[0] == errno.EOPNOTSUPP: >+ writemsg("Operation not supported on destination\n") >+ else: >+ writemsg("!!! Couldn't restore flags ("+str(sstat.st_flags)+") on " + dest+":\n") >+ return None > > return newmtime > >@@ -6705,11 +6726,18 @@ > if mydmode!=None: > # destination exists > >- if bsd_chflags: >+ if freebsd: > # Save then clear flags on dest. >- dflags=bsd_chflags.lgetflags(mydest) >- if(bsd_chflags.lchflags(mydest, 0)<0): >- writemsg("!!! Couldn't clear flags on '"+mydest+"'.\n") >+ dflags=os.lstat(mydest).st_flags >+ try: >+ freebsd.lchflags(mydest, 0) >+ except OSError, e: >+ import errno >+ if e[0] == errno.EOPNOTSUPP: >+ writemsg("Operation not supported on destination\n") >+ else: >+ writemsg("!!! Unable to clear flags on " + mydest + ".\n") >+ return None > > if not os.access(mydest, os.W_OK): > pkgstuff = pkgsplit(self.pkg) >@@ -6723,8 +6751,16 @@ > if stat.S_ISLNK(mydmode) or stat.S_ISDIR(mydmode): > # a symlink to an existing directory will work for us; keep it: > print "---",mydest+"/" >- if bsd_chflags: >- bsd_chflags.lchflags(mydest, dflags) >+ if freebsd: >+ try: >+ freebsd.lchflags(mydest, dflags) >+ except OSError, e: >+ import errno >+ if e[0] == errno.EOPNOTSUPP: >+ writemsg("Operation not supported on destination\n") >+ else: >+ writemsg("!!! Unable to clear flags on " + mydest + ".\n") >+ return None > else: > # a non-directory and non-symlink-to-directory. Won't work for us. Move out of the way. > if movefile(mydest,mydest+".backup", mysettings=self.settings) == None: >@@ -6736,8 +6772,8 @@ > selinux.secure_mkdir(mydest,sid) > else: > os.mkdir(mydest) >- if bsd_chflags: >- bsd_chflags.lchflags(mydest, dflags) >+ if freebsd: >+ freebsd.lchflags(mydest, dflags) > os.chmod(mydest,mystat[0]) > lchown(mydest,mystat[4],mystat[5]) > print ">>>",mydest+"/" >@@ -6749,8 +6785,16 @@ > else: > os.mkdir(mydest) > os.chmod(mydest,mystat[0]) >- if bsd_chflags: >- bsd_chflags.lchflags(mydest, bsd_chflags.lgetflags(mysrc)) >+ if freebsd: >+ try: >+ freebsd.lchflags(mydest, os.lstat(mysrc).st_flags) >+ except OSError, e: >+ import errno >+ if e[0] == errno.EOPNOTSUPP: >+ writemsg("Operation not supported on destination\n") >+ else: >+ writemsg("!!! Unable to set flags on " + mydest + ".\n") >+ return None > lchown(mydest,mystat[4],mystat[5]) > print ">>>",mydest+"/" > outfile.write("dir "+myrealdest+"\n")
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 94661
:
60296
|
60844
|
66075
|
66078
|
69728