On most distributions, /var/run is a symbolic link to /run so using
/var/run or /run lead to the same result. Nevertheless systemd started
to warn about using /var/run in a service file, logging entries such as:
/usr/lib/systemd/system/restorecond.service:8: PIDFile= references
path below legacy directory /var/run/, updating
/var/run/restorecond.pid → /run/restorecond.pid; please update the
unit file accordingly.
Switch to /run in order to follow this advice.
Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
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: 48681bb49c ("policycoreutils: restorecond: make restorecond dbuss-able")
Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
write_pid_file() leaks a file descriptor to /var/run/restorecond.pid if
it fails to write the PID to it. Close the file before returning.
Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
When compiling restorecond with -Wunused, gcc 4.8.4 (from Ubuntu 14.04)
reports the following warnings:
restorecond.c: In function ‘main’:
restorecond.c:208:9: error: ignoring return value of ‘daemon’,
declared with attribute warn_unused_result [-Werror=unused-result]
daemon(0, 0);
^
restorecond.c: In function ‘write_pid_file’:
restorecond.c:106:2: error: ignoring return value of ‘write’,
declared with attribute warn_unused_result [-Werror=unused-result]
(void)write(pidfd, val, (unsigned int)len);
^
If any of these calls returns an error, it is currently silently
discarded. Add a message in order to warn about such an error.
Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
Now that restorecond is separated from policycoreutils, we should not
retain a build dependency on the policycoreutils/setfiles source files.
Fork the restore.[ch] files for restorecond.
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>