copyfile() passes the source mode to open(2), which applies the umask,
so a 0644 file copied with umask 0027 ends up 0640.
Apply the source mode with fchmod() after creating the destination.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
A `const` string is a declaration to the user of an API that the
implementation does not touch the contents.
We do some `(char *)` casting in this patch, but the resulting
code still does not touch the contents of the original pointer.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>