Skip to contentSkip to conversation

Yet another pass at libselinux/matchpathcon fix.

PATCH Daniel J Walsh 1 participant 1 message Jun 21, 2006 SELinux security module

lore
Share & tools
lore
#0 lore raw

functions renamed to
selinux_file_context_cmp and selinux_file_context_verify

Translation is postponed until last second. I think for matchpathcon the default should be NOTRANS.

Tools that display should have to translate. I think we had the other default because of upgrade from FC4? Which we will need to handle when upgrading RHEL4 if we decide to change default.

This change will slow down apps that call matchpathcon many times with translations turned on.

Dan

include/selinux/selinux.h +11 -0
diff --exclude-from=exclude -N -u -r nsalibselinux/include/selinux/selinux.h libselinux-1.30.15/include/selinux/selinux.h
@@ -429,8 +429,19 @@
    Caller must free the returned strings via free. */
 extern int getseuserbyname(const char *linuxuser, char **seuser, char **level);
 
+/* This function compares two file context, ignoring the user component */
+int selinux_file_context_cmp(const security_context_t a, const security_context_t b);
+
+/* This function looks at the file context on disk and compares it to the 
+system defaults, it returns 0 on match non 0 on failure */
+int selinux_file_context_verify(const char *path, mode_t mode);
+
+/* This function sets the file context on to the system defaults returns 0 on success */
+int selinux_lsetfilecon_default(const char *path);
+
 #ifdef __cplusplus
 }
 #endif
 
 #endif
+
man/man8/matchpathcon.8 +15 -3
diff --exclude-from=exclude -N -u -r nsalibselinux/man/man8/matchpathcon.8 libselinux-1.30.15/man/man8/matchpathcon.8
@@ -3,13 +3,25 @@
 matchpathcon \- get the default security context for the specified path from the file contexts configuration.
 
 .SH "SYNOPSIS"
-.B matchpathcon [-n] filepath...
-
+.B matchpathcon [-V] [-N] [-n] [-f file_contexts_file ] [-p prefix ] filepath...
 .SH "DESCRIPTION"
 .B matchpathcon
 Prints the file path and the default security context associated with it.
+.SH OPTIONS
+.B \-n
+Do not display path.
+.br
+.B \-N
+Do not use translations.
+.br
+.B \-f file_context_file
+Use alternate file_context file
+.br
+.B \-p prefix
+Use prefix to speed translations
 .br
-If the -n option is given, do not display path.
+.B \-V
+Verify file context on disk matches defaults
 
 .SH AUTHOR	
 This manual page was written by Dan Walsh <[email protected]>.
src/matchpathcon.c +79 -18

134 lines not on this page · raw message

utils/matchpathcon.c +51 -14

88 lines not on this page · raw message