]> source.dussan.org Git - gitea.git/commitdiff
Make sure that a mirror can't be written to by http or ssh
authorPeter Smit <peter@smitmail.eu>
Mon, 16 Feb 2015 10:00:06 +0000 (12:00 +0200)
committerPeter Smit <peter@smitmail.eu>
Mon, 16 Feb 2015 10:00:06 +0000 (12:00 +0200)
cmd/serve.go
routers/repo/http.go

index e8e5c186c728bfc485f3f4255ec1f267b3fc5201..9e34b95c5a45978315b8771aa1a4a7b30f00b105 100644 (file)
@@ -164,6 +164,11 @@ func runServ(c *cli.Context) {
                        println("You have no right to write this repository")
                        log.GitLogger.Fatal(2, "User %s has no right to write repository %s", user.Name, repoPath)
                }
+
+               if repo.IsMirror {
+                       println("You can't write to a mirror repository")
+                       log.GitLogger.Fatal(2, "User %s tried to write to a mirror repository %s", user.Name, repoPath)
+               }
        case isRead:
                if !repo.IsPrivate {
                        break
index 034b5a7b5e7c6e3b557c3ac7e82073e834bf2976..d47d73ef051d774503d4e47d446ab11ecd14a3c2 100644 (file)
@@ -158,6 +158,11 @@ func Http(ctx *middleware.Context) {
                                        return
                                }
                        }
+
+                       if !isPull && repo.IsMirror {
+                               ctx.Handle(401, "can't push to mirror", nil)
+                               return
+                       }
                }
        }