]> gitweb.factorcode.org Git - factor.git/commitdiff
unix.groups: Get the second parameter to getgrouplist from /etc/passwd.
authorDoug Coleman <doug.coleman@gmail.com>
Fri, 3 Feb 2012 03:53:42 +0000 (19:53 -0800)
committerDoug Coleman <doug.coleman@gmail.com>
Fri, 3 Feb 2012 03:53:42 +0000 (19:53 -0800)
basis/unix/groups/groups-tests.factor
basis/unix/groups/groups.factor

index 4f3b0172ac6cf05045a63fc16438b22ce475cf46..4fd633f8cbd0ff6539e6b53f9e296684b987993a 100644 (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
index 9abdb25e82cfdfeaecd38a79220ed547d98bffb2..531768656f580e5f552be19e16faf78b622ad5e8 100644 (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>