func ModKeyringPerm(ringId KeySerial, mask, setbits uint32) error {
	dest := make([]byte, 1024)
	destBytes := unsafe.Pointer(&dest[0])

	if _, _, err := unix.Syscall6(unix.SYS_KEYCTL, uintptr(KEYCTL_DESCRIBE), uintptr(ringId), uintptr(destBytes), uintptr(len(dest)), 0, 0); err != 0 {
		return err
	}

	res := strings.Split(string(dest), ";")
	if len(res) < 5 {
		return fmt.Errorf("Destination buffer for key description is too small")
	}

	// parse permissions
	perm64, err := strconv.ParseUint(res[3], 16, 32)
	if err != nil {
		return err
	}

	perm := (uint32(perm64) & mask) | setbits

	if _, _, err := unix.Syscall(unix.SYS_KEYCTL, uintptr(KEYCTL_SETPERM), uintptr(ringId), uintptr(perm)); err != 0 {
		return err
	}

	return nil
}
// ModKeyringPerm modifies permissions on a keyring by reading the current permissions,
// anding the bits with the given mask (clearing permissions) and setting
// additional permission bits
ModKeyringPerm modifies permissions on a keyring by reading the current permissions,
anding the bits with the given mask (clearing permissions) and setting
additional permission bits
// ModKeyringPerm modifies permissions on a keyring by reading the current permissions // anding the bits with the given mask ( clearing permissions ) and setting // additional permission bits
func ModKeyringPerm(ringId KeySerial, mask, setbits uint32) error {
	dest := make([]byte, 1024)
	destBytes := unsafe.Pointer(&dest[0])
	if _, _, err := unix.Syscall6(unix.SYS_KEYCTL, uintptr(KEYCTL_DESCRIBE), uintptr(ringId), uintptr(destBytes), uintptr(len(dest)), 0, 0); err != 0 {
		return err
	}
	res := strings.Split(string(dest), ";")
	if len(res) < 5 {
		return fmt.Errorf("Destination buffer for key description is too small")
	}
	perm64, err := strconv.ParseUint(res[3], 16, 32)
	if err != nil {
		return err
	}
	perm := (uint32(perm64) & mask) | setbits
	if _, _, err := unix.Syscall(unix.SYS_KEYCTL, uintptr(KEYCTL_SETPERM), uintptr(ringId), uintptr(perm)); err != 0 {
		return err
	}
	return nil
}
func ModKeyringPerm ( ringId KeySerial , mask , setbits uint32 ) error { dest := make ( [ ] byte , 1024 ) destBytes := unsafe . Pointer ( & dest [ 0 ] ) if _ , _ , err := unix . Syscall6 ( unix . SYS_KEYCTL , uintptr ( KEYCTL_DESCRIBE ) , uintptr ( ringId ) , uintptr ( destBytes ) , uintptr ( len ( dest ) ) , 0 , 0 ) ; err != 0 { return err } res := strings . Split ( string ( dest ) , " " ) if len ( res ) < 5 { return fmt . Errorf ( " " ) } perm64 , err := strconv . ParseUint ( res [ 3 ] , 16 , 32 ) if err != nil { return err } perm := ( uint32 ( perm64 ) & mask ) | setbits if _ , _ , err := unix . Syscall ( unix . SYS_KEYCTL , uintptr ( KEYCTL_SETPERM ) , uintptr ( ringId ) , uintptr ( perm ) ) ; err != 0 { return err } return nil }
ModKeyringPerm modifies permissions on a keyring by reading the current permissions,
anding the bits with the given mask (clearing permissions) and setting
additional permission bits
ModKeyringPerm modifies permissions on a keyring by reading the current permissions anding the bits with the given mask ( clearing permissions ) and setting additional permission bits
// parse permissions