* Fri Feb 11 2005 Dan Walsh <dwalsh@redhat.com> 1.21.15-7

- Fix genhomedircon regular expression
This commit is contained in:
Daniel J Walsh 2005-02-11 20:13:36 +00:00
parent 5e0b9272b3
commit b26d374a91
2 changed files with 26 additions and 13 deletions

View File

@ -1,7 +1,7 @@
diff --exclude-from=exclude -N -u -r nsapolicycoreutils/scripts/genhomedircon policycoreutils-1.21.15/scripts/genhomedircon
--- nsapolicycoreutils/scripts/genhomedircon 2005-01-28 11:16:36.000000000 -0500
+++ policycoreutils-1.21.15/scripts/genhomedircon 2005-02-11 08:22:00.000000000 -0500
@@ -13,38 +13,109 @@
+++ policycoreutils-1.21.15/scripts/genhomedircon 2005-02-11 15:06:35.000000000 -0500
@@ -13,38 +13,116 @@
#
# ASSUMPTIONS:
#
@ -77,6 +77,10 @@ diff --exclude-from=exclude -N -u -r nsapolicycoreutils/scripts/genhomedircon po
+ sys.stderr.flush()
+ sys.exit(1)
+
+def warning(warning = ""):
+ sys.stderr.write("%s\n" % warning)
+ sys.stderr.flush()
+
+def errorExit(error):
+ sys.stderr.write("%s exiting for: " % sys.argv[0])
+ sys.stderr.write("%s\n" % error)
@ -102,14 +106,17 @@ diff --exclude-from=exclude -N -u -r nsapolicycoreutils/scripts/genhomedircon po
+ def getFileContextDir(self):
+ return self.selinuxdir+self.getSelinuxType()+self.filecontextdir
+
+ def getFileContextFile(self):
+ return self.getFileContextDir()+"/file_contexts"
+
+ def getContextDir(self):
+ return self.selinuxdir+self.getSelinuxType()+self.contextdir
+
+ def getHomeDirTemplate(self):
+ return self.getFileContextDir()+"/homedir_template"
+
+ def getHomeRootContext(self):
+ rc=commands.getstatusoutput("grep HOME_ROOT %s | sed -e \"s|^HOME_ROOT|%s|\"" % ( self.getHomeDirTemplate(), getDefaultHomeDir()))
+ def getHomeRootContext(self, homedir):
+ rc=commands.getstatusoutput("grep HOME_ROOT %s | sed -e \"s|^HOME_ROOT|%s|\"" % ( self.getHomeDirTemplate(), homedir))
+ if rc[0] == 0:
+ return rc[1]
+ else:
@ -131,7 +138,7 @@ diff --exclude-from=exclude -N -u -r nsapolicycoreutils/scripts/genhomedircon po
if rc[0] == 0:
ulist = rc[1].strip().split("\n")
for u in ulist:
@@ -68,72 +139,90 @@
@@ -68,72 +146,96 @@
sys.stderr.write("The user \"%s\" is not present in the passwd file, skipping...\n" % (user[1],))
return udict
@ -199,10 +206,9 @@ diff --exclude-from=exclude -N -u -r nsapolicycoreutils/scripts/genhomedircon po
-
+ def getHomeDirContext(self, user, home, role):
+ ret="\n\n#\n# Context for user %s\n#\n\n" % user
+ rc=commands.getstatusoutput("grep -e '^HOME_DIR' %s | sed -e 's|HOME_DIR|%s|' -e 's/ROLE/%s/' -e 's/system_u/%s/'" % (self.getHomeDirTemplate(), home, role, user))
+ rc=commands.getstatusoutput("grep '^HOME_DIR' %s | sed -e 's|HOME_DIR|%s|' -e 's/ROLE/%s/' -e 's/system_u/%s/'" % (self.getHomeDirTemplate(), home, role, user))
+ return ret + rc[1] + "\n"
+
+
+ def genHomeDirContext(self):
+ users = self.getUsers()
+ ret=""
@ -212,6 +218,9 @@ diff --exclude-from=exclude -N -u -r nsapolicycoreutils/scripts/genhomedircon po
+ ret += self.getHomeDirContext (u, users[u]["home"], users[u]["role"])
+ return ret
+
+ def checkExists(self, home):
+ return commands.getstatusoutput("grep -E '^%s[^[:alnum:]_-]' %s" % (home, self.getFileContextFile()))[0]
+
+ def getHomeDirs(self):
+ homedirs = []
+ homedirs.append(getDefaultHomeDir())
@ -226,6 +235,9 @@ diff --exclude-from=exclude -N -u -r nsapolicycoreutils/scripts/genhomedircon po
+ string.count(u[5], "/") > 1:
+ homedir = u[5][:string.rfind(u[5], "/")]
+ if not homedir in homedirs:
+ if self.checkExists(homedir)==0:
+ warning("%s is already defined in %s,\n%s will not create a new context." % (homedir, self.getFileContextFile(), sys.argv[0]))
+ else:
+ homedirs.append(homedir)
+
+ homedirs.sort()
@ -233,9 +245,10 @@ diff --exclude-from=exclude -N -u -r nsapolicycoreutils/scripts/genhomedircon po
+
+ def genoutput(self):
+ ret= self.heading()
+ ret += self.getHomeRootContext()
+ for h in self.getHomeDirs():
+ ret += self.getHomeDirContext ("user_u" , h+'/[^/]*', "user")
+ ret += "\n"
+ ret += self.getHomeRootContext(h)
+ ret += self.genHomeDirContext()
+ return ret
+

View File

@ -1,8 +1,8 @@
%define libselinuxver 1.21.9-2
un%define libselinuxver 1.21.9-2
Summary: SELinux policy core utilities.
Name: policycoreutils
Version: 1.21.15
Release: 6
Release: 7
License: GPL
Group: System Environment/Base
Source: http://www.nsa.gov/selinux/archives/policycoreutils-%{version}.tgz
@ -81,7 +81,7 @@ rm -rf ${RPM_BUILD_ROOT}
%config(noreplace) %{_sysconfdir}/sestatus.conf
%changelog
* Fri Feb 11 2005 Dan Walsh <dwalsh@redhat.com> 1.21.15-6
* Fri Feb 11 2005 Dan Walsh <dwalsh@redhat.com> 1.21.15-7
- Fix genhomedircon regular expression
* Thu Feb 10 2005 Dan Walsh <dwalsh@redhat.com> 1.21.15-5