diff --git a/pkg/keyctl/key.go b/pkg/keyctl/key.go index 0d42a8f1c1..e4396a9df7 100644 --- a/pkg/keyctl/key.go +++ b/pkg/keyctl/key.go @@ -19,8 +19,8 @@ type Key struct { } // ID returns the 32-bit kernel identifier for a specific key -func (k *Key) ID() int { - return int(k.id) +func (k *Key) ID() int32 { + return int32(k.id) } // Get the key's value as a byte slice diff --git a/pkg/keyctl/keyring.go b/pkg/keyctl/keyring.go index dd037840a8..6e029c9235 100644 --- a/pkg/keyctl/keyring.go +++ b/pkg/keyctl/keyring.go @@ -5,6 +5,9 @@ // +build linux // Package keyctl is a Go interface to linux kernel keyrings (keyctl interface) +// +// Deprecated: Most callers should use either golang.org/x/sys/unix directly, +// or the original (and more extensive) github.com/jsipprell/keyctl . package keyctl import ( @@ -24,7 +27,7 @@ type keyring struct { // ID is unique 32-bit serial number identifiers for all Keys and Keyrings have. type ID interface { - ID() int + ID() int32 } // Add a new key to a keyring. The key can be searched for later by name. @@ -49,8 +52,8 @@ func (kr *keyring) Search(name string) (*Key, error) { } // ID returns the 32-bit kernel identifier of a keyring -func (kr *keyring) ID() int { - return int(kr.id) +func (kr *keyring) ID() int32 { + return int32(kr.id) } // SessionKeyring returns the current login session keyring @@ -65,12 +68,12 @@ func UserKeyring() (Keyring, error) { // Unlink an object from a keyring func Unlink(parent Keyring, child ID) error { - _, err := unix.KeyctlInt(unix.KEYCTL_UNLINK, child.ID(), parent.ID(), 0, 0) + _, err := unix.KeyctlInt(unix.KEYCTL_UNLINK, int(child.ID()), int(parent.ID()), 0, 0) return err } // Link a key into a keyring func Link(parent Keyring, child ID) error { - _, err := unix.KeyctlInt(unix.KEYCTL_LINK, child.ID(), parent.ID(), 0, 0) + _, err := unix.KeyctlInt(unix.KEYCTL_LINK, int(child.ID()), int(parent.ID()), 0, 0) return err } diff --git a/pkg/keyctl/perm.go b/pkg/keyctl/perm.go index 152b740047..ae9697149d 100644 --- a/pkg/keyctl/perm.go +++ b/pkg/keyctl/perm.go @@ -28,6 +28,6 @@ const ( // SetPerm sets the permissions on a key or keyring. func SetPerm(k ID, p KeyPerm) error { - err := unix.KeyctlSetperm(k.ID(), uint32(p)) + err := unix.KeyctlSetperm(int(k.ID()), uint32(p)) return err } diff --git a/pkg/keyctl/sys_linux.go b/pkg/keyctl/sys_linux.go index 80e6d6a065..196c827607 100644 --- a/pkg/keyctl/sys_linux.go +++ b/pkg/keyctl/sys_linux.go @@ -10,11 +10,7 @@ import ( "golang.org/x/sys/unix" ) -type keyID int - -func (id keyID) ID() int { - return int(id) -} +type keyID int32 func newKeyring(id keyID) (*keyring, error) { r1, err := unix.KeyctlGetKeyringID(int(id), true)