Skip to contentSkip to conversation

Contributed manual pages for libselinux

PATCH In review Guido Trentalancia 3 participants 10 messages Nov 2, 2009 – Nov 28, 2009 SELinux security module

lore
Share & tools
lore
#0 lore raw

Hello !

I found from http://userspace.selinuxproject.org/trac/wiki/Todo that the following manual pages were missing for libselinux:

* matchpathcon_checkmatches
* matchpathcon_filespec_add
* matchpathcon_filespec_destroy
* matchpathcon_filespec_eval
* matchpathcon_index
* matchpathcon_init_prefix
* print_access_vector
security_canonicalize_context
* security_disable
* security_set_boolean_list
* selinux_check_passwd_access
selinux_customizable_types_path
selinux_get_callback
* selinux_init_load_policy
* selinux_lsetfilecon_default
* selinux_mkload_policy
selinux_raw_to_trans_context
selinux_trans_to_raw_context
selinux_translations_path
selinux_users_path
* set_selinuxmnt

So, I have contributed the ones marked with a "*" in the attached patch. I might do the rest at a later time, if possible (and if needed).

Guido Trentalancia

diff -pruN libselinux/man/man3/fini_selinuxmnt.3 libselinux-new/man/man3/fini_selinuxmnt.3
--- libselinux/man/man3/fini_selinuxmnt.3 1970-01-01 01:00:00.000000000
+0100
+++ libselinux-new/man/man3/fini_selinuxmnt.3 2009-11-03
00:09:04.000000000 +0100
@@ -0,0 +1 @@
+.so man3/init_selinuxmnt.3
diff -pruN libselinux/man/man3/init_selinuxmnt.3 libselinux-new/man/man3/init_selinuxmnt.3
--- libselinux/man/man3/init_selinuxmnt.3 1970-01-01 01:00:00.000000000
+0100
+++ libselinux-new/man/man3/init_selinuxmnt.3 2009-11-03
00:30:08.000000000 +0100
@@ -0,0 +1,31 @@
+.\" Hey Emacs! This file is -*- nroff -*- source.
+.\"
+.\" Author: Guido Trentalancia ([email protected]) 2009 +.TH "init_selinuxmnt" "3" "02 Nov 2009" "" "SELinux API documentation" +.SH "NAME"
+init_selinuxmnt \- initialize the global variable selinux_mnt. +
+.SH "SYNOPSIS"
+.BI "static void init_selinuxmnt(void);"
+.sp
+.BI "static void fini_selinuxmnt(void);"
+.sp
+.BI "void set_selinuxmnt(char *" mnt ");"
+
+.SH "DESCRIPTION"
+.B init_selinuxmnt
+initializes the global variable selinux_mnt to the selinuxfs mountpoint.
+
+.B fini_selinuxmnt
+deinitializes the global variable selinux_mnt that stores the selinuxfs +mountpoint.
+
+.B set_selinuxmnt
+changes the selinuxfs mountpoint to
+.I mnt.
+
+.SH "AUTHOR"
+This manual page has been written by Guido Trentalancia <[email protected]>
+
+.SH "SEE ALSO"
+.BR selinux (8),
diff -pruN libselinux/man/man3/matchpathcon.3 libselinux-new/man/man3/matchpathcon.3
--- libselinux/man/man3/matchpathcon.3 2009-11-01 22:23:01.000000000
+0100
+++ libselinux-new/man/man3/matchpathcon.3 2009-11-03 00:44:53.000000000
+0100
@@ -7,21 +7,35 @@ matchpathcon \- get the default SELinux
.sp
.BI "int matchpathcon_init(const char *" path ");"

+.BI "int matchpathcon_init_prefix(const char *" path ", const char *" subset ");"
+
.BI "int matchpathcon_fini(void);"

-.BI "int matchpathcon(const char *" path ", mode_t " mode ", security_context_t *" con);
+.BI "int matchpathcon(const char *" path ", mode_t " mode ", security_context_t *" con ");
+.sp
+
+.BI "int matchpathcon_index(const char *" name ", mode_t " mode ", security_context_t * " con ");"
+
+.BI "int matchpathcon_filespec_add(ino_t " ino ", int " specind ", const char *" file ");"
+
+.BI "void matchpathcon_filespec_destroy(void);"
+
+.BI "void matchpathcon_filespec_eval(void);"
+
+.BI "void matchpathcon_checkmatches(char *" str ");"
.sp

.BI "void set_matchpathcon_printf(void (*" f ")(const char *" fmt
", ...));"

-.BI "void set_matchpathcon_invalidcon(int (*" f ")(const char *"path ", unsigned " lineno ", char * " context "));"
+.BI "void set_matchpathcon_invalidcon(int (*" f ")(const char *" path ", unsigned " lineno ", char * " context "));"

.BI "void set_matchpathcon_flags(unsigned int " flags ");"

-.BI "int selinux_file_context_cmp(const security_context_t a,
- const security_context_t b);"
+.BI "int selinux_file_context_cmp(const security_context_t " a ", const security_context_t " b ");"

-.BI "int selinux_file_context_verify(const char *path, mode_t mode);" +.BI "int selinux_file_context_verify(const char *" path ", mode_t " mode ");"
+
+.BI "int selinux_lsetfilecon_default(const char *" path ");"

.SH "DESCRIPTION"
.B matchpathcon_init
@@ -44,7 +58,16 @@ and
.B .local
suffix are also looked up and loaded if present. These files provide dynamically generated entries for user home directories and for local
-customizations.
+customizations. Returns zero on success or \-1 on error.
+
+.sp
+.B matchpathcon_init_prefix
+is the same as
+.B matchpathcon_init
+but only loads entries with regexes that have stems that are prefixes +of
+.I prefix.
+Returns zero on success or \-1 on error.

.sp
.B matchpathcon_fini
@@ -78,6 +101,43 @@ its first invocation with a NULL
defaulting to the active file contexts configuration. .sp

+.B matchpathcon_index
+is the same as
+.B matchpathcon
+but returns a specification index that can be used later in a +.B matchpathcon_filespec_add
+call.
+.sp
+
+.B matchpathcon_filespec_add
+maintains an association between an inode
+.I ino
+and a specification index
+.I specind,
+and checks whether a conflicting specification is already associated +with the same inode (e.g. due to multiple hard links). If so, then +it uses the latter of the two specifications based on their order in the
+.I file
+context configuration. Returns the specification index used or \-1 on +error.
+.sp
+
+.B matchpathcon_filespec_destroy
+destroys any inode associations that have been added, e.g. to restart +for a new filesystem.
+.sp
+
+.B matchpathcon_filespec_eval
+displays statistics on the hash table usage for the inode associations. +.sp
+
+.B matchpathcon_checkmatches
+checks whether any specification has no matches and reports them. +The
+.I str
+argument is used as a prefix for any warning messages.
+.sp
+
.B set_matchpathcon_printf
sets the function used by
.B matchpathcon_init
@@ -98,7 +158,7 @@ This can be set to instead perform check
e.g. using
.B sepol_check_context(3),
as is done by
-.B setfiles -c.
+.B setfiles \-c.
The function is also responsible for reporting any such error, and may include the
.I path
@@ -122,10 +182,13 @@ compares two file contexts to see if the
.sp
.B selinux_file_context_verify
compares the file context on disk to the system default.
+.sp
+.B selinux_lsetfilecon_default
+sets the file context to the system defaults.

.sp
.SH "RETURN VALUE"
-Returns 0 on success or -1 otherwise.
+Returns zero on success or \-1 otherwise.

.SH "SEE ALSO"
.BR selinux "(8), " freecon "(3), " setfilecon "(3), " setfscreatecon
"(3)"
diff -pruN libselinux/man/man3/matchpathcon_checkmatches.3 libselinux-new/man/man3/matchpathcon_checkmatches.3
--- libselinux/man/man3/matchpathcon_checkmatches.3 1970-01-01
01:00:00.000000000 +0100
+++ libselinux-new/man/man3/matchpathcon_checkmatches.3 2009-11-02
17:54:56.000000000 +0100
@@ -0,0 +1 @@
+.so man3/matchpathcon.3
diff -pruN libselinux/man/man3/print_access_vector.3 libselinux-new/man/man3/print_access_vector.3
--- libselinux/man/man3/print_access_vector.3 1970-01-01
01:00:00.000000000 +0100
+++ libselinux-new/man/man3/print_access_vector.3 2009-11-02
19:34:40.000000000 +0100
@@ -0,0 +1 @@
+.so man3/security_class_to_string.3
diff -pruN libselinux/man/man3/security_class_to_string.3 libselinux-new/man/man3/security_class_to_string.3
--- libselinux/man/man3/security_class_to_string.3 2009-11-01
22:23:01.000000000 +0100
+++ libselinux-new/man/man3/security_class_to_string.3 2009-11-03
00:23:55.000000000 +0100
@@ -6,6 +6,8 @@
security_class_to_string, security_av_perm_to_string,
string_to_security_class, string_to_av_perm, security_av_string \- convert
between SELinux class and permission values and string names.

+print_access_vector \- display an access vector in human-readable form.
+
.SH "SYNOPSIS"
.B #include <selinux/selinux.h>

@@ -20,6 +22,8 @@ between SELinux class and permission val
.BI "security_class_t string_to_security_class(const char *" name ");" .sp
.BI "access_vector_t string_to_av_perm(security_class_t " tclass ",
const char *" name ");"
+.sp
+.BI "void print_access_vector(security_class_t " tclass ", access_vector_t " av ");"

.SH "DESCRIPTION"
.B security_class_to_string
@@ -56,11 +60,17 @@ and security class
.IR tclass ,
or zero if no such value exists.

+.B print_access_vector
+displays an access vector in human-readable form on the standard output +stream.
+
.SH "RETURN VALUE"
.B security_av_string
-returns returns zero on success or \-1 on error with +returns zero on success or \-1 on error with
.I errno
-set appropriately. All other functions return zero or NULL on error. +set appropriately.
+.B print_access_vector
+does not return a value. All other functions return zero or NULL on error.

.SH "ERRORS"
.TP
diff -pruN libselinux/man/man3/security_compute_av.3 libselinux-new/man/man3/security_compute_av.3
--- libselinux/man/man3/security_compute_av.3 2009-11-01
22:23:01.000000000 +0100
+++ libselinux-new/man/man3/security_compute_av.3 2009-11-02
23:34:49.000000000 +0100
@@ -24,6 +24,8 @@ the SELinux policy database in the kerne
.BI "int security_get_initial_context(const char *" name ",
security_context_t
"con );
.sp
+.BI "int selinux_check_passwd_access(access_vector_t " requested ); +.sp
.BI "int checkPasswdAccess(access_vector_t " requested );

.SH "DESCRIPTION"
@@ -65,18 +67,29 @@ instance.

.B security_compute_user
is used to determine the set of user contexts that can be reached from
a
-source context. Is mainly used by
+source context. It is mainly used by
.B get_ordered_context_list.

.B security_get_initial_context
is used to get the context of a kernel initial security identifier
specified by
.I name

+.B selinux_check_passwd_access
+is used to check for a permission in the
+.I passwd
+class.
+.B selinux_check_passwd_access
+uses getprevcon() for the source and target security contexts. +
+.B checkPasswdAccess
+is a helper function that allows you to check for a permission in the +.I passwd
+class.
.B checkPasswdAccess
-This functions is a helper functions that allows you to check for a permission in the passwd class. checkPasswdAccess uses getprevcon() for the source and target security contexts.
+uses getprevcon() for the source and target security contexts.

.SH "RETURN VALUE"
-0 for success and on error -1 is returned.
+0 for success and on error \-1 is returned.

