21f11b3
From 10cfbd2825e12efdc0faa872987d5987e02e7eae Mon Sep 17 00:00:00 2001
21f11b3
From: Vit Mojzis <vmojzis@redhat.com>
21f11b3
Date: Thu, 1 Jun 2023 16:39:11 +0200
21f11b3
Subject: [PATCH] policycoreutils: Add examples to man pages
21f11b3
21f11b3
While at it, remove trailing whitespaces.
21f11b3
21f11b3
Signed-off-by: Vit Mojzis <vmojzis@redhat.com>
21f11b3
Acked-by: Petr Lautrbach <lautrbach@redhat.com>
21f11b3
---
21f11b3
 policycoreutils/scripts/fixfiles.8          | 34 +++++++++++++--------
21f11b3
 policycoreutils/secon/secon.1               | 12 ++++++--
21f11b3
 policycoreutils/semodule/semodule.8         | 14 ++++-----
21f11b3
 policycoreutils/setfiles/restorecon.8       |  9 ++++++
21f11b3
 policycoreutils/setfiles/restorecon_xattr.8 |  7 +++++
21f11b3
 policycoreutils/setfiles/setfiles.8         |  9 ++++++
21f11b3
 policycoreutils/setsebool/setsebool.8       | 16 +++++++---
21f11b3
 7 files changed, 74 insertions(+), 27 deletions(-)
21f11b3
21f11b3
diff --git a/policycoreutils/scripts/fixfiles.8 b/policycoreutils/scripts/fixfiles.8
21f11b3
index 9a317d91..928b8200 100644
21f11b3
--- a/policycoreutils/scripts/fixfiles.8
21f11b3
+++ b/policycoreutils/scripts/fixfiles.8
21f11b3
@@ -14,7 +14,7 @@ fixfiles \- fix file SELinux security contexts.
21f11b3
 .B fixfiles
21f11b3
 .I [\-v] [\-F] [\-B | \-N time ] [\-T nthreads] { check | restore | verify }
21f11b3
 
21f11b3
-.B fixfiles 
21f11b3
+.B fixfiles
21f11b3
 .I [\-v] [\-F] [\-T nthreads] \-R rpmpackagename[,rpmpackagename...] { check | restore | verify }
21f11b3
 
21f11b3
 .B fixfiles
21f11b3
@@ -31,7 +31,7 @@ This manual page describes the
21f11b3
 script.
21f11b3
 .P
21f11b3
 This script is primarily used to correct the security context
21f11b3
-database (extended attributes) on filesystems.  
21f11b3
+database (extended attributes) on filesystems.
21f11b3
 .P
21f11b3
 It can also be run at any time to relabel when adding support for
21f11b3
 new policy, or  just check whether the file contexts are all
21f11b3
@@ -41,29 +41,29 @@ option.  You can use the \-R flag to use rpmpackages as an alternative.
21f11b3
 The file /etc/selinux/fixfiles_exclude_dirs can contain a list of directories
21f11b3
 excluded from relabeling.
21f11b3
 .P
21f11b3
-.B fixfiles onboot 
21f11b3
+.B fixfiles onboot
21f11b3
 will setup the machine to relabel on the next reboot.
21f11b3
 
21f11b3
 .SH "OPTIONS"
21f11b3
-.TP 
21f11b3
+.TP
21f11b3
 .B \-B
21f11b3
 If specified with onboot, this fixfiles will record the current date in the /.autorelabel file, so that it can be used later to speed up labeling. If used with restore, the restore will only affect files that were modified today.
21f11b3
 .TP
21f11b3
 .B \-F
21f11b3
 Force reset of context to match file_context for customizable files
21f11b3
 
21f11b3
-.TP 
21f11b3
+.TP
21f11b3
 .B \-f
21f11b3
 Clear /tmp directory with out prompt for removal.
21f11b3
 
21f11b3
-.TP 
21f11b3
+.TP
21f11b3
 .B \-R rpmpackagename[,rpmpackagename...]
21f11b3
 Use the rpm database to discover all files within the specified packages and restore the file contexts.
21f11b3
 .TP
21f11b3
 .B \-C PREVIOUS_FILECONTEXT
21f11b3
 Run a diff on  the PREVIOUS_FILECONTEXT file to the currently installed one, and restore the context of all affected files.
21f11b3
 
21f11b3
-.TP 
21f11b3
+.TP
21f11b3
 .B \-N time
21f11b3
 Only act on files created after the specified date.  Date must be specified in
21f11b3
 "YYYY\-MM\-DD HH:MM" format.  Date field will be passed to find \-\-newermt command.
