libselinux: add x_contexts path lookup function
PATCH 1/1 libselinux: add x_contexts path lookup function
This patch adds an selinux_x_context_path() function identical to selinux_media_context_path(), fixing a hardcoded path in the X label backend.
I'm bothered that some of these pathnames are exposed in the interface. I assume that this done so libsemanage knows where to look. But having them in the interface could encourage users to depend on them instead of libsemanage.
There are also a lot of these functions, maybe we should just expose the internal function that takes a type code.
---
include/selinux/selinux.h | 1 + src/file_path_suffixes.h | 1 + src/label_x.c | 2 +- src/selinux_config.c | 10 +++++++++- src/selinux_internal.h | 1 + 5 files changed, 13 insertions(+), 2 deletions(-)
include/selinux/selinux.h +0 -0
@@ -454,6 +454,7 @@
extern const char *selinux_file_context_local_path(void); extern const char *selinux_homedir_context_path(void); extern const char *selinux_media_context_path(void); +extern const char *selinux_x_context_path(void); extern const char *selinux_contexts_path(void); extern const char *selinux_securetty_types_path(void); extern const char *selinux_booleans_path(void);
src/file_path_suffixes.h +1 -0
@@ -18,3 +18,4 @@ S_(NETFILTER_CONTEXTS, "/contexts/netfilter_contexts") S_(FILE_CONTEXTS_HOMEDIR, "/contexts/files/file_contexts.homedir") S_(FILE_CONTEXTS_LOCAL, "/contexts/files/file_contexts.local") +S_ (X_CONTEXTS ,"/contexts/x_contexts" )
src/selinux_internal.h +1 -0
@@ -65,6 +65,7 @@ hidden_proto(selinux_booleans_path) hidden_proto(selinux_customizable_types_path) hidden_proto(selinux_media_context_path) + hidden_proto(selinux_x_context_path) hidden_proto(selinux_path) hidden_proto(selinux_check_passwd_access) hidden_proto(selinux_check_securetty_context)
src/label_x.c +0 -0
@@ -107,7 +107,7 @@
/* Open the specification file. */ if (!path) - path = "/etc/selinux/refpolicy/contexts/x_contexts"; + path = selinux_x_context_path(); if ((fp = fopen(path, "r")) == NULL) return -1; __fsetlocking(fp, FSETLOCKING_BYCALLER);
src/selinux_config.c +0 -0
@@ -38,7 +38,8 @@
#define FILE_CONTEXTS_HOMEDIR 16
#define FILE_CONTEXTS_LOCAL 17
#define SECURETTY_TYPES 18
-#define NEL 19 +#define X_CONTEXTS 19 +#define NEL 20
/* New layout is relative to SELINUXDIR/policytype. */ static char *file_paths[NEL];
@@ -369,3 +370,10 @@
}
hidden_def(selinux_file_context_local_path)
+
+const char *selinux_x_context_path()
+{
+ return get_path(X_CONTEXTS);
+}
+
+hidden_def(selinux_x_context_path)
Signature · 8 lines
Eamon Walsh <[email protected]> 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.
Quoted 9 lines · Eamon Walsh
This patch adds an
selinux_x_context_path()function identical toselinux_media_context_path(), fixing a hardcoded path in the X label backend.I'm bothered that some of these pathnames are exposed in the interface. I assume that this done so libsemanage knows where to look. But having them in the interface could encourage users to depend on them instead of libsemanage.
Quoted 4 lines
There are also a lot of these functions, maybe we should just expose the internal function that takes a type code.
Signed-off-by Eamon Walsh <[email protected]>
Pretty trivial, I'd say merge at will (or wait for another ack, either way)
I still don't like the labeling logic being here but I guess that battle was lost, some apps (DBus, postgres) still maintain their own labeling system, DBus could be moved to this probably but postgres will need to maintain labels in the tables themselves.
src/file_path_suffixes.h
Quoted 25 lines
---
include/selinux/selinux.h | 1 + src/file_path_suffixes.h | 1 + src/label_x.c | 2 +- src/selinux_config.c | 10 +++++++++- src/selinux_internal.h | 1 + 5 files changed, 13 insertions(+), 2 deletions(-)Index:
libselinux/include/selinux/selinux.h
===================================================================include/selinux/selinux.h +1
-0+454,7 @@ extern const char *selinux_file_context_local_path(void);extern const char *selinux_homedir_context_path (void );extern const char *selinux_media_context_path (void ); +extern const char *selinux_x_context_path (void ); extern const char *selinux_contexts_path(void); externconst char
*selinux_securetty_types_path(void);
extern const char*selinux_booleans_path(void);
Index:libselinux/src/file_path_suffixes.h
===================================================================src/file_path_suffixes.h +0
-0
+18,4
Quoted 45 lines
@@
S_(NETFILTER_CONTEXTS, "/contexts/netfilter_contexts")S_(FILE_CONTEXTS_HOMEDIR,
"/contexts/files/file_contexts.homedir")
S_(FILE_CONTEXTS_LOCAL, "/contexts/files/file_contexts.local")
+S_(X_CONTEXTS, "/contexts/x_contexts")
Index:libselinux/src/selinux_internal.h
===================================================================src/selinux_internal.h +1
-0hidden_proto(selinux_booleans_path) hidden_proto(selinux_customizable_types_path) hidden_proto(selinux_media_context_path) + hidden_proto(selinux_x_context_path) hidden_proto(selinux_path) hidden_proto(selinux_check_passwd_access) hidden_proto(selinux_check_securetty_context)Index:
libselinux/src/label_x.c
===================================================================src/label_x.c +1
-1@@ -107,7 +107,7 @@/* Open the specification file. */ if (!path) - path ="/etc/selinux/refpolicy/contexts/x_contexts" ; + path =selinux_x_context_path ();if ((fp =fopen (path,"r" )) ==NULL )return -1 ;__fsetlocking (fp,FSETLOCKING_BYCALLER );Index:
libselinux/src/selinux_config.c
===================================================================src/selinux_config.c +2
-1@@ -38,7 +38,8 @@#define FILE_CONTEXTS_HOMEDIR 16#define FILE_CONTEXTS_LOCAL 17#define SECURETTY_TYPES 18 -#define NEL 19 +#define X_CONTEXTS 19 +#define NEL 20/* New layout is relative to SELINUXDIR/policytype. */ static char *file_paths[NEL]; @@ -369,3 +370,10 @@ }
hidden_def(selinux_file_context_local_path)
src/selinux_config.c
Quoted 7 lines
src/selinux_config.c +7
-0+ +const char *selinux_x_context_path () +{ +return get_path (X_CONTEXTS ); +} + +hidden_def (selinux_x_context_path)
--
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.