[Midnightbsd-cvs] src [8096] trunk: bring some things from Bull GNU/Linux NFSv4 project

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Thu Sep 15 18:53:07 EDT 2016


Revision: 8096
          http://svnweb.midnightbsd.org/src/?rev=8096
Author:   laffer1
Date:     2016-09-15 18:53:07 -0400 (Thu, 15 Sep 2016)
Log Message:
-----------
bring some things from Bull GNU/Linux NFSv4 project

Modified Paths:
--------------
    trunk/include/rpc/auth.h
    trunk/include/rpc/auth_unix.h
    trunk/lib/libc/rpc/auth_unix.c
    trunk/lib/libc/rpc/authunix_prot.c
    trunk/lib/libc/rpc/clnt_perror.c
    trunk/lib/libc/rpc/clnt_vc.c
    trunk/lib/libc/rpc/rpc_generic.c
    trunk/lib/libc/rpc/rpc_soc.3
    trunk/lib/libc/rpc/rpcb_clnt.c
    trunk/lib/libc/rpc/svc_auth_unix.c
    trunk/lib/libc/rpc/svc_run.c
    trunk/sys/rpc/auth.h
    trunk/sys/rpc/clnt_vc.c
    trunk/sys/rpc/rpcb_clnt.c

Modified: trunk/include/rpc/auth.h
===================================================================
--- trunk/include/rpc/auth.h	2016-09-15 22:51:58 UTC (rev 8095)
+++ trunk/include/rpc/auth.h	2016-09-15 22:53:07 UTC (rev 8096)
@@ -243,14 +243,13 @@
  * System style authentication
  * AUTH *authunix_create(machname, uid, gid, len, aup_gids)
  *	char *machname;
- *	int uid;
- *	int gid;
+ *	uid_t uid;
+ *	gid_t gid;
  *	int len;
- *	int *aup_gids;
+ *	gid_t *aup_gids;
  */
 __BEGIN_DECLS
-extern AUTH *authunix_create(char *, int, int, int,
-    int *);
+extern AUTH *authunix_create(char *, uid_t, gid_t, int, gid_t *);
 extern AUTH *authunix_create_default(void);	/* takes no parameters */
 extern AUTH *authnone_create(void);		/* takes no parameters */
 __END_DECLS

Modified: trunk/include/rpc/auth_unix.h
===================================================================
--- trunk/include/rpc/auth_unix.h	2016-09-15 22:51:58 UTC (rev 8095)
+++ trunk/include/rpc/auth_unix.h	2016-09-15 22:53:07 UTC (rev 8096)
@@ -60,10 +60,10 @@
 struct authunix_parms {
 	u_long	 aup_time;
 	char	*aup_machname;
-	int	 aup_uid;
-	int	 aup_gid;
+	uid_t	 aup_uid;
+	gid_t	 aup_gid;
 	u_int	 aup_len;
-	int	*aup_gids;
+	gid_t	*aup_gids;
 };
 
 #define authsys_parms authunix_parms

Modified: trunk/lib/libc/rpc/auth_unix.c
===================================================================
--- trunk/lib/libc/rpc/auth_unix.c	2016-09-15 22:51:58 UTC (rev 8095)
+++ trunk/lib/libc/rpc/auth_unix.c	2016-09-15 22:53:07 UTC (rev 8096)
@@ -94,10 +94,10 @@
 AUTH *
 authunix_create(machname, uid, gid, len, aup_gids)
 	char *machname;
-	int uid;
-	int gid;
+	uid_t uid;
+	gid_t gid;
 	int len;
-	int *aup_gids;
+	gid_t *aup_gids;
 {
 	struct authunix_parms aup;
 	char mymem[MAX_AUTH_BYTES];
@@ -207,9 +207,7 @@
 		abort();
 	if (ngids > NGRPS)
 		ngids = NGRPS;
-	/* XXX: interface problem; those should all have been unsigned */
-	auth = authunix_create(machname, (int)uid, (int)gid, ngids,
-	    (int *)gids);
+	auth = authunix_create(machname, uid, gid, ngids, gids);
 	free(gids);
 	return (auth);
 }

