unix.groups: Get the second parameter to getgrouplist from /etc/passwd.

db4
Doug Coleman 2012-02-02 19:53:42 -08:00
parent d8b963872b
commit 38d09743e0
2 changed files with 5 additions and 3 deletions

View File

@ -37,3 +37,6 @@ IN: unix.groups.tests
[ f ]
[ all-group-names drop all-group-names empty? ] unit-test
{ f }
[ "root" user-groups empty? ] unit-test

View File

@ -70,10 +70,9 @@ ERROR: no-group string ;
[ 4 grouping:group ] dip head-slice [ uint deref group-name ] map ;
: (user-groups) ( string -- seq )
#! first group is -1337, legacy unix code
-1337 64 [ 4 * <byte-array> ] keep
dup user-passwd gid>> 64 [ 4 * <byte-array> ] keep
int <ref> [ [ unix.ffi:getgrouplist ] unix-system-call drop ] 2keep
[ 4 tail-slice ] [ int deref 1 - ] bi* >groups ;
int deref >groups ;
PRIVATE>