Opened 7 years ago

Closed 7 years ago

Last modified 6 years ago

#1279 closed bug (fixed)

System.Posix.User.getAllUserEntries should call setpwent

Reported by: guest Owned by:
Priority: normal Milestone:
Component: libraries/unix Version: 6.6
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

it seems setpwent is never called, and so getAllUserEntries can only
be used once. Here is a suggested fix:

--- User.hsc.old	2007-04-03 16:35:09.000000000 +0200
+++ User.hsc	2007-04-03 16:33:45.000000000 +0200
@@ -332,7 +332,10 @@
 getAllUserEntries :: IO [UserEntry]
 #ifdef HAVE_GETPWENT
 getAllUserEntries = 
-    withMVar lock $ \_ -> worker []
+    withMVar lock $ \_ -> do c_setpwent
+                             l <- worker []
+                             c_endpwent
+                             return l
     where worker accum = 
               do resetErrno
                  ppw <- throwErrnoIfNullAndError "getAllUserEntries" $ 
@@ -344,6 +347,10 @@
 
 foreign import ccall unsafe "getpwent"
   c_getpwent :: IO (Ptr CPasswd)
+foreign import ccall unsafe "setpwent"
+  c_setpwent :: IO ()
+foreign import ccall unsafe "endpwent"
+  c_endpwent :: IO ()
 #else
 getAllUserEntries = error "System.Posix.User.getAllUserEntries: not supported"
 #endif

Attachments (1)

User.hsc.patch (854 bytes) - added by guest 7 years ago.

Download all attachments as: .zip

Change History (4)

Changed 7 years ago by guest

comment:1 Changed 7 years ago by igloo

  • Resolution set to fixed
  • Status changed from new to closed

Thanks for the patch, now applied!

comment:2 Changed 6 years ago by simonmar

  • Architecture changed from Unknown to Unknown/Multiple

comment:3 Changed 6 years ago by simonmar

  • Operating System changed from Unknown to Unknown/Multiple
Note: See TracTickets for help on using tickets.