summaryrefslogtreecommitdiffstats
path: root/usr.bin/ypwhich
diff options
context:
space:
mode:
authorwpaul <wpaul@FreeBSD.org>1995-04-22 00:23:59 +0000
committerwpaul <wpaul@FreeBSD.org>1995-04-22 00:23:59 +0000
commita44587d41a22f9f97697eacb8094f156af031760 (patch)
tree45d474a31251831e6b73335c413bbedffd71853d /usr.bin/ypwhich
parentf50974f2ec0a1239f728b8d2fdc722dbae37d426 (diff)
downloadFreeBSD-src-a44587d41a22f9f97697eacb8094f156af031760.zip
FreeBSD-src-a44587d41a22f9f97697eacb8094f156af031760.tar.gz
Make Rod Grimes's life a little simpler: replace all exit(1)'s with
seperate exit values depending on the error. (The error values are #defined and commented near the top of the file for clarity). This is to help write a small bit of shell script for /etc/rc that calls ypwhich a few times after ypbind is invoked to make sure we're actually bound to a server before proceeding (if we aren't, the automounter can fail if it's using NIS maps).
Diffstat (limited to 'usr.bin/ypwhich')
-rw-r--r--usr.bin/ypwhich/ypwhich.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/usr.bin/ypwhich/ypwhich.c b/usr.bin/ypwhich/ypwhich.c
index 74b85b1..ac8b20c 100644
--- a/usr.bin/ypwhich/ypwhich.c
+++ b/usr.bin/ypwhich/ypwhich.c
@@ -42,6 +42,12 @@ static char rcsid[] = "ypwhich.c,v 1.2 1993/05/16 02:49:10 deraadt Exp";
#include <rpcsvc/yp_prot.h>
#include <rpcsvc/ypclnt.h>
+#define ERR_USAGE 1 /* bad arguments - display 'usage' message */
+#define ERR_NOSUCHHOST 2 /* no such host */
+#define ERR_NOBINDING 3 /* error from ypbind -- domain not bound */
+#define ERR_NOYPBIND 4 /* ypbind not running */
+#define ERR_NOMASTER 5 /* could not find master server */
+
extern bool_t xdr_domainname();
struct ypalias {
@@ -62,7 +68,7 @@ usage()
fprintf(stderr, "Usage:\n");
fprintf(stderr, "\typwhich [-d domain] [[-t] -m [mname] | host]\n");
fprintf(stderr, "\typwhich -x\n");
- exit(1);
+ exit(ERR_USAGE);
}
@@ -166,7 +172,7 @@ char **argv;
sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
if(bind_host(domainname, &sin))
- exit(1);
+ exit(ERR_NOBINDING);
break;
case 1:
bzero(&sin, sizeof sin);
@@ -176,13 +182,13 @@ char **argv;
if(!hent) {
fprintf(stderr, "ypwhich: host %s unknown\n",
argv[optind]);
- exit(1);
+ exit(ERR_NOSUCHHOST);
}
bcopy((char *)hent->h_addr_list[0],
(char *)&sin.sin_addr, sizeof sin.sin_addr);
}
if(bind_host(domainname, &sin))
- exit(1);
+ exit(ERR_NOBINDING);
break;
default:
usage();
@@ -206,11 +212,11 @@ char **argv;
break;
case YPERR_YPBIND:
fprintf(stderr, "ypwhich: not running ypbind\n");
- exit(1);
+ exit(ERR_NOYPBIND);
default:
fprintf(stderr, "Can't find master for map %s. Reason: %s\n",
map, yperr_string(r));
- exit(1);
+ exit(ERR_NOMASTER);
}
exit(0);
}
@@ -239,11 +245,11 @@ char **argv;
break;
case YPERR_YPBIND:
fprintf(stderr, "ypwhich: not running ypbind\n");
- exit(1);
+ exit(ERR_NOYPBIND);
default:
fprintf(stderr, "Can't get map list for domain %s. Reason: %s\n",
domainname, yperr_string(r));
- exit(1);
+ exit(ERR_NOMASTER);
}
exit(0);
}
OpenPOWER on IntegriCloud