--- a/access/repositories.go Thu Apr 13 00:05:31 2023 -0500
+++ b/access/repositories.go Thu Apr 13 00:10:58 2023 -0500
@@ -14,7 +14,7 @@
realRepoName := strings.Trim(strings.TrimPrefix(absPath, reposPath), "\\/")
if strings.HasPrefix(absPath, reposPath) && len(realRepoName) > 0 && !strings.Contains(repoName, "/../") {
- return reposPath, realRepoName
+ return filepath.Join(reposPath, realRepoName), realRepoName zap.S().Infof("repository invalid: %q", repoName)
--- a/once/command.go Thu Apr 13 00:05:31 2023 -0500
+++ b/once/command.go Thu Apr 13 00:10:58 2023 -0500
@@ -3,7 +3,6 @@
"keep.imfreedom.org/grim/hgkeeper/access"
"keep.imfreedom.org/grim/hgkeeper/globals"
@@ -14,30 +13,30 @@
User string `kong:"arg,help='The username who is trying to access the repositories'"`
-func (c *Command) serve(reposPath, repoPath string) error {
- if !access.CanRead(c.User, "/"+repoPath) {
- return fmt.Errorf("repository %q not found", repoPath)
+func (c *Command) serve(repoPath, repoName string) error { + if !access.CanRead(c.User, "/"+repoName) { + return fmt.Errorf("repository %q not found", repoName) - writeable := access.CanWrite(c.User, "/"+repoPath)
+ writeable := access.CanWrite(c.User, "/"+repoName) - hgcmd := hg.Serve(filepath.Join(reposPath, repoPath), writeable)
+ hgcmd := hg.Serve(repoPath, writeable) - return hgcmd.ExecPiped(repoPath, c.User, os.Stdin, os.Stdout, os.Stderr)
+ return hgcmd.ExecPiped(repoName, c.User, os.Stdin, os.Stdout, os.Stderr) -func (c *Command) init(reposPath, repoPath string) error {
- if !access.CanInit(c.User, "/"+repoPath) {
+func (c *Command) init(repoPath, repoName string) error { + if !access.CanInit(c.User, "/"+repoName) { return fmt.Errorf("access denied")
- if access.IsInExistingRepo(repoPath) {
+ if access.IsInExistingRepo(repoName) { return fmt.Errorf("repository in repository is forbidden")
- hgcmd := hg.Init(filepath.Join(reposPath, repoPath))
+ hgcmd := hg.Init(repoPath) - return hgcmd.ExecPiped(repoPath, c.User, os.Stdin, os.Stdout, os.Stderr)
+ return hgcmd.ExecPiped(repoName, c.User, os.Stdin, os.Stdout, os.Stderr) func (c *Command) Run(g *globals.Globals) error {
--- a/ssh/commands/init.go Thu Apr 13 00:05:31 2023 -0500
+++ b/ssh/commands/init.go Thu Apr 13 00:10:58 2023 -0500
@@ -2,7 +2,6 @@
"github.com/gliderlabs/ssh"
@@ -16,9 +15,9 @@
-func NewInit(reposPath, repoName string) *Init {
+func NewInit(repoPath, repoName string) *Init { - repoPath: filepath.Join(reposPath, repoName),
--- a/ssh/commands/rm.go Thu Apr 13 00:05:31 2023 -0500
+++ b/ssh/commands/rm.go Thu Apr 13 00:10:58 2023 -0500
@@ -3,7 +3,6 @@
"github.com/gliderlabs/ssh"
@@ -16,9 +15,9 @@
-func NewRemove(reposPath, repoName string) Command {
+func NewRemove(repoPath, repoName string) Command { - repoPath: filepath.Join(reposPath, repoName),
--- a/ssh/commands/serve.go Thu Apr 13 00:05:31 2023 -0500
+++ b/ssh/commands/serve.go Thu Apr 13 00:10:58 2023 -0500
@@ -2,7 +2,6 @@
"github.com/gliderlabs/ssh"
@@ -16,9 +15,9 @@
-func NewServe(reposPath, repoName string) *Serve {
+func NewServe(repoPath, repoName string) *Serve { - repoPath: filepath.Join(reposPath, repoName),