Skip to content

Commit 6ebee84

Browse files
Gusteddelvhwxiaoguangtechknowlogick
authored andcommitted
Warn on SSH connection for incorrect configuration (go-gitea#19317)
* Warn on SSH connection for incorrect configuration - When `setting.RepoRootPath` cannot be found(most likely due to incorrect configuration) show "Gitea: Incorrect configuration" on the client-side to help easier with debugging the problem. * Update cmd/serv.go Co-authored-by: delvh <dev.lh@web.de> * Don't leak configuration * Update cmd/serv.go Co-authored-by: delvh <dev.lh@web.de> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
1 parent 08eecba commit 6ebee84

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

cmd/serv.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,15 @@ func runServ(c *cli.Context) error {
297297
gitcmd = exec.CommandContext(ctx, verb, repoPath)
298298
}
299299

300+
// Check if setting.RepoRootPath exists. It could be the case that it doesn't exist, this can happen when
301+
// `[repository]` `ROOT` is a relative path and $GITEA_WORK_DIR isn't passed to the SSH connection.
302+
if _, err := os.Stat(setting.RepoRootPath); err != nil {
303+
if os.IsNotExist(err) {
304+
return fail("Incorrect configuration.",
305+
"Directory `[repository]` `ROOT` was not found, please check if $GITEA_WORK_DIR is passed to the SSH connection or make `[repository]` `ROOT` an absolute value.")
306+
}
307+
}
308+
300309
gitcmd.Dir = setting.RepoRootPath
301310
gitcmd.Stdout = os.Stdout
302311
gitcmd.Stdin = os.Stdin

0 commit comments

Comments
 (0)