* Mon Nov 14 2005 Dan Walsh <dwalsh@redhat.com> 1.27.27-4

- Fix genhomedircon to work with non libsemanage systems
This commit is contained in:
Daniel J Walsh 2005-11-14 18:03:56 +00:00
parent e48e95e5da
commit 7fb8345697
2 changed files with 23 additions and 23 deletions

View File

@ -1,6 +1,6 @@
diff --exclude-from=exclude -N -u -r nsapolicycoreutils/scripts/genhomedircon policycoreutils-1.27.27/scripts/genhomedircon
--- nsapolicycoreutils/scripts/genhomedircon 2005-09-12 16:33:30.000000000 -0400
+++ policycoreutils-1.27.27/scripts/genhomedircon 2005-11-11 15:43:58.000000000 -0500
+++ policycoreutils-1.27.27/scripts/genhomedircon 2005-11-14 12:58:49.000000000 -0500
@@ -15,32 +15,19 @@
# The file CONTEXTDIR/files/homedir_template exists. This file is used to
# set up the home directory context for each real user.
@ -220,7 +220,7 @@ diff --exclude-from=exclude -N -u -r nsapolicycoreutils/scripts/genhomedircon po
self.type=type
self.selinuxdir=selinuxdir +"/"
self.contextdir="/contexts"
@@ -313,47 +142,72 @@
@@ -313,47 +142,70 @@
errorExit(string.join("sed error ", rc[1]))
def getUsersFile(self):
@ -279,6 +279,10 @@ diff --exclude-from=exclude -N -u -r nsapolicycoreutils/scripts/genhomedircon po
- prefs = {}
- if users != "":
- ulist = users.split("\n")
- for u in ulist:
- user = u.split()
- try:
- if len(user)==0 or user[1] == "user_u" or user[1] == "system_u":
+ if self.semanaged:
+ (status, list, lsize) = semanage_seuser_list(self.semanageHandle)
+ for idx in range(lsize):
@ -288,16 +292,12 @@ diff --exclude-from=exclude -N -u -r nsapolicycoreutils/scripts/genhomedircon po
+ self.adduser(udict, semanage_seuser_get_name(seuser), seusername, self.defaultrole(seusername))
+
+ else:
+ users=""
+ rc = commands.getstatusoutput("grep -v '^ *#' %s" % self.getUsersFile())
+ if rc[0] == 0 and rc[1] != "":
+ ulist = rc[1].split("\n")
+ print ulist
for u in ulist:
- user = u.split()
- try:
- if len(user)==0 or user[1] == "user_u" or user[1] == "system_u":
- continue
+ for u in ulist:
+ if len(u)==0:
continue
- # !!! chooses first role in the list to use in the file context !!!
- role = user[3]
- if role == "{":
@ -305,27 +305,24 @@ diff --exclude-from=exclude -N -u -r nsapolicycoreutils/scripts/genhomedircon po
- role = role.split("_r")[0]
- home = pwd.getpwnam(user[1])[5]
- if home == "/":
- continue
+ user = u.split(":")
+ if len(user) < 3:
continue
- prefs = {}
- prefs["role"] = role
- prefs["home"] = home
- udict[user[1]] = prefs
- except KeyError:
- sys.stderr.write("The user \"%s\" is not present in the passwd file, skipping...\n" % user[1])
+ if len(u)==0:
+ continue
+ user = u.split(":")
+ if len(user) < 3:
+ continue
+ if user[0] == "root":
+ role="user"
+ else:
+ role=user[0]
+ self.adduser(udict, user[0], user[1], role)
+ if user[0] == "root":
+ role="user"
+ else:
+ role=user[0]
+ self.adduser(udict, user[0], user[1], role)
return udict
def getHomeDirContext(self, user, home, role):
@@ -362,9 +216,8 @@
@@ -362,9 +214,8 @@
return ret + rc[1] + "\n"
def getUserContext(self, user, sel_user, role):
@ -336,7 +333,7 @@ diff --exclude-from=exclude -N -u -r nsapolicycoreutils/scripts/genhomedircon po
def genHomeDirContext(self):
users = self.getUsers()
@@ -478,10 +331,6 @@
@@ -478,10 +329,6 @@
if type==None:
type=getSELinuxType(directory)

View File

@ -3,7 +3,7 @@
Summary: SELinux policy core utilities.
Name: policycoreutils
Version: 1.27.27
Release: 3
Release: 4
License: GPL
Group: System Environment/Base
Source: http://www.nsa.gov/selinux/archives/policycoreutils-%{version}.tgz
@ -88,6 +88,9 @@ rm -rf ${RPM_BUILD_ROOT}
%config(noreplace) %{_sysconfdir}/sestatus.conf
%changelog
* Mon Nov 14 2005 Dan Walsh <dwalsh@redhat.com> 1.27.27-4
- Fix genhomedircon to work with non libsemanage systems
* Fri Nov 11 2005 Dan Walsh <dwalsh@redhat.com> 1.27.27-3
- Patch genhomedircon to use libsemanage.py stuff