1 /* @(#)clnt_perror.c 2.1 88/07/29 4.0 RPCSRC */
3 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
4 * unrestricted use provided that this legend is included on all tape
5 * media and as a part of the software program in whole or part. Users
6 * may copy or modify Sun RPC without charge, but are not authorized
7 * to license or distribute it to anyone else except as part of a product or
8 * program developed by the user.
10 * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
11 * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
12 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
14 * Sun RPC is provided with no support and without any obligation on the
15 * part of Sun Microsystems, Inc. to assist in its use, correction,
16 * modification or enhancement.
18 * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
19 * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
20 * OR ANY PART THEREOF.
22 * In no event will Sun Microsystems, Inc. be liable for any lost revenue
23 * or profits or other special, indirect and consequential damages, even if
24 * Sun has been advised of the possibility of such damages.
26 * Sun Microsystems, Inc.
28 * Mountain View, California 94043
30 #if !defined(lint) && defined(SCCSIDS)
31 static char sccsid
[] = "@(#)clnt_perror.c 1.15 87/10/07 Copyr 1984 Sun Micro";
37 * Copyright (C) 1984, Sun Microsystems, Inc.
43 #include <rpc/types.h>
48 # include <libio/iolibio.h>
49 # define fputs(s, f) _IO_fputs (s, f)
52 static char *auth_errmsg (enum auth_stat stat
) internal_function
;
60 buf
= (char *) malloc (256);
65 * Print reply error info
68 clnt_sperror (CLIENT
* rpch
, const char *msg
)
79 CLNT_GETERR (rpch
, &e
);
81 len
= sprintf (str
, "%s: ", msg
);
84 str
= stpcpy (str
, clnt_sperrno (e
.re_status
));
89 case RPC_CANTENCODEARGS
:
90 case RPC_CANTDECODERES
:
94 case RPC_CANTDECODEARGS
:
97 case RPC_UNKNOWNPROTO
:
99 case RPC_PROGNOTREGISTERED
:
105 len
= sprintf (str
, "; errno = %s", __strerror_r (e
.re_errno
,
110 case RPC_VERSMISMATCH
:
111 len
= sprintf (str
, _("; low version = %lu, high version = %lu"),
112 e
.re_vers
.low
, e
.re_vers
.high
);
117 err
= auth_errmsg (e
.re_why
);
118 str
= stpcpy (str
, _ ("; why = "));
121 str
= stpcpy (str
, err
);
125 len
= sprintf (str
, _("(unknown authentication error - %d)"),
131 case RPC_PROGVERSMISMATCH
:
132 len
= sprintf (str
, _("; low version = %lu, high version = %lu"),
133 e
.re_vers
.low
, e
.re_vers
.high
);
137 default: /* unknown */
138 len
= sprintf (str
, "; s1 = %lu, s2 = %lu", e
.re_lb
.s1
, e
.re_lb
.s2
);
148 clnt_perror (CLIENT
* rpch
, const char *msg
)
150 (void) fputs (clnt_sperror (rpch
, msg
), stderr
);
156 enum clnt_stat status
;
157 unsigned int message_off
;
160 static const char rpc_errstr
[] =
162 #define RPC_SUCCESS_IDX 0
165 #define RPC_CANTENCODEARGS_IDX (RPC_SUCCESS_IDX + sizeof "RPC: Success")
166 N_("RPC: Can't encode arguments")
168 #define RPC_CANTDECODERES_IDX (RPC_CANTENCODEARGS_IDX \
169 + sizeof "RPC: Can't encode arguments")
170 N_("RPC: Can't decode result")
172 #define RPC_CANTSEND_IDX (RPC_CANTDECODERES_IDX \
173 + sizeof "RPC: Can't decode result")
174 N_("RPC: Unable to send")
176 #define RPC_CANTRECV_IDX (RPC_CANTSEND_IDX \
177 + sizeof "RPC: Unable to send")
178 N_("RPC: Unable to receive")
180 #define RPC_TIMEDOUT_IDX (RPC_CANTRECV_IDX \
181 + sizeof "RPC: Unable to receive")
184 #define RPC_VERSMISMATCH_IDX (RPC_TIMEDOUT_IDX \
185 + sizeof "RPC: Timed out")
186 N_("RPC: Incompatible versions of RPC")
188 #define RPC_AUTHERROR_IDX (RPC_VERSMISMATCH_IDX \
189 + sizeof "RPC: Incompatible versions of RPC")
190 N_("RPC: Authentication error")
192 #define RPC_PROGUNAVAIL_IDX (RPC_AUTHERROR_IDX \
193 + sizeof "RPC: Authentication error")
194 N_("RPC: Program unavailable")
196 #define RPC_PROGVERSMISMATCH_IDX (RPC_PROGUNAVAIL_IDX \
197 + sizeof "RPC: Program unavailable")
198 N_("RPC: Program/version mismatch")
200 #define RPC_PROCUNAVAIL_IDX (RPC_PROGVERSMISMATCH_IDX \
201 + sizeof "RPC: Program/version mismatch")
202 N_("RPC: Procedure unavailable")
204 #define RPC_CANTDECODEARGS_IDX (RPC_PROCUNAVAIL_IDX \
205 + sizeof "RPC: Procedure unavailable")
206 N_("RPC: Server can't decode arguments")
208 #define RPC_SYSTEMERROR_IDX (RPC_CANTDECODEARGS_IDX \
209 + sizeof "RPC: Server can't decode arguments")
210 N_("RPC: Remote system error")
212 #define RPC_UNKNOWNHOST_IDX (RPC_SYSTEMERROR_IDX \
213 + sizeof "RPC: Remote system error")
214 N_("RPC: Unknown host")
216 #define RPC_UNKNOWNPROTO_IDX (RPC_UNKNOWNHOST_IDX \
217 + sizeof "RPC: Unknown host")
218 N_("RPC: Unknown protocol")
220 #define RPC_PMAPFAILURE_IDX (RPC_UNKNOWNPROTO_IDX \
221 + sizeof "RPC: Unknown protocol")
222 N_("RPC: Port mapper failure")
224 #define RPC_PROGNOTREGISTERED_IDX (RPC_PMAPFAILURE_IDX \
225 + sizeof "RPC: Port mapper failure")
226 N_("RPC: Program not registered")
228 #define RPC_FAILED_IDX (RPC_PROGNOTREGISTERED_IDX \
229 + sizeof "RPC: Program not registered")
230 N_("RPC: Failed (unspecified error)")
233 static const struct rpc_errtab rpc_errlist
[] =
235 { RPC_SUCCESS
, RPC_SUCCESS_IDX
},
236 { RPC_CANTENCODEARGS
, RPC_CANTENCODEARGS_IDX
},
237 { RPC_CANTDECODERES
, RPC_CANTDECODERES_IDX
},
238 { RPC_CANTSEND
, RPC_CANTSEND_IDX
},
239 { RPC_CANTRECV
, RPC_CANTRECV_IDX
},
240 { RPC_TIMEDOUT
, RPC_TIMEDOUT_IDX
},
241 { RPC_VERSMISMATCH
, RPC_VERSMISMATCH_IDX
},
242 { RPC_AUTHERROR
, RPC_AUTHERROR_IDX
},
243 { RPC_PROGUNAVAIL
, RPC_PROGUNAVAIL_IDX
},
244 { RPC_PROGVERSMISMATCH
, RPC_PROGVERSMISMATCH
},
245 { RPC_PROCUNAVAIL
, RPC_PROCUNAVAIL_IDX
},
246 { RPC_CANTDECODEARGS
, RPC_CANTDECODEARGS_IDX
},
247 { RPC_SYSTEMERROR
, RPC_SYSTEMERROR_IDX
},
248 { RPC_UNKNOWNHOST
, RPC_UNKNOWNHOST_IDX
},
249 { RPC_UNKNOWNPROTO
, RPC_UNKNOWNPROTO_IDX
},
250 { RPC_PMAPFAILURE
, RPC_PMAPFAILURE_IDX
},
251 { RPC_PROGNOTREGISTERED
, RPC_PROGNOTREGISTERED_IDX
},
252 { RPC_FAILED
, RPC_FAILED_IDX
}
257 * This interface for use by clntrpc
260 clnt_sperrno (enum clnt_stat stat
)
264 for (i
= 0; i
< sizeof (rpc_errlist
) / sizeof (struct rpc_errtab
); i
++)
266 if (rpc_errlist
[i
].status
== stat
)
268 return _(rpc_errstr
+ rpc_errlist
[i
].message_off
);
271 return _("RPC: (unknown error code)");
275 clnt_perrno (enum clnt_stat num
)
277 (void) fputs (clnt_sperrno (num
), stderr
);
282 clnt_spcreateerror (const char *msg
)
291 len
= sprintf (str
, "%s: ", msg
);
293 cp
= stpcpy (cp
, clnt_sperrno (rpc_createerr
.cf_stat
));
294 switch (rpc_createerr
.cf_stat
)
296 case RPC_PMAPFAILURE
:
297 cp
= stpcpy (stpcpy (cp
, " - "),
298 clnt_sperrno (rpc_createerr
.cf_error
.re_status
));
301 case RPC_SYSTEMERROR
:
302 cp
= stpcpy (stpcpy (cp
, " - "),
303 __strerror_r (rpc_createerr
.cf_error
.re_errno
,
315 clnt_pcreateerror (const char *msg
)
317 (void) fputs (clnt_spcreateerror (msg
), stderr
);
322 enum auth_stat status
;
323 unsigned int message_off
;
326 static const char auth_errstr
[] =
328 #define AUTH_OK_IDX 0
329 N_("Authentication OK")
331 #define AUTH_BADCRED_IDX (AUTH_OK_IDX + sizeof "Authentication OK")
332 N_("Invalid client credential")
334 #define AUTH_REJECTEDCRED_IDX (AUTH_BADCRED_IDX \
335 + sizeof "Invalid client credential")
336 N_("Server rejected credential")
338 #define AUTH_BADVERF_IDX (AUTH_REJECTEDCRED_IDX \
339 + sizeof "Server rejected credential")
340 N_("Invalid client verifier")
342 #define AUTH_REJECTEDVERF_IDX (AUTH_BADVERF_IDX \
343 + sizeof "Invalid client verifier")
344 N_("Server rejected verifier")
346 #define AUTH_TOOWEAK_IDX (AUTH_REJECTEDVERF_IDX \
347 + sizeof "Server rejected verifier")
348 N_("Client credential too weak")
350 #define AUTH_INVALIDRESP_IDX (AUTH_TOOWEAK_IDX \
351 + sizeof "Client credential too weak")
352 N_("Invalid server verifier")
354 #define AUTH_FAILED_IDX (AUTH_INVALIDRESP_IDX \
355 + sizeof "Invalid server verifier")
356 N_("Failed (unspecified error)")
359 static const struct auth_errtab auth_errlist
[] =
361 { AUTH_OK
, AUTH_OK_IDX
},
362 { AUTH_BADCRED
, AUTH_BADCRED_IDX
},
363 { AUTH_REJECTEDCRED
, AUTH_REJECTEDCRED_IDX
},
364 { AUTH_BADVERF
, AUTH_BADVERF_IDX
},
365 { AUTH_REJECTEDVERF
, AUTH_REJECTEDVERF_IDX
},
366 { AUTH_TOOWEAK
, AUTH_TOOWEAK_IDX
},
367 { AUTH_INVALIDRESP
, AUTH_INVALIDRESP_IDX
},
368 { AUTH_FAILED
, AUTH_FAILED_IDX
}
373 auth_errmsg (enum auth_stat stat
)
377 for (i
= 0; i
< sizeof (auth_errlist
) / sizeof (struct auth_errtab
); i
++)
379 if (auth_errlist
[i
].status
== stat
)
381 return _(auth_errstr
+ auth_errlist
[i
].message_off
);