Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CurrentUsername is not always reliable #1640

Closed
2 of 7 tasks
IzzySoft opened this issue Apr 28, 2017 · 2 comments · Fixed by #4930
Closed
2 of 7 tasks

CurrentUsername is not always reliable #1640

IzzySoft opened this issue Apr 28, 2017 · 2 comments · Fixed by #4930
Labels
type/question Issue needs no code to be fixed, only a description on how to fix it yourself.

Comments

@IzzySoft
Copy link

  • Gitea version (or commit ref): 1.1.0
  • Git version: 2.1.4
  • Operating system: Bananian (based on Debian Jessie)
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist:

Description

This is an issue existing with Gogs as well (but not considered an issue by Unknwon):

When starting Gitea via e.g. init.d using start-stop-daemon (defining the correct user/group), I get the following error:

[...s/setting/setting.go:801 NewContext()] [E] Expect user 'git' but current user is: root

Took me a while to figure (and only the linked Gogs issue brought me on the right path): the environment variable $USER still points to root, though id -un as well as whoami indicate the script is running under the correct user (i.e. git:git). I've worked around that using a shell script, prefixing the gitea web command by a line stating USER=$(id -un) – but shouldn't Gitea figure that itself? Some other users might give up before figuring :)

And while on it: is there a way to tell Gitea it should run in "daemon mode" instead of "in foreground" – other than using &?

@bkcsoft
Copy link
Member

bkcsoft commented Apr 28, 2017

I would say that this is a bug in start-stop-daemon, not gitea :trollface:

@lunny lunny added the type/question Issue needs no code to be fixed, only a description on how to fix it yourself. label Apr 29, 2017
@IzzySoft
Copy link
Author

One could see it that way, sure. But where are the chances better that it gets fixed? 😜

Btw, I just figured how Unknwon worked around that. The Gogs repo contains an init.d script which, with some minor adjustments, could be used for Gitea as well. And guess how it's achieved there? See e.g. lines 27 + 51:

USER=git
…
sh -c "USER=$USER start-stop-daemon …  --chuid $USER …

As it would solve the underlying issue, may I suggest to "pull" that script, make the 3 minor adjustments (variables NAME, DESC, WORKINGDIR), add it to the corresponding directory in the Gitea repo, and have a pointer to it from the documentation (a la "if you want to run it automatically at system start on your Linux system, you can use that init.d script")?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type/question Issue needs no code to be fixed, only a description on how to fix it yourself.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants