You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

103 lines
2.2 KiB

  1. --- a/tirpc/reentrant.h
  2. +++ b/tirpc/reentrant.h
  3. @@ -36,7 +36,7 @@
  4. * These definitions are only guaranteed to be valid on Linux.
  5. */
  6. -#if defined(__linux__)
  7. +#if defined(__linux__) || defined(__MACH__)
  8. #include <pthread.h>
  9. --- a/tirpc/rpc/rpcent.h
  10. +++ b/tirpc/rpc/rpcent.h
  11. @@ -50,7 +50,7 @@ extern "C" {
  12. /* These are defined in /usr/include/rpc/netdb.h, unless we are using
  13. the C library without RPC support. */
  14. -#if defined(__UCLIBC__) && !defined(__UCLIBC_HAS_RPC__) || !defined(__GLIBC__)
  15. +#if (defined(__UCLIBC__) && !defined(__UCLIBC_HAS_RPC__) || !defined(__GLIBC__)) && !defined(__MACH__)
  16. struct rpcent {
  17. char *r_name; /* name of server for this rpc program */
  18. char **r_aliases; /* alias list */
  19. --- a/src/rpc_com.h
  20. +++ b/src/rpc_com.h
  21. @@ -63,6 +63,14 @@ void __xprt_set_raddr(SVCXPRT *, const s
  22. extern int __svc_maxrec;
  23. +#ifndef SOL_IP
  24. +#define SOL_IP IPPROTO_IP
  25. +#endif
  26. +
  27. +#ifndef SOL_IPV6
  28. +#define SOL_IPV6 IPPROTO_IPV6
  29. +#endif
  30. +
  31. #ifdef __cplusplus
  32. }
  33. #endif
  34. --- a/src/svc_dg.c
  35. +++ b/src/svc_dg.c
  36. @@ -37,6 +37,11 @@
  37. *
  38. * Does some caching in the hopes of achieving execute-at-most-once semantics.
  39. */
  40. +
  41. +#ifdef __APPLE__
  42. +#define __APPLE_USE_RFC_3542
  43. +#endif
  44. +
  45. #include <pthread.h>
  46. #include <reentrant.h>
  47. #include <sys/types.h>
  48. --- a/src/svc_raw.c
  49. +++ b/src/svc_raw.c
  50. @@ -43,6 +43,7 @@
  51. #include <sys/types.h>
  52. #include <rpc/raw.h>
  53. #include <stdlib.h>
  54. +#include <string.h>
  55. #ifndef UDPMSGSIZE
  56. #define UDPMSGSIZE 8800
  57. --- a/src/getpeereid.c
  58. +++ b/src/getpeereid.c
  59. @@ -29,12 +29,17 @@
  60. #include <sys/socket.h>
  61. #include <sys/un.h>
  62. +#if __APPLE__ || __FreeBSD__
  63. +#include <sys/ucred.h>
  64. +#endif
  65. +
  66. #include <errno.h>
  67. #include <unistd.h>
  68. int
  69. getpeereid(int s, uid_t *euid, gid_t *egid)
  70. {
  71. +#if defined(SO_PEERCRED)
  72. struct ucred uc;
  73. socklen_t uclen;
  74. int error;
  75. @@ -48,4 +53,19 @@ getpeereid(int s, uid_t *euid, gid_t *eg
  76. *euid = uc.uid;
  77. *egid = uc.gid;
  78. return (0);
  79. +#elif defined(LOCAL_PEERCRED)
  80. + struct xucred uc;
  81. + socklen_t uclen;
  82. + int error;
  83. +
  84. + uclen = sizeof(uc);
  85. + error = getsockopt(s, SOL_LOCAL, LOCAL_PEERCRED, &uc, &uclen); /* SCM_CREDENTIALS */
  86. + if (error != 0)
  87. + return (error);
  88. + *euid = uc.cr_uid;
  89. + *egid = uc.cr_gid;
  90. + return (0);
  91. +#else
  92. + return (ENOTSUP);
  93. +#endif
  94. }