Blame libselinux/src/trans.c
|
Chris PeBenito |
473ea7 |
#include "selinux_internal.h"
|
|
Chris PeBenito |
473ea7 |
#include <string.h>
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
int (*lib_trans_to_raw_context)(char *trans, char **rawp) hidden;
|
|
Chris PeBenito |
473ea7 |
int (*lib_raw_to_trans_context)(char *raw, char **transp) hidden;
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
int hidden trans_to_raw_context(char *trans, char **rawp)
|
|
Chris PeBenito |
473ea7 |
{
|
|
Chris PeBenito |
473ea7 |
*rawp = NULL;
|
|
Chris PeBenito |
473ea7 |
if (!trans)
|
|
Chris PeBenito |
473ea7 |
return 0;
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
if (trans && lib_trans_to_raw_context(trans, rawp))
|
|
Chris PeBenito |
473ea7 |
*rawp = strdup(trans);
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
return *rawp ? 0 : -1;
|
|
Chris PeBenito |
473ea7 |
}
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
int selinux_trans_to_raw_context(security_context_t trans,
|
|
Chris PeBenito |
473ea7 |
security_context_t *rawp)
|
|
Chris PeBenito |
473ea7 |
{
|
|
Chris PeBenito |
473ea7 |
if (context_translations)
|
|
Chris PeBenito |
473ea7 |
return trans_to_raw_context(trans, rawp);
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
if (!trans) {
|
|
Chris PeBenito |
473ea7 |
*rawp = NULL;
|
|
Chris PeBenito |
473ea7 |
return 0;
|
|
Chris PeBenito |
473ea7 |
}
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
*rawp = strdup(trans);
|
|
Chris PeBenito |
473ea7 |
return *rawp ? 0 : -1;
|
|
Chris PeBenito |
473ea7 |
}
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
int hidden raw_to_trans_context(char *raw, char **transp)
|
|
Chris PeBenito |
473ea7 |
{
|
|
Chris PeBenito |
473ea7 |
*transp = NULL;
|
|
Chris PeBenito |
473ea7 |
if (!raw)
|
|
Chris PeBenito |
473ea7 |
return 0;
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
if (raw && lib_raw_to_trans_context(raw, transp))
|
|
Chris PeBenito |
473ea7 |
*transp = strdup(raw);
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
return *transp ? 0 : -1;
|
|
Chris PeBenito |
473ea7 |
}
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
int selinux_raw_to_trans_context(security_context_t raw,
|
|
Chris PeBenito |
473ea7 |
security_context_t *transp)
|
|
Chris PeBenito |
473ea7 |
{
|
|
Chris PeBenito |
473ea7 |
if (context_translations)
|
|
Chris PeBenito |
473ea7 |
return raw_to_trans_context(raw, transp);
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
if (!raw) {
|
|
Chris PeBenito |
473ea7 |
*transp = NULL;
|
|
Chris PeBenito |
473ea7 |
return 0;
|
|
Chris PeBenito |
473ea7 |
}
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
*transp = strdup(raw);
|
|
Chris PeBenito |
473ea7 |
return *transp ? 0 : -1;
|
|
Chris PeBenito |
473ea7 |
}
|