log: chown pidfile to current criu user

If criu run with suid bit set, user should be able
to read pidfiles(i.e. service pidfile).

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
Ruslan Kuprieiev 2015-01-29 22:59:29 +02:00 committed by Pavel Emelyanov
parent 09c3f5d0c7
commit e2c3ad3791

7
log.c
View file

@ -17,6 +17,7 @@
#include "util.h"
#include "cr_options.h"
#include "servicefd.h"
#include "security.h"
#define DEFAULT_LOGFD STDERR_FILENO
/* Enable timestamps if verbosity is increased from default */
@ -191,6 +192,12 @@ int write_pidfile(int pid)
return -1;
}
if (cr_fchown(fd)) {
pr_perror("Can't chown pidfile %s", opts.pidfile);
close(fd);
return -1;
}
dprintf(fd, "%d", pid);
close(fd);
return 0;