From 3366af7aa8212dfa9838fdfd17bae7909eb3797d Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Fri, 30 Sep 2016 17:35:34 -0500 Subject: sed -i run as root wasn't preserving ownership. --- lib/lib.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/lib.c b/lib/lib.c index fe85cbed..c20a06cf 100644 --- a/lib/lib.c +++ b/lib/lib.c @@ -640,11 +640,15 @@ int copy_tempfile(int fdin, char *name, char **tempname) if (!tempfile2zap) sigatexit(tempfile_handler); tempfile2zap = *tempname; - // Set permissions of output file + // Set permissions of output file (ignoring errors, usually due to nonroot) fstat(fdin, &statbuf); fchmod(fd, statbuf.st_mode); + // It's fine if this fails (generally because we're not root), but gcc no + // longer lets a (void) typecast silence the "unused result" warning, so... + if (fchown(fd, statbuf.st_uid, statbuf.st_gid)); + return fd; } -- cgit v1.2.3