Skip to content

Commit

Permalink
Merge pull request #7 from DocLambda/link
Browse files Browse the repository at this point in the history
Implement Link operation
  • Loading branch information
jsipprell authored Oct 11, 2021
2 parents 4450371 + 0dde376 commit 3d409df
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
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

0 comments on commit 3d409df

Please # to comment.