21f11b3
@@ -83,19 +83,28 @@ Use parallel relabeling, see
21f11b3
 
21f11b3
 .SH "ARGUMENTS"
21f11b3
 One of:
21f11b3
-.TP 
21f11b3
+.TP
21f11b3
 .B check | verify
21f11b3
 print any incorrect file context labels, showing old and new context, but do not change them.
21f11b3
-.TP 
21f11b3
+.TP
21f11b3
 .B restore
21f11b3
 change any incorrect file context labels.
21f11b3
-.TP 
21f11b3
+.TP
21f11b3
 .B relabel
21f11b3
 Prompt for removal of contents of /tmp directory and then change any incorrect file context labels to match the install file_contexts file.
21f11b3
-.TP 
21f11b3
-.B [[dir/file] ... ] 
21f11b3
+.TP
21f11b3
+.B [[dir/file] ... ]
21f11b3
 List of files or directories trees that you wish to check file context on.
21f11b3
 
21f11b3
+.SH EXAMPLE
21f11b3
+.nf
21f11b3
+Relabel the whole filesystem, except paths listed in /etc/selinux/fixfiles_exclude_dirs
21f11b3
+# fixfiles relabel
21f11b3
+Schedule the machine to relabel on the next boot and force relabeling of customizable types
21f11b3
+# fixfiles -F onboot
21f11b3
+Check labeling of all files from the samba package (while not changing any labels)
21f11b3
+# fixfiles -R samba check
21f11b3
+
21f11b3
 .SH "AUTHOR"
21f11b3
 This man page was written by Richard Hally <rhally@mindspring.com>.
21f11b3
 The script  was written by Dan Walsh <dwalsh@redhat.com>
21f11b3
@@ -103,4 +112,3 @@ The script  was written by Dan Walsh <dwalsh@redhat.com>
21f11b3
 .SH "SEE ALSO"
21f11b3
 .BR setfiles (8),
21f11b3
 .BR restorecon (8)
21f11b3
-
21f11b3
diff --git a/policycoreutils/secon/secon.1 b/policycoreutils/secon/secon.1
21f11b3
index 501b5cb8..c0e8b05a 100644
21f11b3
--- a/policycoreutils/secon/secon.1
21f11b3
+++ b/policycoreutils/secon/secon.1
21f11b3
@@ -107,16 +107,24 @@ then the context will be read from stdin.
21f11b3
 .br
21f11b3
 If there is no argument,
21f11b3
 .B secon
21f11b3
-will try reading a context from stdin, if that is not a tty, otherwise 
21f11b3
+will try reading a context from stdin, if that is not a tty, otherwise
21f11b3
 .B secon
21f11b3
 will act as though \fB\-\-self\fR had been passed.
21f11b3
 .PP
21f11b3
 If none of \fB\-\-user\fR, \fB\-\-role\fR, \fB\-\-type\fR, \fB\-\-level\fR or
21f11b3
 \fB\-\-mls\-range\fR is passed.
21f11b3
 Then all of them will be output.
21f11b3
+
21f11b3
+.SH EXAMPLE
21f11b3
+.nf
21f11b3
+Show SElinux context of the init process
21f11b3
+# secon --pid 1
21f11b3
+Parse the type portion of given security context
21f11b3
+# secon -t system_u:object_r:httpd_sys_rw_content_t:s0
21f11b3
+
21f11b3
 .PP
21f11b3
 .SH SEE ALSO
21f11b3
 .BR chcon (1)
21f11b3
 .SH AUTHORS
21f11b3
 .nf
21f11b3
-James Antill (james.antill@redhat.com) 
21f11b3
+James Antill (james.antill@redhat.com)
21f11b3
diff --git a/policycoreutils/semodule/semodule.8 b/policycoreutils/semodule/semodule.8
21f11b3
index c56e580f..01757b00 100644
21f11b3
--- a/policycoreutils/semodule/semodule.8
21f11b3
+++ b/policycoreutils/semodule/semodule.8
21f11b3
@@ -1,5 +1,5 @@
21f11b3
 .TH SEMODULE "8" "Nov 2005" "Security Enhanced Linux" NSA
21f11b3
-.SH NAME 
21f11b3
+.SH NAME
21f11b3
 semodule \- Manage SELinux policy modules.
21f11b3
 
21f11b3
 .SH SYNOPSIS
21f11b3
@@ -8,7 +8,7 @@ semodule \- Manage SELinux policy modules.
21f11b3
 .SH DESCRIPTION
21f11b3
 .PP
