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

bug: working dir path its not fully honored with GITEA_WORK_DIR #5482

Closed
3 of 7 tasks
mckaygerhard opened this issue Dec 6, 2018 · 11 comments
Closed
3 of 7 tasks

bug: working dir path its not fully honored with GITEA_WORK_DIR #5482

mckaygerhard opened this issue Dec 6, 2018 · 11 comments

Comments

@mckaygerhard
Copy link

mckaygerhard commented Dec 6, 2018

  • Gitea version (or commit ref): 1.6.0
  • Git version: not relevant
  • Operating system: Linux and Mac
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant

Description

i setup my fles (either compile with bindata or not) in /srv/gitea and the binary in /usr/bin/gitea, then run using GITEA_WORK_DIR to set to /srv/gitea, as cgi or as daemon ...

seems due changes since #2192 due the issue #1419 the gitea assumes many files will be in current path from where are "invoked" the binary (in daemon case from nowhere, in others cases from users home) so some very non-dessire behaviour will happened:

  • a) so if a particular user runs the gitea binary the files will be "regenerated" (if where compiled with bindata) into the home path, and the files under GITEA_WORK_DIR will not be taken all in fact, by exampel the gitea db if are sqlite! its the most clear case as exposed in issue database path is not relative to APP_DATA_PATH #3816 and maybe same proble root of InitIssuesIndexer: create index, mkdir /usr/local/bin/data: permission denied #4672
  • b) in same case as "a" if non-bindata are compiled, a crash will happened!
  • c) if a fake user will run the binary will happened that db will not be created..
  • d) the work dir was set but inclusively if log was defined in the app.ini file (that are already existing in the work dir custon path) a new log file are created in current path directory, this happened due the "a" happened either if the app.ini file are located and readed!

using the variable of working dir gitea "reads" de db (with pingin) and later create it? as i can see in the log file seems that are very confused!

Log

root@venenux: /srv/gitea# GITEA_WORK_DIR=/srv/gitea/aaaa/ /usr/bin/gitea 
2018/12/06 14:40:41 [T] AppPath: /usr/bin/gitea
2018/12/06 14:40:41 [T] AppWorkPath:  /srv/gitea/aaaa/
2018/12/06 14:40:41 [T] Custom path:  /srv/gitea/aaaa/custom
2018/12/06 14:40:41 [T] Log path:  /srv/gitea/bin/log
2018/12/06 14:40:42 [I] Gitea v1.6.0-dev built with: sqlite, pam
2018/12/06 14:40:42 [I] Log Mode: Console(Trace)
2018/12/06 14:40:42 [I] Log Mode: File(Trace)
2018/12/06 14:40:42 [I] XORM Log Mode: Console(Trace)
2018/12/06 14:40:42 [I] XORM Log Mode: File(Trace)
2018/12/06 14:40:42 [I] Cache Service Enabled
2018/12/06 14:40:42 [I] Session Service Enabled
2018/12/06 14:40:42 [I] PING DATABASE sqlite3

later i can see that database are crated:

2018/12/06 14:40:42 [I] [SQL] SELECT sql FROM sqlite_master WHERE type='index' and tbl_name = ? [version]
2018/12/06 14:40:42 [I] [SQL] CREATE TABLE IF NOT EXISTS `user` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `lower_name` TEXT NOT NULL, `name` TEXT NOT NULL, `full_name` TEXT NULL, `email` TEXT NOT NULL, `keep_email_private` INTEGER NULL, `passwd` TEXT NOT NULL, `login_type` INTEGER NULL, `login_source` INTEGER DEFAULT 0 NOT NULL, `login_name` TEXT NULL, `type` INTEGER NULL, `location` TEXT NULL, `website` TEXT NULL, `rands` TEXT NULL, `salt` TEXT NULL, `language` TEXT NULL, `created_unix` INTEGER NULL, `updated_unix` INTEGER NULL, `last_login_unix` INTEGER NULL, `last_repo_visibility` INTEGER NULL, `max_repo_creation` INTEGER DEFAULT -1 NOT NULL, `is_active` INTEGER NULL, `is_admin` INTEGER NULL, `allow_git_hook` INTEGER NULL, `allow_import_local` INTEGER NULL, `allow_create_organization` INTEGER DEFAULT 1 NULL, `prohibit_login` INTEGER DEFAULT 0 NOT NULL, `avatar` TEXT NOT NULL, `avatar_email` TEXT NOT NULL, `use_custom_avatar` INTEGER NULL, `num_followers` INTEGER NULL, `num_following` INTEGER DEFAULT 0 NOT NULL, `num_stars` INTEGER NULL, `num_repos` INTEGER NULL, `description` TEXT NULL, `num_teams` INTEGER NULL, `num_members` INTEGER NULL, `diff_view_style` TEXT DEFAULT '' NOT NULL)
2018/12/06 14:40:42 [I] [SQL] CREATE UNIQUE INDEX `UQE_user_lower_name` ON `user` (`lower_name`)
2018/12/06 14:40:42 [I] [SQL] CREATE UNIQUE INDEX `UQE_user_name` ON `user` (`name`)
2018/12/06 14:40:42 [I] [SQL] CREATE INDEX `IDX_user_created_unix` ON `user` (`created_unix`)
2018/12/06 14:40:42 [I] [SQL] CREATE INDEX `IDX_user_updated_unix` ON `user` (`updated_unix`)
2018/12/06 14:40:42 [I] [SQL] CREATE INDEX `IDX_user_last_login_unix` ON `user` (`last_login_unix`)
2018/12/06 14:40:42 [I] [SQL] CREATE INDEX `IDX_user_is_active` ON `user` (`is_active`)
@mckaygerhard mckaygerhard changed the title working dir path its not honored with GITEA_WORK_DIR bug: working dir path its not honored with GITEA_WORK_DIR Dec 6, 2018
@mckaygerhard mckaygerhard changed the title bug: working dir path its not honored with GITEA_WORK_DIR bug: working dir path its not fully honored with GITEA_WORK_DIR Dec 6, 2018
@lunny lunny added the type/bug label Dec 8, 2018
@mckaygerhard
Copy link
Author

