Skip to content

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

Closed
@mckaygerhard

Description

@mckaygerhard
  • 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`)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions