#1279: System.Posix.User.getAllUserEntries should call setpwent
-------------------------------+--------------------------------------------
Reporter: guest | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: libraries/unix | Version: 6.6
Severity: normal | Keywords:
Difficulty: Unknown | Testcase:
Architecture: Unknown | Os: Unknown
-------------------------------+--------------------------------------------
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
}}}
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/1279>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs