guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

18/36: gnu: Add libtirpc/hurd.


From: guix-commits
Subject: 18/36: gnu: Add libtirpc/hurd.
Date: Fri, 24 Apr 2020 08:14:10 -0400 (EDT)

janneke pushed a commit to branch wip-hurd-vm
in repository guix.

commit e8338359fdd2729349f9e841a1ce058a16631e1f
Author: Ricardo Wurmus <address@hidden>
AuthorDate: Sun Apr 12 23:04:49 2020 +0200

    gnu: Add libtirpc/hurd.
    
    * gnu/packages/onc-rpc.scm (libtirpc/hurd): New variable.
    * gnu/packages/patches/libtirpc-hurd-client.patch,
    gnu/packages/patches/libtirpc-hurd.patch: New files.
    * gnu/local.mk (dist_patch_DATA): Add them.
---
 gnu/local.mk                                    |   2 +
 gnu/packages/onc-rpc.scm                        |  19 ++-
 gnu/packages/patches/libtirpc-hurd-client.patch |  50 +++++++
 gnu/packages/patches/libtirpc-hurd.patch        | 172 ++++++++++++++++++++++++
 4 files changed, 242 insertions(+), 1 deletion(-)

diff --git a/gnu/local.mk b/gnu/local.mk
index 7c117b7..44e9b35 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1175,6 +1175,8 @@ dist_patch_DATA =                                         
\
   %D%/packages/patches/libtgvoip-disable-sse2.patch            \
   %D%/packages/patches/libtgvoip-disable-webrtc.patch          \
   %D%/packages/patches/libtheora-config-guess.patch            \
+  %D%/packages/patches/libtirpc-hurd.patch                     \
+  %D%/packages/patches/libtirpc-hurd-client.patch              \
   %D%/packages/patches/libtommath-fix-linkage.patch            \
   %D%/packages/patches/libtool-skip-tests2.patch               \
   %D%/packages/patches/libusb-0.1-disable-tests.patch          \
diff --git a/gnu/packages/onc-rpc.scm b/gnu/packages/onc-rpc.scm
index 5849b8d..cd31dfd 100644
--- a/gnu/packages/onc-rpc.scm
+++ b/gnu/packages/onc-rpc.scm
@@ -4,6 +4,7 @@
 ;;; Copyright © 2017, 2018 Leo Famulari <address@hidden>
 ;;; Copyright © 2018 Tobias Geerinckx-Rice <address@hidden>
 ;;; Copyright © 2019 Marius Bakke <address@hidden>
+;;; Copyright © 2020 Ricardo Wurmus <address@hidden>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -30,7 +31,8 @@
   #:use-module (gnu packages gettext)
   #:use-module (gnu packages kerberos)
   #:use-module (gnu packages pkg-config)
-  #:use-module (guix build-system gnu))
+  #:use-module (guix build-system gnu)
+  #:use-module (guix utils))
 
 (define-public libtirpc
   (package
@@ -72,6 +74,21 @@ procedure calls) protocol in a transport-independent manner. 
 It supports both
 IPv4 and IPv6.  ONC RPC is notably used by the network file system (NFS).")
     (license bsd-3)))
 