Modified: trunk/lib/libc/rpc/authunix_prot.c
===================================================================
--- trunk/lib/libc/rpc/authunix_prot.c	2016-09-15 22:51:58 UTC (rev 8095)
+++ trunk/lib/libc/rpc/authunix_prot.c	2016-09-15 22:53:07 UTC (rev 8096)
@@ -60,7 +60,7 @@
 	XDR *xdrs;
 	struct authunix_parms *p;
 {
-	int **paup_gids;
+	gid_t **paup_gids;
 
 	assert(xdrs != NULL);
 	assert(p != NULL);
@@ -69,8 +69,8 @@
 
 	if (xdr_u_long(xdrs, &(p->aup_time))
 	    && xdr_string(xdrs, &(p->aup_machname), MAX_MACHINE_NAME)
-	    && xdr_int(xdrs, &(p->aup_uid))
-	    && xdr_int(xdrs, &(p->aup_gid))
+	    && xdr_u_int(xdrs, &(p->aup_uid))
+	    && xdr_u_int(xdrs, &(p->aup_gid))
 	    && xdr_array(xdrs, (char **) paup_gids,
 		    &(p->aup_len), NGRPS, sizeof(int), (xdrproc_t)xdr_int) ) {
 		return (TRUE);

Modified: trunk/lib/libc/rpc/clnt_perror.c
===================================================================
--- trunk/lib/libc/rpc/clnt_perror.c	2016-09-15 22:51:58 UTC (rev 8095)
+++ trunk/lib/libc/rpc/clnt_perror.c	2016-09-15 22:53:07 UTC (rev 8096)
@@ -242,7 +242,7 @@
 clnt_spcreateerror(s)
 	const char *s;
 {
-	char *str;
+	char *str, *err;
 	size_t len, i;
 
 	assert(s != NULL);
@@ -258,8 +258,21 @@
 	switch (rpc_createerr.cf_stat) {
 	case RPC_PMAPFAILURE:
 		(void) strncat(str, " - ", len - 1);
-		(void) strncat(str,
-		    clnt_sperrno(rpc_createerr.cf_error.re_status), len - 4);
+		 err = clnt_sperrno(rpc_createerr.cf_error.re_status);
+		if (err)
+			(void) strncat(str, err+5, len-5);
+		switch(rpc_createerr.cf_error.re_status) {
+		case RPC_CANTSEND:
+		case RPC_CANTRECV:
+			i = strlen(str);
+			len -= i;
+			snprintf(str+i, len, ": errno %d (%s)", 
+				rpc_createerr.cf_error.re_errno,
+				strerror(rpc_createerr.cf_error.re_errno)); 
+			break;
+		default:
+			break;
+		}
 		break;
 
 	case RPC_SYSTEMERROR:

Modified: trunk/lib/libc/rpc/clnt_vc.c
===================================================================
--- trunk/lib/libc/rpc/clnt_vc.c	2016-09-15 22:51:58 UTC (rev 8095)
+++ trunk/lib/libc/rpc/clnt_vc.c	2016-09-15 22:53:07 UTC (rev 8096)
@@ -672,6 +672,10 @@
 	if (ct->ct_addr.buf)
 		free(ct->ct_addr.buf);
 	mem_free(ct, sizeof(struct ct_data));
+	if (cl->cl_netid && cl->cl_netid[0])
+		mem_free(cl->cl_netid, strlen(cl->cl_netid) +1);
+	if (cl->cl_tp && cl->cl_tp[0])
+		mem_free(cl->cl_tp, strlen(cl->cl_tp) +1);
 	mem_free(cl, sizeof(CLIENT));
 	mutex_unlock(&clnt_fd_lock);
 	thr_sigsetmask(SIG_SETMASK, &(mask), NULL);

Modified: trunk/lib/libc/rpc/rpc_generic.c
===================================================================
--- trunk/lib/libc/rpc/rpc_generic.c	2016-09-15 22:51:58 UTC (rev 8095)
+++ trunk/lib/libc/rpc/rpc_generic.c	2016-09-15 22:53:07 UTC (rev 8096)
@@ -269,7 +269,8 @@
 		}
 		while ((nconf = getnetconfig(confighandle)) != NULL) {
 			if (strcmp(nconf->nc_protofmly, NC_INET) == 0) {
-				if (strcmp(nconf->nc_proto, NC_TCP) == 0) {
+				if (strcmp(nconf->nc_proto, NC_TCP) == 0 &&
+				    netid_tcp == NULL) {
 					netid_tcp = strdup(nconf->nc_netid);
 					if (main_thread)
 						netid_tcp_main = netid_tcp;
@@ -277,7 +278,8 @@
 						thr_setspecific(tcp_key,
 							(void *) netid_tcp);
 				} else
-				if (strcmp(nconf->nc_proto, NC_UDP) == 0) {
+				if (strcmp(nconf->nc_proto, NC_UDP) == 0 &&
+				   netid_udp == NULL) {
 					netid_udp = strdup(nconf->nc_netid);
 					if (main_thread)
 						netid_udp_main = netid_udp;
@@ -616,6 +618,9 @@
 #endif
 	u_int16_t port;
 
+	if (nbuf->len <= 0)
+		return NULL;
+
 	switch (af) {
 	case AF_INET:
 		sin = nbuf->buf;

Modified: trunk/lib/libc/rpc/rpc_soc.3
===================================================================
--- trunk/lib/libc/rpc/rpc_soc.3	2016-09-15 22:51:58 UTC (rev 8095)
+++ trunk/lib/libc/rpc/rpc_soc.3	2016-09-15 22:53:07 UTC (rev 8096)
@@ -148,7 +148,7 @@
 .Ft "AUTH *"
 .Xc
 .It Xo
-.Fn authunix_create "char *host" "int uid" "int gid" "int len" "int *aup_gids"
+.Fn authunix_create "char *host" "uid_t uid" "gid_t gid" "int len" "gid_t *aup_gids"
 .Xc
 .Pp
 Create and return an

Modified: trunk/lib/libc/rpc/rpcb_clnt.c
===================================================================
--- trunk/lib/libc/rpc/rpcb_clnt.c	2016-09-15 22:51:58 UTC (rev 8095)
+++ trunk/lib/libc/rpc/rpcb_clnt.c	2016-09-15 22:53:07 UTC (rev 8096)
@@ -770,7 +770,14 @@
 	}
 
 	parms.r_addr = NULL;
+	parms.r_netid = nconf->nc_netid;
 
+       /*
+	* According to wire captures, the reference implementation
+	* (OpenSolaris) sends a blank string here too.
+	*/
+	parms.r_owner = "";
+
 	/*
 	 * Use default total timeout if no timeout is specified.
 	 */

Modified: trunk/lib/libc/rpc/svc_auth_unix.c
===================================================================
--- trunk/lib/libc/rpc/svc_auth_unix.c	2016-09-15 22:51:58 UTC (rev 8095)
+++ trunk/lib/libc/rpc/svc_auth_unix.c	2016-09-15 22:53:07 UTC (rev 8096)
@@ -68,7 +68,7 @@
 	struct area {
 		struct authunix_parms area_aup;
 		char area_machname[MAX_MACHINE_NAME+1];
-		int area_gids[NGRPS];
+		gid_t area_gids[NGRPS];
 	} *area;
 	u_int auth_len;
 	size_t str_len, gid_len;

Modified: trunk/lib/libc/rpc/svc_run.c
===================================================================
--- trunk/lib/libc/rpc/svc_run.c	2016-09-15 22:51:58 UTC (rev 8095)
+++ trunk/lib/libc/rpc/svc_run.c	2016-09-15 22:53:07 UTC (rev 8096)
@@ -60,14 +60,13 @@
 	fd_set readfds, cleanfds;
 	struct timeval timeout;
 
-	timeout.tv_sec = 30;
-	timeout.tv_usec = 0;
-
 	for (;;) {
 		rwlock_rdlock(&svc_fd_lock);
 		readfds = svc_fdset;
 		cleanfds = svc_fdset;
 		rwlock_unlock(&svc_fd_lock);
+		timeout.tv_sec = 30;
+		timeout.tv_usec = 0;
 		switch (_select(svc_maxfd+1, &readfds, NULL, NULL, &timeout)) {
 		case -1:
 			FD_ZERO(&readfds);

Modified: trunk/sys/rpc/auth.h
===================================================================
--- trunk/sys/rpc/auth.h	2016-09-15 22:51:58 UTC (rev 8095)
+++ trunk/sys/rpc/auth.h	2016-09-15 22:53:07 UTC (rev 8096)
@@ -234,10 +234,10 @@
  * System style authentication
  * AUTH *authunix_create(machname, uid, gid, len, aup_gids)
  *	char *machname;
- *	int uid;
- *	int gid;
+ *	uid_t uid;
+ *	gid_t gid;
  *	int len;
- *	int *aup_gids;
+ *	gid_t *aup_gids;
  */
 __BEGIN_DECLS
 #ifdef _KERNEL
@@ -244,8 +244,7 @@
 struct ucred;
 extern AUTH *authunix_create(struct ucred *);
 #else
-extern AUTH *authunix_create(char *, int, int, int,
-    int *);
+extern AUTH *authunix_create(char *, uid_t, gid_t, int, gid_t *);
 extern AUTH *authunix_create_default(void);	/* takes no parameters */
 #endif
 extern AUTH *authnone_create(void);		/* takes no parameters */

Modified: trunk/sys/rpc/clnt_vc.c
===================================================================
--- trunk/sys/rpc/clnt_vc.c	2016-09-15 22:51:58 UTC (rev 8095)
+++ trunk/sys/rpc/clnt_vc.c	2016-09-15 22:53:07 UTC (rev 8096)
@@ -836,6 +836,10 @@
 		soclose(so);
 	}
 	mem_free(ct, sizeof(struct ct_data));
+	if (cl->cl_netid && cl->cl_netid[0])
+		mem_free(cl->cl_netid, strlen(cl->cl_netid) +1);
+	if (cl->cl_tp && cl->cl_tp[0])
+		mem_free(cl->cl_tp, strlen(cl->cl_tp) +1);
 	mem_free(cl, sizeof(CLIENT));
 }
 

Modified: trunk/sys/rpc/rpcb_clnt.c
===================================================================
--- trunk/sys/rpc/rpcb_clnt.c	2016-09-15 22:51:58 UTC (rev 8095)
+++ trunk/sys/rpc/rpcb_clnt.c	2016-09-15 22:53:07 UTC (rev 8096)
@@ -780,7 +780,14 @@
 	}
 
 	parms.r_addr = NULL;
+	parms.r_netid = nconf->nc_netid;
 
+       /*
+	* According to wire captures, the reference implementation
+	* (OpenSolaris) sends a blank string here too.
+	*/
+	parms.r_owner = "";
+
 	/*
 	 * Use default total timeout if no timeout is specified.
 	 */



More information about the Midnightbsd-cvs mailing list