grim/hgkeeper
Clone
Summary
Browse
Changes
Graph
Use Alpine for Dockerfile
12 months ago, aklitzing
274e125f308b
Use Alpine for Dockerfile
Also use mercurial from Alpine repository as it is up-to-date and enables
rust extensions and chg binary.
This decreases the size of docker image.
Reviewed at https://reviews.imfreedom.org/r/2454/
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
}