Skip to contentSkip to conversation

restorecond: Do not ignore the -f option

PATCH In review Ondrej Mosnacek 2 participants 2 messages Oct 3, 2018 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 restorecond: Do not ignore the -f option

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")
---
 restorecond/restorecond.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
restorecond/restorecond.c +2 -1
index e1d26cb9..7b984b29 100644
@@ -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) {
Signature · 1 line
2.17.1
#1 lore raw

Ack. (sorry for the HTML email)

Quoted 44 lines · On Wed, 3 Oct 2018, 23:52 Ondrej Mosnacek, <[email protected]> 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")

---
 restorecond/restorecond.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
restorecond/restorecond.c +2 -0
index e1d26cb9..7b984b29 100644
@@ -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;
restorecond/restorecond.c +0 -2
@@ -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
[email protected]
To unsubscribe, send email to [email protected]. To get help, send an email containing "help" to [email protected].