aboutsummaryrefslogtreecommitdiff
path: root/lib/lib.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2016-09-30 17:35:34 -0500
committerRob Landley <rob@landley.net>2016-09-30 17:35:34 -0500
commit3366af7aa8212dfa9838fdfd17bae7909eb3797d (patch)
treece91b8f071a9a3d13bb2a14a245fdc492b3ad10a /lib/lib.c
parent703c49e0cb9718b4bfad9fcee45329c972aab12e (diff)
downloadtoybox-3366af7aa8212dfa9838fdfd17bae7909eb3797d.tar.gz
sed -i run as root wasn't preserving ownership.
Diffstat (limited to 'lib/lib.c')
-rw-r--r--lib/lib.c6
1 files changed, 5 insertions, 1 deletions
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;
}