Skip to content

Commit

Permalink
libselinux/utils/selabel_digest: pass BASEONLY only for file backend
Browse files Browse the repository at this point in the history
Since commit 65c8fd4 ("libselinux: fail selabel_open(3) on invalid
option") selabel_open(3) rejects options not supported for the
respective backend.  Pass SELABEL_OPT_BASEONLY only if the file backend
is selected.

Reported-by: zgzxx (#427)
Fixes: 65c8fd4 ("libselinux: fail selabel_open(3) on invalid option")
Signed-off-by: Christian Göttsche <[email protected]>
Acked-by: James Carter <[email protected]>
  • Loading branch information
cgzones authored and jwcart2 committed Mar 20, 2024
1 parent 5876aca commit fb49789
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions libselinux/utils/selabel_digest.c
Expand Up @@ -71,8 +71,8 @@ int main(int argc, char **argv)
struct selabel_handle *hnd;
struct selinux_opt selabel_option[] = {
{ SELABEL_OPT_PATH, file },
{ SELABEL_OPT_BASEONLY, baseonly },
{ SELABEL_OPT_DIGEST, digest }
{ SELABEL_OPT_DIGEST, digest },
{ SELABEL_OPT_BASEONLY, baseonly }
};

if (argc < 3)
Expand Down Expand Up @@ -119,10 +119,10 @@ int main(int argc, char **argv)
memset(cmd_buf, 0, sizeof(cmd_buf));

selabel_option[0].value = file;
selabel_option[1].value = baseonly;
selabel_option[2].value = digest;
selabel_option[1].value = digest;
selabel_option[2].value = baseonly;

hnd = selabel_open(backend, selabel_option, 3);
hnd = selabel_open(backend, selabel_option, backend == SELABEL_CTX_FILE ? 3 : 2);
if (!hnd) {
switch (errno) {
case EOVERFLOW:
Expand Down

0 comments on commit fb49789

Please sign in to comment.