21f11b3
 semodule is the tool used to manage SELinux policy modules,
21f11b3
-including installing, upgrading, listing and removing modules.  
21f11b3
+including installing, upgrading, listing and removing modules.
21f11b3
 semodule may also be used to force a rebuild of policy from the
21f11b3
 module store and/or to force a reload of policy without performing
21f11b3
 any other transaction.  semodule acts on module packages created
21f11b3
@@ -39,7 +39,7 @@ install/replace a module package
21f11b3
 .B  \-u,\-\-upgrade=MODULE_PKG
21f11b3
 deprecated, alias for --install
21f11b3
 .TP
21f11b3
-.B  \-b,\-\-base=MODULE_PKG   
21f11b3
+.B  \-b,\-\-base=MODULE_PKG
21f11b3
 deprecated, alias for --install
21f11b3
 .TP
21f11b3
 .B  \-r,\-\-remove=MODULE_NAME
21f11b3
@@ -77,7 +77,7 @@ name of the store to operate on
21f11b3
 .B  \-n,\-\-noreload,\-N
21f11b3
 do not reload policy after commit
21f11b3
 .TP
21f11b3
-.B  \-h,\-\-help        
21f11b3
+.B  \-h,\-\-help
21f11b3
 prints help message and quit
21f11b3
 .TP
21f11b3
 .B \-P,\-\-preserve_tunables
21f11b3
@@ -92,7 +92,7 @@ Use an alternate path for the policy root
21f11b3
 .B \-S,\-\-store-path
21f11b3
 Use an alternate path for the policy store root
21f11b3
 .TP
21f11b3
-.B  \-v,\-\-verbose     
21f11b3
+.B  \-v,\-\-verbose
21f11b3
 be verbose
21f11b3
 .TP
21f11b3
 .B  \-c,\-\-cil
21f11b3
@@ -131,8 +131,6 @@ $ semodule \-B
21f11b3
 $ semodule \-d alsa
21f11b3
 # Install a module at a specific priority.
21f11b3
 $ semodule \-X 100 \-i alsa.pp
21f11b3
-# List all modules.
21f11b3
-$ semodule \-\-list=full
21f11b3
 # Set an alternate path for the policy root
21f11b3
 $ semodule \-B \-p "/tmp"
21f11b3
 # Set an alternate path for the policy store root
21f11b3
@@ -143,6 +141,8 @@ $ semodule \-X 400 \-\-hll \-E puppet \-\-cil \-E wireshark
21f11b3
 # Check whether a module in "localmodule.pp" file is same as installed module "localmodule"
21f11b3
 $ /usr/libexec/selinux/hll/pp localmodule.pp | sha256sum
21f11b3
 $ semodule -l -m | grep localmodule
21f11b3
+# Translate binary module file into CIL (useful for debugging installation errors)
21f11b3
+$ /usr/libexec/selinux/hll/pp alsa.pp > alsa.cil
21f11b3
 .fi
21f11b3
 
21f11b3
 .SH SEE ALSO
21f11b3
diff --git a/policycoreutils/setfiles/restorecon.8 b/policycoreutils/setfiles/restorecon.8
21f11b3
index dbd55ce7..6160aced 100644
21f11b3
--- a/policycoreutils/setfiles/restorecon.8
21f11b3
+++ b/policycoreutils/setfiles/restorecon.8
21f11b3
@@ -224,6 +224,15 @@ and provided the
21f11b3
 option is NOT set and recursive mode is set, files will be relabeled as
21f11b3
 required with the digests then being updated provided there are no errors.
21f11b3
 
21f11b3
+.SH EXAMPLE
21f11b3
+.nf
21f11b3
+Fix labeling of /var/www/ including all sub-directories and list all context changes
21f11b3
+# restorecon -rv /var/www/
21f11b3
+List mislabeled files in user home directory and what the correct label should be
21f11b3
+# restorecon -nvr ~
21f11b3
+Fix labeling of files listed in file_list file, ignoring any that do not exist
21f11b3
+# restorecon -vif file_list
21f11b3
+
21f11b3
 .SH "AUTHOR"
21f11b3
 This man page was written by Dan Walsh <dwalsh@redhat.com>.
21f11b3
 Some of the content of this man page was taken from the setfiles
21f11b3
diff --git a/policycoreutils/setfiles/restorecon_xattr.8 b/policycoreutils/setfiles/restorecon_xattr.8
21f11b3
index 4b1ce304..09bfd8c4 100644
21f11b3
--- a/policycoreutils/setfiles/restorecon_xattr.8
21f11b3
+++ b/policycoreutils/setfiles/restorecon_xattr.8
21f11b3
@@ -112,6 +112,13 @@ If the option is not specified, then the default file_contexts will be used.
21f11b3
 .br
