* Tue Dec 20 2005 Dan Walsh <dwalsh@redhat.com> 1.29.2-4

- Add try catch for files that may not exists

* Mon Dec 19 2005 Dan Walsh <dwalsh@redhat.com> 1.29.2-3
- Remove commands from genhomedircon for installer
This commit is contained in:
Daniel J Walsh 2005-12-20 11:35:21 +00:00
parent 235a937b7a
commit 7e64d5bb54
2 changed files with 26 additions and 20 deletions

View File

@ -1,7 +1,7 @@
diff --exclude-from=exclude -N -u -r nsapolicycoreutils/scripts/genhomedircon policycoreutils-1.29.2/scripts/genhomedircon diff --exclude-from=exclude -N -u -r nsapolicycoreutils/scripts/genhomedircon policycoreutils-1.29.2/scripts/genhomedircon
--- nsapolicycoreutils/scripts/genhomedircon 2005-12-07 07:28:00.000000000 -0500 --- nsapolicycoreutils/scripts/genhomedircon 2005-12-07 07:28:00.000000000 -0500
+++ policycoreutils-1.29.2/scripts/genhomedircon 2005-12-19 18:17:05.000000000 -0500 +++ policycoreutils-1.29.2/scripts/genhomedircon 2005-12-20 06:32:04.000000000 -0500
@@ -26,64 +26,70 @@ @@ -26,64 +26,73 @@
# #
# #
@ -25,16 +25,19 @@ diff --exclude-from=exclude -N -u -r nsapolicycoreutils/scripts/genhomedircon po
+ +
+def findval(file, var, delim=""): +def findval(file, var, delim=""):
+ val="" + val=""
+ fd=open(file, 'r') + try:
+ for i in fd.read().split('\n'): + fd=open(file, 'r')
+ if i.startswith(var) == 1: + for i in fd.read().split('\n'):
+ if delim == "": + if i.startswith(var) == 1:
+ val = i.split()[1] + if delim == "":
+ else: + val = i.split()[1]
+ val = i.split(delim)[1] + else:
+ val = val.split("#")[0] + val = i.split(delim)[1]
+ val = val.strip() + val = val.split("#")[0]
+ fd.close() + val = val.strip()
+ fd.close()
+ except:
+ val=""
+ return val + return val
def getStartingUID(): def getStartingUID():
@ -110,7 +113,7 @@ diff --exclude-from=exclude -N -u -r nsapolicycoreutils/scripts/genhomedircon po
return "targeted" return "targeted"
def usage(error = ""): def usage(error = ""):
@@ -129,11 +135,17 @@ @@ -129,11 +138,17 @@
return self.getFileContextDir()+"/homedir_template" return self.getFileContextDir()+"/homedir_template"
def getHomeRootContext(self, homedir): def getHomeRootContext(self, homedir):
@ -133,7 +136,7 @@ diff --exclude-from=exclude -N -u -r nsapolicycoreutils/scripts/genhomedircon po
def heading(self): def heading(self):
ret = "\n#\n#\n# User-specific file contexts, generated via %s\n" % sys.argv[0] ret = "\n#\n#\n# User-specific file contexts, generated via %s\n" % sys.argv[0]
@@ -152,32 +164,40 @@ @@ -152,32 +167,40 @@
return "user_r" return "user_r"
return name return name
def getOldRole(self, role): def getOldRole(self, role):
@ -190,7 +193,7 @@ diff --exclude-from=exclude -N -u -r nsapolicycoreutils/scripts/genhomedircon po
def getUsers(self): def getUsers(self):
udict = {} udict = {}
@@ -190,30 +210,45 @@ @@ -190,30 +213,45 @@
self.adduser(udict, semanage_seuser_get_name(seuser), seusername, self.defaultrole(seusername)) self.adduser(udict, semanage_seuser_get_name(seuser), seusername, self.defaultrole(seusername))
else: else:
@ -252,7 +255,7 @@ diff --exclude-from=exclude -N -u -r nsapolicycoreutils/scripts/genhomedircon po
warning("genhomedircon: Warning! No support yet for expanding ROLE macros in the %s file when using libsemanage." % self.getHomeDirTemplate()); warning("genhomedircon: Warning! No support yet for expanding ROLE macros in the %s file when using libsemanage." % self.getHomeDirTemplate());
warning("genhomedircon: You must manually update file_contexts.homedirs for any non-user_r users (including root)."); warning("genhomedircon: You must manually update file_contexts.homedirs for any non-user_r users (including root).");
users = self.getUsers() users = self.getUsers()
@@ -225,40 +260,23 @@ @@ -225,40 +263,23 @@
return ret+"\n" return ret+"\n"
def checkExists(self, home): def checkExists(self, home):
@ -308,7 +311,7 @@ diff --exclude-from=exclude -N -u -r nsapolicycoreutils/scripts/genhomedircon po
starting_uid=getStartingUID() starting_uid=getStartingUID()
if self.usepwd==0: if self.usepwd==0:
return homedirs return homedirs
@@ -270,7 +288,7 @@ @@ -270,7 +291,7 @@
string.count(u[5], "/") > 1: string.count(u[5], "/") > 1:
homedir = u[5][:string.rfind(u[5], "/")] homedir = u[5][:string.rfind(u[5], "/")]
if not homedir in homedirs: if not homedir in homedirs:
@ -317,7 +320,7 @@ diff --exclude-from=exclude -N -u -r nsapolicycoreutils/scripts/genhomedircon po
warning("%s homedir %s or its parent directoy conflicts with a\ndefined context in %s,\n%s will not create a new context." % (u[0], u[5], self.getFileContextFile(), sys.argv[0])) warning("%s homedir %s or its parent directoy conflicts with a\ndefined context in %s,\n%s will not create a new context." % (u[0], u[5], self.getFileContextFile(), sys.argv[0]))
else: else:
homedirs.append(homedir) homedirs.append(homedir)
@@ -336,4 +354,4 @@ @@ -336,4 +357,4 @@
except ValueError, error: except ValueError, error:
errorExit("ValueError %s" % error) errorExit("ValueError %s" % error)
except IndexError, error: except IndexError, error:

View File

@ -4,7 +4,7 @@
Summary: SELinux policy core utilities. Summary: SELinux policy core utilities.
Name: policycoreutils Name: policycoreutils
Version: 1.29.2 Version: 1.29.2
Release: 3 Release: 4
License: GPL License: GPL
Group: System Environment/Base Group: System Environment/Base
Source: http://www.nsa.gov/selinux/archives/policycoreutils-%{version}.tgz Source: http://www.nsa.gov/selinux/archives/policycoreutils-%{version}.tgz
@ -96,7 +96,10 @@ rm -rf ${RPM_BUILD_ROOT}
%config(noreplace) %{_sysconfdir}/sestatus.conf %config(noreplace) %{_sysconfdir}/sestatus.conf
%changelog %changelog
* Wed Dec 14 2005 Dan Walsh <dwalsh@redhat.com> 1.29.2-3 * Tue Dec 20 2005 Dan Walsh <dwalsh@redhat.com> 1.29.2-4
- Add try catch for files that may not exists
* Mon Dec 19 2005 Dan Walsh <dwalsh@redhat.com> 1.29.2-3
- Remove commands from genhomedircon for installer - Remove commands from genhomedircon for installer
* Wed Dec 14 2005 Dan Walsh <dwalsh@redhat.com> 1.29.2-1 * Wed Dec 14 2005 Dan Walsh <dwalsh@redhat.com> 1.29.2-1