grim/hgkeeper
Clone
Summary
Browse
Changes
Graph
Eval symlink of repository directory
13 months ago, aklitzing
dca75ada402c
Eval symlink of repository directory
Otherwise "hgkeeper once" cannot find any repository if the absReposPath
is a symlink.
Reviewed at https://reviews.imfreedom.org/r/2437/
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
}