Skip to content
2 changes: 1 addition & 1 deletion crypto/keyring/keyring.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func NewInMemoryWithKeyring(kr keyring.Keyring, cdc codec.Codec, opts ...Option)
// New creates a new instance of a keyring.
// Keyring options can be applied when generating the new instance.
// Available backends are "os", "file", "kwallet", "memory", "pass", "test".
func New(
func newKeyringGeneric(
appName, backend, rootDir string, userInput io.Reader, cdc codec.Codec, opts ...Option,
) (Keyring, error) {
var (
Expand Down
41 changes: 41 additions & 0 deletions crypto/keyring/keyring_linux.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//go:build linux
// +build linux

package keyring

import (
"io"

"github.com/99designs/keyring"
"github.com/cosmos/cosmos-sdk/codec"
)

const BackendKeyctl = "keyctl"

func newKeyctlBackendConfig(appName, _ string, inpt io.Reader) keyring.Config {
return keyring.Config{
AllowedBackends: []keyring.BackendType{keyring.KeyCtlBackend},
ServiceName: appName,
KeyCtlScope: "user",
KeyCtlPerm: 0x3f3f0000,
}
}

// New creates a new instance of a keyring.
// Keyring options can be applied when generating the new instance.
// Available backends are "os", "file", "kwallet", "memory", "pass", "test".
func New(
appName, backend, rootDir string, userInput io.Reader, cdc codec.Codec, opts ...Option,
) (Keyring, error) {

if backend != BackendKeyctl {
return newKeyringGeneric(appName, backend, rootDir, userInput, cdc, opts...)
}

db, err := keyring.Open(newKeyctlBackendConfig(appName, "", userInput))
if err != nil {
return nil, err
}

return newKeystore(db, cdc, backend, opts...), nil
}
16 changes: 16 additions & 0 deletions crypto/keyring/keyring_other.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//go:build !linux
// +build !linux

package keyring

import (
"io"

"github.com/cosmos/cosmos-sdk/codec"
)

func New(
appName, backend, rootDir string, userInput io.Reader, cdc codec.Codec, opts ...Option,
) (Keyring, error) {
return newKeyringGeneric(appName, backend, rootDir, userInput, cdc, opts...)
}