Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion keyring.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,14 @@ func SetKeyringTTL(kr NamedKeyring, nsecs uint) error {
return err
}

// Link an object to a keyring
func Link(parent Keyring, child Id) error {
return keyctl_Link(keyId(child.Id()), keyId(parent.Id()))
}

// Unlink an object from a keyring
func Unlink(parent Keyring, child Id) error {
return keyctl_Unlink(keyId(parent.Id()), keyId(child.Id()))
return keyctl_Unlink(keyId(child.Id()), keyId(parent.Id()))
}

// Unlink a named keyring from its parent.
Expand Down
8 changes: 8 additions & 0 deletions sys_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@ func keyctl_Read(id keyId, b *byte, size int) (int32, error) {
return int32(v1), nil
}

func keyctl_Link(id, ring keyId) error {
_, _, errno := syscall.Syscall(syscall_keyctl, uintptr(keyctlLink), uintptr(id), uintptr(ring))
if errno != 0 {
return errno
}
return nil
}

func keyctl_Unlink(id, ring keyId) error {
_, _, errno := syscall.Syscall(syscall_keyctl, uintptr(keyctlUnlink), uintptr(id), uintptr(ring))
if errno != 0 {
Expand Down