System.Posix.User.getAllUserEntries should call setpwent
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
Trac metadata
| Trac field | Value |
|---|---|
| Version | 6.6 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | libraries/unix |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | Unknown |
| Architecture | Unknown |