Skip to content

Commit

Permalink
libsepol: remove unused functions
Browse files Browse the repository at this point in the history
The functions `role_set_get_role`, `sepol_validate_transition` and
`sepol_sidtab_remove` seem to be unused since the initial import.

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
Acked-by: James Carter <jwcart2@gmail.com>
  • Loading branch information
cgzones authored and jwcart2 committed Jun 24, 2021
1 parent 9ec061b commit 42f3d7c
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 96 deletions.
18 changes: 0 additions & 18 deletions libsepol/src/policydb.c
Expand Up @@ -1791,24 +1791,6 @@ int type_set_or_eq(type_set_t * dst, type_set_t * other)
return ret;
}

int role_set_get_role(role_set_t * x, uint32_t role)
{
if (x->flags & ROLE_STAR)
return 1;

if (ebitmap_get_bit(&x->roles, role - 1)) {
if (x->flags & ROLE_COMP)
return 0;
else
return 1;
} else {
if (x->flags & ROLE_COMP)
return 1;
else
return 0;
}
}

/***********************************************************************/
/* everything below is for policy reads */

Expand Down
47 changes: 0 additions & 47 deletions libsepol/src/services.c
Expand Up @@ -1024,53 +1024,6 @@ static int context_struct_compute_av(context_struct_t * scontext,
return 0;
}

static int sepol_validate_transition(sepol_security_id_t oldsid,
sepol_security_id_t newsid,
sepol_security_id_t tasksid,
sepol_security_class_t tclass)
{
context_struct_t *ocontext;
context_struct_t *ncontext;
context_struct_t *tcontext;
class_datum_t *tclass_datum;
constraint_node_t *constraint;

if (!tclass || tclass > policydb->p_classes.nprim) {
ERR(NULL, "unrecognized class %d", tclass);
return -EINVAL;
}
tclass_datum = policydb->class_val_to_struct[tclass - 1];

ocontext = sepol_sidtab_search(sidtab, oldsid);
if (!ocontext) {
ERR(NULL, "unrecognized SID %d", oldsid);
return -EINVAL;
}

ncontext = sepol_sidtab_search(sidtab, newsid);
if (!ncontext) {
ERR(NULL, "unrecognized SID %d", newsid);
return -EINVAL;
}

tcontext = sepol_sidtab_search(sidtab, tasksid);
if (!tcontext) {
ERR(NULL, "unrecognized SID %d", tasksid);
return -EINVAL;
}

constraint = tclass_datum->validatetrans;
while (constraint) {
if (!constraint_expr_eval_reason(ocontext, ncontext, tcontext,
0, constraint, NULL, 0)) {
return -EPERM;
}
constraint = constraint->next;
}

return 0;
}

/*
* sepol_validate_transition_reason_buffer - the reason buffer is realloc'd
* in the constraint_expr_eval_reason() function.
Expand Down
31 changes: 0 additions & 31 deletions libsepol/src/sidtab.c
Expand Up @@ -84,37 +84,6 @@ int sepol_sidtab_insert(sidtab_t * s, sepol_security_id_t sid,
return 0;
}

int sepol_sidtab_remove(sidtab_t * s, sepol_security_id_t sid)
{
int hvalue;
sidtab_node_t *cur, *last;

if (!s || !s->htable)
return -ENOENT;

hvalue = SIDTAB_HASH(sid);
last = NULL;
cur = s->htable[hvalue];
while (cur != NULL && sid > cur->sid) {
last = cur;
cur = cur->next;
}

if (cur == NULL || sid != cur->sid)
return -ENOENT;

if (last == NULL)
s->htable[hvalue] = cur->next;
else
last->next = cur->next;

context_destroy(&cur->context);

free(cur);
s->nel--;
return 0;
}

context_struct_t *sepol_sidtab_search(sidtab_t * s, sepol_security_id_t sid)
{
int hvalue;
Expand Down

0 comments on commit 42f3d7c

Please sign in to comment.