21f11b3
 the pathname of the directory tree to be searched.
21f11b3
 
21f11b3
+.SH EXAMPLE
21f11b3
+.nf
21f11b3
+List all paths that where assigned a checksum by "restorecon/setfiles -D"
21f11b3
+# restorecon_xattr -r /
21f11b3
+Remove all non-matching checksums
21f11b3
+# restorecon_xattr -rd /
21f11b3
+
21f11b3
 .SH "SEE ALSO"
21f11b3
 .BR restorecon (8),
21f11b3
 .BR setfiles (8)
21f11b3
diff --git a/policycoreutils/setfiles/setfiles.8 b/policycoreutils/setfiles/setfiles.8
21f11b3
index 36fe6b36..6071d9ba 100644
21f11b3
--- a/policycoreutils/setfiles/setfiles.8
21f11b3
+++ b/policycoreutils/setfiles/setfiles.8
21f11b3
@@ -289,6 +289,15 @@ and provided the
21f11b3
 option is NOT set, files will be relabeled as required with the digests then
21f11b3
 being updated provided there are no errors.
21f11b3
 
21f11b3
+.SH EXAMPLE
21f11b3
+.nf
21f11b3
+Fix labeling of /var/www/ including all sub-directories, using targeted policy file context definitions and list all context changes
21f11b3
+# setfiles -v /etc/selinux/targeted/contexts/files/file_contexts /var/www/
21f11b3
+List mislabeled files in user home directory and what the label should be based on targeted policy file context definitions
21f11b3
+# setfiles -nv /etc/selinux/targeted/contexts/files/file_contexts ~
21f11b3
+Fix labeling of files listed in file_list file, ignoring any that do not exist
21f11b3
+# setfiles -vif file_list /etc/selinux/targeted/contexts/files/file_contexts
21f11b3
+
21f11b3
 .SH "AUTHOR"
21f11b3
 This man page was written by Russell Coker <russell@coker.com.au>.
21f11b3
 The program was written by Stephen Smalley <sds@tycho.nsa.gov>
21f11b3
diff --git a/policycoreutils/setsebool/setsebool.8 b/policycoreutils/setsebool/setsebool.8
21f11b3
index 52936f5a..f54664fb 100644
21f11b3
--- a/policycoreutils/setsebool/setsebool.8
21f11b3
+++ b/policycoreutils/setsebool/setsebool.8
21f11b3
@@ -7,13 +7,13 @@ setsebool \- set SELinux boolean value
21f11b3
 .I "[ \-PNV ] boolean value | bool1=val1 bool2=val2 ..."
21f11b3
 
21f11b3
 .SH "DESCRIPTION"
21f11b3
-.B setsebool 
21f11b3
-sets the current state of a particular SELinux boolean or a list of booleans 
21f11b3
-to a given value. The value may be 1 or true or on to enable the boolean, or 0 or false or off to disable it. 
21f11b3
+.B setsebool
21f11b3
+sets the current state of a particular SELinux boolean or a list of booleans
21f11b3
+to a given value. The value may be 1 or true or on to enable the boolean, or 0 or false or off to disable it.
21f11b3
 
21f11b3
 Without the \-P option, only the current boolean value is
21f11b3
-affected; the boot-time default settings 
21f11b3
-are not changed. 
21f11b3
+affected; the boot-time default settings
21f11b3
+are not changed.
21f11b3
 
21f11b3
 If the \-P option is given, all pending values are written to
21f11b3
 the policy file on disk. So they will be persistent across reboots.
21f11b3
@@ -22,6 +22,12 @@ If the \-N option is given, the policy on disk is not reloaded into the kernel.
21f11b3
 
21f11b3
 If the \-V option is given, verbose error messages will be printed from semanage libraries.
21f11b3
 
21f11b3
+.SH EXAMPLE
21f11b3
+.nf
21f11b3
+Enable container_use_devices boolean (will return to persistent value after reboot)
21f11b3
+# setsebool container_use_devices 1
21f11b3
+Persistently enable samba_create_home_dirs and samba_enable_home_dirs booleans
21f11b3
+# setsebool -P samba_create_home_dirs=on samba_enable_home_dirs=on
21f11b3
 
21f11b3
 .SH AUTHOR
21f11b3
 This manual page was written by Dan Walsh <dwalsh@redhat.com>.
21f11b3
-- 
21f11b3
2.40.0
21f11b3