Fix: ucred -> sockpeercred

ok kili@ (maintainer)
This commit is contained in:
dcoppa 2012-10-02 13:35:40 +00:00
parent 311076bbe8
commit a6c495e401
4 changed files with 152 additions and 1 deletions

View File

@ -1,8 +1,9 @@
# $OpenBSD: Makefile,v 1.14 2012/09/02 20:13:08 kili Exp $
# $OpenBSD: Makefile,v 1.15 2012/10/02 13:35:40 dcoppa Exp $
COMMENT = Haskell networking library
DISTNAME = network-2.3.0.13
REVISION = 0
CATEGORIES = devel net
MAINTAINER = Matthias Kilian <kili@openbsd.org>

View File

@ -0,0 +1,43 @@
$OpenBSD: patch-Network_Socket_hsc,v 1.1 2012/10/02 13:35:40 dcoppa Exp $
ucred is sockpeercred on OpenBSD
--- Network/Socket.hsc.orig Mon Oct 1 20:31:59 2012
+++ Network/Socket.hsc Mon Oct 1 20:32:16 2012
@@ -80,7 +80,7 @@ module Network.Socket
, getPeerName
, getSocketName
-#ifdef HAVE_STRUCT_UCRED
+#ifdef HAVE_STRUCT_SOCKPEERCRED
-- get the credentials of our domain socket peer.
, getPeerCred
#endif
@@ -1042,22 +1042,22 @@ getSocketOption (MkSocket s _ _ _ _) so = do
fromIntegral `liftM` peek ptr_v
-#ifdef HAVE_STRUCT_UCRED
+#ifdef HAVE_STRUCT_SOCKPEERCRED
-- | Returns the processID, userID and groupID of the socket's peer.
--
-- Only available on platforms that support SO_PEERCRED on domain sockets.
getPeerCred :: Socket -> IO (CUInt, CUInt, CUInt)
getPeerCred sock = do
let fd = fdSocket sock
- let sz = (fromIntegral (#const sizeof(struct ucred)))
+ let sz = (fromIntegral (#const sizeof(struct sockpeercred)))
with sz $ \ ptr_cr ->
alloca $ \ ptr_sz -> do
poke ptr_sz sz
throwErrnoIfMinus1 "getPeerCred" $
c_getsockopt fd (#const SOL_SOCKET) (#const SO_PEERCRED) ptr_cr ptr_sz
- pid <- (#peek struct ucred, pid) ptr_cr
- uid <- (#peek struct ucred, uid) ptr_cr
- gid <- (#peek struct ucred, gid) ptr_cr
+ pid <- (#peek struct sockpeercred, pid) ptr_cr
+ uid <- (#peek struct sockpeercred, uid) ptr_cr
+ gid <- (#peek struct sockpeercred, gid) ptr_cr
return (pid, uid, gid)
#endif

View File

@ -0,0 +1,90 @@
$OpenBSD: patch-configure,v 1.1 2012/10/02 13:35:40 dcoppa Exp $
ucred is sockpeercred on OpenBSD
--- configure.orig Mon Oct 1 20:30:38 2012
+++ configure Mon Oct 1 20:31:01 2012
@@ -4292,8 +4292,8 @@ fi
rm -f -r conftest*
-{ echo "$as_me:$LINENO: checking for SO_PEERCRED and struct ucred in sys/socket.h" >&5
-echo $ECHO_N "checking for SO_PEERCRED and struct ucred in sys/socket.h... $ECHO_C" >&6; }
+{ echo "$as_me:$LINENO: checking for SO_PEERCRED and struct sockpeercred in sys/socket.h" >&5
+echo $ECHO_N "checking for SO_PEERCRED and struct sockpeercred in sys/socket.h... $ECHO_C" >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
@@ -4305,7 +4305,7 @@ cat >>conftest.$ac_ext <<_ACEOF
#ifndef SO_PEERCRED
# error no SO_PEERCRED
#endif
-struct ucred u;
+struct sockpeercred u;
int
main ()
{
@@ -4331,16 +4331,16 @@ eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
- ac_cv_ucred=yes
+ ac_cv_sockpeercred=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
- ac_cv_ucred=no
+ ac_cv_sockpeercred=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-if test "x$ac_cv_ucred" = xno; then
+if test "x$ac_cv_sockpeercred" = xno; then
old_CFLAGS="$CFLAGS"
CFLAGS="-D_GNU_SOURCE $CFLAGS"
cat >conftest.$ac_ext <<_ACEOF
@@ -4354,7 +4354,7 @@ cat >>conftest.$ac_ext <<_ACEOF
#ifndef SO_PEERCRED
# error no SO_PEERCRED
#endif
-struct ucred u;
+struct sockpeercred u;
int
main ()
{
@@ -4380,29 +4380,29 @@ eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
- ac_cv_ucred=yes
+ ac_cv_sockpeercred=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
- ac_cv_ucred=no
+ ac_cv_sockpeercred=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
- if test "x$ac_cv_ucred" = xyes; then
+ if test "x$ac_cv_sockpeercred" = xyes; then
EXTRA_CPPFLAGS=-D_GNU_SOURCE
fi
else
old_CFLAGS="$CFLAGS"
fi
-if test "x$ac_cv_ucred" = xno; then
+if test "x$ac_cv_sockpeercred" = xno; then
CFLAGS="$old_CFLAGS"
{ echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6; }
else
cat >>confdefs.h <<\_ACEOF
-#define HAVE_STRUCT_UCRED 1
+#define HAVE_STRUCT_SOCKPEERCRED 1
_ACEOF
{ echo "$as_me:$LINENO: result: yes" >&5

View File

@ -0,0 +1,17 @@
$OpenBSD: patch-include_HsNetworkConfig_h_in,v 1.1 2012/10/02 13:35:40 dcoppa Exp $
ucred is sockpeercred on OpenBSD
--- include/HsNetworkConfig.h.in.orig Mon Oct 1 20:33:21 2012
+++ include/HsNetworkConfig.h.in Mon Oct 1 20:33:39 2012
@@ -89,8 +89,8 @@
/* Define to 1 if `sa_len' is member of `struct sockaddr'. */
#undef HAVE_STRUCT_SOCKADDR_SA_LEN
-/* Define to 1 if you have both SO_PEERCRED and struct ucred. */
-#undef HAVE_STRUCT_UCRED
+/* Define to 1 if you have both SO_PEERCRED and struct sockpeercred. */
+#undef HAVE_STRUCT_SOCKPEERCRED
/* Define to 1 if you have the `symlink' function. */
#undef HAVE_SYMLINK