sbase

commit51e432cc44310c503650d83269cef81df875f580parent3276fbea1cfb23ed5eeb11aa18813c461acca004Author: Michael Forney <mforney@mforney.org>
Date: Mon, 3 Jul 2017 14:58:50 -0700
cp: Only call chmod with -p or -a
Previously, when the destination file was created with fopen, we needed
to use fchmod to set its permissions.
Now that we pass in the mode to creat, we already get the desired
behavior of creating the file with the same mode as the source file
modified by the user's file creation mask.
This fixes the issue where a directory or special file created with
mkdir/mknod does not end up with the appropriate mode with -p or -a
(since it may have been narrowed by the umask).
This also allows us to clear the SUID and SGID bits from the mode if the
chown fails, as specified by POSIX.
Diffstat: