Bug 1388331 - semodule doesn't support input from stdin
Summary: semodule doesn't support input from stdin
Keywords:
Status: CLOSED CANTFIX
Alias: None
Product: Fedora
Classification: Fedora
Component: policycoreutils
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
low
Target Milestone: ---
Assignee: Petr Lautrbach
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-10-25 07:00 UTC by Dominik 'Rathann' Mierzejewski
Modified: 2016-10-25 13:34 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-10-25 07:12:12 UTC
Type: Bug


Attachments (Terms of Use)

Description Dominik 'Rathann' Mierzejewski 2016-10-25 07:00:00 UTC
Description of problem:
semodule -i doesn't support input from stdin

Version-Release number of selected component (if applicable):
policycoreutils-2.5-13.fc24.x86_64

How reproducible:
Always.

Steps to Reproduce:
# echo '(allow psad_t psad_var_log_t(file (read rename unlink write)))' | semodule -i
semodule: option requires an argument -- 'i'
usage:  semodule [options]... MODE [MODES]...
[...]
# echo '(allow psad_t psad_var_log_t(file (read rename unlink write)))' | semodule -i -
libsemanage.map_file: Unable to open -
 (No such file or directory).
libsemanage.semanage_direct_install_file: Unable to read file -
 (No such file or directory).
semodule:  Failed on -!

Expected results:
Successful policy import.

Additional info:
This would be useful in rpm scriptlets while avoiding temporary file creation. For now, I'm using this:

TMPDIR=$(%{_bindir}/mktemp -d)
cat >> $TMPDIR/psad-rpm.cil << __EOF__
(allow psad_t psad_var_log_t(file (read rename unlink write)))
__EOF__
%{_sbindir}/semodule -i $TMPDIR/psad-rpm.cil
rm $TMPDIR/psad-rpm.cil && rmdir $TMPDIR

Comment 1 Petr Lautrbach 2016-10-25 07:12:12 UTC
'semodule -i'  uses a filename as a module name and for detection if the module uses pp or cil language. In your case, 'semodule -i -' would create a module called '-' and wouldn't know what if it's cil or pp.

Comment 2 Dominik 'Rathann' Mierzejewski 2016-10-25 13:25:37 UTC
Well, how about adding command line options to set the module name and the "language" together with stdin input support?

Comment 3 Petr Lautrbach 2016-10-25 13:34:37 UTC
Please send your ideas and rationale to upstream mailing list at selinux.gov 

When it's accepted we can backport it to Fedora.


Note You need to log in before you can comment on or make changes to this bug.