version 1.6.1 released !! i can understand that this issue are not easy to solve but...

@mathong
Copy link

mathong commented Jan 19, 2019

I had the same issue (v1.6.4). And the binary's path is written in some files like repositories hooks and authorized_keys.

I ended up moving the binary in a writeable directory, and sedding the previously mentioned files to update the path...

@mckaygerhard
Copy link
Author

I ended up moving the binary in a writeable directory, and sedding the previously mentioned files to update the path...

this still does not work for other webservers using reverse proxy and also for binary distribution.. again more features = more bugs

@zeripath
Copy link
Contributor

I think this might not be so hard to fix and I'd put a PR in to do so, but I don't understand what the problem is exactly from the above comments.

Can you for each problem file:

  • Tell me what the path is currently.
  • Give me a some idea of what you think that path is in terms of Gitea app.ini variables or working paths.
  • Tell me what it should be.

@harleypig
Copy link

I'm not sure if this is related to this issue or not. If not, I'll create a new one.

I am using Arch Linux installation of gitea, which is using this service file.

After updating to 1.7.0, the service fails to start and the following can be found from the status command.

$ systemctl status gitea
...
Jan 29 01:35:00 harleypig.com gitea[17175]: 2019/01/29 01:35:00 [...s/setting/setting.go:882 NewContext()] [E] Failed to create '/home/git/.ssh': mkdir /home/git: permission denied

If I run the followng as root gitea starts with no errors, but I'm unable to access anything ssh related. Logs show that it is a permissions error to /home/git/.ssh.

GITEA_WORK_DIR=/var/lib/gitea sudo -u gitea --preserve-env='GITEA_WORK_DIR' /usr/bin/gitea web -c /etc/gitea/app.ini

@harleypig
Copy link

So, my original app.ini had SSH_ROOT_PATH set to /home/git/.ssh. I changed it to be null and gitea service started up.

@mckaygerhard
Copy link
Author

now we have 1.7.3 and this problem still persist!

@techknowlogick
Copy link
Member

@mckaygerhard we are unable to assist you and solve the issue if we don't have all the information about your problem. Are you able to respond to @zeripath's questions?

@mckaygerhard
Copy link
Author

mckaygerhard commented Mar 7, 2019

@zeripath and @techknowlogick all are obviously posted in the original iisue request, but well let's posted that wants you here in detail again:

Tell me what the path is currently.

can you see in the original request: root@venenux: /srv/gitea# GITEA_WORK_DIR=/srv/gitea/aaaa/ /usr/bin/gitea

Give me a some idea of what you think that path is in terms of Gitea app.ini variables or working paths.

i setup in gitea ini a "xxxx" path .. whatever path i setup , no matter what, i set at command line GITEA_WORK_DIR=/srv/gitea/aaaa/ so then IT SUPPOST to that gitea search to the ini file at "/srv/gitea/aaaa/custom" right? well all that happened are in the original post in this issue, can you see that log said that the gitea does not find the database, and so then due tyhat try to re-create again? that means that the ini files does not are readed!

Tell me what it should be.

no re-creates database again (sqlite) and read ini file (where i setup database to mysql or sqlite, no matter what i setup or environment variable i set, it's not honored)

@stale
Copy link

stale bot commented May 6, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.

@stale stale bot added the issue/stale label May 6, 2019
@zeripath
Copy link
Contributor

Hmm... I think this is solved already.

@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.
Projects
None yet
Development

No branches or pull requests

6 participants