grim/hgkeeper
Clone
Summary
Browse
Changes
Graph
Do not allow repositories in a repository
14 months ago, aklitzing
ebf8e3bd9e68
Do not allow repositories in a repository
It will be strange to support something like this
$ hg init ssh://hg.host.com/hgkeeper/keys
Reviewed at https://reviews.imfreedom.org/r/2423/
package
authorized_keys
import
(
"fmt"
"strings"
"keep.imfreedom.org/grim/hgkeeper/access"
"keep.imfreedom.org/grim/hgkeeper/globals"
)
type
Command
struct
{
FingerPrint
string
`kong:"arg,help='The fingerprint of the calling user'"`
HGKeeperExec
string
`kong:"flag,help='The path to hgkeeper executable',default='hgkeeper'"`
}
func
(
c
*
Command
)
Run
(
g
*
globals
.
Globals
)
error
{
if
err
:=
access
.
Setup
(
g
.
ReposPath
,
g
.
AdminRepo
);
err
!=
nil
{
return
err
}
defer
access
.
Teardown
()
pubkey
,
err
:=
access
.
PubkeyFromFingerprint
(
c
.
FingerPrint
)
if
err
!=
nil
{
return
err
}
username
,
err
:=
access
.
UsernameFromFingerprint
(
c
.
FingerPrint
)
if
err
!=
nil
{
return
err
}
options
:=
[]
string
{
fmt
.
Sprintf
(
"command=\"%s --repos-path='%s' once %s\""
,
c
.
HGKeeperExec
,
g
.
ReposPath
,
username
),
"restrict"
,
}
fmt
.
Printf
(
"%s %s"
,
strings
.
Join
(
options
,
","
),
pubkey
)
return
nil
}