mirror of
https://github.com/SELinuxProject/selinux
synced 2025-04-27 13:18:03 +00:00
libsepol: rewrite sepol_string_to_security_class to use hashtab_search
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
This commit is contained in:
parent
69da2076e5
commit
28e92c5325
@ -1152,23 +1152,17 @@ int hidden sepol_compute_av(sepol_security_id_t ssid,
|
|||||||
int hidden sepol_string_to_security_class(const char *class_name,
|
int hidden sepol_string_to_security_class(const char *class_name,
|
||||||
sepol_security_class_t *tclass)
|
sepol_security_class_t *tclass)
|
||||||
{
|
{
|
||||||
char *class = NULL;
|
class_datum_t *tclass_datum;
|
||||||
sepol_security_class_t id;
|
|
||||||
|
|
||||||
for (id = 1; id <= policydb->p_classes.nprim; id++) {
|
tclass_datum = hashtab_search(policydb->p_classes.table,
|
||||||
class = policydb->p_class_val_to_name[id - 1];
|
(hashtab_key_t) class_name);
|
||||||
if (class == NULL) {
|
if (!tclass_datum) {
|
||||||
ERR(NULL, "could not convert %s to class id", class_name);
|
ERR(NULL, "unrecognized class %s", class_name);
|
||||||
return STATUS_ERR;
|
return STATUS_ERR;
|
||||||
}
|
}
|
||||||
if ((strcmp(class, class_name)) == 0) {
|
*tclass = tclass_datum->s.value;
|
||||||
*tclass = id;
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
ERR(NULL, "unrecognized class %s", class_name);
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return access vector bit associated with the class ID and permission
|
* Return access vector bit associated with the class ID and permission
|
||||||
|
Loading…
Reference in New Issue
Block a user