FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Ubuntu > Ubuntu User

 
 
LinkBack Thread Tools
 
Old 03-09-2011, 06:52 PM
Chris Lumens
 
Default Make our resetFileContext loop truly recursive (#681494).

Before, it really just supported traversing the contents of a directory
that was one level deep. Now, it'll set context on everything in an entire
subtree which is the behavior we always wanted anyway.
---
packages.py | 34 ++++++++++++++++++++--------------
1 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/packages.py b/packages.py
index 86b2a47..a866e0d 100644
--- a/packages.py
+++ b/packages.py
@@ -218,6 +218,14 @@ def setupTimezone(anaconda):
# FIXME: this is a huge gross hack. hard coded list of files
# created by anaconda so that we can not be killed by selinux
def setFileCons(anaconda):
+ def lst(root):
+ rc = [root]
+ for (root, dirs, files) in os.walk(root):
+ rc.extend(map(lambda d: root+"/"+d, dirs))
+ rc.extend(map(lambda d: root+"/"+d, files))
+
+ return rc
+
if flags.selinux:
log.info("setting SELinux contexts for anaconda created files")

@@ -237,22 +245,20 @@ def setFileCons(anaconda):
vgs = ["/dev/%s" % vg.name for vg in anaconda.id.storage.vgs]

# ugh, this is ugly
- for dir in ["/etc/sysconfig/network-scripts", "/var/lib/rpm", "/var/lib/yum", "/etc/lvm", "/dev/mapper", "/etc/iscsi", "/var/lib/iscsi", "/root", "/var/log", "/etc/modprobe.d", "/etc/sysconfig" ] + vgs:
- def addpath(x): return dir + "/" + x
-
- if not os.path.isdir(anaconda.rootPath + dir):
+ for d in ["/etc/sysconfig/network-scripts", "/var/cache/yum", "/var/lib/rpm", "/var/lib/yum", "/etc/lvm", "/dev/mapper", "/etc/iscsi", "/var/lib/iscsi", "/root", "/var/log", "/etc/modprobe.d", "/etc/sysconfig" ] + vgs:
+ if not os.path.isdir(anaconda.rootPath + d):
continue
- dirfiles = os.listdir(anaconda.rootPath + dir)
- files.extend(map(addpath, dirfiles))
- files.append(dir)

- for f in files:
- if not os.access("%s/%s" %(anaconda.rootPath, f), os.R_OK):
- log.warning("%s doesn't exist" %(f,))
- continue
- ret = isys.resetFileContext(os.path.normpath(f),
- anaconda.rootPath)
- log.info("set fc of %s to %s" %(f, ret))
+ # This is stupid, but resetFileContext expects to get the path
+ # without "/mnt/sysimage" in front, whereas everything else needs
+ # it there. So we add it to get the list of files, then
+ # immediately remove it, then pass it back to resetFileContext
+ # anyway.
+ for f in map(lambda f: f.replace(anaconda.rootPath, ""),
+ filter(lambda f: os.access(f, os.R_OK),
+ lst(anaconda.rootPath+d))):
+ ret = isys.resetFileContext(os.path.normpath(f),
+ anaconda.rootPath)

return

--
1.7.4.1

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 

Thread Tools




All times are GMT. The time now is 05:19 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org