go-gitea / gitea

Git with a cup of tea! Painless self-hosted all-in-one software development service, including Git hosting, code review, team collaboration, package registry and CI/CD
https://gitea.com
MIT License
44.08k stars 5.41k forks source link

Rewriting SSH Public Keys Fails After Migration #29457

Closed inferenceus closed 6 months ago

inferenceus commented 6 months ago

Description

I have migrated my Gitea database, copied all configuration files exactly as they were previously, and renamed all configuration code and system directories to the correct new names wherever they needed to be changed. When I start the Gitea service on the new system, the logs are able to find the new binary, configuration file, and /var/lib/gitea/ directory; however, they state Unable to MkDirAll(/var/lib/<old_name>/.ssh): mkdir /var/lib/<old_name>: permission denied.

There are no references to the old name in the configuration file, and the database and database user have been renamed correctly. It seems Gitea is attempting to create a new directory under the old directory name, despite everything being changed.

Gitea Version

1.21.7

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

https://gist.github.com/inferenceus/2960870b3fbaeba808787832a02eec6c

Screenshots

No response

Git Version

2.43.0

Operating System

Gentoo Linux

How are you running Gitea?

Compiled from source via Gentoo Linux package manager.

Database

PostgreSQL

jolheiser commented 6 months ago

Can you double-check your app.ini? https://github.com/go-gitea/gitea/blob/2df38af752c13ca02a899d6a53848c68259d3336/models/asymkey/ssh_key_authorized_keys.go#L134-L138 setting.SSH.RootPath should be sourced from the config.

If it's not explicitly set, it is derived from the current environment https://github.com/go-gitea/gitea/blob/db545b208b4bd3d1961c519da66ee2b4421afa5c/modules/util/path.go#L248-L266 https://github.com/go-gitea/gitea/blob/2df38af752c13ca02a899d6a53848c68259d3336/modules/setting/ssh.go#L114

inferenceus commented 6 months ago

setting.SSH.RootPath should be sourced from the config.

If it's not explicitly set, it is derived from the current environment

Awesome. I didn't know that. It works flawlessly. Thanks for the help.