Skip to content

Commit c413f99

Browse files
committed
sshd: exclude gssapi when building without cgo
MR #682 broke building without cgo enabled as it introduced a dependency on a Kerberos library. This can only be disabled at runtime and thus static builds of gitlab-sshd are no longer possible. This change introduces an alternative implementation of the GSSAPI structure which just rejects attempts to use it. That alternative implementation gets automatically activated in case the user is building without cgo.
1 parent 84324a0 commit c413f99

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

internal/sshd/gssapi.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build cgo
2+
13
package sshd
24

35
import (

internal/sshd/gssapi_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build cgo
2+
13
package sshd
24

35
import (

internal/sshd/gssapi_unsupported.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//go:build !cgo
2+
3+
package sshd
4+
5+
import (
6+
"errors"
7+
8+
"gitlab.com/gitlab-org/gitlab-shell/v14/internal/config"
9+
10+
"gitlab.com/gitlab-org/labkit/log"
11+
)
12+
13+
func LoadGSSAPILib(c *config.GSSAPIConfig) error {
14+
if c.Enabled {
15+
log.New().Error("gssapi-with-mic disabled, built without CGO")
16+
c.Enabled = false
17+
}
18+
return nil
19+
}
20+
21+
type OSGSSAPIServer struct {
22+
ServicePrincipalName string
23+
}
24+
25+
func (*OSGSSAPIServer) AcceptSecContext([]byte) ([]byte, string, bool, error) {
26+
return []byte{}, "", false, errors.New("gssapi is unsupported")
27+
}
28+
29+
func (*OSGSSAPIServer) VerifyMIC([]byte, []byte) error {
30+
return errors.New("gssapi is unsupported")
31+
}
32+
func (*OSGSSAPIServer) DeleteSecContext() error {
33+
return errors.New("gssapi is unsupported")
34+
}

0 commit comments

Comments
 (0)