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

View File

@ -3,7 +3,7 @@
Summary: SELinux policy core utilities. Summary: SELinux policy core utilities.
Name: policycoreutils Name: policycoreutils
Version: 1.27.27 Version: 1.27.27
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
@ -88,6 +88,9 @@ rm -rf ${RPM_BUILD_ROOT}
%config(noreplace) %{_sysconfdir}/sestatus.conf %config(noreplace) %{_sysconfdir}/sestatus.conf
%changelog %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 * Fri Nov 11 2005 Dan Walsh <dwalsh@redhat.com> 1.27.27-3
- Patch genhomedircon to use libsemanage.py stuff - Patch genhomedircon to use libsemanage.py stuff