X-Git-Url: http://git.marmaro.de/?a=blobdiff_plain;f=zotnet%2Fmts%2Fclient.c;h=009595901fb9a5feaf0346381cd2b8fd78225deb;hb=278a48ef53b5dde10d7c88f67f51ce15ad11c0c0;hp=6d86057831c43e05901db9b8434b8c9639215333;hpb=1691e80890e5d8ba258c51c214a3e91880e1db2b;p=mmh diff --git a/zotnet/mts/client.c b/zotnet/mts/client.c index 6d86057..0095959 100644 --- a/zotnet/mts/client.c +++ b/zotnet/mts/client.c @@ -35,8 +35,6 @@ #define MAXNETS 5 #define MAXHOSTS 25 -extern int errno; - struct addrent { int a_addrtype; /* assumes AF_INET for inet_netof () */ union { @@ -63,7 +61,7 @@ char krb_realm[REALM_SZ]; char *PrincipalHostname(); #endif /* KPOP */ -#if defined(BIND) && !defined(h_addr) +#if !defined(h_addr) # define h_addr h_addr_list[0] #endif @@ -94,7 +92,7 @@ client (char *args, char *protocol, char *service, int rproto, char *arguments[MAXARGS]; register struct hostent *hp; register struct servent *sp; -#ifndef BIND +#ifndef HAVE_GETHOSTBYNAME register struct netent *np; #endif @@ -145,9 +143,18 @@ client (char *args, char *protocol, char *service, int rproto, for (ap = arguments; *ap; ap++) { if (**ap == '\01') { -#ifndef BIND +/* + * the assumption here is that if the system doesn't have a + * gethostbyname() function, it must not use DNS. So we need to look + * into the /etc/hosts using gethostent(). There probablly aren't any + * systems still like this, but you never know. On every system I have + * access to, this section is ignored. + */ +#ifndef HAVE_GETHOSTBYNAME if ((np = getnetbyname (*ap + 1))) { +#ifdef HAVE_SETHOSTENT sethostent (1); +#endif /* HAVE_SETHOSTENT */ while ((hp = gethostent())) if (np->n_addrtype == hp->h_addrtype && inet (hp, np->n_net)) { @@ -165,7 +172,7 @@ client (char *args, char *protocol, char *service, int rproto, break; } } -#endif +#endif /* don't HAVE_GETHOSTBYNAME */ continue; } @@ -201,6 +208,7 @@ rcaux (struct servent *sp, struct hostent *hp, int rproto, #ifdef KPOP int rem; + struct hostent *hp2; #endif /* KPOP */ for (ap = nets; ap < n1; ap++) @@ -249,7 +257,11 @@ rcaux (struct servent *sp, struct hostent *hp, int rproto, if (kservice) { /* "pop" */ char *instance; - if ((instance = strdup (hp->h_name)) == NULL) { + if (( hp2 = gethostbyaddr( hp->h_addr, hp->h_length, hp->h_addrtype )) + == NULL ) { + return NOTOK; + } + if ((instance = strdup (hp2->h_name)) == NULL) { close (sd); strncpy (response, "Out of memory.", len_response); return OOPS2;