Skip to contentSkip to conversation

genhomedircon

PATCH Russell Coker 1 participant 1 message Jul 19, 2004

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

The attached patch fixes a bug in genhomedircon.

Without this if you create system users with "useradd -r" and give them home directories in unusual locations (such as /usr/DIR or /var/run/DIR) then a file_contexts file will be generated that will mess up your system.

This match makes it check /etc/login.defs for the value of UID_MIN.

Also perhaps we should make STARTING_UID default to 500. 500 is the default value for this in Fedora.

Signature · 4 lines
http://www.coker.com.au/selinux/   My NSA Security Enhanced Linux packages
http://www.coker.com.au/bonnie++/  Bonnie++ hard drive benchmark
http://www.coker.com.au/postal/    Postal SMTP/POP benchmark
http://www.coker.com.au/~russell/  My home page
usr/sbin/genhomedircon renamed from genhomedircon +6 -1
@@ -25,7 +25,6 @@
 import commands, sys, os, pwd, string
 
 EXCLUDE_LOGINS=["/sbin/nologin", "/bin/false"]
-STARTING_UID=100
 
 def getPrefixes():
 	ulist = pwd.getpwall()
@@ -92,6 +91,12 @@
 		print len(sys.argv)
 		usage("Incorrect parameters")
 
+	rc=commands.getstatusoutput("grep -h '^UID_MIN' /etc/login.defs | sed -e 's/^UID_MIN[^0-9]*//'")
+	if rc[0] == 0:
+		STARTING_UID=rc[1]
+	else:
+		STARTING_UID=100
+
 	FILECONTEXTDIR=sys.argv[1]
 	prefixes = getPrefixes()