.SH "SEE ALSO"
.BR selinux "(8), " getcon "(3), " getfilecon "(3), "
get_ordered_context_list "(3)"
diff -pruN libselinux/man/man3/security_disable.3 libselinux-new/man/man3/security_disable.3
--- libselinux/man/man3/security_disable.3 1970-01-01 01:00:00.000000000
+0100
+++ libselinux-new/man/man3/security_disable.3 2009-11-03
00:30:18.000000000 +0100
@@ -0,0 +1,26 @@
+.\" Hey Emacs! This file is -*- nroff -*- source.
+.\"
+.\" Author: Guido Trentalancia ([email protected]) 2009 +.TH "security_disable" "3" "02 Nov 2009" "" "SELinux API documentation" +.SH "NAME"
+security_disable \- disable the SELinux kernel code at runtime. +
+.SH "SYNOPSIS"
+.B #include <selinux/selinux.h>
+.sp
+.BI "int security_disable(void);"
+
+.SH "DESCRIPTION"
+.B security_disable
+disables the SELinux kernel code, unregisters selinuxfs from /proc/filesystems,
+and then umounts /selinux.
+
+.SH "RETURN VALUE"
+.B security_disable
+returns returns zero on success or \-1 on error.
+
+.SH "AUTHOR"
+This manual page has been written by Guido Trentalancia <[email protected]>
+
+.SH "SEE ALSO"
+.BR selinux (8),
diff -pruN libselinux/man/man3/security_load_booleans.3 libselinux-new/man/man3/security_load_booleans.3
--- libselinux/man/man3/security_load_booleans.3 2009-11-01
22:23:01.000000000 +0100
+++ libselinux-new/man/man3/security_load_booleans.3 2009-11-02
20:23:28.000000000 +0100
@@ -6,17 +6,19 @@ security_get_boolean_pending \- routines
.SH "SYNOPSIS"
.B #include <selinux/selinux.h>
.sp
-extern int security_load_booleans(char *path);
-
-extern int security_get_boolean_names(char ***names, int *len); -
-extern int security_get_boolean_pending(const char *name); -
-extern int security_get_boolean_active(const char *name);
-
-extern int security_set_boolean(const char *name, int value); -
-extern int security_commit_booleans(void);
+.BI "int security_load_booleans(char *" path ");"
+.sp
+.BI "int security_get_boolean_names(char ***" names ", int *" len ");" +.sp
+.BI "int security_get_boolean_pending(const char *" name ");" +.sp
+.BI "int security_get_boolean_active(const char *" name ");" +.sp
+.BI "int security_set_boolean(const char *" name ", int " value ");" +.sp
+.BI "int security_set_boolean_list(size_t " boolcnt ", SELboolean *" boollist ", int " permanent ");"
+.sp
+.BI "int security_commit_booleans(void);"

.SH "DESCRIPTION"
@@ -26,31 +28,37 @@ disabled based on the current values of
These policy booleans allow runtime modification of the security policy without having to load a new policy.

-The SELinux API allows for a transaction based update. So you can set several boolean values and the commit them all at once.
+The SELinux API allows for a transaction based update. So you can +set several boolean values and then commit them all at once. +
+.B security_load_booleans
+
+loads policy boolean settings. Path may be NULL, in which case the +booleans are loaded from the active policy boolean configuration file.

-security_load_booleans
+.B security_get_boolean_names

-Load policy boolean settings. Path may be NULL, in which case the booleans are loaded from the active policy boolean configuration file. +returns a list of boolean names, currently supported by the loaded policy.

-security_get_boolean_names
+.B security_get_boolean_pending

-Returns a list of boolean names, currently supported by the loaded policy.
+returns pending value for boolean

-security_set_boolean
+.B security_get_boolean_active

-Sets the pending value for boolean
+returns active value for boolean

-security_get_boolean_pending
+.B security_set_boolean

-Return pending value for boolean
+sets the pending value for boolean

-security_get_boolean_active
+.B security_set_boolean_list

-Return active value for boolean
+saves a list of booleans in a single transaction.

-security_commit_booleans
+.B security_commit_booleans

-Commit all pending values for the booleans.
+commits all pending values for the booleans.

.SH AUTHOR
This manual page was written by Dan Walsh <[email protected]>.
diff -pruN libselinux/man/man3/security_load_policy.3 libselinux-new/man/man3/security_load_policy.3
--- libselinux/man/man3/security_load_policy.3 2009-11-01
22:23:01.000000000 +0100
+++ libselinux-new/man/man3/security_load_policy.3 2009-11-03
00:30:45.000000000 +0100
@@ -1,14 +1,46 @@
-.TH "security_load_policy" "3" "1 January 2004" "[email protected]" "SELinux API documentation"
+.TH "security_load_policy" "3" "3 November 2009" "[email protected]" "SELinux API documentation"
.SH "NAME"
security_load_policy \- load a new SELinux policy
.SH "SYNOPSIS"
.B #include <selinux/selinux.h>
.sp
.BI "int security_load_policy(void *" data ", size_t "len );
+.sp
+.BI "int selinux_mkload_policy(int " preservebools ");" +.sp
+.BI "int selinux_init_load_policy(int *" enforce ");"

.SH "DESCRIPTION"
.B security_load_policy
-loads a new policy, returns 0 for success and -1 for error. +loads a new policy, returns 0 for success and \-1 for error. +
+.B selinux_mkload_policy
+makes a policy image and loads it. This function provides a higher level
+interface for loading policy than
+.B security_load_policy,
+internally determining the right policy version, locating and opening +the policy file, mapping it into memory, manipulating it as needed for +current boolean settings and/or local definitions, and then calling +security_load_policy to load it.
+.I preservebools
+is a boolean flag indicating whether current policy boolean values should
+be preserved into the new policy (if 1) or reset to the saved policy +settings (if 0). The former case is the default for policy reloads, while
+the latter case is an option for policy reloads but is primarily used for
+the initial policy load.
+.B selinux_init_load_policy
+performs the initial policy load. This function determines the desired +enforcing mode, sets the
+.I enforce
+argument accordingly for the caller to use, sets the SELinux kernel +enforcing status to match it, and loads the policy. It also internally +handles the initial selinuxfs mount required to perform these actions. +
+.SH "RETURN VALUE"
+returns zero on success or \-1 on error.
+
+.SH "AUTHOR"
+This manual page has been written by Guido Trentalancia <[email protected]>

.SH "SEE ALSO"
.BR selinux "(8)"
diff -pruN libselinux/man/man3/security_mkload_policy.3 libselinux-new/man/man3/security_mkload_policy.3
--- libselinux/man/man3/security_mkload_policy.3 1970-01-01
01:00:00.000000000 +0100
+++ libselinux-new/man/man3/security_mkload_policy.3 2009-11-03
00:21:00.000000000 +0100
@@ -0,0 +1 @@
+.so man3/security_load_policy.3
diff -pruN libselinux/man/man3/selinux_lsetfilecon_default.3 libselinux-new/man/man3/selinux_lsetfilecon_default.3
--- libselinux/man/man3/selinux_lsetfilecon_default.3 1970-01-01
01:00:00.000000000 +0100
+++ libselinux-new/man/man3/selinux_lsetfilecon_default.3 2009-11-03
00:45:13.000000000 +0100
@@ -0,0 +1 @@
+.so man3/matchpathcon.3
diff -pruN libselinux/man/man3/set_selinuxmnt.3 libselinux-new/man/man3/set_selinuxmnt.3
--- libselinux/man/man3/set_selinuxmnt.3 1970-01-01 01:00:00.000000000
+0100
+++ libselinux-new/man/man3/set_selinuxmnt.3 2009-11-03
00:08:40.000000000 +0100
@@ -0,0 +1 @@
+.so man3/init_selinuxmnt.3

man/man3/fini_selinuxmnt.3 +1 -0
diff -pruN libselinux/man/man3/fini_selinuxmnt.3 libselinux-new/man/man3/fini_selinuxmnt.3
@@ -0,0 +1 @@
+.so man3/init_selinuxmnt.3
man/man3/init_selinuxmnt.3 +31 -0
diff -pruN libselinux/man/man3/init_selinuxmnt.3 libselinux-new/man/man3/init_selinuxmnt.3
@@ -0,0 +1,31 @@
+.\" Hey Emacs! This file is -*- nroff -*- source.
+.\"
+.\" Author: Guido Trentalancia ([email protected]) 2009
+.TH "init_selinuxmnt" "3" "02 Nov 2009" "" "SELinux API documentation"
+.SH "NAME"
+init_selinuxmnt \- initialize the global variable selinux_mnt.
+
+.SH "SYNOPSIS"
+.BI "static void init_selinuxmnt(void);"
+.sp
+.BI "static void fini_selinuxmnt(void);"
+.sp
+.BI "void set_selinuxmnt(char *" mnt ");"
+
+.SH "DESCRIPTION"
+.B init_selinuxmnt 
+initializes the global variable selinux_mnt to the selinuxfs mountpoint.
+
+.B fini_selinuxmnt
+deinitializes the global variable selinux_mnt that stores the selinuxfs
+mountpoint.
+
+.B set_selinuxmnt
+changes the selinuxfs mountpoint to
+.I mnt. 
+
+.SH "AUTHOR"
+This manual page has been written by Guido Trentalancia <[email protected]>
+
+.SH "SEE ALSO"
+.BR selinux (8),
man/man3/matchpathcon.3 +71 -8

122 lines not on this page · raw message

man/man3/matchpathcon_checkmatches.3 +1 -0
diff -pruN libselinux/man/man3/matchpathcon_checkmatches.3 libselinux-new/man/man3/matchpathcon_checkmatches.3
@@ -0,0 +1 @@
+.so man3/matchpathcon.3
man/man3/print_access_vector.3 +1 -0
diff -pruN libselinux/man/man3/print_access_vector.3 libselinux-new/man/man3/print_access_vector.3
@@ -0,0 +1 @@
+.so man3/security_class_to_string.3
man/man3/security_class_to_string.3 +12 -2
diff -pruN libselinux/man/man3/security_class_to_string.3 libselinux-new/man/man3/security_class_to_string.3
@@ -6,6 +6,8 @@
 security_class_to_string, security_av_perm_to_string, string_to_security_class, string_to_av_perm, security_av_string \- convert
 between SELinux class and permission values and string names.
 
+print_access_vector \- display an access vector in human-readable form. 
+
 .SH "SYNOPSIS"
 .B #include <selinux/selinux.h>
 
@@ -20,6 +22,8 @@ between SELinux class and permission val
 .BI "security_class_t string_to_security_class(const char *" name ");"
 .sp
 .BI "access_vector_t string_to_av_perm(security_class_t " tclass ", const char *" name ");"
+.sp
+.BI "void print_access_vector(security_class_t " tclass ", access_vector_t " av ");"
 
 .SH "DESCRIPTION"
 .B security_class_to_string
@@ -56,11 +60,17 @@ and security class
 .IR tclass ,
 or zero if no such value exists.
 
+.B print_access_vector
+displays an access vector in human-readable form on the standard output
+stream.
+
 .SH "RETURN VALUE"
 .B security_av_string
-returns returns zero on success or \-1 on error with
+returns zero on success or \-1 on error with
 .I errno
-set appropriately.  All other functions return zero or NULL on error.
+set appropriately.
+.B print_access_vector
+does not return a value. All other functions return zero or NULL on error.
 
 .SH "ERRORS"
 .TP
man/man3/security_compute_av.3 +16 -3
diff -pruN libselinux/man/man3/security_compute_av.3 libselinux-new/man/man3/security_compute_av.3
@@ -24,6 +24,8 @@ the SELinux policy database in the kerne
 .BI "int security_get_initial_context(const char *" name ", security_context_t
 "con );
 .sp
+.BI "int selinux_check_passwd_access(access_vector_t " requested );
+.sp
 .BI "int checkPasswdAccess(access_vector_t " requested );
 
 .SH "DESCRIPTION"
@@ -65,18 +67,29 @@ instance.
 
 .B security_compute_user
 is used to determine the set of user contexts that can be reached from a
-source context. Is mainly used by
+source context. It is mainly used by
 .B get_ordered_context_list.
 
 .B security_get_initial_context
 is used to get the context of a kernel initial security identifier specified by 
 .I name
 
+.B selinux_check_passwd_access
+is used to check for a permission in the
+.I passwd
+class.
+.B selinux_check_passwd_access
+uses getprevcon() for the source and target security contexts.
+
+.B checkPasswdAccess
+is a helper function that allows you to check for a permission in the
+.I passwd
+class.
 .B checkPasswdAccess
-This functions is a helper functions that allows you to check for a permission in the passwd class. checkPasswdAccess uses getprevcon() for the source and target security contexts.
+uses getprevcon() for the source and target security contexts.
 
 .SH "RETURN VALUE"
-0 for success and on error -1 is returned.
+0 for success and on error \-1 is returned.
 
 .SH "SEE ALSO"
 .BR selinux "(8), " getcon "(3), " getfilecon "(3), " get_ordered_context_list "(3)"
man/man3/security_disable.3 +26 -0
diff -pruN libselinux/man/man3/security_disable.3 libselinux-new/man/man3/security_disable.3
@@ -0,0 +1,26 @@
+.\" Hey Emacs! This file is -*- nroff -*- source.
+.\"
+.\" Author: Guido Trentalancia ([email protected]) 2009
+.TH "security_disable" "3" "02 Nov 2009" "" "SELinux API documentation"
+.SH "NAME"
+security_disable \- disable the SELinux kernel code at runtime.
+
+.SH "SYNOPSIS"
+.B #include <selinux/selinux.h>
+.sp
+.BI "int security_disable(void);"
+
+.SH "DESCRIPTION"
+.B security_disable
+disables the SELinux kernel code, unregisters selinuxfs from /proc/filesystems,
+and then umounts /selinux.
+
+.SH "RETURN VALUE"
+.B security_disable
+returns returns zero on success or \-1 on error.
+
+.SH "AUTHOR"
+This manual page has been written by Guido Trentalancia <[email protected]>
+
+.SH "SEE ALSO"
+.BR selinux (8),
man/man3/security_load_booleans.3 +32 -24

80 lines not on this page · raw message

