xref: /freebsd/crypto/krb5/src/lib/rpc/clnt_perror.c (revision 7f2fe78b9dd5f51c821d771b63d2e096f6fd49e9)
1*7f2fe78bSCy Schubert /* @(#)clnt_perror.c	2.1 88/07/29 4.0 RPCSRC */
2*7f2fe78bSCy Schubert /*
3*7f2fe78bSCy Schubert  * Copyright (c) 2010, Oracle America, Inc.
4*7f2fe78bSCy Schubert  *
5*7f2fe78bSCy Schubert  * All rights reserved.
6*7f2fe78bSCy Schubert  *
7*7f2fe78bSCy Schubert  * Redistribution and use in source and binary forms, with or without
8*7f2fe78bSCy Schubert  * modification, are permitted provided that the following conditions are met:
9*7f2fe78bSCy Schubert  *
10*7f2fe78bSCy Schubert  *     * Redistributions of source code must retain the above copyright
11*7f2fe78bSCy Schubert  *       notice, this list of conditions and the following disclaimer.
12*7f2fe78bSCy Schubert  *
13*7f2fe78bSCy Schubert  *     * Redistributions in binary form must reproduce the above copyright
14*7f2fe78bSCy Schubert  *       notice, this list of conditions and the following disclaimer in
15*7f2fe78bSCy Schubert  *       the documentation and/or other materials provided with the
16*7f2fe78bSCy Schubert  *       distribution.
17*7f2fe78bSCy Schubert  *
18*7f2fe78bSCy Schubert  *     * Neither the name of the "Oracle America, Inc." nor the names of
19*7f2fe78bSCy Schubert  *       its contributors may be used to endorse or promote products
20*7f2fe78bSCy Schubert  *       derived from this software without specific prior written permission.
21*7f2fe78bSCy Schubert  *
22*7f2fe78bSCy Schubert  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
23*7f2fe78bSCy Schubert  * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
24*7f2fe78bSCy Schubert  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
25*7f2fe78bSCy Schubert  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26*7f2fe78bSCy Schubert  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27*7f2fe78bSCy Schubert  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
28*7f2fe78bSCy Schubert  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
29*7f2fe78bSCy Schubert  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
30*7f2fe78bSCy Schubert  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31*7f2fe78bSCy Schubert  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32*7f2fe78bSCy Schubert  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33*7f2fe78bSCy Schubert  */
34*7f2fe78bSCy Schubert #if !defined(lint) && defined(SCCSIDS)
35*7f2fe78bSCy Schubert static char sccsid[] = "@(#)clnt_perror.c 1.15 87/10/07 Copyr 1984 Sun Micro";
36*7f2fe78bSCy Schubert #endif
37*7f2fe78bSCy Schubert 
38*7f2fe78bSCy Schubert /*
39*7f2fe78bSCy Schubert  * clnt_perror.c
40*7f2fe78bSCy Schubert  */
41*7f2fe78bSCy Schubert #include "autoconf.h"
42*7f2fe78bSCy Schubert #include <stdio.h>
43*7f2fe78bSCy Schubert #include <string.h>
44*7f2fe78bSCy Schubert #include <errno.h>
45*7f2fe78bSCy Schubert 
46*7f2fe78bSCy Schubert #include <gssrpc/types.h>
47*7f2fe78bSCy Schubert #include <gssrpc/auth.h>
48*7f2fe78bSCy Schubert #include <gssrpc/clnt.h>
49*7f2fe78bSCy Schubert 
50*7f2fe78bSCy Schubert #ifndef HAVE_STRERROR
51*7f2fe78bSCy Schubert #ifdef NEED_SYS_ERRLIST
52*7f2fe78bSCy Schubert extern char *sys_errlist[];
53*7f2fe78bSCy Schubert #endif
54*7f2fe78bSCy Schubert extern int sys_nerr;
55*7f2fe78bSCy Schubert #undef strerror
56*7f2fe78bSCy Schubert #define strerror(N) (((N) > 0 && (N) < sys_nerr) ? sys_errlist[N] : (char *)0)
57*7f2fe78bSCy Schubert #endif /* HAVE_STRERROR */
58*7f2fe78bSCy Schubert static char *auth_errmsg(enum auth_stat);
59*7f2fe78bSCy Schubert 
60*7f2fe78bSCy Schubert 
61*7f2fe78bSCy Schubert 
62*7f2fe78bSCy Schubert static char *buf;
63*7f2fe78bSCy Schubert 
64*7f2fe78bSCy Schubert static char *
get_buf(void)65*7f2fe78bSCy Schubert get_buf(void)
66*7f2fe78bSCy Schubert {
67*7f2fe78bSCy Schubert 	if (buf == NULL)
68*7f2fe78bSCy Schubert 		buf = (char *)malloc(BUFSIZ);
69*7f2fe78bSCy Schubert 	return (buf);
70*7f2fe78bSCy Schubert }
71*7f2fe78bSCy Schubert 
72*7f2fe78bSCy Schubert /*
73*7f2fe78bSCy Schubert  * Print reply error info
74*7f2fe78bSCy Schubert  */
75*7f2fe78bSCy Schubert char *
clnt_sperror(CLIENT * rpch,char * s)76*7f2fe78bSCy Schubert clnt_sperror(CLIENT *rpch, char *s)
77*7f2fe78bSCy Schubert {
78*7f2fe78bSCy Schubert 	struct rpc_err e;
79*7f2fe78bSCy Schubert 	void clnt_perrno();
80*7f2fe78bSCy Schubert 	char *err;
81*7f2fe78bSCy Schubert 	char *bufstart = get_buf();
82*7f2fe78bSCy Schubert 	char *str = bufstart;
83*7f2fe78bSCy Schubert 	char *strstart = str;
84*7f2fe78bSCy Schubert 	char *strend;
85*7f2fe78bSCy Schubert 
86*7f2fe78bSCy Schubert 	if (str == 0)
87*7f2fe78bSCy Schubert 		return (0);
88*7f2fe78bSCy Schubert 	strend = str + BUFSIZ;
89*7f2fe78bSCy Schubert 	CLNT_GETERR(rpch, &e);
90*7f2fe78bSCy Schubert 
91*7f2fe78bSCy Schubert 	strncpy (str, s, BUFSIZ - 1);
92*7f2fe78bSCy Schubert 	str[BUFSIZ - 1] = 0;
93*7f2fe78bSCy Schubert 	strncat (str, ": ", BUFSIZ - 1 - strlen (bufstart));
94*7f2fe78bSCy Schubert 	str += strlen(str);
95*7f2fe78bSCy Schubert 	strncat (str, clnt_sperrno(e.re_status), BUFSIZ - 1 - strlen (bufstart));
96*7f2fe78bSCy Schubert 	strstart[BUFSIZ - 1] = '\0';
97*7f2fe78bSCy Schubert 	str += strlen(str);
98*7f2fe78bSCy Schubert 
99*7f2fe78bSCy Schubert 	switch (e.re_status) {
100*7f2fe78bSCy Schubert 	case RPC_SUCCESS:
101*7f2fe78bSCy Schubert 	case RPC_CANTENCODEARGS:
102*7f2fe78bSCy Schubert 	case RPC_CANTDECODERES:
103*7f2fe78bSCy Schubert 	case RPC_TIMEDOUT:
104*7f2fe78bSCy Schubert 	case RPC_PROGUNAVAIL:
105*7f2fe78bSCy Schubert 	case RPC_PROCUNAVAIL:
106*7f2fe78bSCy Schubert 	case RPC_CANTDECODEARGS:
107*7f2fe78bSCy Schubert 	case RPC_SYSTEMERROR:
108*7f2fe78bSCy Schubert 	case RPC_UNKNOWNHOST:
109*7f2fe78bSCy Schubert 	case RPC_UNKNOWNPROTO:
110*7f2fe78bSCy Schubert 	case RPC_PMAPFAILURE:
111*7f2fe78bSCy Schubert 	case RPC_PROGNOTREGISTERED:
112*7f2fe78bSCy Schubert 	case RPC_FAILED:
113*7f2fe78bSCy Schubert 		break;
114*7f2fe78bSCy Schubert 
115*7f2fe78bSCy Schubert 	case RPC_CANTSEND:
116*7f2fe78bSCy Schubert 	case RPC_CANTRECV:
117*7f2fe78bSCy Schubert 		/* 10 for the string */
118*7f2fe78bSCy Schubert 		if (str - bufstart + 10 + strlen(strerror(e.re_errno)) < BUFSIZ)
119*7f2fe78bSCy Schubert 		    (void) snprintf(str, strend-str, "; errno = %s",
120*7f2fe78bSCy Schubert 				    strerror(e.re_errno));
121*7f2fe78bSCy Schubert 		str += strlen(str);
122*7f2fe78bSCy Schubert 		break;
123*7f2fe78bSCy Schubert 
124*7f2fe78bSCy Schubert 	case RPC_VERSMISMATCH:
125*7f2fe78bSCy Schubert 		/* 33 for the string, 22 for the numbers */
126*7f2fe78bSCy Schubert 		if(str - bufstart + 33 + 22 < BUFSIZ)
127*7f2fe78bSCy Schubert 		    (void) snprintf(str, strend-str,
128*7f2fe78bSCy Schubert 				    "; low version = %lu, high version = %lu",
129*7f2fe78bSCy Schubert 				    (u_long) e.re_vers.low,
130*7f2fe78bSCy Schubert 				    (u_long) e.re_vers.high);
131*7f2fe78bSCy Schubert 		str += strlen(str);
132*7f2fe78bSCy Schubert 		break;
133*7f2fe78bSCy Schubert 
134*7f2fe78bSCy Schubert 	case RPC_AUTHERROR:
135*7f2fe78bSCy Schubert 		err = auth_errmsg(e.re_why);
136*7f2fe78bSCy Schubert 		/* 8 for the string */
137*7f2fe78bSCy Schubert 		if(str - bufstart + 8 < BUFSIZ)
138*7f2fe78bSCy Schubert 		    (void) snprintf(str, strend-str, "; why = ");
139*7f2fe78bSCy Schubert 		str += strlen(str);
140*7f2fe78bSCy Schubert 		if (err != NULL) {
141*7f2fe78bSCy Schubert 			if(str - bufstart + strlen(err) < BUFSIZ)
142*7f2fe78bSCy Schubert 			    (void) snprintf(str, strend-str, "%s",err);
143*7f2fe78bSCy Schubert 		} else {
144*7f2fe78bSCy Schubert 		    /* 33 for the string, 11 for the number */
145*7f2fe78bSCy Schubert 		    if(str - bufstart + 33 + 11 < BUFSIZ)
146*7f2fe78bSCy Schubert 			(void) snprintf(str, strend-str,
147*7f2fe78bSCy Schubert 					"(unknown authentication error - %d)",
148*7f2fe78bSCy Schubert 					(int) e.re_why);
149*7f2fe78bSCy Schubert 		}
150*7f2fe78bSCy Schubert 		str += strlen(str);
151*7f2fe78bSCy Schubert 		break;
152*7f2fe78bSCy Schubert 
153*7f2fe78bSCy Schubert 	case RPC_PROGVERSMISMATCH:
154*7f2fe78bSCy Schubert 		/* 33 for the string, 22 for the numbers */
155*7f2fe78bSCy Schubert 		if(str - bufstart + 33 + 22 < BUFSIZ)
156*7f2fe78bSCy Schubert 		    (void) snprintf(str, strend-str,
157*7f2fe78bSCy Schubert 				    "; low version = %lu, high version = %lu",
158*7f2fe78bSCy Schubert 				    (u_long) e.re_vers.low,
159*7f2fe78bSCy Schubert 				    (u_long) e.re_vers.high);
160*7f2fe78bSCy Schubert 		str += strlen(str);
161*7f2fe78bSCy Schubert 		break;
162*7f2fe78bSCy Schubert 
163*7f2fe78bSCy Schubert 	default:	/* unknown */
164*7f2fe78bSCy Schubert 		/* 14 for the string, 22 for the numbers */
165*7f2fe78bSCy Schubert 		if(str - bufstart + 14 + 22 < BUFSIZ)
166*7f2fe78bSCy Schubert 		    (void) snprintf(str, strend-str,
167*7f2fe78bSCy Schubert 				    "; s1 = %lu, s2 = %lu",
168*7f2fe78bSCy Schubert 				    (u_long) e.re_lb.s1,
169*7f2fe78bSCy Schubert 				    (u_long) e.re_lb.s2);
170*7f2fe78bSCy Schubert 		str += strlen(str);
171*7f2fe78bSCy Schubert 		break;
172*7f2fe78bSCy Schubert 	}
173*7f2fe78bSCy Schubert 	if (str - bufstart + 1 < BUFSIZ)
174*7f2fe78bSCy Schubert 	    (void) snprintf(str, strend-str, "\n");
175*7f2fe78bSCy Schubert 	return(strstart) ;
176*7f2fe78bSCy Schubert }
177*7f2fe78bSCy Schubert 
178*7f2fe78bSCy Schubert void
clnt_perror(CLIENT * rpch,char * s)179*7f2fe78bSCy Schubert clnt_perror(CLIENT *rpch, char *s)
180*7f2fe78bSCy Schubert {
181*7f2fe78bSCy Schubert 	(void) fprintf(stderr,"%s",clnt_sperror(rpch,s));
182*7f2fe78bSCy Schubert }
183*7f2fe78bSCy Schubert 
184*7f2fe78bSCy Schubert 
185*7f2fe78bSCy Schubert struct rpc_errtab {
186*7f2fe78bSCy Schubert 	enum clnt_stat status;
187*7f2fe78bSCy Schubert 	char *message;
188*7f2fe78bSCy Schubert };
189*7f2fe78bSCy Schubert 
190*7f2fe78bSCy Schubert static struct rpc_errtab  rpc_errlist[] = {
191*7f2fe78bSCy Schubert 	{ RPC_SUCCESS,
192*7f2fe78bSCy Schubert 		"RPC: Success" },
193*7f2fe78bSCy Schubert 	{ RPC_CANTENCODEARGS,
194*7f2fe78bSCy Schubert 		"RPC: Can't encode arguments" },
195*7f2fe78bSCy Schubert 	{ RPC_CANTDECODERES,
196*7f2fe78bSCy Schubert 		"RPC: Can't decode result" },
197*7f2fe78bSCy Schubert 	{ RPC_CANTSEND,
198*7f2fe78bSCy Schubert 		"RPC: Unable to send" },
199*7f2fe78bSCy Schubert 	{ RPC_CANTRECV,
200*7f2fe78bSCy Schubert 		"RPC: Unable to receive" },
201*7f2fe78bSCy Schubert 	{ RPC_TIMEDOUT,
202*7f2fe78bSCy Schubert 		"RPC: Timed out" },
203*7f2fe78bSCy Schubert 	{ RPC_VERSMISMATCH,
204*7f2fe78bSCy Schubert 		"RPC: Incompatible versions of RPC" },
205*7f2fe78bSCy Schubert 	{ RPC_AUTHERROR,
206*7f2fe78bSCy Schubert 		"RPC: Authentication error" },
207*7f2fe78bSCy Schubert 	{ RPC_PROGUNAVAIL,
208*7f2fe78bSCy Schubert 		"RPC: Program unavailable" },
209*7f2fe78bSCy Schubert 	{ RPC_PROGVERSMISMATCH,
210*7f2fe78bSCy Schubert 		"RPC: Program/version mismatch" },
211*7f2fe78bSCy Schubert 	{ RPC_PROCUNAVAIL,
212*7f2fe78bSCy Schubert 		"RPC: Procedure unavailable" },
213*7f2fe78bSCy Schubert 	{ RPC_CANTDECODEARGS,
214*7f2fe78bSCy Schubert 		"RPC: Server can't decode arguments" },
215*7f2fe78bSCy Schubert 	{ RPC_SYSTEMERROR,
216*7f2fe78bSCy Schubert 		"RPC: Remote system error" },
217*7f2fe78bSCy Schubert 	{ RPC_UNKNOWNHOST,
218*7f2fe78bSCy Schubert 		"RPC: Unknown host" },
219*7f2fe78bSCy Schubert 	{ RPC_UNKNOWNPROTO,
220*7f2fe78bSCy Schubert 		"RPC: Unknown protocol" },
221*7f2fe78bSCy Schubert 	{ RPC_PMAPFAILURE,
222*7f2fe78bSCy Schubert 		"RPC: Port mapper failure" },
223*7f2fe78bSCy Schubert 	{ RPC_PROGNOTREGISTERED,
224*7f2fe78bSCy Schubert 		"RPC: Program not registered"},
225*7f2fe78bSCy Schubert 	{ RPC_FAILED,
226*7f2fe78bSCy Schubert 		"RPC: Failed (unspecified error)"}
227*7f2fe78bSCy Schubert };
228*7f2fe78bSCy Schubert 
229*7f2fe78bSCy Schubert 
230*7f2fe78bSCy Schubert /*
231*7f2fe78bSCy Schubert  * This interface for use by clntrpc
232*7f2fe78bSCy Schubert  */
233*7f2fe78bSCy Schubert char *
clnt_sperrno(enum clnt_stat stat)234*7f2fe78bSCy Schubert clnt_sperrno(enum clnt_stat stat)
235*7f2fe78bSCy Schubert {
236*7f2fe78bSCy Schubert 	unsigned int i;
237*7f2fe78bSCy Schubert 
238*7f2fe78bSCy Schubert 	for (i = 0; i < sizeof(rpc_errlist)/sizeof(struct rpc_errtab); i++) {
239*7f2fe78bSCy Schubert 		if (rpc_errlist[i].status == stat) {
240*7f2fe78bSCy Schubert 			return (rpc_errlist[i].message);
241*7f2fe78bSCy Schubert 		}
242*7f2fe78bSCy Schubert 	}
243*7f2fe78bSCy Schubert 	return ("RPC: (unknown error code)");
244*7f2fe78bSCy Schubert }
245*7f2fe78bSCy Schubert 
246*7f2fe78bSCy Schubert void
clnt_perrno(enum clnt_stat num)247*7f2fe78bSCy Schubert clnt_perrno(enum clnt_stat num)
248*7f2fe78bSCy Schubert {
249*7f2fe78bSCy Schubert 	(void) fprintf(stderr,"%s",clnt_sperrno(num));
250*7f2fe78bSCy Schubert }
251*7f2fe78bSCy Schubert 
252*7f2fe78bSCy Schubert 
253*7f2fe78bSCy Schubert char *
clnt_spcreateerror(char * s)254*7f2fe78bSCy Schubert clnt_spcreateerror(char *s)
255*7f2fe78bSCy Schubert {
256*7f2fe78bSCy Schubert 	char *str = get_buf();
257*7f2fe78bSCy Schubert 	char *strend;
258*7f2fe78bSCy Schubert 
259*7f2fe78bSCy Schubert 	if (str == 0)
260*7f2fe78bSCy Schubert 		return(0);
261*7f2fe78bSCy Schubert 	strend = str+BUFSIZ;
262*7f2fe78bSCy Schubert 	(void) snprintf(str, strend-str, "%s: ", s);
263*7f2fe78bSCy Schubert 	str[BUFSIZ - 1] = '\0';
264*7f2fe78bSCy Schubert 	(void) strncat(str, clnt_sperrno(rpc_createerr.cf_stat), BUFSIZ - 1);
265*7f2fe78bSCy Schubert 	switch (rpc_createerr.cf_stat) {
266*7f2fe78bSCy Schubert 	case RPC_PMAPFAILURE:
267*7f2fe78bSCy Schubert 		(void) strncat(str, " - ", BUFSIZ - 1 - strlen(str));
268*7f2fe78bSCy Schubert 		(void) strncat(str,
269*7f2fe78bSCy Schubert 		    clnt_sperrno(rpc_createerr.cf_error.re_status),
270*7f2fe78bSCy Schubert 		    BUFSIZ - 1 - strlen(str));
271*7f2fe78bSCy Schubert 		break;
272*7f2fe78bSCy Schubert 
273*7f2fe78bSCy Schubert 	case RPC_SYSTEMERROR:
274*7f2fe78bSCy Schubert 		(void) strncat(str, " - ", BUFSIZ - 1 - strlen(str));
275*7f2fe78bSCy Schubert 		{
276*7f2fe78bSCy Schubert 		    const char *m = strerror(rpc_createerr.cf_error.re_errno);
277*7f2fe78bSCy Schubert 		    if (m)
278*7f2fe78bSCy Schubert 			(void) strncat(str, m, BUFSIZ - 1 - strlen(str));
279*7f2fe78bSCy Schubert 		    else
280*7f2fe78bSCy Schubert 			(void) snprintf(&str[strlen(str)], BUFSIZ - strlen(str),
281*7f2fe78bSCy Schubert 					"Error %d",
282*7f2fe78bSCy Schubert 					rpc_createerr.cf_error.re_errno);
283*7f2fe78bSCy Schubert 		}
284*7f2fe78bSCy Schubert 		break;
285*7f2fe78bSCy Schubert 
286*7f2fe78bSCy Schubert 	case RPC_CANTSEND:
287*7f2fe78bSCy Schubert 	case RPC_CANTDECODERES:
288*7f2fe78bSCy Schubert 	case RPC_CANTENCODEARGS:
289*7f2fe78bSCy Schubert 	case RPC_SUCCESS:
290*7f2fe78bSCy Schubert 	case RPC_UNKNOWNPROTO:
291*7f2fe78bSCy Schubert 	case RPC_PROGNOTREGISTERED:
292*7f2fe78bSCy Schubert 	case RPC_FAILED:
293*7f2fe78bSCy Schubert 	case RPC_UNKNOWNHOST:
294*7f2fe78bSCy Schubert 	case RPC_CANTDECODEARGS:
295*7f2fe78bSCy Schubert 	case RPC_PROCUNAVAIL:
296*7f2fe78bSCy Schubert 	case RPC_PROGVERSMISMATCH:
297*7f2fe78bSCy Schubert 	case RPC_PROGUNAVAIL:
298*7f2fe78bSCy Schubert 	case RPC_AUTHERROR:
299*7f2fe78bSCy Schubert 	case RPC_VERSMISMATCH:
300*7f2fe78bSCy Schubert 	case RPC_TIMEDOUT:
301*7f2fe78bSCy Schubert 	case RPC_CANTRECV:
302*7f2fe78bSCy Schubert 	default:
303*7f2fe78bSCy Schubert 	    break;
304*7f2fe78bSCy Schubert 	}
305*7f2fe78bSCy Schubert 	(void) strncat(str, "\n", BUFSIZ - 1 - strlen(str));
306*7f2fe78bSCy Schubert 	return (str);
307*7f2fe78bSCy Schubert }
308*7f2fe78bSCy Schubert 
309*7f2fe78bSCy Schubert void
clnt_pcreateerror(char * s)310*7f2fe78bSCy Schubert clnt_pcreateerror(char *s)
311*7f2fe78bSCy Schubert {
312*7f2fe78bSCy Schubert 	(void) fprintf(stderr,"%s",clnt_spcreateerror(s));
313*7f2fe78bSCy Schubert }
314*7f2fe78bSCy Schubert 
315*7f2fe78bSCy Schubert struct auth_errtab {
316*7f2fe78bSCy Schubert 	enum auth_stat status;
317*7f2fe78bSCy Schubert 	char *message;
318*7f2fe78bSCy Schubert };
319*7f2fe78bSCy Schubert 
320*7f2fe78bSCy Schubert static struct auth_errtab auth_errlist[] = {
321*7f2fe78bSCy Schubert 	{ AUTH_OK,
322*7f2fe78bSCy Schubert 		"Authentication OK" },
323*7f2fe78bSCy Schubert 	{ AUTH_BADCRED,
324*7f2fe78bSCy Schubert 		"Invalid client credential" },
325*7f2fe78bSCy Schubert 	{ AUTH_REJECTEDCRED,
326*7f2fe78bSCy Schubert 		"Server rejected credential" },
327*7f2fe78bSCy Schubert 	{ AUTH_BADVERF,
328*7f2fe78bSCy Schubert 		"Invalid client verifier" },
329*7f2fe78bSCy Schubert 	{ AUTH_REJECTEDVERF,
330*7f2fe78bSCy Schubert 		"Server rejected verifier" },
331*7f2fe78bSCy Schubert 	{ AUTH_TOOWEAK,
332*7f2fe78bSCy Schubert 		"Client credential too weak" },
333*7f2fe78bSCy Schubert 	{ AUTH_INVALIDRESP,
334*7f2fe78bSCy Schubert 		"Invalid server verifier" },
335*7f2fe78bSCy Schubert 	{ AUTH_FAILED,
336*7f2fe78bSCy Schubert 		"Failed (unspecified error)" },
337*7f2fe78bSCy Schubert };
338*7f2fe78bSCy Schubert 
339*7f2fe78bSCy Schubert static char *
auth_errmsg(enum auth_stat stat)340*7f2fe78bSCy Schubert auth_errmsg(enum auth_stat stat)
341*7f2fe78bSCy Schubert {
342*7f2fe78bSCy Schubert 	unsigned int i;
343*7f2fe78bSCy Schubert 
344*7f2fe78bSCy Schubert 	for (i = 0; i < sizeof(auth_errlist)/sizeof(struct auth_errtab); i++) {
345*7f2fe78bSCy Schubert 		if (auth_errlist[i].status == stat) {
346*7f2fe78bSCy Schubert 			return(auth_errlist[i].message);
347*7f2fe78bSCy Schubert 		}
348*7f2fe78bSCy Schubert 	}
349*7f2fe78bSCy Schubert 	return(NULL);
350*7f2fe78bSCy Schubert }
351