17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*cb620785Sraf  * Common Development and Distribution License (the "License").
6*cb620785Sraf  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
2061961e0fSrobinson  */
2161961e0fSrobinson 
2261961e0fSrobinson /*
23*cb620785Sraf  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
26*cb620785Sraf 
277c478bd9Sstevel@tonic-gate /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
287c478bd9Sstevel@tonic-gate /* All Rights Reserved */
297c478bd9Sstevel@tonic-gate /*
307c478bd9Sstevel@tonic-gate  * Portions of this source code were derived from Berkeley
317c478bd9Sstevel@tonic-gate  * 4.3 BSD under license from the Regents of the University of
327c478bd9Sstevel@tonic-gate  * California.
337c478bd9Sstevel@tonic-gate  */
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate /*
367c478bd9Sstevel@tonic-gate  * clnt_perror.c
377c478bd9Sstevel@tonic-gate  *
387c478bd9Sstevel@tonic-gate  */
397c478bd9Sstevel@tonic-gate 
407c478bd9Sstevel@tonic-gate #include "mt.h"
417c478bd9Sstevel@tonic-gate #include "rpc_mt.h"
427c478bd9Sstevel@tonic-gate #include <stdio.h>
437c478bd9Sstevel@tonic-gate #include <libintl.h>
447c478bd9Sstevel@tonic-gate #include <string.h>
457c478bd9Sstevel@tonic-gate #include <rpc/types.h>
467c478bd9Sstevel@tonic-gate #include <rpc/auth.h>
477c478bd9Sstevel@tonic-gate #include <sys/tiuser.h>
487c478bd9Sstevel@tonic-gate #include <rpc/clnt.h>
497c478bd9Sstevel@tonic-gate #include <stdlib.h>
507c478bd9Sstevel@tonic-gate #include <syslog.h>
517c478bd9Sstevel@tonic-gate #include <string.h>
527c478bd9Sstevel@tonic-gate 
537c478bd9Sstevel@tonic-gate extern char *netdir_sperror();
547c478bd9Sstevel@tonic-gate 
557c478bd9Sstevel@tonic-gate const char __nsl_dom[]  = "SUNW_OST_NETRPC";
567c478bd9Sstevel@tonic-gate 
577c478bd9Sstevel@tonic-gate #define	ERRBUFSZ	512
587c478bd9Sstevel@tonic-gate 
597c478bd9Sstevel@tonic-gate static char *
__buf(void)6061961e0fSrobinson __buf(void)
617c478bd9Sstevel@tonic-gate {
627c478bd9Sstevel@tonic-gate 	char *buf;
637c478bd9Sstevel@tonic-gate 	static char buf_main[ERRBUFSZ];
64*cb620785Sraf 	static pthread_key_t perror_key = PTHREAD_ONCE_KEY_NP;
657c478bd9Sstevel@tonic-gate 
667c478bd9Sstevel@tonic-gate 	buf = thr_main()? buf_main :
677c478bd9Sstevel@tonic-gate 		thr_get_storage(&perror_key, ERRBUFSZ, free);
687c478bd9Sstevel@tonic-gate 	if (buf == NULL)
697c478bd9Sstevel@tonic-gate 		syslog(LOG_WARNING,
707c478bd9Sstevel@tonic-gate 		"clnt_sperror: malloc failed when trying to create buffer\n");
717c478bd9Sstevel@tonic-gate 	return (buf);
727c478bd9Sstevel@tonic-gate }
737c478bd9Sstevel@tonic-gate 
747c478bd9Sstevel@tonic-gate static char *
auth_errmsg(enum auth_stat stat)7561961e0fSrobinson auth_errmsg(enum auth_stat stat)
767c478bd9Sstevel@tonic-gate {
777c478bd9Sstevel@tonic-gate 	switch (stat) {
787c478bd9Sstevel@tonic-gate 	case AUTH_OK:
797c478bd9Sstevel@tonic-gate 		return (dgettext(__nsl_dom, "Authentication OK"));
807c478bd9Sstevel@tonic-gate 	case AUTH_BADCRED:
817c478bd9Sstevel@tonic-gate 		return (dgettext(__nsl_dom, "Invalid client credential"));
827c478bd9Sstevel@tonic-gate 	case AUTH_REJECTEDCRED:
837c478bd9Sstevel@tonic-gate 		return (dgettext(__nsl_dom, "Server rejected credential"));
847c478bd9Sstevel@tonic-gate 	case AUTH_BADVERF:
857c478bd9Sstevel@tonic-gate 		return (dgettext(__nsl_dom, "Invalid client verifier"));
867c478bd9Sstevel@tonic-gate 	case AUTH_REJECTEDVERF:
877c478bd9Sstevel@tonic-gate 		return (dgettext(__nsl_dom, "Server rejected verifier"));
887c478bd9Sstevel@tonic-gate 	case AUTH_TOOWEAK:
897c478bd9Sstevel@tonic-gate 		return (dgettext(__nsl_dom, "Client credential too weak"));
907c478bd9Sstevel@tonic-gate 	case AUTH_INVALIDRESP:
917c478bd9Sstevel@tonic-gate 		return (dgettext(__nsl_dom, "Invalid server verifier"));
927c478bd9Sstevel@tonic-gate 	case AUTH_FAILED:
937c478bd9Sstevel@tonic-gate 		return (dgettext(__nsl_dom, "Failed (unspecified error)"));
947c478bd9Sstevel@tonic-gate 
957c478bd9Sstevel@tonic-gate 	/* kerberos specific */
967c478bd9Sstevel@tonic-gate 	case AUTH_DECODE:
977c478bd9Sstevel@tonic-gate 		return (dgettext(__nsl_dom, "Could not decode authenticator"));
987c478bd9Sstevel@tonic-gate 	case AUTH_TIMEEXPIRE:
997c478bd9Sstevel@tonic-gate 		return (dgettext(__nsl_dom, "Time of credential expired"));
1007c478bd9Sstevel@tonic-gate 	case AUTH_TKT_FILE:
1017c478bd9Sstevel@tonic-gate 		return (dgettext(__nsl_dom,
1027c478bd9Sstevel@tonic-gate 			"Something wrong with kerberos ticket file"));
1037c478bd9Sstevel@tonic-gate 	case AUTH_NET_ADDR:
1047c478bd9Sstevel@tonic-gate 		return (dgettext(__nsl_dom,
1057c478bd9Sstevel@tonic-gate 		"Incorrect network address in kerberos ticket"));
1067c478bd9Sstevel@tonic-gate 	case AUTH_KERB_GENERIC:
1077c478bd9Sstevel@tonic-gate 		return (dgettext(__nsl_dom, "Kerberos generic error"));
1087c478bd9Sstevel@tonic-gate 	}
1097c478bd9Sstevel@tonic-gate 	return (dgettext(__nsl_dom, "Unknown authentication error"));
1107c478bd9Sstevel@tonic-gate }
1117c478bd9Sstevel@tonic-gate 
1127c478bd9Sstevel@tonic-gate /*
1137c478bd9Sstevel@tonic-gate  * Return string reply error info. For use after clnt_call()
1147c478bd9Sstevel@tonic-gate  */
1157c478bd9Sstevel@tonic-gate 
1167c478bd9Sstevel@tonic-gate #define	REMAINDER	(ERRBUFSZ - (str - strstart))
1177c478bd9Sstevel@tonic-gate 
1187c478bd9Sstevel@tonic-gate char *
clnt_sperror(const CLIENT * cl,const char * s)11961961e0fSrobinson clnt_sperror(const CLIENT *cl, const char *s)
1207c478bd9Sstevel@tonic-gate {
1217c478bd9Sstevel@tonic-gate 	struct rpc_err e;
1227c478bd9Sstevel@tonic-gate 	char *err;
1237c478bd9Sstevel@tonic-gate 	char *str = __buf();
1247c478bd9Sstevel@tonic-gate 	char *strstart = str;
1257c478bd9Sstevel@tonic-gate 
12661961e0fSrobinson 	if (str == NULL)
1277c478bd9Sstevel@tonic-gate 		return (NULL);
1287c478bd9Sstevel@tonic-gate 	CLNT_GETERR((CLIENT *) cl, &e);
1297c478bd9Sstevel@tonic-gate 
1307c478bd9Sstevel@tonic-gate 	(void) snprintf(str, ERRBUFSZ, "%s: ", s);
1317c478bd9Sstevel@tonic-gate 	str += strlcat(str, clnt_sperrno(e.re_status), ERRBUFSZ);
1327c478bd9Sstevel@tonic-gate 
1337c478bd9Sstevel@tonic-gate 	switch (e.re_status) {
1347c478bd9Sstevel@tonic-gate 	case RPC_SUCCESS:
1357c478bd9Sstevel@tonic-gate 	case RPC_CANTENCODEARGS:
1367c478bd9Sstevel@tonic-gate 	case RPC_CANTDECODERES:
1377c478bd9Sstevel@tonic-gate 	case RPC_TIMEDOUT:
1387c478bd9Sstevel@tonic-gate 	case RPC_PROGUNAVAIL:
1397c478bd9Sstevel@tonic-gate 	case RPC_PROCUNAVAIL:
1407c478bd9Sstevel@tonic-gate 	case RPC_CANTDECODEARGS:
1417c478bd9Sstevel@tonic-gate 	case RPC_SYSTEMERROR:
1427c478bd9Sstevel@tonic-gate 	case RPC_UNKNOWNHOST:
1437c478bd9Sstevel@tonic-gate 	case RPC_UNKNOWNPROTO:
1447c478bd9Sstevel@tonic-gate 	case RPC_UNKNOWNADDR:
1457c478bd9Sstevel@tonic-gate 	case RPC_NOBROADCAST:
1467c478bd9Sstevel@tonic-gate 	case RPC_RPCBFAILURE:
1477c478bd9Sstevel@tonic-gate 	case RPC_PROGNOTREGISTERED:
1487c478bd9Sstevel@tonic-gate 	case RPC_FAILED:
1497c478bd9Sstevel@tonic-gate 		break;
1507c478bd9Sstevel@tonic-gate 
1517c478bd9Sstevel@tonic-gate 	case RPC_N2AXLATEFAILURE:
1527c478bd9Sstevel@tonic-gate 		(void) snprintf(str, REMAINDER, "; %s", netdir_sperror());
1537c478bd9Sstevel@tonic-gate 		str += strlen(str);
1547c478bd9Sstevel@tonic-gate 		break;
1557c478bd9Sstevel@tonic-gate 
1567c478bd9Sstevel@tonic-gate 	case RPC_TLIERROR:
1577c478bd9Sstevel@tonic-gate 		(void) snprintf(str, REMAINDER, "; %s", t_errlist[e.re_terrno]);
1587c478bd9Sstevel@tonic-gate 		str += strlen(str);
1597c478bd9Sstevel@tonic-gate 		if (e.re_errno) {
1607c478bd9Sstevel@tonic-gate 			(void) snprintf(str, REMAINDER,
1617c478bd9Sstevel@tonic-gate 			    "; %s", strerror(e.re_errno));
1627c478bd9Sstevel@tonic-gate 			str += strlen(str);
1637c478bd9Sstevel@tonic-gate 		}
1647c478bd9Sstevel@tonic-gate 		break;
1657c478bd9Sstevel@tonic-gate 
1667c478bd9Sstevel@tonic-gate 	case RPC_CANTSTORE:
1677c478bd9Sstevel@tonic-gate 	case RPC_CANTSEND:
1687c478bd9Sstevel@tonic-gate 	case RPC_CANTRECV:
1697c478bd9Sstevel@tonic-gate 		if (e.re_errno) {
1707c478bd9Sstevel@tonic-gate 			(void) snprintf(str, REMAINDER, "; errno = %s",
1717c478bd9Sstevel@tonic-gate 					strerror(e.re_errno));
1727c478bd9Sstevel@tonic-gate 			str += strlen(str);
1737c478bd9Sstevel@tonic-gate 		}
1747c478bd9Sstevel@tonic-gate 		if (e.re_terrno) {
1757c478bd9Sstevel@tonic-gate 			(void) snprintf(str, REMAINDER,
1767c478bd9Sstevel@tonic-gate 				"; %s", t_errlist[e.re_terrno]);
1777c478bd9Sstevel@tonic-gate 			str += strlen(str);
1787c478bd9Sstevel@tonic-gate 		}
1797c478bd9Sstevel@tonic-gate 		break;
1807c478bd9Sstevel@tonic-gate 
1817c478bd9Sstevel@tonic-gate 	case RPC_VERSMISMATCH:
1827c478bd9Sstevel@tonic-gate 		(void) snprintf(str, REMAINDER,
1837c478bd9Sstevel@tonic-gate 				"; low version = %lu, high version = %lu",
1847c478bd9Sstevel@tonic-gate 				e.re_vers.low, e.re_vers.high);
1857c478bd9Sstevel@tonic-gate 		str += strlen(str);
1867c478bd9Sstevel@tonic-gate 		break;
1877c478bd9Sstevel@tonic-gate 
1887c478bd9Sstevel@tonic-gate 	case RPC_AUTHERROR:
1897c478bd9Sstevel@tonic-gate 		err = auth_errmsg(e.re_why);
1907c478bd9Sstevel@tonic-gate 		(void) snprintf(str, REMAINDER, "; why = ");
1917c478bd9Sstevel@tonic-gate 		str += strlen(str);
1927c478bd9Sstevel@tonic-gate 		if (err != NULL) {
1937c478bd9Sstevel@tonic-gate 			(void) snprintf(str, REMAINDER, "%s", err);
1947c478bd9Sstevel@tonic-gate 		} else {
1957c478bd9Sstevel@tonic-gate 			(void) snprintf(str, REMAINDER,
1967c478bd9Sstevel@tonic-gate 				"(unknown authentication error - %d)",
1977c478bd9Sstevel@tonic-gate 				(int)e.re_why);
1987c478bd9Sstevel@tonic-gate 		}
1997c478bd9Sstevel@tonic-gate 		str += strlen(str);
2007c478bd9Sstevel@tonic-gate 		break;
2017c478bd9Sstevel@tonic-gate 
2027c478bd9Sstevel@tonic-gate 	case RPC_PROGVERSMISMATCH:
2037c478bd9Sstevel@tonic-gate 		(void) snprintf(str, REMAINDER,
2047c478bd9Sstevel@tonic-gate 				"; low version = %lu, high version = %lu",
2057c478bd9Sstevel@tonic-gate 				e.re_vers.low, e.re_vers.high);
2067c478bd9Sstevel@tonic-gate 		str += strlen(str);
2077c478bd9Sstevel@tonic-gate 		break;
2087c478bd9Sstevel@tonic-gate 
2097c478bd9Sstevel@tonic-gate 	default:	/* unknown */
2107c478bd9Sstevel@tonic-gate 		(void) snprintf(str, REMAINDER, "; s1 = %lu, s2 = %lu",
2117c478bd9Sstevel@tonic-gate 				e.re_lb.s1, e.re_lb.s2);
2127c478bd9Sstevel@tonic-gate 		str += strlen(str);
2137c478bd9Sstevel@tonic-gate 		break;
2147c478bd9Sstevel@tonic-gate 	}
2157c478bd9Sstevel@tonic-gate 	return (strstart);
2167c478bd9Sstevel@tonic-gate }
2177c478bd9Sstevel@tonic-gate #undef	REMAINDER
2187c478bd9Sstevel@tonic-gate 
2197c478bd9Sstevel@tonic-gate void
clnt_perror(const CLIENT * cl,const char * s)22061961e0fSrobinson clnt_perror(const CLIENT *cl, const char *s)
2217c478bd9Sstevel@tonic-gate {
2227c478bd9Sstevel@tonic-gate 	(void) fprintf(stderr, "%s\n", clnt_sperror(cl, s));
2237c478bd9Sstevel@tonic-gate }
2247c478bd9Sstevel@tonic-gate 
2257c478bd9Sstevel@tonic-gate void
clnt_perrno(const enum clnt_stat num)22661961e0fSrobinson clnt_perrno(const enum clnt_stat num)
2277c478bd9Sstevel@tonic-gate {
2287c478bd9Sstevel@tonic-gate 	(void) fprintf(stderr, "%s\n", clnt_sperrno(num));
2297c478bd9Sstevel@tonic-gate }
2307c478bd9Sstevel@tonic-gate 
2317c478bd9Sstevel@tonic-gate /*
2327c478bd9Sstevel@tonic-gate  * Why a client handle could not be created
2337c478bd9Sstevel@tonic-gate  */
2347c478bd9Sstevel@tonic-gate char *
clnt_spcreateerror(const char * s)23561961e0fSrobinson clnt_spcreateerror(const char *s)
2367c478bd9Sstevel@tonic-gate {
2377c478bd9Sstevel@tonic-gate 	char *errstr;
2387c478bd9Sstevel@tonic-gate 	char *str = __buf();
2397c478bd9Sstevel@tonic-gate 
24061961e0fSrobinson 	if (str == NULL)
2417c478bd9Sstevel@tonic-gate 		return (NULL);
2427c478bd9Sstevel@tonic-gate 	(void) snprintf(str, ERRBUFSZ, "%s: ", s);
2437c478bd9Sstevel@tonic-gate 	(void) strlcat(str, clnt_sperrno(rpc_createerr.cf_stat), ERRBUFSZ);
2447c478bd9Sstevel@tonic-gate 
2457c478bd9Sstevel@tonic-gate 	switch (rpc_createerr.cf_stat) {
2467c478bd9Sstevel@tonic-gate 	case RPC_N2AXLATEFAILURE:
2477c478bd9Sstevel@tonic-gate 		(void) strlcat(str, " - ", ERRBUFSZ);
2487c478bd9Sstevel@tonic-gate 		(void) strlcat(str, netdir_sperror(), ERRBUFSZ);
2497c478bd9Sstevel@tonic-gate 		break;
2507c478bd9Sstevel@tonic-gate 
2517c478bd9Sstevel@tonic-gate 	case RPC_RPCBFAILURE:
2527c478bd9Sstevel@tonic-gate 		(void) strlcat(str, " - ", ERRBUFSZ);
2537c478bd9Sstevel@tonic-gate 		(void) strlcat(str,
2547c478bd9Sstevel@tonic-gate 			clnt_sperrno(rpc_createerr.cf_error.re_status),
2557c478bd9Sstevel@tonic-gate 			ERRBUFSZ);
2567c478bd9Sstevel@tonic-gate 		break;
2577c478bd9Sstevel@tonic-gate 
2587c478bd9Sstevel@tonic-gate 	case RPC_SYSTEMERROR:
2597c478bd9Sstevel@tonic-gate 		(void) strlcat(str, " - ", ERRBUFSZ);
2607c478bd9Sstevel@tonic-gate 		errstr = strerror(rpc_createerr.cf_error.re_errno);
2617c478bd9Sstevel@tonic-gate 		if (errstr != NULL)
2627c478bd9Sstevel@tonic-gate 			(void) strlcat(str, errstr, ERRBUFSZ);
2637c478bd9Sstevel@tonic-gate 		else
2647c478bd9Sstevel@tonic-gate 			(void) snprintf(&str[strlen(str)],
2657c478bd9Sstevel@tonic-gate 			    ERRBUFSZ - strlen(str), "Error %d",
2667c478bd9Sstevel@tonic-gate 			    rpc_createerr.cf_error.re_errno);
2677c478bd9Sstevel@tonic-gate 		break;
2687c478bd9Sstevel@tonic-gate 
2697c478bd9Sstevel@tonic-gate 	case RPC_TLIERROR:
2707c478bd9Sstevel@tonic-gate 		(void) strlcat(str, " - ", ERRBUFSZ);
2717c478bd9Sstevel@tonic-gate 		if ((rpc_createerr.cf_error.re_terrno > 0) &&
2727c478bd9Sstevel@tonic-gate 			(rpc_createerr.cf_error.re_terrno < t_nerr)) {
2737c478bd9Sstevel@tonic-gate 			(void) strlcat(str,
2747c478bd9Sstevel@tonic-gate 				t_errlist[rpc_createerr.cf_error.re_terrno],
2757c478bd9Sstevel@tonic-gate 				ERRBUFSZ);
2767c478bd9Sstevel@tonic-gate 			if (rpc_createerr.cf_error.re_terrno == TSYSERR) {
2777c478bd9Sstevel@tonic-gate 				char *err;
2787c478bd9Sstevel@tonic-gate 				err = strerror(rpc_createerr.cf_error.re_errno);
2797c478bd9Sstevel@tonic-gate 				if (err) {
28061961e0fSrobinson 					(void) strlcat(str, " (", ERRBUFSZ);
28161961e0fSrobinson 					(void) strlcat(str, err, ERRBUFSZ);
28261961e0fSrobinson 					(void) strlcat(str, ")", ERRBUFSZ);
2837c478bd9Sstevel@tonic-gate 				}
2847c478bd9Sstevel@tonic-gate 			}
2857c478bd9Sstevel@tonic-gate 		} else {
2867c478bd9Sstevel@tonic-gate 			(void) snprintf(&str[strlen(str)],
2877c478bd9Sstevel@tonic-gate 			    ERRBUFSZ - strlen(str),
2887c478bd9Sstevel@tonic-gate 			    dgettext(__nsl_dom,  "TLI Error %d"),
2897c478bd9Sstevel@tonic-gate 			    rpc_createerr.cf_error.re_terrno);
2907c478bd9Sstevel@tonic-gate 		}
2917c478bd9Sstevel@tonic-gate 		errstr = strerror(rpc_createerr.cf_error.re_errno);
2927c478bd9Sstevel@tonic-gate 		if (errstr != NULL)
2937c478bd9Sstevel@tonic-gate 			(void) strlcat(str, errstr, ERRBUFSZ);
2947c478bd9Sstevel@tonic-gate 		else
2957c478bd9Sstevel@tonic-gate 			(void) snprintf(&str[strlen(str)],
2967c478bd9Sstevel@tonic-gate 			    ERRBUFSZ - strlen(str), "Error %d",
2977c478bd9Sstevel@tonic-gate 			    rpc_createerr.cf_error.re_errno);
2987c478bd9Sstevel@tonic-gate 		break;
2997c478bd9Sstevel@tonic-gate 
3007c478bd9Sstevel@tonic-gate 	case RPC_AUTHERROR:
3017c478bd9Sstevel@tonic-gate 		(void) strlcat(str, " - ", ERRBUFSZ);
3027c478bd9Sstevel@tonic-gate 		(void) strlcat(str,
3037c478bd9Sstevel@tonic-gate 			auth_errmsg(rpc_createerr.cf_error.re_why), ERRBUFSZ);
3047c478bd9Sstevel@tonic-gate 		break;
3057c478bd9Sstevel@tonic-gate 	}
3067c478bd9Sstevel@tonic-gate 	return (str);
3077c478bd9Sstevel@tonic-gate }
3087c478bd9Sstevel@tonic-gate 
3097c478bd9Sstevel@tonic-gate void
clnt_pcreateerror(const char * s)31061961e0fSrobinson clnt_pcreateerror(const char *s)
3117c478bd9Sstevel@tonic-gate {
3127c478bd9Sstevel@tonic-gate 	(void) fprintf(stderr, "%s\n", clnt_spcreateerror(s));
3137c478bd9Sstevel@tonic-gate }
3147c478bd9Sstevel@tonic-gate 
3157c478bd9Sstevel@tonic-gate /*
3167c478bd9Sstevel@tonic-gate  * This interface for use by rpc_call() and rpc_broadcast()
3177c478bd9Sstevel@tonic-gate  */
3187c478bd9Sstevel@tonic-gate const char *
clnt_sperrno(const enum clnt_stat stat)31961961e0fSrobinson clnt_sperrno(const enum clnt_stat stat)
3207c478bd9Sstevel@tonic-gate {
3217c478bd9Sstevel@tonic-gate 	switch (stat) {
3227c478bd9Sstevel@tonic-gate 	case RPC_SUCCESS:
3237c478bd9Sstevel@tonic-gate 		return (dgettext(__nsl_dom, "RPC: Success"));
3247c478bd9Sstevel@tonic-gate 	case RPC_CANTENCODEARGS:
3257c478bd9Sstevel@tonic-gate 		return (dgettext(__nsl_dom, "RPC: Can't encode arguments"));
3267c478bd9Sstevel@tonic-gate 	case RPC_CANTDECODERES:
3277c478bd9Sstevel@tonic-gate 		return (dgettext(__nsl_dom, "RPC: Can't decode result"));
3287c478bd9Sstevel@tonic-gate 	case RPC_CANTSTORE:
3297c478bd9Sstevel@tonic-gate 		return (dgettext(__nsl_dom, "RPC: Can't store request"));
3307c478bd9Sstevel@tonic-gate 	case RPC_CANTSEND:
3317c478bd9Sstevel@tonic-gate 		return (dgettext(__nsl_dom, "RPC: Unable to send"));
3327c478bd9Sstevel@tonic-gate 	case RPC_CANTRECV:
3337c478bd9Sstevel@tonic-gate 		return (dgettext(__nsl_dom, "RPC: Unable to receive"));
3347c478bd9Sstevel@tonic-gate 	case RPC_TIMEDOUT:
3357c478bd9Sstevel@tonic-gate 		return (dgettext(__nsl_dom, "RPC: Timed out"));
3367c478bd9Sstevel@tonic-gate 	case RPC_VERSMISMATCH:
3377c478bd9Sstevel@tonic-gate 		return (dgettext(__nsl_dom,
3387c478bd9Sstevel@tonic-gate 			"RPC: Incompatible versions of RPC"));
3397c478bd9Sstevel@tonic-gate 	case RPC_AUTHERROR:
3407c478bd9Sstevel@tonic-gate 		return (dgettext(__nsl_dom, "RPC: Authentication error"));
3417c478bd9Sstevel@tonic-gate 	case RPC_PROGUNAVAIL:
3427c478bd9Sstevel@tonic-gate 		return (dgettext(__nsl_dom, "RPC: Program unavailable"));
3437c478bd9Sstevel@tonic-gate 	case RPC_PROGVERSMISMATCH:
3447c478bd9Sstevel@tonic-gate 		return (dgettext(__nsl_dom, "RPC: Program/version mismatch"));
3457c478bd9Sstevel@tonic-gate 	case RPC_PROCUNAVAIL:
3467c478bd9Sstevel@tonic-gate 		return (dgettext(__nsl_dom, "RPC: Procedure unavailable"));
3477c478bd9Sstevel@tonic-gate 	case RPC_CANTDECODEARGS:
3487c478bd9Sstevel@tonic-gate 		return (dgettext(__nsl_dom,
3497c478bd9Sstevel@tonic-gate 			"RPC: Server can't decode arguments"));
3507c478bd9Sstevel@tonic-gate 
3517c478bd9Sstevel@tonic-gate 	case RPC_SYSTEMERROR:
3527c478bd9Sstevel@tonic-gate 		return (dgettext(__nsl_dom, "RPC: Remote system error"));
3537c478bd9Sstevel@tonic-gate 	case RPC_UNKNOWNHOST:
3547c478bd9Sstevel@tonic-gate 		return (dgettext(__nsl_dom, "RPC: Unknown host"));
3557c478bd9Sstevel@tonic-gate 	case RPC_UNKNOWNPROTO:
3567c478bd9Sstevel@tonic-gate 		return (dgettext(__nsl_dom, "RPC: Unknown protocol"));
3577c478bd9Sstevel@tonic-gate 	case RPC_RPCBFAILURE:
3587c478bd9Sstevel@tonic-gate 		return (dgettext(__nsl_dom, "RPC: Rpcbind failure"));
3597c478bd9Sstevel@tonic-gate 	case RPC_N2AXLATEFAILURE:
3607c478bd9Sstevel@tonic-gate 		return (dgettext(__nsl_dom,
3617c478bd9Sstevel@tonic-gate 			"RPC: Name to address translation failed"));
3627c478bd9Sstevel@tonic-gate 	case RPC_NOBROADCAST:
3637c478bd9Sstevel@tonic-gate 		return (dgettext(__nsl_dom, "RPC: Broadcast not supported"));
3647c478bd9Sstevel@tonic-gate 	case RPC_PROGNOTREGISTERED:
3657c478bd9Sstevel@tonic-gate 		return (dgettext(__nsl_dom, "RPC: Program not registered"));
3667c478bd9Sstevel@tonic-gate 	case RPC_UNKNOWNADDR:
3677c478bd9Sstevel@tonic-gate 		return (dgettext(__nsl_dom,
3687c478bd9Sstevel@tonic-gate 			"RPC: Remote server address unknown"));
3697c478bd9Sstevel@tonic-gate 	case RPC_TLIERROR:
3707c478bd9Sstevel@tonic-gate 		return (dgettext(__nsl_dom, "RPC: Miscellaneous tli error"));
3717c478bd9Sstevel@tonic-gate 	case RPC_FAILED:
3727c478bd9Sstevel@tonic-gate 		return (dgettext(__nsl_dom, "RPC: Failed (unspecified error)"));
3737c478bd9Sstevel@tonic-gate 	case RPC_INPROGRESS:
3747c478bd9Sstevel@tonic-gate 		return (dgettext(__nsl_dom, "RPC: RAC call in progress"));
3757c478bd9Sstevel@tonic-gate 	case RPC_STALERACHANDLE:
3767c478bd9Sstevel@tonic-gate 		return (dgettext(__nsl_dom, "RPC: Stale RAC handle"));
3777c478bd9Sstevel@tonic-gate 	case RPC_CANTCONNECT:
3787c478bd9Sstevel@tonic-gate 		return (dgettext(__nsl_dom, "RPC: Couldn't make connection"));
3797c478bd9Sstevel@tonic-gate 	case RPC_XPRTFAILED:
3807c478bd9Sstevel@tonic-gate 		return (dgettext(__nsl_dom,
3817c478bd9Sstevel@tonic-gate 			"RPC: Received disconnect from remote"));
3827c478bd9Sstevel@tonic-gate 	case RPC_CANTCREATESTREAM:
3837c478bd9Sstevel@tonic-gate 		return (dgettext(__nsl_dom, "RPC: Can't push RPC module"));
3847c478bd9Sstevel@tonic-gate 	}
3857c478bd9Sstevel@tonic-gate 	return (dgettext(__nsl_dom, "RPC: (unknown error code)"));
3867c478bd9Sstevel@tonic-gate }
387