[RFC PATCH v2 2/4] libsepol: introduce sepol_const_security_context_t typedef

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The typedef `sepol_security_context_t` is used for contexts.  For the
read-only input parameter in `sepol_context_to_sid()`
`const sepol_security_context_t` is used as type, which does not expand
to the expected `const char*` but `char *const`.

Introduce a corresponding typedef for `const char*`.

Signed-off-by: Christian Göttsche <cgzones@xxxxxxxxxxxxxx>
---
 libsepol/include/sepol/policydb/flask_types.h | 1 +
 libsepol/include/sepol/policydb/services.h    | 2 +-
 libsepol/src/context.c                        | 2 +-
 libsepol/src/services.c                       | 2 +-
 4 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/libsepol/include/sepol/policydb/flask_types.h b/libsepol/include/sepol/policydb/flask_types.h
index 7bec5129..02c22eac 100644
--- a/libsepol/include/sepol/policydb/flask_types.h
+++ b/libsepol/include/sepol/policydb/flask_types.h
@@ -27,6 +27,7 @@ extern "C" {
  * understanding of the security policy.
  */
 typedef char *sepol_security_context_t;
+typedef const char *sepol_const_security_context_t;
 
 /*
  * An access vector (AV) is a collection of related permissions
diff --git a/libsepol/include/sepol/policydb/services.h b/libsepol/include/sepol/policydb/services.h
index 44de3863..bcb0930f 100644
--- a/libsepol/include/sepol/policydb/services.h
+++ b/libsepol/include/sepol/policydb/services.h
@@ -155,7 +155,7 @@ extern int sepol_sid_to_context(sepol_security_id_t sid,	/* IN */
  * Return a SID associated with the security context that
  * has the string representation specified by `scontext'.
  */
-extern int sepol_context_to_sid(const sepol_security_context_t scontext,	/* IN */
+extern int sepol_context_to_sid(sepol_const_security_context_t scontext,	/* IN */
 				size_t scontext_len,	/* IN */
 				sepol_security_id_t * out_sid);	/* OUT */
 
diff --git a/libsepol/src/context.c b/libsepol/src/context.c
index e81b28c6..5cc90afb 100644
--- a/libsepol/src/context.c
+++ b/libsepol/src/context.c
@@ -22,7 +22,7 @@ int policydb_context_isvalid(const policydb_t * p, const context_struct_t * c)
 int sepol_check_context(const char *context)
 {
 
-	return sepol_context_to_sid((const sepol_security_context_t)context,
+	return sepol_context_to_sid(context,
 				    strlen(context) + 1, NULL);
 }
 
diff --git a/libsepol/src/services.c b/libsepol/src/services.c
index b2fb804e..c3897c91 100644
--- a/libsepol/src/services.c
+++ b/libsepol/src/services.c
@@ -1269,7 +1269,7 @@ int sepol_sid_to_context(sepol_security_id_t sid,
  * Return a SID associated with the security context that
  * has the string representation specified by `scontext'.
  */
-int sepol_context_to_sid(const sepol_security_context_t scontext,
+int sepol_context_to_sid(sepol_const_security_context_t scontext,
 				size_t scontext_len, sepol_security_id_t * sid)
 {
 
-- 
2.35.1




[Index of Archives]     [Selinux Refpolicy]     [Linux SGX]     [Fedora Users]     [Fedora Desktop]     [Yosemite Photos]     [Yosemite Camping]     [Yosemite Campsites]     [KDE Users]     [Gnome Users]

  Powered by Linux