From: Petr Lautrbach <lautrbach@redhat.com>
To: "Christian Göttsche" <cgoettsche@seltendoof.de>, selinux@vger.kernel.org
Cc: "Christian Göttsche" <cgzones@googlemail.com>
Subject: Re: [PATCH v2] semanage: improve -e documentation and fix delete operation
Date: Tue, 10 Jun 2025 09:36:40 +0200 [thread overview]
Message-ID: <871prsf3p3.fsf@redhat.com> (raw)
In-Reply-To: <87sel733v4.fsf@redhat.com>
Petr Lautrbach <lautrbach@redhat.com> writes:
> Christian Göttsche <cgoettsche@seltendoof.de> writes:
>
>> From: Christian Göttsche <cgzones@googlemail.com>
>>
>> Improve the documentation around the -e/--equal option for semanage
>> fcontext.
>>
>> Closes: https://github.com/SELinuxProject/selinux/issues/457
>> Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
Acked-by: Petr Lautrbach <lautrbach@redhat.com>
Merged with the missing ','
Thanks.
>> ---
>> v2: drop delete_equal() addition
>> ---
>> python/semanage/semanage | 13 +++++++------
>> python/semanage/semanage-fcontext.8 | 6 +++---
>> 2 files changed, 10 insertions(+), 9 deletions(-)
>>
>> diff --git a/python/semanage/semanage b/python/semanage/semanage
>> index b269b9fc..dd5066bf 100644
>> --- a/python/semanage/semanage
>> +++ b/python/semanage/semanage
>> @@ -54,7 +54,7 @@ usage_login = "semanage login [-h] [-n] [-N] [-S STORE] ["
>> usage_login_dict = {' --add': ('-s SEUSER', '-r RANGE', 'LOGIN',), ' --modify': ('-s SEUSER', '-r RANGE', 'LOGIN',), ' --delete': ('LOGIN',), ' --list': ('-C',), ' --extract': ('',), ' --deleteall': ('',)}
>>
>> usage_fcontext = "semanage fcontext [-h] [-n] [-N] [-S STORE] ["
>> -usage_fcontext_dict = {' --add': ('(', '-t TYPE', '-f FTYPE', '-r RANGE', '-s SEUSER', '|', '-e EQUAL', ')', 'FILE_SPEC',), ' --delete': ('(', '-t TYPE', '-f FTYPE', '|', '-e EQUAL', ')', 'FILE_SPEC',), ' --modify': ('(', '-t TYPE', '-f FTYPE', '-r RANGE', '-s SEUSER', '|', '-e EQUAL', ')', 'FILE_SPEC',), ' --list': ('[-C]',), ' --extract': ('',), ' --deleteall': ('',)}
>> +usage_fcontext_dict = {' --add': ('(', '-t TYPE', '-f FTYPE', '-r RANGE', '-s SEUSER', '|', '-e TARGET_PATH', ')', 'FILE_SPEC',), ' --delete': ('(', '-t TYPE', '-f FTYPE', '|', '-e TARGET_PATH', ')', 'FILE_SPEC',), ' --modify': ('(', '-t TYPE', '-f FTYPE', '-r RANGE', '-s SEUSER', '|', '-e TARGET_PATH', ')', 'FILE_SPEC',), ' --list': ('[-C]',), ' --extract': ('',), ' --deleteall': ('',)}
>>
>> usage_user = "semanage user [-h] [-n] [-N] [-S STORE] ["
>> usage_user_dict = {' --add': ('(', '-L LEVEL', '-R ROLES', '-r RANGE', 'SEUSER', ')'), ' --delete': ('SEUSER',), ' --modify': ('(', '-L LEVEL', '-R ROLES', '-r RANGE', '-s SEUSER', 'SEUSER', ')'), ' --list': ('-C',), ' --extract': ('',), ' --deleteall': ('',)}
>> @@ -306,7 +306,7 @@ def setupLoginParser(subparsers):
>> def handleFcontext(args):
>> fcontext_args = {'list': [('equal', 'ftype', 'seuser', 'type'), ('')], 'add': [('locallist'), ('type', 'file_spec')], 'modify': [('locallist'), ('type', 'file_spec')], 'delete': [('locallist'), ('file_spec')], 'extract': [('locallist', 'equal', 'ftype', 'seuser', 'type'), ('')], 'deleteall': [('locallist'), ('')]}
>> # we can not use mutually for equal because we can define some actions together with equal
>> - fcontext_equal_args = {'equal': [('list', 'locallist', 'type', 'ftype', 'seuser', 'deleteall', 'extract'), ()]}
>> + fcontext_equal_args = {'equal': [('list', 'locallist', 'type', 'ftype', 'seuser', 'deleteall', 'extract'), ('file_spec')]}
>>
>> if args.action and args.equal:
>> handle_opts(args, fcontext_equal_args, "equal")
>> @@ -355,9 +355,10 @@ def setupFcontextParser(subparsers):
>> parser_add_extract(fcontext_action, "fcontext")
>> parser_add_deleteall(fcontext_action, "fcontext")
>>
>> - fcontextParser.add_argument('-e', '--equal', help=_(
>> - 'Substitute target path with sourcepath when generating default label. This is used with fcontext. Requires source and target \
>> -path arguments. The context labeling for the target subtree is made equivalent to that defined for the source.'
>> + fcontextParser.add_argument('-e', '--equal', metavar='TARGET_PATH' help=_(
>> + 'Substitute FILE_SPEC with TARGET_PATH for file label lookup. This is used with fcontext. Requires source and target \
>> +path arguments to be path prefixes and does not support regular expressions. \
>> +The context labeling for the target subtree is made equivalent to that defined for the source.'
>> ))
>> fcontextParser.add_argument('-f', '--ftype', default="", choices=["a", "f", "d", "c", "b", "s", "l", "p"], help=_(
>> 'File Type. This is used with fcontext. Requires a file type as shown in the mode field by ls, e.g. use d to match only \
>
> # semanage fcontext -h
> File "/usr/sbin/semanage", line 358
> fcontextParser.add_argument('-e', '--equal', metavar='TARGET_PATH' help=_(
> ^^^^^^^^^^^^^^^^^^
> SyntaxError: invalid syntax. Perhaps you forgot a comma?
>
>
>
>
>> @@ -368,7 +369,7 @@ If you do not specify a file type, the file type will default to "all files".'
>> parser_add_seuser(fcontextParser, "fcontext")
>> parser_add_type(fcontextParser, "fcontext")
>> parser_add_range(fcontextParser, "fcontext")
>> - fcontextParser.add_argument('file_spec', nargs='?', default=None, help=_('Path to be labeled (may be in the form of a Perl compatible regular expression)'))
>> + fcontextParser.add_argument('file_spec', nargs='?', default=None, metavar='FILE_SPEC', help=_('Path to be labeled (may be in the form of a Perl compatible regular expression)'))
>> fcontextParser.set_defaults(func=handleFcontext)
>>
>>
>> diff --git a/python/semanage/semanage-fcontext.8 b/python/semanage/semanage-fcontext.8
>> index 3e327d88..3a96c62f 100644
>> --- a/python/semanage/semanage-fcontext.8
>> +++ b/python/semanage/semanage-fcontext.8
>> @@ -3,7 +3,7 @@
>> semanage\-fcontext \- SELinux Policy Management file context tool
>>
>> .SH "SYNOPSIS"
>> -.B semanage fcontext [\-h] [\-n] [\-N] [\-S STORE] [ \-\-add ( \-t TYPE \-f FTYPE \-r RANGE \-s SEUSER | \-e EQUAL ) FILE_SPEC | \-\-delete ( \-t TYPE \-f FTYPE | \-e EQUAL ) FILE_SPEC | \-\-deleteall | \-\-extract | \-\-list [\-C] | \-\-modify ( \-t TYPE \-f FTYPE \-r RANGE \-s SEUSER | \-e EQUAL ) FILE_SPEC ]
>> +.B semanage fcontext [\-h] [\-n] [\-N] [\-S STORE] [ \-\-add ( \-t TYPE \-f FTYPE \-r RANGE \-s SEUSER | \-e TARGET_PATH ) FILE_SPEC | \-\-delete ( \-t TYPE \-f FTYPE | \-e TARGET_PATH ) FILE_SPEC | \-\-deleteall | \-\-extract | \-\-list [\-C] | \-\-modify ( \-t TYPE \-f FTYPE \-r RANGE \-s SEUSER | \-e TARGET_PATH ) FILE_SPEC ]
>>
>> .SH "DESCRIPTION"
>> semanage is used to configure certain elements of
>> @@ -66,8 +66,8 @@ Extract customizable commands, for use within a transaction
>> .I \-D, \-\-deleteall
>> Remove all local customizations
>> .TP
>> -.I \-e EQUAL, \-\-equal EQUAL
>> -Substitute target path with sourcepath when generating default label. This is used with fcontext. Requires source and target path arguments. The context labeling for the target subtree is made equivalent to that defined for the source.
>> +.I \-e TARGET_PATH, \-\-equal TARGET_PATH
>> +Substitute FILE_SPEC with TARGET_PATH for file label lookup. This is used with fcontext. Requires source and target path arguments to be path prefixes and does not support regular expressions. The context labeling for the target subtree is made equivalent to that defined for the source.
>> .TP
>> .I \-f [{a,f,d,c,b,s,l,p}], \-\-ftype [{a,f,d,c,b,s,l,p}]
>> File Type. This is used with fcontext. Requires a file type as shown in the mode field by ls, e.g. use 'd' to match only directories or 'f' to match only regular files. The following file type options can be passed: f (regular file),d (directory),c (character device), b (block device),s (socket),l (symbolic link),p (named pipe). If you do not specify a file type, the file type will default to "all files".
>> --
>> 2.47.1
prev parent reply other threads:[~2025-06-10 7:36 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-14 15:52 [PATCH v2] semanage: improve -e documentation and fix delete operation Christian Göttsche
2025-05-14 10:04 ` Petr Lautrbach
2025-06-10 7:36 ` Petr Lautrbach [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=871prsf3p3.fsf@redhat.com \
--to=lautrbach@redhat.com \
--cc=cgoettsche@seltendoof.de \
--cc=cgzones@googlemail.com \
--cc=selinux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).