Skip to content

Commit b06a739

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 <[email protected]> * Don't leak configuration * Update cmd/serv.go Co-authored-by: delvh <[email protected]> Co-authored-by: wxiaoguang <[email protected]> Co-authored-by: techknowlogick <[email protected]>
1 parent f8e2e00 commit b06a739

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
@@ -296,6 +296,15 @@ func runServ(c *cli.Context) error {
296296
gitcmd = exec.CommandContext(ctx, verb, repoPath)
297297
}
298298

299+
// Check if setting.RepoRootPath exists. It could be the case that it doesn't exist, this can happen when
300+
// `[repository]` `ROOT` is a relative path and $GITEA_WORK_DIR isn't passed to the SSH connection.
301+
if _, err := os.Stat(setting.RepoRootPath); err != nil {
302+
if os.IsNotExist(err) {
303+
return fail("Incorrect configuration.",
304+
"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.")
305+
}
306+
}
307+
299308
gitcmd.Dir = setting.RepoRootPath
300309
gitcmd.Stdout = os.Stdout
301310
gitcmd.Stdin = os.Stdin

0 commit comments

Comments
 (0)