[commit: unix] master: cope with missing pw_gecos (for Android) (625b9f8)

Simon Marlow marlowsd at gmail.com
Wed Jan 30 12:04:13 CET 2013


Repository : ssh://darcs.haskell.org//srv/darcs/packages/unix

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/625b9f86ff3ef8b9e0f7b58982268e5351b2eda2

>---------------------------------------------------------------

commit 625b9f86ff3ef8b9e0f7b58982268e5351b2eda2
Author: Simon Marlow <marlowsd at gmail.com>
Date:   Wed Jan 30 09:20:23 2013 +0000

    cope with missing pw_gecos (for Android)
    
    Submitted by: Nathan Hüsken <nathan.huesken at posteo.de>

>---------------------------------------------------------------

 System/Posix/User.hsc |    4 ++++
 configure.ac          |    2 ++
 2 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/System/Posix/User.hsc b/System/Posix/User.hsc
index a62648d..de08314 100644
--- a/System/Posix/User.hsc
+++ b/System/Posix/User.hsc
@@ -453,7 +453,11 @@ unpackUserEntry ptr = do
    passwd <- (#peek struct passwd, pw_passwd) ptr >>= peekCAString
    uid    <- (#peek struct passwd, pw_uid)    ptr
    gid    <- (#peek struct passwd, pw_gid)    ptr
+#ifdef HAVE_NO_PASSWD_PW_GECOS
+   gecos  <- return ""  -- pw_gecos does not exist on android
+#else
    gecos  <- (#peek struct passwd, pw_gecos)  ptr >>= peekCAString
+#endif
    dir    <- (#peek struct passwd, pw_dir)    ptr >>= peekCAString
    shell  <- (#peek struct passwd, pw_shell)  ptr >>= peekCAString
    return (UserEntry name passwd uid gid gecos dir shell)
diff --git a/configure.ac b/configure.ac
index 818303b..7528c3e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -50,6 +50,8 @@ AC_CHECK_MEMBERS([struct stat.st_uatime])
 AC_CHECK_MEMBERS([struct stat.st_umtime])
 AC_CHECK_MEMBERS([struct stat.st_uctime])
 
+AC_CHECK_MEMBER([struct passwd.pw_gecos], [], [AC_DEFINE([HAVE_NO_PASSWD_PW_GECOS],[],[Ignore the pw_gecos member of passwd where it does not exist])], [[#include <pwd.h>]])
+
 # Functions for changing file timestamps
 AC_CHECK_FUNCS([utimensat futimens])
 AC_CHECK_FUNCS([lutimes futimes])





More information about the ghc-commits mailing list