hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit f0d4dcf60d1fa6f30e2c286d26ec16c790372eca
parent 255d5f785bf75ede677d6c1e318f18619a975261
Author: Tom Lebreux <me@tomlebreux.com>
Date:   Fri, 10 Nov 2023 22:14:56 -0500

linux::keyctl: Add chown and setperm

Signed-off-by: Tom Lebreux <me@tomlebreux.com>

Diffstat:
Mlinux/keyctl/+linux/keyctl.ha | 10++++++++++
Mlinux/keyctl/+linux/types.ha | 34++++++++++++++++++++++++++++++++++
2 files changed, 44 insertions(+), 0 deletions(-)

diff --git a/linux/keyctl/+linux/keyctl.ha b/linux/keyctl/+linux/keyctl.ha @@ -95,3 +95,13 @@ export fn read(id: serial, buf: []u8) (size | error) = { return keyctl(command::READ, id: u64, buf: uintptr: u64, bufln: u64, 0)?: size; }; + +// Changes the user and group ownership of the key. +export fn chown(id: serial, uid: uint, gid: uint) (void | error) = { + keyctl(command::CHOWN, id: u64, uid: u64, gid: u64, 0)?; +}; + +// Changes the permissions mask of the key. +export fn setperm(id: serial, perm: perm) (void | error) = { + keyctl(command::SETPERM, id: u64, perm, 0, 0)?; +}; diff --git a/linux/keyctl/+linux/types.ha b/linux/keyctl/+linux/types.ha @@ -143,6 +143,40 @@ export type caps = enum u8 { CAPS1_NOTIFICATIONS = 0x04, }; +export type perm = enum u32 { + KEY_OTH_VIEW = 0x01, + KEY_OTH_READ = 0x02, + KEY_OTH_WRITE = 0x04, + KEY_OTH_SEARCH = 0x08, + KEY_OTH_LINK = 0x10, + KEY_OTH_SETATTR = 0x20, + KEY_OTH_ALL = 0x3f, + + KEY_GRP_VIEW = 0x0100, + KEY_GRP_READ = 0x0200, + KEY_GRP_WRITE = 0x0400, + KEY_GRP_SEARCH = 0x0800, + KEY_GRP_LINK = 0x1000, + KEY_GRP_SETATTR = 0x2000, + KEY_GRP_ALL = 0x3f00, + + KEY_USR_VIEW = 0x010000, + KEY_USR_READ = 0x020000, + KEY_USR_WRITE = 0x040000, + KEY_USR_SEARCH = 0x080000, + KEY_USR_LINK = 0x100000, + KEY_USR_SETATTR = 0x200000, + KEY_USR_ALL = 0x3f0000, + + KEY_POS_VIEW = 0x01000000, + KEY_POS_READ = 0x02000000, + KEY_POS_WRITE = 0x04000000, + KEY_POS_SEARCH = 0x08000000, + KEY_POS_LINK = 0x10000000, + KEY_POS_SETATTR = 0x20000000, + KEY_POS_ALL = 0x3f000000, +}; + // Converts an [[error]] into a human-friendly string. export fn strerror(err: error) const str = match (err) { case nokey =>