From: James Carter <jwcart2@gmail.com>
To: Vit Mojzis <vmojzis@redhat.com>
Cc: SElinux list <selinux@vger.kernel.org>
Subject: Re: [PATCH v2] libselinux: Strip spaces before values in config
Date: Thu, 3 Mar 2022 13:18:38 -0500 [thread overview]
Message-ID: <CAP+JOzRmGdkhSK5n6NELPhiYYiVqbq=eTPc92_DNh=vh8GTjAA@mail.gmail.com> (raw)
In-Reply-To: <CAP+JOzSX3iLRQgOEwzt1uXEV=--r77n4bUFLT6uPHeFTp=vGjQ@mail.gmail.com>
On Mon, Feb 28, 2022 at 3:22 PM James Carter <jwcart2@gmail.com> wrote:
>
> On Thu, Feb 17, 2022 at 1:24 PM Vit Mojzis <vmojzis@redhat.com> wrote:
> >
> > Spaces before values in /etc/selinux/config should be ignored just as
> > spaces after them are.
> >
> > E.g. "SELINUXTYPE= targeted" should be a valid value.
> >
> > Fixes:
> > # sed -i 's/^SELINUXTYPE=/SELINUXTYPE= /g' /etc/selinux/config
> > # dnf install <any_package>
> > ...
> > RPM: error: selabel_open: (/etc/selinux/ targeted/contexts/files/file_contexts) No such file or directory
> > RPM: error: Plugin selinux: hook tsm_pre failed
> > ...
> > Error: Could not run transaction.
> >
> > Signed-off-by: Vit Mojzis <vmojzis@redhat.com>
>
> Acked-by: James Carter <jwcart2@gmail.com>
>
Merged.
Thanks,
Jim
> > ---
> >
> > Sorry for the delay. I sent the fixed patch to a wrong mailing list.
> >
> > libselinux/src/selinux_config.c | 17 +++++++++++++----
> > 1 file changed, 13 insertions(+), 4 deletions(-)
> >
> > diff --git a/libselinux/src/selinux_config.c b/libselinux/src/selinux_config.c
> > index 97f81a8b..d2e49ee1 100644
> > --- a/libselinux/src/selinux_config.c
> > +++ b/libselinux/src/selinux_config.c
> > @@ -92,6 +92,7 @@ int selinux_getenforcemode(int *enforce)
> > FILE *cfg = fopen(SELINUXCONFIG, "re");
> > if (cfg) {
> > char *buf;
> > + char *tag;
> > int len = sizeof(SELINUXTAG) - 1;
> > buf = malloc(selinux_page_size);
> > if (!buf) {
> > @@ -101,21 +102,24 @@ int selinux_getenforcemode(int *enforce)
> > while (fgets_unlocked(buf, selinux_page_size, cfg)) {
> > if (strncmp(buf, SELINUXTAG, len))
> > continue;
> > + tag = buf+len;
> > + while (isspace(*tag))
> > + tag++;
> > if (!strncasecmp
> > - (buf + len, "enforcing", sizeof("enforcing") - 1)) {
> > + (tag, "enforcing", sizeof("enforcing") - 1)) {
> > *enforce = 1;
> > ret = 0;
> > break;
> > } else
> > if (!strncasecmp
> > - (buf + len, "permissive",
> > + (tag, "permissive",
> > sizeof("permissive") - 1)) {
> > *enforce = 0;
> > ret = 0;
> > break;
> > } else
> > if (!strncasecmp
> > - (buf + len, "disabled",
> > + (tag, "disabled",
> > sizeof("disabled") - 1)) {
> > *enforce = -1;
> > ret = 0;
> > @@ -176,7 +180,10 @@ static void init_selinux_config(void)
> >
> > if (!strncasecmp(buf_p, SELINUXTYPETAG,
> > sizeof(SELINUXTYPETAG) - 1)) {
> > - type = strdup(buf_p + sizeof(SELINUXTYPETAG) - 1);
> > + buf_p += sizeof(SELINUXTYPETAG) - 1;
> > + while (isspace(*buf_p))
> > + buf_p++;
> > + type = strdup(buf_p);
> > if (!type) {
> > free(line_buf);
> > fclose(fp);
> > @@ -199,6 +206,8 @@ static void init_selinux_config(void)
> > } else if (!strncmp(buf_p, REQUIRESEUSERS,
> > sizeof(REQUIRESEUSERS) - 1)) {
> > value = buf_p + sizeof(REQUIRESEUSERS) - 1;
> > + while (isspace(*value))
> > + value++;
> > intptr = &require_seusers;
> > } else {
> > continue;
> > --
> > 2.30.2
> >
prev parent reply other threads:[~2022-03-03 18:18 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-13 20:43 [PATCH] libselinux: Strip spaces before values in config Vit Mojzis
2022-01-15 17:28 ` Christian Göttsche
2022-01-17 9:42 ` Vit Mojzis
2022-02-17 13:14 ` [PATCH v2] " Vit Mojzis
2022-02-17 14:16 ` Christian Göttsche
2022-02-21 10:31 ` Vit Mojzis
2022-02-28 20:25 ` James Carter
2022-02-28 20:22 ` James Carter
2022-03-03 18:18 ` James Carter [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAP+JOzRmGdkhSK5n6NELPhiYYiVqbq=eTPc92_DNh=vh8GTjAA@mail.gmail.com' \
--to=jwcart2@gmail.com \
--cc=selinux@vger.kernel.org \
--cc=vmojzis@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).