Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • G gitlabhq1
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 21
    • Issues 21
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 12
    • Merge requests 12
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Infrastructure Registry
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • gpt
  • large_projects
  • gitlabhq1
  • Issues
  • #6900

Closed
Open
Created Apr 30, 2014 by Administrator@rootOwner

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?

Assignee
Assign to
Time tracking