man/man3/security_load_policy.3 +34 -2
diff -pruN libselinux/man/man3/security_load_policy.3 libselinux-new/man/man3/security_load_policy.3
@@ -1,14 +1,46 @@
-.TH "security_load_policy" "3" "1 January 2004" "[email protected]" "SELinux API documentation"
+.TH "security_load_policy" "3" "3 November 2009" "[email protected]" "SELinux API documentation"
 .SH "NAME"
 security_load_policy \- load a new SELinux policy
 .SH "SYNOPSIS"
 .B #include <selinux/selinux.h>
 .sp
 .BI "int security_load_policy(void *" data ", size_t "len );
+.sp
+.BI "int selinux_mkload_policy(int " preservebools ");"
+.sp
+.BI "int selinux_init_load_policy(int *" enforce ");"
 
 .SH "DESCRIPTION"
 .B security_load_policy
-loads a new policy, returns 0 for success and -1 for error.
+loads a new policy, returns 0 for success and \-1 for error.
+
+.B selinux_mkload_policy
+makes a policy image and loads it. This function provides a higher level
+interface for loading policy than
+.B security_load_policy,
+internally determining the right policy version, locating and opening
+the policy file, mapping it into memory, manipulating it as needed for
+current boolean settings and/or local definitions, and then calling
+security_load_policy to load it.
+.I preservebools
+is a boolean flag indicating whether current policy boolean values should
+be preserved into the new policy (if 1) or reset to the saved policy
+settings (if 0). The former case is the default for policy reloads, while
+the latter case is an option for policy reloads but is primarily used for
+the initial policy load.
+.B selinux_init_load_policy
+performs the initial policy load. This function determines the desired
+enforcing mode, sets the
+.I enforce
+argument accordingly for the caller to use, sets the SELinux kernel
+enforcing status to match it, and loads the policy. It also internally
+handles the initial selinuxfs mount required to perform these actions.
+
+.SH "RETURN VALUE"
+returns zero on success or \-1 on error.
+
+.SH "AUTHOR"
+This manual page has been written by Guido Trentalancia <[email protected]>
 
 .SH "SEE ALSO"
 .BR selinux "(8)"
man/man3/security_mkload_policy.3 +1 -0
diff -pruN libselinux/man/man3/security_mkload_policy.3 libselinux-new/man/man3/security_mkload_policy.3
@@ -0,0 +1 @@
+.so man3/security_load_policy.3
man/man3/selinux_lsetfilecon_default.3 +1 -0
diff -pruN libselinux/man/man3/selinux_lsetfilecon_default.3 libselinux-new/man/man3/selinux_lsetfilecon_default.3
@@ -0,0 +1 @@
+.so man3/matchpathcon.3
man/man3/set_selinuxmnt.3 +1 -0
diff -pruN libselinux/man/man3/set_selinuxmnt.3 libselinux-new/man/man3/set_selinuxmnt.3
@@ -0,0 +1 @@
+.so man3/init_selinuxmnt.3
#1 lore raw
Quoted 5 lines · Guido Trentalancia

Hello !

I found from http://userspace.selinuxproject.org/trac/wiki/Todo that the following manual pages were missing for libselinux:

