I've got a file owned by a non-root user:
# ls -l example.php -rw------- 1 foo bar ... example.php
I just applied a patch with a command like
patch -p0 <<-EOF --- .../example.php.orig 2012-06-20 15:07:13.000000000 +0200 +++ .../example.php 2012-06-20 15:43:05.000000000 +0200 ... EOF
as root and the target file user and group were both changed to
root. I couldn't find any reference to this in the
Is there a way to leave the file ownership as before without using
suseems unable to specify a group.
sudo -u foo patch ...runs fine, but sets the wrong group.
sudo -u foo -g bar patch ...returns
Sorry, user root is not allowed to execute '/usr/bin/patch' as foo:bar on hostname. This might be because user
foois not a member of group
chownwould mean having to store the permissions before running
patch, adding another two lines of code.