sed: report SELinux status in --version output

Report whether sed was built with SELinux support (determined at compile
time), and whether it is enabled on this system (determined at runtime).

Relates to https://bugs.gnu.org/35997 .

* sed/sed.c (selinux_support): New function, print SELinux status to
stdout. (main): Call selinux_support on --version.
This commit is contained in:
Assaf Gordon committed 2019-06-02 01:11:19 -06:00
1 parent 2a7125a8b3
commit 07ef8a3138
1 file changed
+18
+18
View File
@@ -29,6 +29,7 @@
#include "progname.h"
#include "version.h"
#include "xalloc.h"
#include <selinux/selinux.h>
#include "version-etc.h"
@@ -130,6 +131,22 @@ General help using GNU software: <https://www.gnu.org/gethelp/>.\n"));
fprintf (out, _("E-mail bug reports to: <%s>.\n"), PACKAGE_BUGREPORT);
}
static void
selinux_support (void)
{
putchar ('\n');
#if HAVE_SELINUX_SELINUX_H
puts (_("This sed program was built with SELinux support."));
if (is_selinux_enabled())
puts (_("SELinux is enabled on this system."));
else
puts (_("SELinux is disabled on this system."));
#else
puts (_("This sed program was built without SELinux support."));
#endif
putchar ('\n');
}
_Noreturn static void
usage (int status)
{
@@ -344,6 +361,7 @@ main (int argc, char **argv)
case 'v':
version_etc (stdout, program_name, PACKAGE_NAME, Version,
AUTHORS, (char *) NULL);
selinux_support ();
contact (false);
ck_fclose (NULL);
exit (EXIT_SUCCESS);