+(define-public libtirpc/hurd
+  (package
+    (inherit libtirpc)
+    (name "libtirpc-hurd")
+    (source (origin (inherit (package-source libtirpc))
+                    (patches (search-patches "libtirpc-hurd.patch"
+                                             "libtirpc-hurd-client.patch"))))
+    (arguments
+     (substitute-keyword-arguments (package-arguments libtirpc)
+       ((#:configure-flags flags ''())
+        ;; When cross-building the target system's krb5-config should be used.
+        `(list (string-append "ac_cv_prog_KRB5_CONFIG="
+                              (assoc-ref %build-inputs "mit-krb5")
+                              "/bin/krb5-config")))))))
+
 (define-public rpcbind
   (package
     (name "rpcbind")
diff --git a/gnu/packages/patches/libtirpc-hurd-client.patch 
b/gnu/packages/patches/libtirpc-hurd-client.patch
new file mode 100644
index 0000000..526ad26
--- /dev/null
+++ b/gnu/packages/patches/libtirpc-hurd-client.patch
@@ -0,0 +1,50 @@
+Taken from 
https://salsa.debian.org/debian/libtirpc/-/raw/master/debian/patches/06-hurd-client-port.diff
+
+Description: Fix client code for hurd, avoiding malloc overflow
+ When trying to setup a inet connection, it happens the following:
+ - in libtirp, src/clnt_vc.c, clnt_vc_create gets called
+ - when trying to allocate vc_fd_locks, __rpc_dtbsize() is used as size
+   for that array of fd locks
+ - __rpc_dtbsize(), in src/rpc_generic.c, queries using rlimit the
+   maximum (rlim_max) number of file descriptors (RLIMIT_NOFILE):
+   - on Linux, the default is { rlim_cur = 1024, rlim_max = 4096 }
+   - on kFreeBSD, the default is { rlim_cur = 1024, rlim_max = 1024 }
+   - on Hurd, the default is { rlim_cur = 1024, rlim_max = RLIM_INFINITY }
+  meaning that on Hurd the memory allocation fails (as
+  __rpc_dtbsize() * sizeof(int) overflows and is negative)
+
+ Change libtiprc so __rpc_dtbsize falls back on rlim_cur if rlim_max
+ is unlimited.
+
+ This patch fixes the client connection using inet sockets; local unix
+ sockets are not working, for two reasons so far:
+ - getpeername on them gives EOPNOTSUPP
+ - SO_REUSEADDR is not implemented for them
+Author: Pino Toscano <address@hidden>
+
+Bug-Debian: http://bugs.debian.org/739674
+Forwarded: no
+Reviewed-By: Petter Reinholdtsen
+Last-Update: 2014-03-03
+
+--- a/src/rpc_generic.c
++++ b/src/rpc_generic.c
+@@ -107,12 +107,17 @@
+ {
+       static int tbsize;
+       struct rlimit rl;
++      rlim_t lim;
+ 
+       if (tbsize) {
+               return (tbsize);
+       }
+       if (getrlimit(RLIMIT_NOFILE, &rl) == 0) {
+-              return (tbsize = (int)rl.rlim_max);
++              lim = rl.rlim_max;
++              if (lim == RLIM_INFINITY) {
++                      lim = rl.rlim_cur;
++              }
++              return (tbsize = (int)lim);
+       }
+       /*
+        * Something wrong.  I'll try to save face by returning a
diff --git a/gnu/packages/patches/libtirpc-hurd.patch 
b/gnu/packages/patches/libtirpc-hurd.patch
new file mode 100644
index 0000000..cd625d6
--- /dev/null
+++ b/gnu/packages/patches/libtirpc-hurd.patch
@@ -0,0 +1,172 @@
+This is a combination of two patches:
+
+1) Taken from 
https://salsa.debian.org/debian/libtirpc/-/raw/master/debian/patches/03-kfreebsd.diff
+
+Description: Fix build on non Linux architectures
+Author: Andreas Beckmann <address@hidden>
+Last-Update: 2019-09-01
+
+2) Taken from 
https://salsa.debian.org/debian/libtirpc/-/raw/master/debian/patches/05-hurd-port.diff
+
+Description: Get source building on Hurd
+ - Look for <sys/user.h> before using it.
+ - Define MAXHOSTNAMELEN to 64 if missing.
+ - Bind sockets on Hurd like on Linux.
+Author: Petter Reinholdtsen <address@hidden>
+
+--- a/src/svc_dg.c
++++ b/src/svc_dg.c
+@@ -648,6 +648,7 @@
+ void
+ svc_dg_enable_pktinfo(int fd, const struct __rpc_sockinfo *si)
+ {
++#ifdef __linux__
+       int val = 1;
+ 
+       switch (si->si_af) {
+@@ -660,6 +661,7 @@
+               break;
+ #endif
+       }
++#endif
+ }
+ 
+ /*
+@@ -670,6 +672,7 @@
+ int
+ svc_dg_valid_pktinfo(struct msghdr *msg)
+ {
++#ifdef __linux__
+       struct cmsghdr *cmsg;
+ 
+       if (!msg->msg_name)
+@@ -716,4 +719,7 @@
+       }
+ 
+       return 1;
++#else
++        return 0;
++#endif
+ }
+--- a/src/clnt_vc.c
++++ b/src/clnt_vc.c
+@@ -71,10 +71,12 @@
+ #define MCALL_MSG_SIZE 24
+ 
+ #define CMGROUP_MAX    16
+-#define SCM_CREDS      0x03            /* process creds (struct cmsgcred) */
+ 
+ #undef rpc_createerr                   /* make it clear it is a thread safe 
variable */
+ 
++#ifndef SCM_CREDS
++#define SCM_CREDS      0x03            /* process creds (struct cmsgcred) */
++
+ /*
+  * Credentials structure, used to verify the identity of a peer
+  * process that has sent us a message. This is allocated by the
+@@ -90,6 +92,7 @@
+         short   cmcred_ngroups;         /* number or groups */
+         gid_t   cmcred_groups[CMGROUP_MAX];     /* groups */
+ };
++#endif
+ 
+ struct cmessage {
+         struct cmsghdr cmsg;
+--- a/src/getpeereid.c
++++ b/src/getpeereid.c
+@@ -25,9 +25,14 @@
+  */
+ 
+ 
++#include "config.h"
++
+ #include <sys/param.h>
+ #include <sys/socket.h>
+ #include <sys/un.h>
++#ifdef HAVE_SYS_USER_H
++#  include <sys/user.h>
++#endif /* HAVE_SYS_USER_H */
+ 
+ #include <errno.h>
+ #include <unistd.h>
+--- a/src/getpeereid.c
++++ b/src/getpeereid.c
+@@ -35,12 +36,25 @@
+ int
+ getpeereid(int s, uid_t *euid, gid_t *egid)
+ {
++#ifndef HAVE_SYS_USER_H
++        return(-1);
++#else
++#ifdef XUCRED_VERSION
++      struct xucred uc;
++#define uid  cr_uid
++#define gid  cr_gid
++#else
+       struct ucred uc;
++#endif
+       socklen_t uclen;
+       int error;
+ 
+       uclen = sizeof(uc); 
++#ifdef XUCRED_VERSION
++      error = getsockopt(s, 0, LOCAL_PEERCRED, &uc, &uclen);
++#else
+       error = getsockopt(s, SOL_SOCKET, SO_PEERCRED, &uc, &uclen); /*  
SCM_CREDENTIALS */
++#endif
+       if (error != 0)
+               return (error);
+       //      if (uc.cr_version != XUCRED_VERSION)
+@@ -59,4 +66,5 @@
+       *euid = uc.uid;
+       *egid = uc.gid;
+       return (0);
++#endif /* HAVE_SYS_USER_H */
+  }
+--- a/tirpc/reentrant.h
++++ b/tirpc/reentrant.h
+@@ -36,7 +36,7 @@
+  * These definitions are only guaranteed to be valid on Linux. 
+  */
+ 
+-#if defined(__linux__)
++#if defined(__linux__) || defined(__GLIBC__)
+ 
+ #include <pthread.h>
+ 
+--- a/configure.ac
++++ b/configure.ac
+@@ -93,7 +93,7 @@
+ AC_PROG_LIBTOOL
+ AC_HEADER_DIRENT
+ AC_PREFIX_DEFAULT(/usr)
+-AC_CHECK_HEADERS([arpa/inet.h fcntl.h libintl.h limits.h locale.h netdb.h 
netinet/in.h stddef.h stdint.h stdlib.h string.h sys/ioctl.h sys/param.h 
sys/socket.h sys/time.h syslog.h unistd.h features.h gssapi/gssapi_ext.h])
++AC_CHECK_HEADERS([arpa/inet.h fcntl.h libintl.h limits.h locale.h netdb.h 
netinet/in.h stddef.h stdint.h stdlib.h string.h sys/ioctl.h sys/param.h 
sys/socket.h sys/time.h syslog.h unistd.h features.h gssapi/gssapi_ext.h 
sys/user.h])
+ AC_CHECK_LIB([pthread], [pthread_create])
+ AC_CHECK_FUNCS([getrpcbyname getrpcbynumber setrpcent endrpcent getrpcent])
+ 
+--- a/src/auth_unix.c
++++ b/src/auth_unix.c
+@@ -56,6 +56,11 @@
+ #include <rpc/auth.h>
+ #include <rpc/auth_unix.h>
+ 
++/* Workaround for Hurd */
++#ifndef MAXHOSTNAMELEN
++#  define MAXHOSTNAMELEN   64
++#endif
++
+ /* auth_unix.c */
+ static void authunix_nextverf (AUTH *);
+ static bool_t authunix_marshal (AUTH *, XDR *);
+--- a/src/bindresvport.c
++++ b/src/bindresvport.c
+@@ -64,7 +64,7 @@
+         return bindresvport_sa(sd, (struct sockaddr *)sin);
+ }
+ 
+-#ifdef __linux__
++#if defined(__linux__) || defined(__GNU__)
+ 
+ #define STARTPORT 600
+ #define LOWPORT 512



reply via email to

[Prev in Thread] Current Thread [Next in Thread]