diff options
author | 2007-05-04 10:49:56 +0000 | |
---|---|---|
committer | 2007-05-04 10:49:56 +0000 | |
commit | db4d39f628390fcc328f7b04fd3ebe0ad576cc73 (patch) | |
tree | cecb33f9933f275faac6bb1c4c35bd3d0a82b6c9 /System/Posix/User.hsc | |
parent | e3c17825cd6de850cc7e4936ea6068f5275f2a6a (diff) |
Fix calling getAllUserEntries twice (trac #1279).
It used to return [] on all but the first call.
Patch from an unidentified guest.
Diffstat (limited to 'System/Posix/User.hsc')
-rw-r--r-- | System/Posix/User.hsc | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/System/Posix/User.hsc b/System/Posix/User.hsc index 49c834a..d7a786d 100644 --- a/System/Posix/User.hsc +++ b/System/Posix/User.hsc @@ -52,6 +52,9 @@ import System.Posix.Internals ( CGroup, CPasswd ) #if !defined(HAVE_GETPWNAM_R) || !defined(HAVE_GETPWUID_R) || defined(HAVE_GETPWENT) || defined(HAVE_GETGRENT) import Control.Concurrent.MVar ( newMVar, withMVar ) #endif +#ifdef HAVE_GETPWENT +import Control.Exception +#endif -- ----------------------------------------------------------------------------- -- user environemnt @@ -331,7 +334,7 @@ getUserEntryForName = error "System.Posix.User.getUserEntryForName: not supporte getAllUserEntries :: IO [UserEntry] #ifdef HAVE_GETPWENT getAllUserEntries = - withMVar lock $ \_ -> worker [] + withMVar lock $ \_ -> bracket_ c_setpwent c_endpwent $ worker [] where worker accum = do resetErrno ppw <- throwErrnoIfNullAndError "getAllUserEntries" $ @@ -343,6 +346,10 @@ getAllUserEntries = 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 |