Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 200329 Details for
Bug 280521
update portage selinux support
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
portage code patch
portage-selinux.diff (text/plain), 4.37 KB, created by
Chris PeBenito (RETIRED)
on 2009-08-06 02:08:07 UTC
(
hide
)
Description:
portage code patch
Filename:
MIME Type:
Creator:
Chris PeBenito (RETIRED)
Created:
2009-08-06 02:08:07 UTC
Size:
4.37 KB
patch
obsolete
>Index: pym/portage/__init__.py >=================================================================== >--- pym/portage/__init__.py (revision 13925) >+++ pym/portage/__init__.py (working copy) >@@ -6688,8 +6688,7 @@ > if destexists and not stat.S_ISDIR(dstat[stat.ST_MODE]): > os.unlink(dest) > if selinux_enabled: >- sid = selinux.get_lsid(src) >- selinux.secure_symlink(target,dest,sid) >+ selinux.symlink(target,dest,src) > else: > os.symlink(target,dest) > lchown(dest,sstat[stat.ST_UID],sstat[stat.ST_GID]) >@@ -6744,7 +6743,7 @@ > if not hardlinked and (selinux_enabled or sstat.st_dev == dstat.st_dev): > try: > if selinux_enabled: >- ret=selinux.secure_rename(src,dest) >+ ret=selinux.rename(src,dest) > else: > ret=os.rename(src,dest) > renamefailed=0 >@@ -6762,8 +6761,8 @@ > if stat.S_ISREG(sstat[stat.ST_MODE]): > try: # For safety copy then move it over. > if selinux_enabled: >- selinux.secure_copy(src,dest+"#new") >- selinux.secure_rename(dest+"#new",dest) >+ selinux.copyfile(src,dest+"#new") >+ selinux.rename(dest+"#new",dest) > else: > shutil.copyfile(src,dest+"#new") > os.rename(dest+"#new",dest) >@@ -6776,15 +6775,12 @@ > return None > else: > #we don't yet handle special, so we need to fall back to /bin/mv >- if selinux_enabled: >- a=commands.getstatusoutput(MOVE_BINARY+" -c -f "+"'"+src+"' '"+dest+"'") >- else: >- a=commands.getstatusoutput(MOVE_BINARY+" -f "+"'"+src+"' '"+dest+"'") >- if a[0]!=0: >- print "!!! Failed to move special file:" >- print "!!! '"+src+"' to '"+dest+"'" >- print "!!!",a >- return None # failure >+ a=commands.getstatusoutput(MOVE_BINARY+" -f "+"'"+src+"' '"+dest+"'") >+ if a[0]!=0: >+ print "!!! Failed to move special file:" >+ print "!!! '"+src+"' to '"+dest+"'" >+ print "!!!",a >+ return None # failure > try: > if didcopy: > if stat.S_ISLNK(sstat[stat.ST_MODE]): >Index: pym/portage/_selinux.py >=================================================================== >--- pym/portage/_selinux.py (revision 13925) >+++ pym/portage/_selinux.py (working copy) >@@ -2,7 +2,75 @@ > # Distributed under the terms of the GNU General Public License v2 > # $Id$ > >-import selinux >-from selinux import is_selinux_enabled >-from selinux_aux import setexec, secure_symlink, secure_rename, \ >- secure_copy, secure_mkdir, getcontext, get_sid, get_lsid >+import os,shutil,selinux,string >+from selinux import is_selinux_enabled, getfilecon, lgetfilecon >+ >+def copyfile(src,dest): >+ # without the str() I get an error: >+ # failed to move src, dest >+ # in method 'getfilecon', argument 1 of type 'char const *' >+ (rc,ctx)=selinux.lgetfilecon(str(src)) >+ if rc < 0: >+ raise OSError("copyfile: Failed getting context of \"%s\"." % src) >+ >+ setfscreate(ctx) >+ shutil.copyfile(src,dest) >+ setfscreate() >+ >+def getcontext(): >+ (rc,ctx)=selinux.getcon() >+ if rc < 0: >+ raise OSError("getcontext: Failed getting current process context.") >+ >+ return ctx >+ >+def mkdir(target,refdir): >+ (rc,ctx)=selinux.getfilecon(refdir) >+ if rc < 0: >+ raise OSError("mkdir: Failed getting context of reference directory \"%s\"." % refdir) >+ >+ setfscreatecon(ctx) >+ os.mkdir(target) >+ setfscreatecon() >+ >+def rename(src,dest): >+ # without the str() I get an error: >+ # failed to move src, dest >+ # in method 'getfilecon', argument 1 of type 'char const *' >+ (rc,ctx)=selinux.lgetfilecon(str(src)) >+ if rc < 0: >+ raise OSError("rename: Failed getting context of \"%s\"." % src) >+ >+ setfscreate(ctx) >+ os.rename(src,dest) >+ setfscreate() >+ >+def setexec(ctx="\n"): >+ if selinux.setexeccon(ctx) < 0: >+ raise OSError("setexec: Failed setting exec() context \"%s\"." % ctx) >+ >+def setfscreate(ctx="\n"): >+ if selinux.setfscreatecon(ctx) < 0: >+ raise OSError("setfscreate: Failed setting fs create context \"%s\"." % ctx) >+ >+def spawn(selinux_type,spawn_func,mycommand, opt_name=None, **keywords): >+ con = getcontext().split(":") >+ con[2] = selinux_type >+ setexec(string.join(con,":")) >+ >+ retval = spawn_func(mycommand, opt_name=opt_name, **keywords) >+ >+ setexec() >+ return retval >+ >+def symlink(target,link,reflnk): >+ # without the str() I get an error: >+ # failed to properly create symlink >+ # in method 'lgetfilecon', argument 1 of type 'char const *' >+ (rc,ctx)=selinux.lgetfilecon(str(reflnk)) >+ if rc < 0: >+ raise OSError("symlink: Failed getting context of reference symlink \"%s\"." % reflnk) >+ >+ setfscreate(ctx) >+ os.symlink(target,link) >+ setfscreate()
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 280521
: 200329 |
200331