restorecond: Do not unlink pidfile if not used
PATCH 1/1 restorecond: Do not unlink pidfile if not used
With -F or -d, restorecond does not create nor use pidfile and therefore it should not try to remove it.
--- restorecond/restorecond.c | 2 ++ 1 file changed, 2 insertions(+)
restorecond/restorecond.c +2 -0
@@ -217,6 +217,8 @@ int main(int argc, char **argv)if (daemon (0 ,0 ) <0 )exitApp ("daemon" );write_pid_file (); + }else { + pidfile =0 ; }while (watch (master_fd, watch_file) ==0 ) {
Signature · 1 line
2.54.0
Quoted 5 lines · Petr Lautrbach
With -F or -d, restorecond does not create nor use pidfile and therefore it should not try to remove it.
Signed-off-by Petr Lautrbach <[email protected]>
Is there a reason we are using 0 instead of NULL for pidfile despite it being a pointer?
Otherwise,
Quoted 21 lines
--- restorecond/restorecond.c | 2 ++ 1 file changed, 2 insertions(+)restorecond/restorecond.c +2
-1@@ -217,6 +217,8 @@ int main(int argc, char **argv)if (daemon (0 ,0 ) <0 )exitApp ("daemon" );write_pid_file (); + }else { + pidfile =0 ; }while (watch (master_fd, watch_file) ==0 ) { --2.54.0
Quoted 9 lines · Stephen Smalley
Quoted 5 lines · Petr Lautrbach
With -F or -d, restorecond does not create nor use pidfile and therefore it should not try to remove it.
Signed-off-by Petr Lautrbach <[email protected]>Is there a reason we are using 0 instead of NULL for pidfile despite it being a pointer?
I wanted to be consistent with the rest of the code in in write_pid():
if (len < 0) {
syslog(LOG_ERR, "Pid error (%s)", strerror(errno));
pidfile = 0;
return 1;
}
pidfd = open(pidfile, O_CREAT | O_TRUNC | O_NOFOLLOW | O_WRONLY, 0644);
if (pidfd < 0) {
syslog(LOG_ERR, "Unable to set pidfile (%s)", strerror(errno));
pidfile = 0;
return 1;
}Quoted 24 lines
Otherwise,
Acked-by Stephen Smalley <[email protected]>Quoted 21 lines
--- restorecond/restorecond.c | 2 ++ 1 file changed, 2 insertions(+)restorecond/restorecond.c +2
-1@@ -217,6 +217,8 @@ int main(int argc, char **argv)if (daemon (0 ,0 ) <0 )exitApp ("daemon" );write_pid_file (); + }else { + pidfile =0 ; }while (watch (master_fd, watch_file) ==0 ) { --2.54.0
Stephen Smalley
maintainerQuoted 6 lines · Stephen Smalley
Quoted 4 lines · Petr Lautrbach
With -F or -d, restorecond does not create nor use pidfile and therefore it should not try to remove it.
Quoted 7 lines
Quoted 1 line
Signed-off-by Petr Lautrbach <[email protected]>Is there a reason we are using 0 instead of NULL for pidfile despite it being a pointer?
Otherwise,
Acked-by Stephen Smalley <[email protected]>
Merged.