[Added some cc's]

Hi, thanks for doing this. Some quick review below.

Quoted 7 lines

* matchpathcon_checkmatches
* matchpathcon_filespec_add
* matchpathcon_filespec_destroy
* matchpathcon_filespec_eval
* matchpathcon_index
* matchpathcon_init_prefix

There is too much in matchpathcon(3) now. It's going to need to be split up into different pages, perhaps the init/fini/teardown stuff in one page, the lookup calls in another, and the non-matchpathcon prefixed calls in a third page.

Also, .so manpage links are needed for all the calls here.

Quoted 2 lines

* print_access_vector

Looks good.

Quoted 2 lines

* security_disable

See the selinux.h comments for this. It needs to be documented that this function can only be called at startup time.

Quoted 2 lines

* security_set_boolean_list

a RETURN VALUE section is needed in this page, documenting at least this call if not the others in that page.

Quoted 2 lines

* selinux_check_passwd_access

This is a replacement for the inconsistently named "checkPasswdAccess" function. So, the existing description of checkPasswdAccess should be moved to this function, and checkPasswdAccess should be changed to "this is a deprecated alias for selinux_check_passwd_access".

Quoted 2 lines

* selinux_init_load_policy

A paragraph break is needed in the DESCRIPTION section before this function.

Quoted 2 lines

* selinux_lsetfilecon_default

See notes above about the matchpathcon manpage.

Quoted 2 lines

* selinux_mkload_policy

Looks good.

Quoted 2 lines

* set_selinuxmnt

This manpage includes two static functions that are not part of the libselinux API (at least, not anymore) and should be removed.

Also, I'm not comfortable with the description given. Instead, use the comments in selinux.h, which are more accurate and verbose.

Signature · 8 lines
Eamon Walsh 
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#2 lore raw

Hello Eamon !

Quoted 1 line · Eamon Walsh

Hi, thanks for doing this. Some quick review below.

You are welcome, I suppose it was a boring task for many...

Thanks very much for reviewing the changes. And please accept my apologies for not placing "[PATCH]" in the subject of the original post. I had just subscribed to the list.

I left you cc address intact here...

Quoted 6 lines

There is too much in matchpathcon(3) now. It's going to need to be split up into different pages, perhaps the init/fini/teardown stuff in one page, the lookup calls in another, and the non-matchpathcon prefixed calls in a third page.

Also, .so manpage links are needed for all the calls here.

Yes, matchpathcon is a mess. Following your guidelines, I have now splitted the huge and messy page in several different man pages. It's easier to consult and easier to maintain.

The first part (page) is strictly related to _init, its variant _init_index, _fini, matchpathcon and its variant matchpathcon_index. Nice and concise. References are provided in the "SEE ALSO" section to the rest.

The second page describes the auxiliary lookup calls (matchpathcon_checkmatches) and the inode associations functions (matchpathcon_filespec_{add,destroy,eval}). The reference section points to the main matchpathcon page.

A third page has been created for the functions that are used to set the flags (set_matchpathcon_flags) or to configure the behaviour of the main matchpathcon functions (set_matchpathcon_invalidcon and set_matchpathcon_printf).

A fourth and fifth page is devoted to functions that should never had ended up in matchpathcon (selinux_file_context_cmp and selinux_file_context_verify in one page and selinux_lsetfilecon_default in another one): we do not really need to save electrons needed for new pages...

Quoted 6 lines
Quoted 4 lines

* print_access_vector

Looks good.

No modifications.

Quoted 5 lines
Quoted 2 lines

* security_disable

See the selinux.h comments for this. It needs to be documented that this function can only be called at startup time.

Ok. I have stressed that now and also mentioned that after the policy has been loaded at startup, then only "setenforce" can be used to alter (not disable) the mode of the SELinux kernel code (for example by placing it into "permissive" mode).

Quoted 5 lines
Quoted 2 lines

* security_set_boolean_list

a RETURN VALUE section is needed in this page, documenting at least this call if not the others in that page.

I have now added a "RETURN VALUE" section.

Also, to avoid confusion, I have rephrased the word "returns" in "provides" when not strictly referring the to the return value of the function (take for example security_get_boolean_names(), strictly speaking the function returns an integer representing 0=success or -1=failure, although from a conceptual point of view it also returns a list trough modification of one of its parameters passed by reference).

Usually when an application developer looks at the "RETURN VALUE" section it is because he/she has already planned/coded the call to the function (and thus also the handling to parameters passed by reference) and only needs to check for the function exit status so that it can be handled properly at the call point.

Quoted 7 lines
Quoted 2 lines

* selinux_check_passwd_access

This is a replacement for the inconsistently named "checkPasswdAccess" function. So, the existing description of checkPasswdAccess should be moved to this function, and checkPasswdAccess should be changed to "this is a deprecated alias for selinux_check_passwd_access".

Yes, I have now mentioned that checkPasswdAccess is deprecated. We are referring to file security_compute_av.3 as the description of these two functions lives there...

By the way, it has been pointed out that this function should not hard-code a string. I also agree with him, there is a generic constant for such "passwd" object class, it is defined in flask.h could be used instead of the string, thus avoiding hard-coding and also allowing to save a few cycles and be theoretically future-proof (if ever the name would change, say to "password", "auth-token" or anything else).

--- libselinux/src/checkAccess.c.orig 2009-11-21 20:07:21.000000000
+0100
+++ libselinux/src/checkAccess.c 2009-11-21 20:08:36.000000000
+0100
@@ -13,17 +13,12 @@ int selinux_check_passwd_access(access_v

        if (is_selinux_enabled() == 0)
                return 0;
        if (getprevcon_raw(&user_context) == 0) {
-               security_class_t passwd_class;
                struct av_decision avd;
                int retval;

- passwd_class = string_to_security_class("passwd");
- if (passwd_class == 0)
- return 0;
-
retval = security_compute_av_raw(user_context,
user_context,
- passwd_class,
+ SECCLASS_PASSWD,

                                                     requested,
                                                     &avd);

Note that the above code, should really live in the application and not in the selinux library. It used to be like that, then for some reason it has been introduced. Redhat's passwd and cronie are calling the library function and thus at the moment they rely on it. But for example, util-linux-ng has the code in it and does not call this function, as I believe it should be. A very minor issue anyway...

Quoted 4 lines
Quoted 2 lines

* selinux_init_load_policy

A paragraph break is needed in the DESCRIPTION section before this function.

Done. I have also added a note to the already mentioned fact that after initial policy load, SELinux cannot be anymore disabled using calls to security_disable(3).

Quoted 4 lines
Quoted 2 lines

* selinux_lsetfilecon_default

See notes above about the matchpathcon manpage.

Yes, separate man page now.

Quoted 4 lines
Quoted 2 lines

* selinux_mkload_policy

Looks good.

No modifications.

Quoted 9 lines
Quoted 2 lines

* set_selinuxmnt

This manpage includes two static functions that are not part of the libselinux API (at least, not anymore) and should be removed.

Also, I'm not comfortable with the description given. Instead, use the comments in selinux.h, which are more accurate and verbose.

Please let me know if things are any better now.

I did also provide on the same day a patch for beautifying and improving the command-line option parsing of a few utilities (a ticket had been created by somebody). That patch provides those improvement according to GNU-style parsing of "help" and "version" options (including long-option variants). I think it also fixes a couple of typos here and there. Feel free to include that patch too if you like it, so that the ticket can be closed ! I will attach it again in another separate message: it has been slightly modified in order to apply cleanly to the latest git snapshot.

More important, I was also thinking about fingerprinting (and subsequently checking) the libraries with some cryptographic hash function such as the NIST-recommended SHA2. It is beginning to be done for security-related projects like OpenSSL, so I believe it is even more essential for SELinux. Ever thought about anything like that ?

Best regards,

Guido

libselinux/man/man3/fini_selinuxmnt.3 +1 -0
diff -pru --new-file selinux-dev-211109/libselinux/man/man3/fini_selinuxmnt.3 selinux-dev-211109-patched/libselinux/man/man3/fini_selinuxmnt.3
@@ -0,0 +1 @@
+.so man3/init_selinuxmnt.3
libselinux/man/man3/init_selinuxmnt.3 +28 -0
diff -pru --new-file selinux-dev-211109/libselinux/man/man3/init_selinuxmnt.3 selinux-dev-211109-patched/libselinux/man/man3/init_selinuxmnt.3
@@ -0,0 +1,28 @@
+.TH "init_selinuxmnt" "3" "21 Nov 2009" "" "SELinux API documentation"
+.SH "NAME"
+init_selinuxmnt \- initialize the global variable selinux_mnt.
+
+.SH "SYNOPSIS"
+.BI "static void init_selinuxmnt(void);"
+.sp
+.BI "static void fini_selinuxmnt(void);"
+.sp
+.BI "void set_selinuxmnt(char *" mnt ");"
+
+.SH "DESCRIPTION"
+.B init_selinuxmnt 
+initializes the global variable selinux_mnt to the selinuxfs mountpoint.
+
+.B fini_selinuxmnt
+deinitializes the global variable selinux_mnt that stores the selinuxfs
+mountpoint.
+
+.B set_selinuxmnt
+changes the selinuxfs mountpoint to
+.I mnt. 
+
+.SH "AUTHOR"
+This manual page has been written by Guido Trentalancia <[email protected]>
+
+.SH "SEE ALSO"
+.BR selinux (8),
libselinux/man/man3/matchpathcon.3 +28 -61

129 lines not on this page · raw message

libselinux/man/man3/matchpathcon_checkmatches.3 +52 -0

52 lines not on this page · raw message

libselinux/man/man3/matchpathcon_filespec_add.3 +1 -0
diff -pru --new-file selinux-dev-211109/libselinux/man/man3/matchpathcon_filespec_add.3 selinux-dev-211109-patched/libselinux/man/man3/matchpathcon_filespec_add.3
@@ -0,0 +1 @@
+.so man3/matchpathcon_checkmatches.3
libselinux/man/man3/matchpathcon_filespec_destroy.3 +1 -0
diff -pru --new-file selinux-dev-211109/libselinux/man/man3/matchpathcon_filespec_destroy.3 selinux-dev-211109-patched/libselinux/man/man3/matchpathcon_filespec_destroy.3
@@ -0,0 +1 @@
+.so man3/matchpathcon_checkmatches.3
libselinux/man/man3/matchpathcon_filespec_eval.3 +1 -0
diff -pru --new-file selinux-dev-211109/libselinux/man/man3/matchpathcon_filespec_eval.3 selinux-dev-211109-patched/libselinux/man/man3/matchpathcon_filespec_eval.3
@@ -0,0 +1 @@
+.so man3/matchpathcon_checkmatches.3
libselinux/man/man3/matchpathcon_index.3 +1 -0
diff -pru --new-file selinux-dev-211109/libselinux/man/man3/matchpathcon_index.3 selinux-dev-211109-patched/libselinux/man/man3/matchpathcon_index.3
@@ -0,0 +1 @@
+.so man3/matchpathcon.3
libselinux/man/man3/print_access_vector.3 +1 -0
diff -pru --new-file selinux-dev-211109/libselinux/man/man3/print_access_vector.3 selinux-dev-211109-patched/libselinux/man/man3/print_access_vector.3
@@ -0,0 +1 @@
+.so man3/security_class_to_string.3
libselinux/man/man3/security_class_to_string.3 +12 -2
diff -pru --new-file selinux-dev-211109/libselinux/man/man3/security_class_to_string.3 selinux-dev-211109-patched/libselinux/man/man3/security_class_to_string.3
@@ -6,6 +6,8 @@
 security_class_to_string, security_av_perm_to_string, string_to_security_class, string_to_av_perm, security_av_string \- convert
 between SELinux class and permission values and string names.
 
+print_access_vector \- display an access vector in human-readable form. 
+
 .SH "SYNOPSIS"
 .B #include <selinux/selinux.h>
 
@@ -20,6 +22,8 @@ between SELinux class and permission val
 .BI "security_class_t string_to_security_class(const char *" name ");"
 .sp
 .BI "access_vector_t string_to_av_perm(security_class_t " tclass ", const char *" name ");"
+.sp
+.BI "void print_access_vector(security_class_t " tclass ", access_vector_t " av ");"
 
 .SH "DESCRIPTION"
 .B security_class_to_string
@@ -56,11 +60,17 @@ and security class
 .IR tclass ,
 or zero if no such value exists.
 
+.B print_access_vector
+displays an access vector in human-readable form on the standard output
+stream.
+
 .SH "RETURN VALUE"
 .B security_av_string
-returns returns zero on success or \-1 on error with
+returns zero on success or \-1 on error with
 .I errno
-set appropriately.  All other functions return zero or NULL on error.
+set appropriately.
+.B print_access_vector
+does not return a value. All other functions return zero or NULL on error.
 
 .SH "ERRORS"
 .TP
libselinux/man/man3/security_compute_av.3 +14 -3
diff -pru --new-file selinux-dev-211109/libselinux/man/man3/security_compute_av.3 selinux-dev-211109-patched/libselinux/man/man3/security_compute_av.3
@@ -24,6 +24,8 @@ the SELinux policy database in the kerne
 .BI "int security_get_initial_context(const char *" name ", security_context_t
 "con );
 .sp
+.BI "int selinux_check_passwd_access(access_vector_t " requested );
+.sp
 .BI "int checkPasswdAccess(access_vector_t " requested );
 
 .SH "DESCRIPTION"
@@ -65,18 +67,27 @@ instance.
 
 .B security_compute_user
 is used to determine the set of user contexts that can be reached from a
-source context. Is mainly used by
+source context. It is mainly used by
 .B get_ordered_context_list.
 
 .B security_get_initial_context
 is used to get the context of a kernel initial security identifier specified by 
 .I name
 
+.B selinux_check_passwd_access
+is used to check for a permission in the
+.I passwd
+class.
+.B selinux_check_passwd_access
+uses getprevcon() for the source and target security contexts.
+
 .B checkPasswdAccess
-This functions is a helper functions that allows you to check for a permission in the passwd class. checkPasswdAccess uses getprevcon() for the source and target security contexts.
+is a deprecated alias of the
+.B selinux_check_passwd_access
+function.
 
 .SH "RETURN VALUE"
-0 for success and on error -1 is returned.
+Returns zero on success or \-1 on error.
 
 .SH "SEE ALSO"
 .BR selinux "(8), " getcon "(3), " getfilecon "(3), " get_ordered_context_list "(3)"
libselinux/man/man3/security_disable.3 +28 -0
diff -pru --new-file selinux-dev-211109/libselinux/man/man3/security_disable.3 selinux-dev-211109-patched/libselinux/man/man3/security_disable.3
@@ -0,0 +1,28 @@
+.TH "security_disable" "3" "21 Nov 2009" "" "SELinux API documentation"
+.SH "NAME"
+security_disable \- disable the SELinux kernel code at runtime.
+
+.SH "SYNOPSIS"
+.B #include <selinux/selinux.h>
+.sp
+.BI "int security_disable(void);"
+
+.SH "DESCRIPTION"
+.B security_disable
+disables the SELinux kernel code, unregisters selinuxfs from /proc/filesystems,
+and then unmounts /selinux.
+.sp
+This function can only be called at runtime and prior to the initial policy
+load. After the initial policy load, the SELinux kernel code cannot be disabled,
+but only placed in "permissive" mode by using
+.B setenforce(1).
+
+.SH "RETURN VALUE"
+.B security_disable
+returns zero on success or \-1 on error.
+
+.SH "AUTHOR"
+This manual page has been written by Guido Trentalancia <[email protected]>
+
+.SH "SEE ALSO"
+.BR selinux (8), " setenforce "(3)
libselinux/man/man3/security_load_booleans.3 +36 -24

84 lines not on this page · raw message

libselinux/man/man3/security_load_policy.3 +46 -3

61 lines not on this page · raw message

libselinux/man/man3/security_mkload_policy.3 +1 -0
diff -pru --new-file selinux-dev-211109/libselinux/man/man3/security_mkload_policy.3 selinux-dev-211109-patched/libselinux/man/man3/security_mkload_policy.3
@@ -0,0 +1 @@
+.so man3/security_load_policy.3
libselinux/man/man3/selinux_binary_policy_path.3 +1 -1
diff -pru --new-file selinux-dev-211109/libselinux/man/man3/selinux_binary_policy_path.3 selinux-dev-211109-patched/libselinux/man/man3/selinux_binary_policy_path.3
@@ -68,7 +68,7 @@ selinux_x_context_path() - file containi
 .sp
 selinux_netfilter_context_path - default netfilter context 
 .sp
-selinux_file_context_path() - default sysstem file contexts configuration
+selinux_file_context_path() - default system file contexts configuration
 .sp
 selinux_file_context_local_path() - local customization file contexts configuration
 .sp
libselinux/man/man3/selinux_check_passwd_access.3 +1 -0
diff -pru --new-file selinux-dev-211109/libselinux/man/man3/selinux_check_passwd_access.3 selinux-dev-211109-patched/libselinux/man/man3/selinux_check_passwd_access.3
@@ -0,0 +1 @@
+.so man3/security_compute_av.3
libselinux/man/man3/selinux_file_context_cmp.3 +25 -1
diff -pru --new-file selinux-dev-211109/libselinux/man/man3/selinux_file_context_cmp.3 selinux-dev-211109-patched/libselinux/man/man3/selinux_file_context_cmp.3
@@ -1 +1,25 @@
-.so man3/matchpathcon.3
+.TH "selinux_file_context_cmp" "3" "21 November 2009" "[email protected]" "SELinux API documentation"
+.SH "NAME"
+selinux_file_context_cmp, selinux_file_context_verify \- comparison of two file contexts.
+
+.SH "SYNOPSIS"
+.B #include <selinux/selinux.h>
+.sp
+
+.BI "int selinux_file_context_cmp(const security_context_t " a ", const security_context_t " b ");"
+
+.BI "int selinux_file_context_verify(const char *" path ", mode_t " mode ");"
+
+.SH "DESCRIPTION"
+.B selinux_file_context_cmp
+compares two file contexts to see if their differences are "significant", the function runs the strcmp function ignoring the user componant of the file context.  
+.sp
+.B selinux_file_context_verify
+compares the file context on disk to the system default.
+.sp
+
+.SH "RETURN VALUE"
+Returns zero on success or \-1 otherwise.
+
+.SH "SEE ALSO"
+.BR selinux "(8), " selinux_lsetfilecon "(3), " matchpathcon "(3), " freecon "(3), " setfilecon "(3), " setfscreatecon "(3)"
libselinux/man/man3/selinux_file_context_verify.3 +1 -1
diff -pru --new-file selinux-dev-211109/libselinux/man/man3/selinux_file_context_verify.3 selinux-dev-211109-patched/libselinux/man/man3/selinux_file_context_verify.3
@@ -1 +1 @@
-.so man3/matchpathcon.3
+.so man3/selinux_file_context_cmp.3
libselinux/man/man3/selinux_lsetfilecon_default.3 +20 -0
diff -pru --new-file selinux-dev-211109/libselinux/man/man3/selinux_lsetfilecon_default.3 selinux-dev-211109-patched/libselinux/man/man3/selinux_lsetfilecon_default.3
@@ -0,0 +1,20 @@
+.TH "selinux_lsetfilecon_default" "3" "21 November 2009" "[email protected]" "SELinux API documentation"
+.SH "NAME"
+selinux_lsetfilecon_default \- set the file context to the system defaults.
+
+.SH "SYNOPSIS"
+.B #include <selinux/selinux.h>
+.sp
+
+.BI "int selinux_lsetfilecon_default(const char *" path ");"
+
+.SH "DESCRIPTION"
+.B selinux_lsetfilecon_default
+sets the file context to the system defaults.
+.sp
+
+.SH "RETURN VALUE"
+Returns zero on success or \-1 otherwise.
+
+.SH "SEE ALSO"
+.BR selinux "(8), " selinux_file_context_cmp "(3), " selinux_file_context_verify "(3), " matchpathcon "(3), " freecon "(3), " setfilecon "(3), " setfscreatecon "(3)"
libselinux/man/man3/set_matchpathcon_flags.3 +62 -1

63 lines not on this page · raw message

libselinux/man/man3/set_matchpathcon_invalidcon.3 +1 -0
diff -pru --new-file selinux-dev-211109/libselinux/man/man3/set_matchpathcon_invalidcon.3 selinux-dev-211109-patched/libselinux/man/man3/set_matchpathcon_invalidcon.3
@@ -0,0 +1 @@
+.so man3/set_matchpathcon_flags.3
libselinux/man/man3/set_matchpathcon_printf.3 +1 -1
diff -pru --new-file selinux-dev-211109/libselinux/man/man3/set_matchpathcon_printf.3 selinux-dev-211109-patched/libselinux/man/man3/set_matchpathcon_printf.3
@@ -1 +1 @@
-.so man3/matchpathcon.3
+.so man3/set_matchpathcon_flags.3
libselinux/man/man3/set_selinuxmnt.3 +1 -0
diff -pru --new-file selinux-dev-211109/libselinux/man/man3/set_selinuxmnt.3 selinux-dev-211109-patched/libselinux/man/man3/set_selinuxmnt.3
@@ -0,0 +1 @@
+.so man3/init_selinuxmnt.3
#5 lore raw

PATCH 1/1 Support for long-options in policycoreutils and checkpolicy (Ticket #1 [1672486])

In reply to Eamon Walsh

Dear Eamon,

here are the two "maintenance" patches that I did post earlier this month (along with the new manual pages). They are intended to close Ticket #1 [1672486] that I found open on Tresys pages
(http://userspace.selinuxproject.org/trac/ticket/1).

I do apologize for not putting the keyword "[PATCH]" in the original message.

Here is a summary of what has been changed for policycoreutils:

- introduced proper handling of -h, -V options and their respective long formats --help and --version to all binaries that are produced from C code. The same issue is not tackled for Python-based tools (e.g. semanage);
- relative manual pages have also been updated accordingly.

And here is what has been changed for checkpolicy/checkmodule:

- introduced proper handling of -h, -V and the long formats --help and --version to all binaries (checkpolicy/checkmodule);
- introduced the handling of long options for some of the other available options;
- manual pages have also been updated accordingly (and a few undocumented options have been documented).

One of the original two patches (the one against policycoreutils) did not compile cleanly anymore against the current HEAD of SELinux, so I have created an updated one, which is the one attached here.

It's just a matter of some really minor issues, but I hope it helps, at least the ticket can now be closed...

Kind regards,

Guido

policycoreutils/load_policy/load_policy.8 +15 -1
diff -pruN selinux-dev-211109/policycoreutils/load_policy/load_policy.8 selinux-dev-211109-patched/policycoreutils/load_policy/load_policy.8
@@ -15,11 +15,25 @@ values in the policy file.
 
 .SH "OPTIONS"
 .TP
+.B \-V
+or
+.B \-\-version
+shows the current version of load_policy
+.TP
+.B \-h
+or
+.B \-\-help
+shows the usage information for load_policy
+.TP
 .B \-q
+or
+.B \-\-quiet
 suppress warning messages.
 .TP
 .B \-i
-inital policy load. Only use this if this is the first time policy is being loaded since boot (usually called from initramfs).
+or
+.B \-\-init
+initial policy load. Only use this if this is the first time policy is being loaded since boot (usually called from initramfs).
 
 .SH "EXIT STATUS"
 .TP
policycoreutils/load_policy/load_policy.c +43 -5

88 lines not on this page · raw message

policycoreutils/load_policy/Makefile +2 -1
diff -pruN selinux-dev-211109/policycoreutils/load_policy/Makefile selinux-dev-211109-patched/policycoreutils/load_policy/Makefile
@@ -5,8 +5,9 @@ USRSBINDIR ?= $(PREFIX)/sbin
 MANDIR ?= $(PREFIX)/share/man
 LOCALEDIR ?= /usr/share/locale
 
+VERSION = $(shell cat ../VERSION)
 CFLAGS ?= -Werror -Wall -W
-override CFLAGS += $(LDFLAGS) -I$(PREFIX)/include -DUSE_NLS -DLOCALEDIR="\"$(LOCALEDIR)\"" -DPACKAGE="\"policycoreutils\""
+override CFLAGS += $(LDFLAGS) -I$(PREFIX)/include -DUSE_NLS -DLOCALEDIR="\"$(LOCALEDIR)\"" -DPACKAGE="\"policycoreutils\"" -DVERSION=\"$(VERSION)\"
 LDLIBS += -lsepol -lselinux -L$(PREFIX)/lib
 
 TARGETS=$(patsubst %.c,%,$(wildcard *.c))
policycoreutils/load_policy/Makefile.orig +31 -0
diff -pruN selinux-dev-211109/policycoreutils/load_policy/Makefile.orig selinux-dev-211109-patched/policycoreutils/load_policy/Makefile.orig
@@ -0,0 +1,31 @@
+# Installation directories.
+PREFIX ?= ${DESTDIR}/usr
+SBINDIR ?= $(DESTDIR)/sbin
+USRSBINDIR ?= $(PREFIX)/sbin
+MANDIR ?= $(PREFIX)/share/man
+LOCALEDIR ?= /usr/share/locale
+
+CFLAGS ?= -Werror -Wall -W
+override CFLAGS += $(LDFLAGS) -I$(PREFIX)/include -DUSE_NLS -DLOCALEDIR="\"$(LOCALEDIR)\"" -DPACKAGE="\"policycoreutils\""
+LDLIBS += -lsepol -lselinux -L$(PREFIX)/lib
+
+TARGETS=$(patsubst %.c,%,$(wildcard *.c))
+
+all: $(TARGETS)
+
+install: all
+	-mkdir -p $(SBINDIR)
+	install -m 755 $(TARGETS) $(SBINDIR)
+	test -d $(MANDIR)/man8 || install -m 755 -d $(MANDIR)/man8
+	install -m 644 load_policy.8 $(MANDIR)/man8/
+	-mkdir -p $(USRSBINDIR)
+	ln -sf /sbin/load_policy $(USRSBINDIR)/load_policy
+
+clean:
+	-rm -f $(TARGETS) *.o 
+
+indent:
+	../../scripts/Lindent $(wildcard *.[ch])
+
+relabel:
+	/sbin/restorecon $(SBINDIR)/load_policy 
policycoreutils/newrole/newrole.1 +7 -1
diff -pruN selinux-dev-211109/policycoreutils/newrole/newrole.1 selinux-dev-211109-patched/policycoreutils/newrole/newrole.1
@@ -58,10 +58,16 @@ The new shell will be the shell specifie
 file.
 .PP
 The
+.B -h
+or
+.B --help
+shows the usage information for newrole.
+.PP
+The
 .B -V
 or 
 .B --version
-shows the current version of newrole
+shows the current version of newrole.
 .PP
 .SH EXAMPLE
 .br
policycoreutils/newrole/newrole.c +8 -5
diff -pruN selinux-dev-211109/policycoreutils/newrole/newrole.c selinux-dev-211109-patched/policycoreutils/newrole/newrole.c
@@ -10,7 +10,7 @@
  *
  * USAGE:
  *
- * newrole [ -r role ] [ -t type ] [ -l level ] [ -V ] [ -- args ]
+ * newrole -h | -V | [ -r role ] [ -t type ] [ -l level ] [ -- args ]
  *
  * BUILD OPTIONS:
  *
@@ -91,7 +91,7 @@
 #endif
 
 /* USAGE_STRING describes the command-line args of this program. */
-#define USAGE_STRING "USAGE: newrole [ -r role ] [ -t type ] [ -l level ] [ -p ] [ -V ] [ -- args ]"
+#define USAGE_STRING "USAGE: newrole -h | -V | [ -r role ] [ -t type ] [ -l level ] [ -p ] [ -- args ]"
 
 #ifdef USE_PAM
 #define PAM_SERVICE_CONFIG "/etc/selinux/newrole_pam.conf";
@@ -877,21 +877,24 @@ static int parse_command_line_arguments(
 		{"level", 1, 0, 'l'},
 		{"preserve-environment", 0, 0, 'p'},
 		{"version", 0, 0, 'V'},
+		{"help", 0, 0, 'h'},
 		{NULL, 0, 0, 0}
 	};
 
 	*preserve_environment = 0;
 	while (1) {
-		clflag = getopt_long(argc, argv, "r:t:l:pV", long_options,
+		clflag = getopt_long(argc, argv, "r:t:l:pVh", long_options,
 				     &flag_index);
 		if (clflag == -1)
 			break;
 
 		switch (clflag) {
+		case 'h':
+			fprintf(stderr, "%s\n", USAGE_STRING);
+			exit(EXIT_SUCCESS);
 		case 'V':
 			printf("newrole: %s version %s\n", PACKAGE, VERSION);
-			exit(0);
-			break;
+			exit(EXIT_SUCCESS);
 		case 'p':
 			*preserve_environment = 1;
 			break;
policycoreutils/restorecond/Makefile +2 -1
diff -pruN selinux-dev-211109/policycoreutils/restorecond/Makefile selinux-dev-211109-patched/policycoreutils/restorecond/Makefile
@@ -5,8 +5,9 @@ MANDIR = $(PREFIX)/share/man
 INITDIR = $(DESTDIR)/etc/rc.d/init.d
 SELINUXDIR = $(DESTDIR)/etc/selinux
 
+VERSION = $(shell cat ../VERSION)
 CFLAGS ?= -g -Werror -Wall -W
-override CFLAGS += -I$(PREFIX)/include -D_FILE_OFFSET_BITS=64
+override CFLAGS += -I$(PREFIX)/include -DVERSION=\"$(VERSION)\" -D_FILE_OFFSET_BITS=64
 LDLIBS += -lselinux -L$(PREFIX)/lib
 
 all: restorecond
policycoreutils/restorecond/restorecond.8 +18 -1
diff -pruN selinux-dev-211109/policycoreutils/restorecond/restorecond.8 selinux-dev-211109-patched/policycoreutils/restorecond/restorecond.8
@@ -3,7 +3,7 @@
 restorecond \- daemon that watches for file creation and then sets the default SELinux file context
 
 .SH "SYNOPSIS"
-.B restorecond  [\-d]
+.B restorecond  [\-d] [\-v] | \-h | \-V
 .P
 
 .SH "DESCRIPTION"
@@ -17,8 +17,25 @@ the correct file context associated with
 .SH "OPTIONS"
 .TP 
 .B \-d
+or
+.B \-\-debug
 Turns on debugging mode.   Application will stay in the foreground and lots of
 debugs messages start printing.
+.TP
+.B \-v
+or
+.B \-\-verbose
+Turns on verbose mode. Missing files are reported.
+.TP
+.B \-h
+or
+.B \-\-help
+Shows the usage information.
+.TP
+.B \-V
+or
+.B \-\-version
+Shows the version information.
 
 .SH "AUTHOR"
 This man page was written by Dan Walsh <[email protected]>.
policycoreutils/restorecond/restorecond.c +45 -6

94 lines not on this page · raw message

policycoreutils/run_init/Makefile +2 -1
diff -pruN selinux-dev-211109/policycoreutils/run_init/Makefile selinux-dev-211109-patched/policycoreutils/run_init/Makefile
@@ -8,8 +8,9 @@ LOCALEDIR ?= /usr/share/locale
 PAMH = $(shell ls /usr/include/security/pam_appl.h 2>/dev/null)
 AUDITH = $(shell ls /usr/include/libaudit.h 2>/dev/null)
 
+VERSION = $(shell cat ../VERSION)
 CFLAGS ?= -Werror -Wall -W
-override CFLAGS += -I$(PREFIX)/include -DUSE_NLS -DLOCALEDIR="\"$(LOCALEDIR)\"" -DPACKAGE="\"policycoreutils\""
+override CFLAGS += -I$(PREFIX)/include -DUSE_NLS -DLOCALEDIR="\"$(LOCALEDIR)\"" -DPACKAGE="\"policycoreutils\"" -DVERSION=\"$(VERSION)\"
 LDLIBS += -lselinux -L$(PREFIX)/lib
 ifeq (${PAMH}, /usr/include/security/pam_appl.h)
 	override CFLAGS += -DUSE_PAM
policycoreutils/run_init/run_init.8 +8 -1
diff -pruN selinux-dev-211109/policycoreutils/run_init/run_init.8 selinux-dev-211109-patched/policycoreutils/run_init/run_init.8
@@ -3,12 +3,19 @@
 run_init \- run an init script in the proper SELinux context
 .SH SYNOPSIS
 .B run_init 
-\fISCRIPT\fR [[\fIARGS\fR]...] 
+\fISCRIPT\fR [[\fIARGS\fR]...] | -h | -V 
 .br
 .SH DESCRIPTION
 .PP
 Run a init script under the proper context, which is specified in 
 /etc/selinux/POLICYTYPE/contexts/initrc_context.
+.SH OPTIONS
+.TP
+.B \-h,\-\-help
+Print the help message.
+.TP
+.B \-V,\-\-version
+Print the version information.
 .SH FILES
 /etc/passwd - user account information
 .br
policycoreutils/run_init/run_init.c +61 -5

111 lines not on this page · raw message

policycoreutils/semodule/Makefile +2 -1
diff -pruN selinux-dev-211109/policycoreutils/semodule/Makefile selinux-dev-211109-patched/policycoreutils/semodule/Makefile
@@ -5,8 +5,9 @@ SBINDIR ?= $(PREFIX)/sbin
 MANDIR = $(PREFIX)/share/man
 LIBDIR ?= ${PREFIX}/lib
 
+VERSION = $(shell cat ../VERSION)
 CFLAGS ?= -Werror -Wall -W
-override CFLAGS += -I$(INCLUDEDIR)
+override CFLAGS += -I$(INCLUDEDIR) -DVERSION=\"$(VERSION)\"
 LDLIBS = -lsepol -lselinux -lsemanage -L$(LIBDIR)
 SEMODULE_OBJS = semodule.o
 
policycoreutils/semodule/semodule.8 +3 -0
diff -pruN selinux-dev-211109/policycoreutils/semodule/semodule.8 selinux-dev-211109-patched/policycoreutils/semodule/semodule.8
@@ -52,6 +52,9 @@ prints help message and quit
 .TP
 .B  \-v,\-\-verbose     
 be verbose
+.TP
+.B  \-V,\-\-version
+shows the version information
 
 .SH EXAMPLE
 .nf
policycoreutils/semodule/semodule.c +48 -18

203 lines not on this page · raw message

policycoreutils/semodule_deps/Makefile +2 -1
diff -pruN selinux-dev-211109/policycoreutils/semodule_deps/Makefile selinux-dev-211109-patched/policycoreutils/semodule_deps/Makefile
@@ -5,8 +5,9 @@ BINDIR ?= $(PREFIX)/bin
 LIBDIR ?= ${PREFIX}/lib
 MANDIR ?= $(PREFIX)/share/man
 
+VERSION = $(shell cat ../VERSION)
 CFLAGS ?= -Werror -Wall -W
-override CFLAGS += -I$(INCLUDEDIR)
+override CFLAGS += -I$(INCLUDEDIR) -DVERSION=\"$(VERSION)\"
 LDLIBS = $(LIBDIR)/libsepol.a
 
 all: semodule_deps
policycoreutils/semodule_deps/semodule_deps.8 +9 -3
diff -pruN selinux-dev-211109/policycoreutils/semodule_deps/semodule_deps.8 selinux-dev-211109-patched/policycoreutils/semodule_deps/semodule_deps.8
@@ -29,14 +29,20 @@ dependencies.
 
 .SH "OPTIONS"
 .TP
-.B \-v
+.B \-v,\-\-verbose
 verbose mode
 .TP
-.B \-g
+.B \-g,\-\-graphviz
 output dependency information in Graphviz dot format
 .TP
-.B \-b
+.B \-b,\-\-base
 include dependencies to the base module - by default these are excluded
+.TP
+.B \-h,\-\-help
+print usage information
+.TP
+.B \-V,\-\-version
+print version information
 
 .SH SEE ALSO
 .B checkmodule(8), semodule_package(8), semodule(8), semodule_link(8)
policycoreutils/semodule_deps/semodule_deps.c +49 -11

125 lines not on this page · raw message

policycoreutils/semodule_expand/semodule_expand.8 +12 -3
diff -pruN selinux-dev-211109/policycoreutils/semodule_expand/semodule_expand.8 selinux-dev-211109-patched/policycoreutils/semodule_expand/semodule_expand.8
@@ -3,7 +3,7 @@
 semodule_expand \- Expand a SELinux policy module package.
 
 .SH SYNOPSIS
-.B semodule_expand [-V -c [version]] basemodpkg outputfile
+.B semodule_expand -h | [-V] [-v] [-a] [-c version] basemodpkg outputfile
 .br
 .SH DESCRIPTION
 .PP
@@ -17,11 +17,20 @@ together a set of packages into a single
 
 .SH "OPTIONS"
 .TP
-.B \-V
+.B \-V,\-\-version
 show version
 .TP
-.B \-c [version]
+.B \-v,\-\-verbose
+be verbose
+.TP
+.B \-c,\-\-create version
 policy version to create
+.TP
+.B \-a
+suppress assertions and hierarchy checking
+.TP
+.B \-h,\-\-help
+print usage information
 
 .SH SEE ALSO
 .B checkmodule(8), semodule_package(8), semodule(8), semodule_link(8)
policycoreutils/semodule_expand/semodule_expand.c +11 -2
diff -pruN selinux-dev-211109/policycoreutils/semodule_expand/semodule_expand.c selinux-dev-211109-patched/policycoreutils/semodule_expand/semodule_expand.c
@@ -30,7 +30,7 @@ int policyvers = 0;
 
 static void usage(char *program_name)
 {
-	printf("usage: %s [-V -a -c [version]] basemodpkg outputfile\n",
+	printf("usage: %s -h | [-V] [-v] [-a] [-c version] basemodpkg outputfile\n",
 	       program_name);
 	exit(1);
 }
@@ -45,8 +45,15 @@ int main(int argc, char **argv)
 	FILE *fp, *outfile;
 	int check_assertions = 1;
 	sepol_handle_t *handle;
+	struct option long_options[] = {
+		{"version", no_argument, NULL, 'V'},
+		{"verbose", no_argument, NULL, 'v'},
+		{"create", required_argument, NULL, 'c'},
+		{"help", no_argument, NULL, 'h'},
+		{NULL, 0, NULL, 0}
+	};
 
-	while ((ch = getopt(argc, argv, "c:Vva")) != EOF) {
+	while ((ch = getopt_long(argc, argv, "c:Vvha", long_options, NULL)) != -1) {
 		switch (ch) {
 		case 'V':
 			show_version = 1;
@@ -76,6 +83,8 @@ int main(int argc, char **argv)
 				policyvers = n;
 				break;
 			}
+		case 'h':
+			usage(argv[0]);
 		case 'a':{
 				check_assertions = 0;
 				break;
policycoreutils/semodule_link/semodule_link.8 +6 -3
diff -pruN selinux-dev-211109/policycoreutils/semodule_link/semodule_link.8 selinux-dev-211109-patched/policycoreutils/semodule_link/semodule_link.8
@@ -16,14 +16,17 @@ semodule_package.
 
 .SH "OPTIONS"
 .TP
-.B \-V
+.B \-V,\-\-version
 show version
 .TP
-.B \-v
+.B \-v,\-\-verbose
 verbose mode
 .TP
-.B \-o <output file> 
+.B \-o,\-\-output <output file> 
 Linked policy module package generated by this tool.
+.TP
+.B \-h,\-\-help
+show usage information
 
 
 .SH SEE ALSO
policycoreutils/semodule_link/semodule_link.c +9 -1
diff -pruN selinux-dev-211109/policycoreutils/semodule_link/semodule_link.c selinux-dev-211109-patched/policycoreutils/semodule_link/semodule_link.c
@@ -81,10 +81,17 @@ int main(int argc, char **argv)
 	sepol_module_package_t *base, **mods;
 	FILE *outfile;
 	struct sepol_policy_file *pf;
+	struct option long_options[] = {
+		{"version", no_argument, NULL, 'V'},
+		{"verbose", no_argument, NULL, 'v'},
+		{"output", required_argument, NULL, 'o'},
+		{"help", no_argument, NULL, 'h'},
+		{NULL, 0, NULL, 0}
+	};
 
 	progname = argv[0];
 
-	while ((ch = getopt(argc, argv, "o:Vv")) != EOF) {
+	while ((ch = getopt_long(argc, argv, "o:Vvh", long_options, NULL)) != -1) {
 		switch (ch) {
 		case 'V':
 			show_version = 1;
@@ -95,6 +102,7 @@ int main(int argc, char **argv)
 		case 'o':
 			outname = optarg;
 			break;
+		case 'h':
 		default:
 			usage(argv[0]);
 		}
policycoreutils/semodule_package/Makefile +2 -1
diff -pruN selinux-dev-211109/policycoreutils/semodule_package/Makefile selinux-dev-211109-patched/policycoreutils/semodule_package/Makefile
@@ -5,8 +5,9 @@ BINDIR ?= $(PREFIX)/bin
 LIBDIR ?= ${PREFIX}/lib
 MANDIR ?= $(PREFIX)/share/man
 
+VERSION = $(shell cat ../VERSION)
 CFLAGS ?= -Werror -Wall -W
-override CFLAGS += -I$(INCLUDEDIR)
+override CFLAGS += -I$(INCLUDEDIR) -DVERSION=\"$(VERSION)\"
 LDLIBS = -lsepol -lselinux -L$(LIBDIR)
 
 all: semodule_package
policycoreutils/semodule_package/semodule_package.8 +6 -0
diff -pruN selinux-dev-211109/policycoreutils/semodule_package/semodule_package.8 selinux-dev-211109-patched/policycoreutils/semodule_package/semodule_package.8
@@ -25,6 +25,12 @@ $ semodule_package -o local.pp -m local.
 
 .SH "OPTIONS"
 .TP
+.B \-h \-\-help
+Print usage information.
+.TP
+.B \-V \-\-version
+Print version information.
+.TP
 .B \-o \-\-outfile <output file> 
 Policy module package file generated by this tool.
 .TP
policycoreutils/semodule_package/semodule_package.c +35 -9

99 lines not on this page · raw message

policycoreutils/sestatus/Makefile +2 -1
diff -pruN selinux-dev-211109/policycoreutils/sestatus/Makefile selinux-dev-211109-patched/policycoreutils/sestatus/Makefile
@@ -5,8 +5,9 @@ MANDIR = $(PREFIX)/share/man
 ETCDIR ?= $(DESTDIR)/etc
 LIBDIR ?= ${PREFIX}/lib
 
+VERSION = $(shell cat ../VERSION)
 CFLAGS = -Werror -Wall -W
-override CFLAGS += -I$(PREFIX)/include -D_FILE_OFFSET_BITS=64
+override CFLAGS += -I$(PREFIX)/include -DVERSION=\"$(VERSION)\" -D_FILE_OFFSET_BITS=64
 LDLIBS = -lselinux -L$(LIBDIR)
 
 all: sestatus
policycoreutils/sestatus/sestatus.8 +11 -3
diff -pruN selinux-dev-211109/policycoreutils/sestatus/sestatus.8 selinux-dev-211109-patched/policycoreutils/sestatus/sestatus.8
@@ -4,7 +4,7 @@ sestatus \- SELinux status tool
 
 .SH "SYNOPSIS"
 .B sestatus
-.I [\-v] [\-b]  
+.I -h | -V | [\-v] [\-b]  
 .P
 This tool is used to get the status of a system running SELinux.
 
@@ -28,12 +28,20 @@ Policy version:         16
 .SH "OPTIONS"
 .TP 
 
-.B \-v
+.B \-h,\-\-help
+.P
+ Print usage information.
+
+.B \-V,\-\-version
+.P
+ Print version information.
+
+.B \-v,\-\-verbose
 .P
  Checks the contexts of a files , and a processes listed in the /etc/sestatus.conf file.  It also checks the context of the target, in cases of
 symlinks.
 
-.B \-b
+.B \-b,\-\-show-bools
 .P
 Display the current state of booleans.
 
policycoreutils/sestatus/sestatus.c +19 -2
diff -pruN selinux-dev-211109/policycoreutils/sestatus/sestatus.c selinux-dev-211109-patched/policycoreutils/sestatus/sestatus.c
@@ -15,6 +15,7 @@
 #include <sys/stat.h>
 #include <dirent.h>
 #include <unistd.h>
+#include <getopt.h>
 #include <libgen.h>
 #include <ctype.h>
 
@@ -196,22 +197,38 @@ int main(int argc, char **argv)
 	const char *pol_name;
 	char *pol_path;
 
+	struct option long_options[] = {
+		{"version", no_argument, NULL, 'V'},
+		{"help", no_argument, NULL, 'h'},
+		{"verbose", no_argument, NULL, 'v'},
+		{"show-bools", no_argument, NULL, 'b'},
+		{NULL, 0, NULL, 0}
+	};
+
 	while (1) {
-		opt = getopt(argc, argv, "vb");
+		opt = getopt_long(argc, argv, "vbVh", long_options, NULL);
 		if (opt == -1)
 			break;
 		switch (opt) {
+		case 'V':
+			fprintf(stdout,
+				" %s version %s.\n", basename(argv[0]), VERSION);
+			exit(EXIT_SUCCESS);
 		case 'v':
 			verbose = 1;
 			break;
 		case 'b':
 			show_bools = 1;
 			break;
+		case 'h':
 		default:
 			/* invalid option */
 			printf("\nUsage: %s [OPTION]\n\n", basename(argv[0]));
+			printf("  -h,--help     Print this help message.\n");
+			printf("  -V,--version     Print version information.\n");
 			printf
-			    ("  -v  Verbose check of process and file contexts.\n");
+			    ("  -v,--verbose     Verbose check of process and file contexts.\n");
+			printf("  -b,--show-bools     Display the current state of booleans.\n");
 			printf("\nWithout options, show SELinux status.\n");
 			return -1;
 		}
policycoreutils/setfiles/Makefile +3 -1
diff -pruN selinux-dev-211109/policycoreutils/setfiles/Makefile selinux-dev-211109-patched/policycoreutils/setfiles/Makefile
@@ -5,8 +5,10 @@ MANDIR = $(PREFIX)/share/man
 LIBDIR ?= $(PREFIX)/lib
 AUDITH = $(shell ls /usr/include/libaudit.h 2>/dev/null)
 
+VERSION = $(shell cat ../VERSION)
+
 CFLAGS = -g -Werror -Wall -W
-override CFLAGS += -I$(PREFIX)/include
+override CFLAGS += -I$(PREFIX)/include -DVERSION=\"$(VERSION)\"
 LDLIBS = -lselinux -lsepol -L$(LIBDIR)
 
 ifeq (${AUDITH}, /usr/include/libaudit.h)
policycoreutils/setfiles/restorecon.8 +6 -0
diff -pruN selinux-dev-211109/policycoreutils/setfiles/restorecon.8 selinux-dev-211109-patched/policycoreutils/setfiles/restorecon.8
@@ -22,6 +22,12 @@ new policy, or with the \-n option it ca
 contexts are all as you expect.
 
 .SH "OPTIONS"
+.TP
+.B \-h,\-\-help
+print usage information
+.TP
+.B \-V,\-\-version
+print version information
 .TP 
 .B \-i
 ignore files that do not exist
policycoreutils/setfiles/setfiles.8 +6 -0
diff -pruN selinux-dev-211109/policycoreutils/setfiles/setfiles.8 selinux-dev-211109-patched/policycoreutils/setfiles/setfiles.8
@@ -19,6 +19,12 @@ new policy, or with the \-n option it ca
 contexts are all as you expect.
 
 .SH "OPTIONS"
+.TP
+.B \-h,\-\-help
+print usage information
+.TP
+.B \-V,\-\-version
+print version information
 .TP 
 .B \-c
 check the validity of the contexts against the specified binary policy.
policycoreutils/setfiles/setfiles.c +19 -3
diff -pruN selinux-dev-211109/policycoreutils/setfiles/setfiles.c selinux-dev-211109-patched/policycoreutils/setfiles/setfiles.c
@@ -2,6 +2,7 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <stdio_ext.h>
+#include <getopt.h>
 #include <ctype.h>
 #include <regex.h>
 #include <sys/vfs.h>
@@ -44,14 +45,18 @@ void usage(const char *const name)
 {
 	if (iamrestorecon) {
 		fprintf(stderr,
+			"usage:  %s -h,--help     print this usage information\n"
+			"usage:  %s -V,--version     print version information\n"
 			"usage:  %s [-iFnrRv0] [-e excludedir ] [-o filename ] [-f filename | pathname... ]\n",
-			name);
+			name, name, name);
 	} else {
 		fprintf(stderr,
+			"usage:  %s -h,--help     print this usage information\n"
+			"usage:  %s -V,--version     print version information\n"
 			"usage:  %s [-dnpqvW] [-o filename] [-r alt_root_path ] spec_file pathname...\n"
 			"usage:  %s -c policyfile spec_file\n"
 			"usage:  %s -s [-dnqvW] [-o filename ] spec_file\n", name, name,
-			name);
+			name, name, name);
 	}
 	exit(1);
 }
@@ -211,6 +216,12 @@ int main(int argc, char **argv)
 	size_t buf_len;
 	int recurse; /* Recursive descent. */
 	char *base;
+
+	const struct option long_options[] = {
+		{"version", no_argument, NULL, 'V'},
+		{"help", no_argument, NULL, 'h'},
+		{NULL, 0, NULL, 0}
+	};
 	
 	memset(&r_opts, 0, sizeof(r_opts));
 
@@ -283,7 +294,7 @@ int main(int argc, char **argv)
 	exclude_non_seclabel_mounts();
 
 	/* Process any options. */
-	while ((opt = getopt(argc, argv, "c:de:f:ilnpqrsvo:FRW0")) > 0) {
+	while ((opt = getopt_long(argc, argv, "c:de:f:hilnpqrsvo:FRVW0", long_options, NULL)) != -1) {
 		switch (opt) {
 		case 'c':
 			{
@@ -410,6 +421,11 @@ int main(int argc, char **argv)
 		case '0':
 			null_terminated = 1;
 			break;
+		case 'V':
+			fprintf(stdout,
+				" %s version %s.\n", base, VERSION);
+			exit(EXIT_SUCCESS);
+		case 'h':
 		case '?':
 			usage(argv[0]);
 		}
policycoreutils/setsebool/Makefile +2 -1
diff -pruN selinux-dev-211109/policycoreutils/setsebool/Makefile selinux-dev-211109-patched/policycoreutils/setsebool/Makefile
@@ -5,8 +5,9 @@ SBINDIR ?= $(PREFIX)/sbin
 MANDIR = $(PREFIX)/share/man
 LIBDIR ?= ${PREFIX}/lib
 
+VERSION = $(shell cat ../VERSION)
 CFLAGS ?= -Werror -Wall -W
-override CFLAGS += -I$(INCLUDEDIR)
+override CFLAGS += -I$(INCLUDEDIR) -DVERSION=\"$(VERSION)\"
 LDLIBS = -lsepol -lselinux -lsemanage -L$(LIBDIR)
 SETSEBOOL_OBJS = setsebool.o
 
policycoreutils/setsebool/setsebool.8 +11 -0
diff -pruN selinux-dev-211109/policycoreutils/setsebool/setsebool.8 selinux-dev-211109-patched/policycoreutils/setsebool/setsebool.8
@@ -11,6 +11,17 @@ setsebool \- set SELinux boolean value
 sets the current state of a particular SELinux boolean or a list of booleans 
 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. 
 
+.SH "OPTIONS"
+.TP
+
+.B \-h,\-\-help
+.P
+ Print usage information.
+
+.B \-V,\-\-version
+.P
+ Print version information.
+
 Without the -P option, only the current boolean value is 
 affected; the boot-time default settings 
 are not changed. 
policycoreutils/setsebool/setsebool.c +52 -14

103 lines not on this page · raw message

checkpolicy/checkmodule.8 +7 -4
diff -pruN selinux-dev-211109/checkpolicy/checkmodule.8 selinux-dev-211109-patched/checkpolicy/checkmodule.8
@@ -21,23 +21,26 @@ the module package into the module store
 
 .SH OPTIONS
 .TP
-.B \-b
+.B \-b,\-\-binary
 Read an existing binary policy module file rather than a source policy
 module file.  This option is a development/debugging aid.
 .TP
 .B \-m
 Generate a non-base policy module.
 .TP
-.B \-M
+.B \-M,\-\-mls
 Enable the MLS/MCS support when checking and compiling the policy module.
 .TP
-.B \-V
+.B \-V,\-\-version
  Show policy versions created by this program
 .TP
-.B \-o filename
+.B \-o,\-\-output filename
 Write a binary policy module file to the specified filename.
 Otherwise, checkmodule will only check the syntax of the module source file
 and will not generate a binary module at all.
+.TP
+.B \-U,\-\-handle-unknown <action>
+Specify how the kernel should handle unknown classes or permissions (deny, allow or reject).
 
 .SH EXAMPLE
 .nf
checkpolicy/checkmodule.c +11 -1
diff -pruN selinux-dev-211109/checkpolicy/checkmodule.c selinux-dev-211109-patched/checkpolicy/checkmodule.c
@@ -163,8 +163,18 @@ int main(int argc, char **argv)
 	int ch;
 	int show_version = 0;
 	policydb_t modpolicydb;
+	struct option long_options[] = {
+		{"help", no_argument, NULL, 'h'},
+		{"output", required_argument, NULL, 'o'},
+		{"binary", no_argument, NULL, 'b'},
+		{"version", no_argument, NULL, 'V'},
+		{"handle-unknown", optional_argument, NULL, 'U'},
+		{"debug", no_argument, NULL, 'd'},
+		{"mls", no_argument, NULL, 'M'},
+		{NULL, 0, NULL, 0}
+	};
 
-	while ((ch = getopt(argc, argv, "ho:dbVU:mM")) != EOF) {
+	while ((ch = getopt_long(argc, argv, "ho:bVU:mM", long_options, NULL)) != -1) {
 		switch (ch) {
 		case 'h':
 			usage(argv[0]);
checkpolicy/checkpolicy.8 +16 -4
diff -pruN selinux-dev-211109/checkpolicy/checkpolicy.8 selinux-dev-211109-patched/checkpolicy/checkpolicy.8
@@ -18,20 +18,32 @@ policy.conf or policy, depending on whet
 
 .SH OPTIONS
 .TP
-.B \-b
+.B \-b,\-\-binary
 Read an existing binary policy file rather than a source policy.conf file.
 .TP
-.B \-d
+.B \-d,\-\-debug
 Enter debug mode after loading the policy.
 .TP
-.B \-M
+.B \-M,\-\-mls
 Enable the MLS policy when checking and compiling the policy.
 .TP
-.B \-o filename
+.B \-o,\-\-output filename
 Write a binary policy file to the specified filename.
 .TP
 .B \-c policyvers
 Specify the policy version, defaults to the latest.
+.TP
+.B \-t,\-\-target
+Specify the target platform (selinux or xen).
+.TP
+.B \-U,\-\-handle-unknown <action>
+Specify how the kernel should handle unknown classes or permissions (deny, allow or reject).
+.TP
+.B \-V,\-\-version
+Show version information.
+.TP
+.B \-h,\-\-help
+Show usage information.
 
 .SH "SEE ALSO"
 SELinux documentation at http://www.nsa.gov/selinux,
checkpolicy/checkpolicy.c +13 -1
diff -pruN selinux-dev-211109/checkpolicy/checkpolicy.c selinux-dev-211109-patched/checkpolicy/checkpolicy.c
@@ -392,8 +392,19 @@ int main(int argc, char **argv)
 	int state;
 	int show_version = 0;
 	struct policy_file pf;
+	struct option long_options[] = {
+		{"output", required_argument, NULL, 'o'},
+		{"target", required_argument, NULL, 't'},
+		{"binary", no_argument, NULL, 'b'},
+		{"debug", no_argument, NULL, 'd'},
+		{"version", no_argument, NULL, 'V'},
+		{"handle-unknown", optional_argument, NULL, 'U'},
+		{"mls", no_argument, NULL, 'M'},
+		{"help", no_argument, NULL, 'h'},
+		{NULL, 0, NULL, 0}
+	};
 
-	while ((ch = getopt(argc, argv, "o:t:dbU:MVc:")) != EOF) {
+	while ((ch = getopt_long(argc, argv, "o:t:dbU:MVc:h", long_options, NULL)) != -1) {
 		switch (ch) {
 		case 'o':
 			outfile = optarg;
@@ -458,6 +469,7 @@ int main(int argc, char **argv)
 					policyvers = n;
 				break;
 			}
+		case 'h':
 		default:
 			usage(argv[0]);
 		}
#6 lore raw

Re: [PATCH] Support for long-options in policycoreutils and checkpolicy (Ticket #1 [1672486])

Quoted 31 lines · Guido Trentalancia

Dear Eamon,

here are the two "maintenance" patches that I did post earlier this month (along with the new manual pages). They are intended to close Ticket #1 [1672486] that I found open on Tresys pages
(http://userspace.selinuxproject.org/trac/ticket/1).

I do apologize for not putting the keyword "[PATCH]" in the original message.

Here is a summary of what has been changed for policycoreutils:

- introduced proper handling of -h, -V options and their respective long formats --help and --version to all binaries that are produced from C code. The same issue is not tackled for Python-based tools (e.g. semanage);
- relative manual pages have also been updated accordingly.

And here is what has been changed for checkpolicy/checkmodule:

- introduced proper handling of -h, -V and the long formats --help and --version to all binaries (checkpolicy/checkmodule);
- introduced the handling of long options for some of the other available options;
- manual pages have also been updated accordingly (and a few undocumented options have been documented).

One of the original two patches (the one against policycoreutils) did not compile cleanly anymore against the current HEAD of SELinux, so I have created an updated one, which is the one attached here.

Quoted 7 lines

It's just a matter of some really minor issues, but I hope it helps, at least the ticket can now be closed...

Kind regards,

Guido

Thank you for doing this. Unfortunately it looks like your mail client decided to base64 encode the attachment.

It is always best to use git to generate patch emails, please see:
http://andrewprice.me.uk/weblog/entry/generating-patch-emails-with-git

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#7 lore raw

Re: [PATCH] Support for long-options in policycoreutils and checkpolicy (Ticket #1 [1672486])

Quoted 41 lines · Joshua Brindle
Quoted 31 lines · Guido Trentalancia

Dear Eamon,

here are the two "maintenance" patches that I did post earlier this month (along with the new manual pages). They are intended to close Ticket #1 [1672486] that I found open on Tresys pages
(http://userspace.selinuxproject.org/trac/ticket/1).

I do apologize for not putting the keyword "[PATCH]" in the original message.

Here is a summary of what has been changed for policycoreutils:

- introduced proper handling of -h, -V options and their respective long formats --help and --version to all binaries that are produced from C code. The same issue is not tackled for Python-based tools (e.g. semanage);
- relative manual pages have also been updated accordingly.

And here is what has been changed for checkpolicy/checkmodule:

- introduced proper handling of -h, -V and the long formats --help and --version to all binaries (checkpolicy/checkmodule);
- introduced the handling of long options for some of the other available options;
- manual pages have also been updated accordingly (and a few undocumented options have been documented).

One of the original two patches (the one against policycoreutils) did not compile cleanly anymore against the current HEAD of SELinux, so I have created an updated one, which is the one attached here.

Quoted 7 lines

It's just a matter of some really minor issues, but I hope it helps, at least the ticket can now be closed...

Kind regards,

Guido

Quoted 6 lines

Thank you for doing this. Unfortunately it looks like your mail client decided to base64 encode the attachment.

It is always best to use git to generate patch emails, please see:
http://andrewprice.me.uk/weblog/entry/generating-patch-emails-with-git

I also have a couple comments about this patch. First I'm not so sure about the:
"[program name] version [version]."

format. For people to be able to test versions in shell scripts I think the output should simply be the version.

I'm not sure what the "libtool" hack thing is all about, why is that necessary? In fact I'm not sure what the whole opt_program_name thing is about, what are you trying to address here? That change makes the patch very messy since you are going through and replacing every occurrence of argv[0] with program_name. Typically changes should be separated in patches to ease review, I'm not sure what this has to do with adding --version to the apps.

Also, why -V rather than -v ?

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#3 lore raw
In reply to Guido Trentalancia
Quoted 5 lines · Guido Trentalancia

Hello Eamon !

Quoted 1 line · Eamon Walsh

Hi, thanks for doing this. Some quick review below.

<snip>

Quoted 11 lines

Yes, I have now mentioned that checkPasswdAccess is deprecated. We are referring to file security_compute_av.3 as the description of these two functions lives there...

By the way, it has been pointed out that this function should not hard-code a string. I also agree with him, there is a generic constant for such "passwd" object class, it is defined in flask.h could be used instead of the string, thus avoiding hard-coding and also allowing to save a few cycles and be theoretically future-proof (if ever the name would change, say to "password", "auth-token" or anything else).

You can see here:
http://marc.info/?l=selinux&m=118115728003670&w=2

That the way it is now is quite intentional. For many years we relied on the hardcoded offsets in flask.h and it prevented us from removing, or reordering object classes. Therefore we now export the values out of the kernel in /selinux/class and use those values rather than the ones from flask.h (which hopefully could go away some day.)

Quoted 13 lines

--- libselinux/src/checkAccess.c.orig 2009-11-21 20:07:21.000000000
+0100
+++ libselinux/src/checkAccess.c 2009-11-21 20:08:36.000000000
+0100

(quoted diff) +0 -2
@@ -13,17 +13,12 @@ int selinux_check_passwd_access(access_v
         if (is_selinux_enabled() == 0)
                 return 0;
         if (getprevcon_raw(&user_context) == 0) {
-               security_class_t passwd_class;
                 struct av_decision avd;
                 int retval;
 
-               passwd_class = string_to_security_class("passwd");

Review int selinux_check_passwd_access(access_v · line 24

Quoted 10 lines
(quoted diff) +1 -4
-               if (passwd_class == 0)
-                       return 0;
-
                 retval = security_compute_av_raw(user_context,
                                                      user_context,
-                                                    passwd_class,
+                                                    SECCLASS_PASSWD,
                                                      requested,
                                                      &avd);
 

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#4 lore raw
In reply to Guido Trentalancia
Quoted 177 lines · Guido Trentalancia

Hello Eamon !

Quoted 1 line · Eamon Walsh

Hi, thanks for doing this. Some quick review below.

You are welcome, I suppose it was a boring task for many...

Thanks very much for reviewing the changes. And please accept my apologies for not placing "[PATCH]" in the subject of the original post. I had just subscribed to the list.

I left you cc address intact here...

Quoted 6 lines

There is too much in matchpathcon(3) now. It's going to need to be split up into different pages, perhaps the init/fini/teardown stuff in one page, the lookup calls in another, and the non-matchpathcon prefixed calls in a third page.

Also, .so manpage links are needed for all the calls here.

Yes, matchpathcon is a mess. Following your guidelines, I have now splitted the huge and messy page in several different man pages. It's easier to consult and easier to maintain.

The first part (page) is strictly related to _init, its variant _init_index, _fini, matchpathcon and its variant matchpathcon_index. Nice and concise. References are provided in the "SEE ALSO" section to the rest.

The second page describes the auxiliary lookup calls (matchpathcon_checkmatches) and the inode associations functions (matchpathcon_filespec_{add,destroy,eval}). The reference section points to the main matchpathcon page.

A third page has been created for the functions that are used to set the flags (set_matchpathcon_flags) or to configure the behaviour of the main matchpathcon functions (set_matchpathcon_invalidcon and set_matchpathcon_printf).

A fourth and fifth page is devoted to functions that should never had ended up in matchpathcon (selinux_file_context_cmp and selinux_file_context_verify in one page and selinux_lsetfilecon_default in another one): we do not really need to save electrons needed for new pages...

Quoted 4 lines
Quoted 3 lines

* print_access_vector

Looks good.

No modifications.

Quoted 4 lines
Quoted 2 lines

* security_disable

See the selinux.h comments for this. It needs to be documented that this function can only be called at startup time.

Ok. I have stressed that now and also mentioned that after the policy has been loaded at startup, then only "setenforce" can be used to alter (not disable) the mode of the SELinux kernel code (for example by placing it into "permissive" mode).

Quoted 4 lines
Quoted 2 lines

* security_set_boolean_list

a RETURN VALUE section is needed in this page, documenting at least this call if not the others in that page.

I have now added a "RETURN VALUE" section.

Also, to avoid confusion, I have rephrased the word "returns" in "provides" when not strictly referring the to the return value of the function (take for example security_get_boolean_names(), strictly speaking the function returns an integer representing 0=success or -1=failure, although from a conceptual point of view it also returns a list trough modification of one of its parameters passed by reference).

Usually when an application developer looks at the "RETURN VALUE" section it is because he/she has already planned/coded the call to the function (and thus also the handling to parameters passed by reference) and only needs to check for the function exit status so that it can be handled properly at the call point.

Quoted 6 lines
Quoted 2 lines

* selinux_check_passwd_access

This is a replacement for the inconsistently named "checkPasswdAccess" function. So, the existing description of checkPasswdAccess should be moved to this function, and checkPasswdAccess should be changed to "this is a deprecated alias for selinux_check_passwd_access".

Yes, I have now mentioned that checkPasswdAccess is deprecated. We are referring to file security_compute_av.3 as the description of these two functions lives there...

By the way, it has been pointed out that this function should not hard-code a string. I also agree with him, there is a generic constant for such "passwd" object class, it is defined in flask.h could be used instead of the string, thus avoiding hard-coding and also allowing to save a few cycles and be theoretically future-proof (if ever the name would change, say to "password", "auth-token" or anything else).

--- libselinux/src/checkAccess.c.orig 2009-11-21 20:07:21.000000000
+0100
+++ libselinux/src/checkAccess.c 2009-11-21 20:08:36.000000000
+0100

(quoted diff) +1 -6
@@ -13,17 +13,12 @@ int selinux_check_passwd_access(access_v
         if (is_selinux_enabled() == 0)
                 return 0;
         if (getprevcon_raw(&user_context) == 0) {
-               security_class_t passwd_class;
                 struct av_decision avd;
                 int retval;
 
-               passwd_class = string_to_security_class("passwd");
-               if (passwd_class == 0)
-                       return 0;
-
                 retval = security_compute_av_raw(user_context,
                                                      user_context,
-                                                    passwd_class,
+                                                    SECCLASS_PASSWD,
                                                      requested,
                                                      &avd);
 

Note that the above code, should really live in the application and not in the selinux library. It used to be like that, then for some reason it has been introduced. Redhat's passwd and cronie are calling the library function and thus at the moment they rely on it. But for example, util-linux-ng has the code in it and does not call this function, as I believe it should be. A very minor issue anyway...

Quoted 3 lines
Quoted 2 lines

* selinux_init_load_policy

A paragraph break is needed in the DESCRIPTION section before this function.

Done. I have also added a note to the already mentioned fact that after initial policy load, SELinux cannot be anymore disabled using calls to security_disable(3).

Quoted 3 lines
Quoted 2 lines

* selinux_lsetfilecon_default

See notes above about the matchpathcon manpage.

Yes, separate man page now.

Quoted 3 lines
Quoted 2 lines

* selinux_mkload_policy

Looks good.

No modifications.

Quoted 8 lines
Quoted 2 lines

* set_selinuxmnt

This manpage includes two static functions that are not part of the libselinux API (at least, not anymore) and should be removed.

Also, I'm not comfortable with the description given. Instead, use the comments in selinux.h, which are more accurate and verbose.

Please let me know if things are any better now.

I did also provide on the same day a patch for beautifying and improving the command-line option parsing of a few utilities (a ticket had been created by somebody). That patch provides those improvement according to GNU-style parsing of "help" and "version" options (including long-option variants). I think it also fixes a couple of typos here and there. Feel free to include that patch too if you like it, so that the ticket can be closed ! I will attach it again in another separate message: it has been slightly modified in order to apply cleanly to the latest git snapshot.

More important, I was also thinking about fingerprinting (and subsequently checking) the libraries with some cryptographic hash function such as the NIST-recommended SHA2. It is beginning to be done for security-related projects like OpenSSL, so I believe it is even more essential for SELinux. Ever thought about anything like that ?

Quoted 3 lines

Best regards,

Guido

Merged in libselinux 2.0.90

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#8 lore raw

Re: [PATCH] Support for long-options in policycoreutils and checkpolicy (Ticket #1 [1672486])

In reply to Joshua Brindle

Dear Joshua,

thanks for your reply and for your comments.

My reply follows the quoted text.

Quoted 64 lines · Joshua Brindle
Quoted 41 lines · Joshua Brindle
Quoted 31 lines · Guido Trentalancia

Dear Eamon,

here are the two "maintenance" patches that I did post earlier this month (along with the new manual pages). They are intended to close Ticket #1 [1672486] that I found open on Tresys pages
(http://userspace.selinuxproject.org/trac/ticket/1).

I do apologize for not putting the keyword "[PATCH]" in the original message.

Here is a summary of what has been changed for policycoreutils:

- introduced proper handling of -h, -V options and their respective long formats --help and --version to all binaries that are produced from C code. The same issue is not tackled for Python-based tools (e.g. semanage);
- relative manual pages have also been updated accordingly.

And here is what has been changed for checkpolicy/checkmodule:

- introduced proper handling of -h, -V and the long formats --help and --version to all binaries (checkpolicy/checkmodule);
- introduced the handling of long options for some of the other available options;
- manual pages have also been updated accordingly (and a few undocumented options have been documented).

One of the original two patches (the one against policycoreutils) did not compile cleanly anymore against the current HEAD of SELinux, so I have created an updated one, which is the one attached here.

Quoted 7 lines

It's just a matter of some really minor issues, but I hope it helps, at least the ticket can now be closed...

Kind regards,

Guido

Quoted 6 lines

Thank you for doing this. Unfortunately it looks like your mail client decided to base64 encode the attachment.

It is always best to use git to generate patch emails, please see:
http://andrewprice.me.uk/weblog/entry/generating-patch-emails-with-git

I also have a couple comments about this patch. First I'm not so sure about the:
"[program name] version [version]."

format. For people to be able to test versions in shell scripts I think the output should simply be the version.

I'm not sure what the "libtool" hack thing is all about, why is that necessary? In fact I'm not sure what the whole opt_program_name thing is about, what are you trying to address here? That change makes the patch very messy since you are going through and replacing every occurrence of argv[0] with program_name. Typically changes should be separated in patches to ease review, I'm not sure what this has to do with adding --version to the apps.

Quoted 1 line

Also, why -V rather than -v ?

The "[program name] version [version] is the standard (see other GNU packages like gcc or binutils). Scripts that only need the "version" argument can still filter out the rest using awk or something like that.

The opt_program_name thing has been taken from secon.c. It is intended to provide the name of the program without the path to the binary or other garbage. It has to do with adding version simply because of the standard format mentioned above which requires the name of the program.

If you have not received the patch because of the encoding performed by my mail client, I can send it again.

I look forward to hearing from you. Thank you.

Greetings,

Guido Trentalancia

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#9 lore raw

Re: [PATCH] Support for long-options in policycoreutils and checkpolicy (Ticket #1 [1672486])

In reply to Joshua Brindle

Dear Joshua,

in your previous message you were also asking why the option "-V" instead of "-v" has been used for getting the version of the program. Again, this is according to the GNU coding style (because "-v" is generally used for making the program "verbose").

Regards,

Guido

Quoted 64 lines · Joshua Brindle
Quoted 41 lines · Joshua Brindle
Quoted 31 lines · Guido Trentalancia

Dear Eamon,

here are the two "maintenance" patches that I did post earlier this month (along with the new manual pages). They are intended to close Ticket #1 [1672486] that I found open on Tresys pages
(http://userspace.selinuxproject.org/trac/ticket/1).

I do apologize for not putting the keyword "[PATCH]" in the original message.

Here is a summary of what has been changed for policycoreutils:

- introduced proper handling of -h, -V options and their respective long formats --help and --version to all binaries that are produced from C code. The same issue is not tackled for Python-based tools (e.g. semanage);
- relative manual pages have also been updated accordingly.

And here is what has been changed for checkpolicy/checkmodule:

- introduced proper handling of -h, -V and the long formats --help and --version to all binaries (checkpolicy/checkmodule);
- introduced the handling of long options for some of the other available options;
- manual pages have also been updated accordingly (and a few undocumented options have been documented).

One of the original two patches (the one against policycoreutils) did not compile cleanly anymore against the current HEAD of SELinux, so I have created an updated one, which is the one attached here.

Quoted 7 lines

It's just a matter of some really minor issues, but I hope it helps, at least the ticket can now be closed...

Kind regards,

Guido

Quoted 6 lines

Thank you for doing this. Unfortunately it looks like your mail client decided to base64 encode the attachment.

It is always best to use git to generate patch emails, please see:
http://andrewprice.me.uk/weblog/entry/generating-patch-emails-with-git

I also have a couple comments about this patch. First I'm not so sure about the:
"[program name] version [version]."

format. For people to be able to test versions in shell scripts I think the output should simply be the version.

I'm not sure what the "libtool" hack thing is all about, why is that necessary? In fact I'm not sure what the whole opt_program_name thing is about, what are you trying to address here? That change makes the patch very messy since you are going through and replacing every occurrence of argv[0] with program_name. Typically changes should be separated in patches to ease review, I'm not sure what this has to do with adding --version to the apps.

Quoted 6 lines

Also, why -V rather than -v ?

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.