Ticket #1279 (closed bug: fixed)

Opened 6 years ago

Last modified 5 years ago

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

User.hsc.patch Download (0.8 KB) - added by guest 6 years ago.

Change History

Changed 6 years ago by guest

Changed 6 years ago by igloo

  • status changed from new to closed
  • resolution set to fixed

Thanks for the patch, now applied!

Changed 5 years ago by simonmar

  • architecture changed from Unknown to Unknown/Multiple

Changed 5 years ago by simonmar

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