small NIS binding fixes:

ypbind.c: if a client program asks ypbind for the name of the server
for a particular domain, and there isn't a binding for that domain
available yet, ypbind needs to supply a status value along with its
failure message. Set yprespbody.ypbind_error before returning from
a ypbindproc_domain request.

yplib.c: properly handle the error status messages ypbind now has the
ability to send us. Add a ypbinderr_string() function to decode the
error values.

ypwhich.c: handle ypbind errors correctly: yperr_string() can't handle
ypbind_status messages -- use ypbinderr_string instead.
This commit is contained in:
Bill Paul 1995-04-21 18:04:36 +00:00
parent 8da0f3b87a
commit 644161688b
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=7982
3 changed files with 31 additions and 5 deletions

View File

@ -28,7 +28,7 @@
*/
#ifndef LINT
static char *rcsid = "$Id: yplib.c,v 1.4 1995/03/24 21:21:37 wpaul Exp $";
static char *rcsid = "$Id: yplib.c,v 1.6 1995/04/09 21:52:31 wpaul Exp $";
#endif
#include <sys/param.h>
@ -168,6 +168,25 @@ int *vallen;
}
#endif
char *
ypbinderr_string(incode)
int incode;
{
static char err[80];
switch(incode) {
case 0:
return "Success";
case 1:
return "Internal ypbind error";
case 2:
return "Domain not bound";
case 3:
return "System resource allocation failure";
}
sprintf(err, "Unknown ypbind error %d\n", incode);
return err;
}
int
_yp_dobind(dom, ypdb)
char *dom;
@ -329,6 +348,12 @@ struct dom_binding **ypdb;
clnt_destroy(client);
ysd->dom_vers = -1;
goto again;
} else {
if (ypbr.ypbind_status != YPBIND_SUCC_VAL) {
fprintf(stderr, "yp_bind: %s\n",
ypbinderr_string(ypbr.ypbind_status));
return YPERR_YPBIND;
}
}
clnt_destroy(client);

View File

@ -103,7 +103,7 @@ struct sockaddr_in *sin;
} else {
if (ypbr.ypbind_status != YPBIND_SUCC_VAL) {
fprintf(stderr, "can't yp_bind: Reason: %s\n",
yperr_string(ypbr.ypbind_status));
ypbinderr_string(ypbr.ypbind_status));
clnt_destroy(client);
return r;
}

View File

@ -28,7 +28,7 @@
*/
#ifndef LINT
static char rcsid[] = "$Id: ypbind.c,v 1.5 1995/04/02 03:10:55 wpaul Exp $";
static char rcsid[] = "$Id: ypbind.c,v 1.6 1995/04/15 23:35:46 wpaul Exp $";
#endif
#include <sys/param.h>
@ -132,6 +132,7 @@ CLIENT *clnt;
bzero((char *)&res, sizeof res);
res.ypbind_status = YPBIND_FAIL_VAL;
res.ypbind_respbody.ypbind_error = YPBIND_ERR_NOSERV;
for(ypdb=ypbindlist; ypdb; ypdb=ypdb->dom_pnext)
if( strcmp(ypdb->dom_domain, argp) == 0)
@ -148,11 +149,11 @@ CLIENT *clnt;
unlink(path);
ypdb->dom_pnext = ypbindlist;
ypbindlist = ypdb;
return NULL;
return &res;
}
if(ypdb->dom_alive==0)
return NULL;
return &res;
#if 0
delta = ypdb->dom_check_t - ypdb->dom_ask_t;