Chmod working in sudo run script but chown isn't

My git user has permission in sudoers to run a wrapper script to move files into my webroot.

Everything is working fine except for the chown line. After the script has run, the files ar still root:root instead of apache:apache.

Scratching my head...:confused:

#!/bin/sh

echo
echo "**** Pulling changes into Prime [Hub's post-update hook]"
echo
cd /usr/local/apache/htdocs || exit
unset GIT_DIR
git pull hub master
exec /usr/libexec/git-core/git-update-server-info
chmod -R 0644 /usr/local/apache/htdocs
chown -R apache:apache /usr/local/apache/htdocs

Any ideas? Thanks.

Maybe include -v with the chown command to see what it's doing.

Maybe try different chmod value to verify sure chmod is really running.

I added -v to the chown command but I'm not getting any output...perhaps because the script is run over ssh and there's !requiretty in the sudoer? I guess I could try piping the output into a file?

UPDATE: Added 2>&1 | tee /tmp/test.txt to the end of the chown command. Didn't create a file. Is there any other way to debug this?

Run the git-update-server-info without exec

1 Like

Thanks.