[CRIU] [PATCH] log: chown pidfile to criu user

Ruslan Kuprieiev kupruser at gmail.com
Thu Jan 22 07:52:53 PST 2015


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

Signed-off-by: Ruslan Kuprieiev <kupruser at gmail.com>
---
 log.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/log.c b/log.c
index c6e64da..bbc3828 100644
--- a/log.c
+++ b/log.c
@@ -191,6 +191,12 @@ int write_pidfile(int pid)
 		return -1;
 	}
 
+	if (fchown(fd, getuid(), -1)) {
+		pr_perror("Can't chown %s to uid %u", opts.pidfile, getuid());
+		close(fd);
+		return -1;
+	}
+
 	dprintf(fd, "%d", pid);
 	close(fd);
 	return 0;
-- 
2.1.0



More information about the CRIU mailing list