diff options
author | Rob Landley <rob@landley.net> | 2016-09-30 17:35:34 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2016-09-30 17:35:34 -0500 |
commit | 3366af7aa8212dfa9838fdfd17bae7909eb3797d (patch) | |
tree | ce91b8f071a9a3d13bb2a14a245fdc492b3ad10a | |
parent | 703c49e0cb9718b4bfad9fcee45329c972aab12e (diff) | |
download | toybox-3366af7aa8212dfa9838fdfd17bae7909eb3797d.tar.gz |
sed -i run as root wasn't preserving ownership.
-rw-r--r-- | lib/lib.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -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; } |