Change user to git in init script is broken
Created by: TomLottermann
I stumbled across a bug when setting up gitlab on my Ubuntu 14.04 with the git user being in an LDAP and the gitlab home being on an nfs. The init script fails to start up anything. I ran it again as the git user and it worked, so I was curious what would cause that behaviour. I found the following lines in the code:
# Switch to the app_user if it is not he/she who is running the script.
if [ "$USER" != "$app_user" ]; then
eval su - "$app_user" -c $(echo \")$0 "$@"$(echo \"); exit;
fi
As far as I understand (and people on #bash on freenode told me) this reexecutes the script as the user git. However they strongly discouraged to achieve this in the way done above. Sadly I do not have any idea about bash, but they provided me with a quite useful link which explains all this: http://mywiki.wooledge.org/BashFAQ/028
As far as I can see $0 might not be set correctly, although when I echo $0 out from the script before it fails, I actually get the output "/etc/init.d/gitlab" - which should be what was desired, or not? Never the less the server does not start up and stops in the if above.
Has anybody run into the same issue, or know a fix for it?