Procházet zdrojové kódy

add support for getrpcbynumber_r/getrpcbyname_r/getrpcent_r and a config option to enable REENTRANT RPC

Mike Frysinger před 21 roky
rodič
revize
253acb104d
2 změnil soubory, kde provedl 19 přidání a 15 odebrání
  1. 9 0
      extra/Configs/Config.in
  2. 10 15
      libc/inet/rpc/rcmd.c

+ 9 - 0
extra/Configs/Config.in

@@ -552,6 +552,15 @@ config UCLIBC_HAS_FULL_RPC
 	  nfs mounts to work.  If you find you need the rest of the RPC stuff,
 	  nfs mounts to work.  If you find you need the rest of the RPC stuff,
 	  then enable this option.  Most people can safely answer N.
 	  then enable this option.  Most people can safely answer N.
 
 
+config UCLIBC_HAS_REENTRANT_RPC
+	bool "Reentrant RPC support"
+	depends on UCLIBC_HAS_RPC
+	default y if !HAVE_SHARED
+	help
+	  Most packages utilize the normal (non-reentrant) RPC functions, but 
+	  some (like exportfs from nfs-utils) need these reentrant versions.  
+	  Most people can safely answer N.
+
 endmenu
 endmenu
 
 
 
 

+ 10 - 15
libc/inet/rpc/rcmd.c

@@ -57,11 +57,6 @@ static char sccsid[] = "@(#)rcmd.c	8.3 (Berkeley) 3/26/94";
 #include <netinet/in.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
 #include <arpa/inet.h>
 
 
-#ifdef __UCLIBC_HAS_THREADS__
-#undef __UCLIBC_HAS_THREADS__
-#warning FIXME I am not reentrant yet...
-#endif
-
 
 
 /* some forward declarations */
 /* some forward declarations */
 static int __ivaliduser2(FILE *hostf, u_int32_t raddr,
 static int __ivaliduser2(FILE *hostf, u_int32_t raddr,
@@ -76,13 +71,13 @@ int rcmd(ahost, rport, locuser, remuser, cmd, fd2p)
      const char *locuser, *remuser, *cmd;
      const char *locuser, *remuser, *cmd;
      int *fd2p;
      int *fd2p;
 {
 {
-#ifdef __UCLIBC_HAS_THREADS__
+#ifdef __UCLIBC_HAS_REENTRANT_RPC__
 	int herr;
 	int herr;
-        struct hostent hostbuf;
+	struct hostent hostbuf;
 	size_t hstbuflen;
 	size_t hstbuflen;
 	char *tmphstbuf;
 	char *tmphstbuf;
 #endif
 #endif
-        struct hostent *hp;
+	struct hostent *hp;
 	struct sockaddr_in sin, from;
 	struct sockaddr_in sin, from;
 	struct pollfd pfd[2];
 	struct pollfd pfd[2];
 	int32_t oldmask;
 	int32_t oldmask;
@@ -92,7 +87,7 @@ int rcmd(ahost, rport, locuser, remuser, cmd, fd2p)
 
 
 	pid = getpid();
 	pid = getpid();
 
 
-#ifdef __UCLIBC_HAS_THREADS__
+#ifdef __UCLIBC_HAS_REENTRANT_RPC__
 	hstbuflen = 1024;
 	hstbuflen = 1024;
 #ifdef __ARCH_HAS_MMU__
 #ifdef __ARCH_HAS_MMU__
 	tmphstbuf = alloca (hstbuflen);
 	tmphstbuf = alloca (hstbuflen);
@@ -299,14 +294,14 @@ int ruserok(rhost, superuser, ruser, luser)
         struct hostent *hp;
         struct hostent *hp;
 	u_int32_t addr;
 	u_int32_t addr;
 	char **ap;
 	char **ap;
-#ifdef __UCLIBC_HAS_THREADS__
+#ifdef __UCLIBC_HAS_REENTRANT_RPC__
 	size_t buflen;
 	size_t buflen;
 	char *buffer;
 	char *buffer;
 	int herr;
 	int herr;
 	struct hostent hostbuf;
 	struct hostent hostbuf;
 #endif
 #endif
 
 
-#ifdef __UCLIBC_HAS_THREADS__
+#ifdef __UCLIBC_HAS_REENTRANT_RPC__
 	buflen = 1024;
 	buflen = 1024;
 #ifdef __ARCH_HAS_MMU__
 #ifdef __ARCH_HAS_MMU__
 	buffer = alloca (buflen);
 	buffer = alloca (buflen);
@@ -432,7 +427,7 @@ iruserok2 (raddr, superuser, ruser, luser, rhost)
 		size_t dirlen;
 		size_t dirlen;
 		uid_t uid;
 		uid_t uid;
 
 
-#ifdef __UCLIBC_HAS_THREADS__
+#ifdef __UCLIBC_HAS_REENTRANT_RPC__
 		size_t buflen = sysconf (_SC_GETPW_R_SIZE_MAX);
 		size_t buflen = sysconf (_SC_GETPW_R_SIZE_MAX);
 		struct passwd pwdbuf;
 		struct passwd pwdbuf;
 #ifdef __ARCH_HAS_MMU__
 #ifdef __ARCH_HAS_MMU__
@@ -515,7 +510,7 @@ __icheckhost (u_int32_t raddr, char *lhost, const char *rhost)
 	int negate=1;    /* Multiply return with this to get -1 instead of 1 */
 	int negate=1;    /* Multiply return with this to get -1 instead of 1 */
 	char **pp;
 	char **pp;
 
 
-#ifdef __UCLIBC_HAS_THREADS__
+#ifdef __UCLIBC_HAS_REENTRANT_RPC__
 	int save_errno;
 	int save_errno;
 	size_t buflen;
 	size_t buflen;
 	char *buffer;
 	char *buffer;
@@ -545,7 +540,7 @@ __icheckhost (u_int32_t raddr, char *lhost, const char *rhost)
 		return negate * (! (raddr ^ laddr));
 		return negate * (! (raddr ^ laddr));
 
 
 	/* Better be a hostname. */
 	/* Better be a hostname. */
-#ifdef __UCLIBC_HAS_THREADS__
+#ifdef __UCLIBC_HAS_REENTRANT_RPC__
 	buflen = 1024;
 	buflen = 1024;
 	buffer = malloc(buflen);
 	buffer = malloc(buflen);
 	save_errno = errno;
 	save_errno = errno;
@@ -559,7 +554,7 @@ __icheckhost (u_int32_t raddr, char *lhost, const char *rhost)
 	__set_errno (save_errno);
 	__set_errno (save_errno);
 #else
 #else
 	hp = gethostbyname(lhost);
 	hp = gethostbyname(lhost);
-#endif /* __UCLIBC_HAS_THREADS__ */
+#endif /* __UCLIBC_HAS_REENTRANT_RPC__ */
 
 
 	if (hp == NULL)
 	if (hp == NULL)
 		return 0;
 		return 0;