From 313e82e55314bf30a8b80b16dfc9d4bdba0c96b4 Mon Sep 17 00:00:00 2001 From: Alex Shinn Date: Sun, 9 Mar 2014 20:29:58 +0900 Subject: [PATCH] Adding group entry API. --- lib/chibi/system.sld | 7 ++++++- lib/chibi/system.stub | 23 ++++++++++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/lib/chibi/system.sld b/lib/chibi/system.sld index 0d97af16..4d7a619e 100644 --- a/lib/chibi/system.sld +++ b/lib/chibi/system.sld @@ -2,6 +2,7 @@ (define-library (chibi system) (export user-information user? user-name user-password user-id user-group-id user-gecos user-home user-shell + group-information group-name group-password group-id current-user-id current-group-id current-effective-user-id current-effective-group-id set-current-user-id! set-current-effective-user-id! @@ -14,4 +15,8 @@ (define (user-information user) (car (if (string? user) (getpwnam_r user (make-string 1024)) - (getpwuid_r user (make-string 1024))))))) + (getpwuid_r user (make-string 1024))))) + (define (group-information group) + (car (if (string? group) + (getgrnam_r group (make-string 1024)) + (getgrgid_r group (make-string 1024))))))) diff --git a/lib/chibi/system.stub b/lib/chibi/system.stub index b0f09572..bcb2588d 100644 --- a/lib/chibi/system.stub +++ b/lib/chibi/system.stub @@ -1,9 +1,10 @@ (c-system-include "unistd.h") (c-system-include "pwd.h") +(c-system-include "grp.h") (c-system-include "sys/types.h") -;;> \subsubsubsection{\scheme{(user-information name-or-id)}} +;;> \section{\scheme{(user-information name-or-id)}} ;;> Returns the password entry for the given user. \var{name-or-id} ;;> should be a string indicating the user name, or an integer @@ -62,3 +63,23 @@ (link string) (value (string-size arg2) int) (result pointer passwd))) + +(define-c-struct group + predicate: group? + (string gr_name group-name) + (string gr_passwd group-password) + (gid_t gr_gid group-id) + ;;((array string) gr_mem group-members) + ) + +(define-c errno getgrgid_r + (gid_t (result group) + (link string) + (value (string-size arg2) int) + (result pointer group))) + +(define-c errno getgrnam_r + (string (result group) + (link string) + (value (string-size arg2) int) + (result pointer group)))