python/semanage: document and export the user labeling prefix
Stephen Smalley
maintainerPATCH v2 1/1 python/semanage: document and export the user labeling prefix
semanage user -l has always printed a Labeling / Prefix column and semanage user -a/-m -P PREFIX has always set it (stored in users_extra as 'user NAME prefix PREFIX;' and consumed by genhomedircon for the ROLE template substitution and homedir_role selection), but -P has been argparse-suppressed and undocumented since the 2013 argparse conversion, and seluserRecords.customized() does not emit it, so 'semanage export | semanage import' silently resets any non-default prefix to 'user'.
Give -P a real --help string, document it in semanage-user(8), and have customized() emit '-P PREFIX' when the stored prefix differs from the 'user' default so export/import round-trips.
---
v2 adds a space in the man page to prevent bolding (8).
python/semanage/semanage | 3 ++- python/semanage/semanage-user.8 | 10 +++++++++- python/semanage/seobject.py | 8 +++++--- 3 files changed, 16 insertions(+), 5 deletions(-)
python/semanage/semanage +2 -1
@@ -416,7 +416,8 @@ def setupUserParser(subparsers): userParser.add_argument('-R', '--roles', default=[], action=CheckRole, help=_("SELinux Roles. You must enclose multiple roles within quotes, separate by spaces. Or specify -R multiple times.")) - userParser.add_argument('-P', '--prefix', default="user", help=argparse.SUPPRESS) + userParser.add_argument('-P', '--prefix', default="user", + help=_("Labeling prefix for the SELinux user, used by genhomedircon when generating home directory labels. Defaults to 'user'.")) userParser.add_argument('selinux_name', nargs='?', default=None, help=_('selinux_name')) userParser.set_defaults(func=handleUser)
python/semanage/semanage-user.8 +9 -1
@@ -2,7 +2,7 @@ .SH "NAME" .B semanage\-user \- SELinux Policy Management SELinux User mapping tool .SH "SYNOPSIS" -.B semanage user [\-h] [\-n] [\-N] [\-S STORE] [ \-\-add ( \-L LEVEL \-R ROLES \-r RANGE SEUSER) | \-\-delete SEUSER | \-\-deleteall | \-\-extract | \-\-list [\-C] | \-\-modify ( \-L LEVEL \-R ROLES \-r RANGE SEUSER ) ] +.B semanage user [\-h] [\-n] [\-N] [\-S STORE] [ \-\-add ( \-L LEVEL \-R ROLES \-r RANGE \-P PREFIX SEUSER) | \-\-delete SEUSER | \-\-deleteall | \-\-extract | \-\-list [\-C] | \-\-modify ( \-L LEVEL \-R ROLES \-r RANGE \-P PREFIX SEUSER ) ] .SH "DESCRIPTION" semanage is used to configure certain elements of
@@ -54,6 +54,14 @@ MLS/MCS Security Range (MLS/MCS Systems only) SELinux Range for SELinux login ma .TP .I \-R [ROLES], \-\-roles [ROLES] SELinux Roles. You must enclose multiple roles within quotes, separate by spaces. Or specify \-R multiple times. +.TP +.I \-P PREFIX, \-\-prefix PREFIX +Labeling prefix for the SELinux user, stored in +.I users_extra +and used by +.BR genhomedircon (8) +when generating home directory context entries. Defaults to +.BR user . .SH EXAMPLE .nf
python/semanage/seobject.py +5 -3
@@ -1043,10 +1043,12 @@ class seluserRecords(semanageRecords): l = [] ddict = self.get_all(True) for k in sorted(ddict.keys()): - if ddict[k][1] or ddict[k][2]: - l.append("-a -L %s -r %s -R '%s' %s" % (ddict[k][1], ddict[k][2], ddict[k][3], k)) + prefix, level, srange, roles = ddict[k] + popt = "-P %s " % prefix if prefix and prefix != "user" else "" + if level or srange: + l.append("-a %s-L %s -r %s -R '%s' %s" % (popt, level, srange, roles, k)) else: - l.append("-a -R '%s' %s" % (ddict[k][3], k)) + l.append("-a %s-R '%s' %s" % (popt, roles, k)) return l def list(self, heading=1, locallist=0):
Signature · 1 line
2.55.0
Stephen Smalley
maintainerQuoted 14 lines · Stephen Smalley
semanage user -l has always printed a Labeling / Prefix column and semanage user -a/-m -P PREFIX has always set it (stored in
users_extraas 'user NAME prefix PREFIX;' and consumed by genhomedircon for the ROLE template substitution andhomedir_roleselection), but -P has been argparse-suppressed and undocumented since the 2013 argparse conversion, andseluserRecords.customized()does not emit it, so 'semanage export | semanage import' silently resets any non-default prefix to 'user'.Give -P a real --help string, document it in semanage-user(8), and have
customized()emit '-P PREFIX' when the stored prefix differs from the 'user' default so export/import round-trips.
Quoted 5 lines
Reported-by Laurent Bigonville <[email protected]>Signed-off-by Stephen Smalley <[email protected]>---
v2 adds a space in the man page to prevent bolding (8).
This has been merged.