diff mbox series

restorecond: Do not ignore the -f option

Message ID 20181003155007.26898-1-omosnace@redhat.com (mailing list archive)
State Not Applicable
Headers show
Series restorecond: Do not ignore the -f option | expand

Commit Message

Ondrej Mosnacek Oct. 3, 2018, 3:50 p.m. UTC
Since the default value of watch_file is set unconditionally *after* the
command-line arguments have been parsed, the -f option is (and has
always been) effectively ignored. Fix this by setting it before the
parsing.

Fixes: 48681bb49c03 ("policycoreutils: restorecond: make restorecond dbuss-able")
Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
---
 restorecond/restorecond.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Jason Zaman Oct. 3, 2018, 6:05 p.m. UTC | #1
Ack. (sorry for the HTML email)

On Wed, 3 Oct 2018, 23:52 Ondrej Mosnacek, <omosnace@redhat.com> wrote:

> Since the default value of watch_file is set unconditionally *after* the
> command-line arguments have been parsed, the -f option is (and has
> always been) effectively ignored. Fix this by setting it before the
> parsing.
>
> Fixes: 48681bb49c03 ("policycoreutils: restorecond: make restorecond
> dbuss-able")
> Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
> ---
>  restorecond/restorecond.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/restorecond/restorecond.c b/restorecond/restorecond.c
> index e1d26cb9..7b984b29 100644
> --- a/restorecond/restorecond.c
> +++ b/restorecond/restorecond.c
> @@ -148,6 +148,8 @@ int main(int argc, char **argv)
>         if (is_selinux_enabled() != 1)
>                 return 0;
>
> +       watch_file = server_watch_file;
> +
>         /* Set all options to zero/NULL except for ignore_noent & digest.
> */
>         memset(&r_opts, 0, sizeof(r_opts));
>         r_opts.ignore_noent = SELINUX_RESTORECON_IGNORE_NOENTRY;
> @@ -205,7 +207,6 @@ int main(int argc, char **argv)
>                 return 0;
>         }
>
> -       watch_file = server_watch_file;
>         read_config(master_fd, watch_file);
>
>         if (!debug_mode) {
> --
> 2.17.1
>
> _______________________________________________
> Selinux mailing list
> Selinux@tycho.nsa.gov
> To unsubscribe, send email to Selinux-leave@tycho.nsa.gov.
> To get help, send an email containing "help" to
> Selinux-request@tycho.nsa.gov.
>
<div dir="auto">Ack. (sorry for the HTML email)</div><br><div class="gmail_quote"><div dir="ltr">On Wed, 3 Oct 2018, 23:52 Ondrej Mosnacek, &lt;<a href="mailto:omosnace@redhat.com">omosnace@redhat.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Since the default value of watch_file is set unconditionally *after* the<br>
command-line arguments have been parsed, the -f option is (and has<br>
always been) effectively ignored. Fix this by setting it before the<br>
parsing.<br>
<br>
Fixes: 48681bb49c03 (&quot;policycoreutils: restorecond: make restorecond dbuss-able&quot;)<br>
Signed-off-by: Ondrej Mosnacek &lt;<a href="mailto:omosnace@redhat.com" target="_blank" rel="noreferrer">omosnace@redhat.com</a>&gt;<br>
---<br>
 restorecond/restorecond.c | 3 ++-<br>
 1 file changed, 2 insertions(+), 1 deletion(-)<br>
<br>
diff --git a/restorecond/restorecond.c b/restorecond/restorecond.c<br>
index e1d26cb9..7b984b29 100644<br>
--- a/restorecond/restorecond.c<br>
+++ b/restorecond/restorecond.c<br>
@@ -148,6 +148,8 @@ int main(int argc, char **argv)<br>
        if (is_selinux_enabled() != 1)<br>
                return 0;<br>
<br>
+       watch_file = server_watch_file;<br>
+<br>
        /* Set all options to zero/NULL except for ignore_noent &amp; digest. */<br>
        memset(&amp;r_opts, 0, sizeof(r_opts));<br>
        r_opts.ignore_noent = SELINUX_RESTORECON_IGNORE_NOENTRY;<br>
@@ -205,7 +207,6 @@ int main(int argc, char **argv)<br>
                return 0;<br>
        }<br>
<br>
-       watch_file = server_watch_file;<br>
        read_config(master_fd, watch_file);<br>
<br>
        if (!debug_mode) {<br>
-- <br>
2.17.1<br>
<br>
_______________________________________________<br>
Selinux mailing list<br>
<a href="mailto:Selinux@tycho.nsa.gov" target="_blank" rel="noreferrer">Selinux@tycho.nsa.gov</a><br>
To unsubscribe, send email to <a href="mailto:Selinux-leave@tycho.nsa.gov" target="_blank" rel="noreferrer">Selinux-leave@tycho.nsa.gov</a>.<br>
To get help, send an email containing &quot;help&quot; to <a href="mailto:Selinux-request@tycho.nsa.gov" target="_blank" rel="noreferrer">Selinux-request@tycho.nsa.gov</a>.<br>
</blockquote></div>
diff mbox series

Patch

diff --git a/restorecond/restorecond.c b/restorecond/restorecond.c
index e1d26cb9..7b984b29 100644
--- a/restorecond/restorecond.c
+++ b/restorecond/restorecond.c
@@ -148,6 +148,8 @@  int main(int argc, char **argv)
 	if (is_selinux_enabled() != 1)
 		return 0;
 
+	watch_file = server_watch_file;
+
 	/* Set all options to zero/NULL except for ignore_noent & digest. */
 	memset(&r_opts, 0, sizeof(r_opts));
 	r_opts.ignore_noent = SELINUX_RESTORECON_IGNORE_NOENTRY;
@@ -205,7 +207,6 @@  int main(int argc, char **argv)
 		return 0;
 	}
 
-	watch_file = server_watch_file;
 	read_config(master_fd, watch_file);
 
 	if (!debug_mode) {