libsepol: introduce sepol_const_security_context_t typedef

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*`.

Acked-by: James Carter <jwcart2@gmail.com>
Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
This commit is contained in:
Christian Göttsche 2022-02-22 14:54:33 +01:00 committed by James Carter
parent f0e085f684
commit 3ae07ec36f
4 changed files with 4 additions and 3 deletions

View File

@ -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

View File

@ -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 */

View File

@ -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);
}

View File

@ -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)
{