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

Expect user 'gitea' but current user is: #4894

Closed
2 of 7 tasks
tinxx opened this issue Sep 8, 2018 · 7 comments
Closed
2 of 7 tasks

Expect user 'gitea' but current user is: #4894

tinxx opened this issue Sep 8, 2018 · 7 comments
Labels
issue/duplicate The issue has already been reported. type/enhancement An improvement of existing functionality

Comments

@tinxx
Copy link

tinxx commented Sep 8, 2018

  • Gitea version (or commit ref): 1.5.1
  • Git version: 2.18.0
  • Operating system: Alpine Linux v3.8
  • 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

Gitea is unable to identify current user on Alpine Linux.
I have build a simple docker container using Alpine Linux to run the official release of Gitea taken from dl.gitea.io. Problem is that it does not seem to be able to identify current user, so if I set a RUN_USER in app.ini, all I get is the following error message:

2018/09/08 12:20:59 [...s/setting/setting.go:990 NewContext()] [E] Expect user 'gitea' but current user is: 

Gitea runs if you omit setting RUN_USER, but it uses empty user name in ssh strings, too, like so: ssh:https://@domain.tld/RepoName.git

@SagePtr
Copy link
Contributor

SagePtr commented Sep 8, 2018

Now gitea relies on USER environment variable (don't know why, it can easily be spoofed).
So try to run
USER=gitea /path/to/gitea web

Maybe this should be fixed and CurrentUsername function should use Current() function from "os/user" to determine actual username rather than looking at USER environment variable?

@tinxx
Copy link
Author

tinxx commented Sep 9, 2018

So try to run

USER=gitea /path/to/gitea web

@SagePtr, it actually solved the problem, thanks!

EDIT:
A follow-up problem is that ssh connection is not possible. This is due to the same problem, as gitea is called as part of the auth (ref. .ssh/authorized_keys).

EDIT 2:
I have added ENV USER=gitea to my Dockerfile for the time being :)

Hi there, You've successfully authenticated, but Gitea does not provide shell access.
If this is unexpected, please log in with password and setup Gitea under another user.

EDIT 3:
I don't know (yet) what exactly Gitea does after ssh login but it is probably not portable across busybox. This is what I see:

halt: unrecognized option: c
BusyBox v1.28.4 (2018-07-17 15:21:40 UTC) multi-call binary.

Usage: halt [-d DELAY] [-n] [-f]

Halt the system

	-d SEC	Delay interval
	-n	Do not sync
	-f	Force (don't go through init)

@adelowo
Copy link
Member

adelowo commented Sep 9, 2018

A follow-up problem is that ssh connection is not possible. This is due to the same problem, as gitea is called as part of the auth (ref. .ssh/authorized_keys).

ssh -o PreferredAuthentications=password -o PubkeyAuthentication=no server@IP

@SagePtr
Copy link
Contributor

SagePtr commented Sep 9, 2018

Try setting HOME environment variable as well, probably it relies on it when accessing .ssh/authorized_keys file

@tinxx
Copy link
Author

tinxx commented Sep 9, 2018

No, I think you misunderstood. HOME is already set. The problem must be something Gitea executes after SSH auth is granted.

EDIT:
I fixed it by installing and providing dash as default shell for user gitea. We could still consider fixing busybox compatibility.

I think I'm fine now. Thanks for your help! :)

EDIT 2:
Sadly, I was mistaken. Gitea seems to rely on bash after. Pull worked just fine but this happens when trying to push:

remote: env: can't execute 'bash': No such file or directory

EDIT 3:
I replaced dash with bash in my previous fix (see above) and all seems to be good now.

I think, though, that Gitea should be made POSIX compliant so it could run on any standard shell!

@lafriks lafriks added the type/enhancement An improvement of existing functionality label Sep 10, 2018
@techknowlogick techknowlogick added the issue/duplicate The issue has already been reported. label Sep 10, 2018
@techknowlogick
Copy link
Member

Closing as dupe of #1640

@bboysoulcn
Copy link

write a shell script and
docker exec -it gogs cat /data/gogs/backup.sh
shell content

#!/bin/bash
su - git -s /bin/bash -c "/app/gogs/gogs backup"

@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
issue/duplicate The issue has already been reported. type/enhancement An improvement of existing functionality
Projects
None yet
Development

No branches or pull requests

6 participants