From 590aa672a2f06f4019f0e0186ca96310cd69a08e Mon Sep 17 00:00:00 2001 From: Solderpunk Date: Sun, 17 May 2020 14:12:11 +0200 Subject: [PATCH] Be more careful with permission issues on index.gmi --- handler.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/handler.go b/handler.go index d5c5bec..8c1f3eb 100644 --- a/handler.go +++ b/handler.go @@ -108,9 +108,13 @@ func handleGeminiRequest(conn net.Conn, config Config, logEntries chan LogEntry) // Add index.gmi to directory paths, if it exists index_path := filepath.Join(path, "index.gmi") index_info, err := os.Stat(index_path) - if !os.IsNotExist(err) { + if err == nil { path = index_path info = index_info + } else if os.IsPermission(err) { + conn.Write([]byte("51 Not found!\r\n")) + log.Status = 51 + return } } // Fail if file is not world readable