1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* 23*0Sstevel@tonic-gate * Copyright 2000 Sun Microsystems, Inc. All rights reserved. 24*0Sstevel@tonic-gate * Use is subject to license terms. 25*0Sstevel@tonic-gate */ 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ 28*0Sstevel@tonic-gate /* All Rights Reserved */ 29*0Sstevel@tonic-gate 30*0Sstevel@tonic-gate /* 31*0Sstevel@tonic-gate * Portions of this source code were derived from Berkeley 4.3 BSD 32*0Sstevel@tonic-gate * under license from the Regents of the University of California. 33*0Sstevel@tonic-gate */ 34*0Sstevel@tonic-gate 35*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 36*0Sstevel@tonic-gate 37*0Sstevel@tonic-gate #ifndef lint 38*0Sstevel@tonic-gate static char sccsid[] = "@(#)rpc.ypupdated.c 1.9 87/10/30 Copyr 1986 Sun Micro"; 39*0Sstevel@tonic-gate #endif 40*0Sstevel@tonic-gate 41*0Sstevel@tonic-gate /* 42*0Sstevel@tonic-gate * YP update service 43*0Sstevel@tonic-gate */ 44*0Sstevel@tonic-gate #include <stdio.h> 45*0Sstevel@tonic-gate #include <stdlib.h> 46*0Sstevel@tonic-gate #include <sys/types.h> 47*0Sstevel@tonic-gate #include <sys/file.h> 48*0Sstevel@tonic-gate #include <sys/signal.h> 49*0Sstevel@tonic-gate #include <sys/wait.h> 50*0Sstevel@tonic-gate #include <rpc/rpc.h> 51*0Sstevel@tonic-gate #include <rpc/nettype.h> 52*0Sstevel@tonic-gate #include <rpcsvc/ypupd.h> 53*0Sstevel@tonic-gate #include <rpcsvc/ypclnt.h> 54*0Sstevel@tonic-gate #include <netdir.h> 55*0Sstevel@tonic-gate #include <stropts.h> 56*0Sstevel@tonic-gate #ifdef SYSLOG 57*0Sstevel@tonic-gate #include <syslog.h> 58*0Sstevel@tonic-gate #else 59*0Sstevel@tonic-gate #define LOG_ERR 1 60*0Sstevel@tonic-gate #define openlog(a, b, c) 61*0Sstevel@tonic-gate #endif 62*0Sstevel@tonic-gate 63*0Sstevel@tonic-gate #ifdef DEBUG 64*0Sstevel@tonic-gate #define RPC_SVC_FG 65*0Sstevel@tonic-gate #define debug(msg) fprintf(stderr, "%s\n", msg); 66*0Sstevel@tonic-gate #else 67*0Sstevel@tonic-gate #define debug(msg) /* turn off debugging */ 68*0Sstevel@tonic-gate #endif 69*0Sstevel@tonic-gate 70*0Sstevel@tonic-gate static char YPDIR[] = "/var/yp"; 71*0Sstevel@tonic-gate static char UPDATEFILE[] = "/var/yp/updaters"; 72*0Sstevel@tonic-gate #define _RPCSVC_CLOSEDOWN 120 73*0Sstevel@tonic-gate 74*0Sstevel@tonic-gate static int addr2netname(); 75*0Sstevel@tonic-gate static void closedown(); 76*0Sstevel@tonic-gate static void ypupdate_prog(); 77*0Sstevel@tonic-gate static void msgout(); 78*0Sstevel@tonic-gate static int update(); 79*0Sstevel@tonic-gate static int insecure; 80*0Sstevel@tonic-gate static int _rpcpmstart; /* Started by a port monitor ? */ 81*0Sstevel@tonic-gate static int _rpcsvcdirty; /* Still serving ? */ 82*0Sstevel@tonic-gate 83*0Sstevel@tonic-gate extern unsigned int alarm(); 84*0Sstevel@tonic-gate extern void exit(); 85*0Sstevel@tonic-gate extern int close(); 86*0Sstevel@tonic-gate extern long fork(); 87*0Sstevel@tonic-gate extern int free(); 88*0Sstevel@tonic-gate extern struct netconfig *getnetconfigent(); 89*0Sstevel@tonic-gate extern int strcmp(); 90*0Sstevel@tonic-gate extern int strcpy(); 91*0Sstevel@tonic-gate extern int syslog(); 92*0Sstevel@tonic-gate extern void *signal(); 93*0Sstevel@tonic-gate extern int setsid(); 94*0Sstevel@tonic-gate extern int t_getinfo(); 95*0Sstevel@tonic-gate extern int user2netname(); 96*0Sstevel@tonic-gate extern int _openchild(); 97*0Sstevel@tonic-gate 98*0Sstevel@tonic-gate main(argc, argv) 99*0Sstevel@tonic-gate int argc; 100*0Sstevel@tonic-gate char *argv[]; 101*0Sstevel@tonic-gate { 102*0Sstevel@tonic-gate pid_t pid; 103*0Sstevel@tonic-gate char *cmd; 104*0Sstevel@tonic-gate char mname[FMNAMESZ + 1]; 105*0Sstevel@tonic-gate 106*0Sstevel@tonic-gate if (geteuid() != 0) { 107*0Sstevel@tonic-gate (void) fprintf(stderr, "must be root to run %s\n", argv[0]); 108*0Sstevel@tonic-gate exit(1); 109*0Sstevel@tonic-gate } 110*0Sstevel@tonic-gate 111*0Sstevel@tonic-gate cmd = argv[0]; 112*0Sstevel@tonic-gate switch (argc) { 113*0Sstevel@tonic-gate case 0: 114*0Sstevel@tonic-gate cmd = "ypupdated"; 115*0Sstevel@tonic-gate break; 116*0Sstevel@tonic-gate case 1: 117*0Sstevel@tonic-gate break; 118*0Sstevel@tonic-gate case 2: 119*0Sstevel@tonic-gate if (strcmp(argv[1], "-i") == 0) { 120*0Sstevel@tonic-gate insecure++; 121*0Sstevel@tonic-gate break; 122*0Sstevel@tonic-gate } 123*0Sstevel@tonic-gate default: 124*0Sstevel@tonic-gate fprintf(stderr, "%s: warning -- options ignored\n", cmd); 125*0Sstevel@tonic-gate break; 126*0Sstevel@tonic-gate } 127*0Sstevel@tonic-gate 128*0Sstevel@tonic-gate if (chdir(YPDIR) < 0) { 129*0Sstevel@tonic-gate fprintf(stderr, "%s: can't chdir to ", cmd); 130*0Sstevel@tonic-gate perror(YPDIR); 131*0Sstevel@tonic-gate exit(1); 132*0Sstevel@tonic-gate } 133*0Sstevel@tonic-gate 134*0Sstevel@tonic-gate if (!ioctl(0, I_LOOK, mname) && 135*0Sstevel@tonic-gate (strcmp(mname, "sockmod") == 0 || 136*0Sstevel@tonic-gate strcmp(mname, "timod") == 0)) { 137*0Sstevel@tonic-gate /* 138*0Sstevel@tonic-gate * Started from port monitor: use 0 as fd 139*0Sstevel@tonic-gate */ 140*0Sstevel@tonic-gate char *netid; 141*0Sstevel@tonic-gate struct netconfig *nconf = NULL; 142*0Sstevel@tonic-gate SVCXPRT *transp; 143*0Sstevel@tonic-gate int pmclose; 144*0Sstevel@tonic-gate extern char *getenv(); 145*0Sstevel@tonic-gate 146*0Sstevel@tonic-gate _rpcpmstart = 1; 147*0Sstevel@tonic-gate if ((netid = getenv("NLSPROVIDER")) == NULL) { 148*0Sstevel@tonic-gate msgout("cannot get transport name"); 149*0Sstevel@tonic-gate } 150*0Sstevel@tonic-gate if ((nconf = getnetconfigent(netid)) == NULL) { 151*0Sstevel@tonic-gate msgout("cannot get transport info"); 152*0Sstevel@tonic-gate } 153*0Sstevel@tonic-gate if (strcmp(mname, "sockmod") == 0) { 154*0Sstevel@tonic-gate if (ioctl(0, I_POP, 0) || ioctl(0, I_PUSH, "timod")) { 155*0Sstevel@tonic-gate msgout("could not get the right module"); 156*0Sstevel@tonic-gate exit(1); 157*0Sstevel@tonic-gate } 158*0Sstevel@tonic-gate } 159*0Sstevel@tonic-gate pmclose = (t_getstate(0) != T_DATAXFER); 160*0Sstevel@tonic-gate if ((transp = svc_tli_create(0, nconf, NULL, 0, 0)) == NULL) { 161*0Sstevel@tonic-gate msgout("cannot create update server handle"); 162*0Sstevel@tonic-gate exit(1); 163*0Sstevel@tonic-gate } 164*0Sstevel@tonic-gate if (!svc_reg(transp, YPU_PROG, YPU_VERS, ypupdate_prog, 0)) { 165*0Sstevel@tonic-gate msgout("unable to register (YPBINDPROG, YPBINDVERS)."); 166*0Sstevel@tonic-gate exit(1); 167*0Sstevel@tonic-gate } 168*0Sstevel@tonic-gate if (nconf) 169*0Sstevel@tonic-gate freenetconfigent(nconf); 170*0Sstevel@tonic-gate 171*0Sstevel@tonic-gate if (pmclose) { 172*0Sstevel@tonic-gate (void) signal(SIGALRM, closedown); 173*0Sstevel@tonic-gate (void) alarm(_RPCSVC_CLOSEDOWN); 174*0Sstevel@tonic-gate } 175*0Sstevel@tonic-gate svc_run(); 176*0Sstevel@tonic-gate exit(1); 177*0Sstevel@tonic-gate } 178*0Sstevel@tonic-gate #ifndef RPC_SVC_FG 179*0Sstevel@tonic-gate /* 180*0Sstevel@tonic-gate * Started from shell; background thyself and run 181*0Sstevel@tonic-gate */ 182*0Sstevel@tonic-gate pid = fork(); 183*0Sstevel@tonic-gate 184*0Sstevel@tonic-gate if (pid < 0) { 185*0Sstevel@tonic-gate perror("cannot fork"); 186*0Sstevel@tonic-gate exit(1); 187*0Sstevel@tonic-gate } 188*0Sstevel@tonic-gate if (pid) 189*0Sstevel@tonic-gate exit(0); 190*0Sstevel@tonic-gate closefrom(0); 191*0Sstevel@tonic-gate (void) setsid(); 192*0Sstevel@tonic-gate openlog("ypupdated", LOG_PID, LOG_DAEMON); 193*0Sstevel@tonic-gate #endif 194*0Sstevel@tonic-gate if (!svc_create(ypupdate_prog, YPU_PROG, YPU_VERS, "netpath")) { 195*0Sstevel@tonic-gate msgout("unable to create (YPU_PROG, YPU_VERS) for netpath."); 196*0Sstevel@tonic-gate exit(1); 197*0Sstevel@tonic-gate } 198*0Sstevel@tonic-gate 199*0Sstevel@tonic-gate svc_run(); 200*0Sstevel@tonic-gate msgout("svc_run returned"); 201*0Sstevel@tonic-gate exit(1); 202*0Sstevel@tonic-gate /* NOTREACHED */ 203*0Sstevel@tonic-gate } 204*0Sstevel@tonic-gate 205*0Sstevel@tonic-gate static void 206*0Sstevel@tonic-gate ypupdate_prog(rqstp, transp) 207*0Sstevel@tonic-gate struct svc_req *rqstp; 208*0Sstevel@tonic-gate SVCXPRT *transp; 209*0Sstevel@tonic-gate { 210*0Sstevel@tonic-gate struct ypupdate_args args; 211*0Sstevel@tonic-gate uint_t rslt; 212*0Sstevel@tonic-gate uint_t op; 213*0Sstevel@tonic-gate char *netname; 214*0Sstevel@tonic-gate char namebuf[MAXNETNAMELEN+1]; 215*0Sstevel@tonic-gate struct authunix_parms *aup; 216*0Sstevel@tonic-gate 217*0Sstevel@tonic-gate switch (rqstp->rq_proc) { 218*0Sstevel@tonic-gate case NULLPROC: 219*0Sstevel@tonic-gate svc_sendreply(transp, xdr_void, NULL); 220*0Sstevel@tonic-gate return; 221*0Sstevel@tonic-gate case YPU_CHANGE: 222*0Sstevel@tonic-gate op = YPOP_CHANGE; 223*0Sstevel@tonic-gate break; 224*0Sstevel@tonic-gate case YPU_DELETE: 225*0Sstevel@tonic-gate op = YPOP_DELETE; 226*0Sstevel@tonic-gate break; 227*0Sstevel@tonic-gate case YPU_INSERT: 228*0Sstevel@tonic-gate op = YPOP_INSERT; 229*0Sstevel@tonic-gate break; 230*0Sstevel@tonic-gate case YPU_STORE: 231*0Sstevel@tonic-gate op = YPOP_STORE; 232*0Sstevel@tonic-gate break; 233*0Sstevel@tonic-gate default: 234*0Sstevel@tonic-gate svcerr_noproc(transp); 235*0Sstevel@tonic-gate return; 236*0Sstevel@tonic-gate } 237*0Sstevel@tonic-gate #ifdef DEBUG 238*0Sstevel@tonic-gate fprintf(stderr, "ypupdated: request received\n"); 239*0Sstevel@tonic-gate #endif 240*0Sstevel@tonic-gate switch (rqstp->rq_cred.oa_flavor) { 241*0Sstevel@tonic-gate case AUTH_DES: 242*0Sstevel@tonic-gate netname = ((struct authdes_cred *) 243*0Sstevel@tonic-gate rqstp->rq_clntcred)->adc_fullname.name; 244*0Sstevel@tonic-gate break; 245*0Sstevel@tonic-gate case AUTH_UNIX: 246*0Sstevel@tonic-gate if (insecure) { 247*0Sstevel@tonic-gate aup = (struct authunix_parms *)rqstp->rq_clntcred; 248*0Sstevel@tonic-gate if (aup->aup_uid == 0) { 249*0Sstevel@tonic-gate if (addr2netname(namebuf, transp) != 0) { 250*0Sstevel@tonic-gate fprintf(stderr, 251*0Sstevel@tonic-gate "addr2netname failing for %d\n", 252*0Sstevel@tonic-gate aup->aup_uid); 253*0Sstevel@tonic-gate svcerr_systemerr(transp); 254*0Sstevel@tonic-gate return; 255*0Sstevel@tonic-gate } 256*0Sstevel@tonic-gate } else { 257*0Sstevel@tonic-gate if (user2netname(namebuf, aup->aup_uid, NULL) 258*0Sstevel@tonic-gate != 0) { 259*0Sstevel@tonic-gate fprintf(stderr, 260*0Sstevel@tonic-gate "user2netname failing for %d\n", 261*0Sstevel@tonic-gate aup->aup_uid); 262*0Sstevel@tonic-gate svcerr_systemerr(transp); 263*0Sstevel@tonic-gate return; 264*0Sstevel@tonic-gate } 265*0Sstevel@tonic-gate } 266*0Sstevel@tonic-gate netname = namebuf; 267*0Sstevel@tonic-gate break; 268*0Sstevel@tonic-gate } 269*0Sstevel@tonic-gate default: 270*0Sstevel@tonic-gate svcerr_weakauth(transp); 271*0Sstevel@tonic-gate return; 272*0Sstevel@tonic-gate } 273*0Sstevel@tonic-gate memset(&args, 0, sizeof (args)); 274*0Sstevel@tonic-gate if (!svc_getargs(transp, xdr_ypupdate_args, (char *)&args)) { 275*0Sstevel@tonic-gate svcerr_decode(transp); 276*0Sstevel@tonic-gate return; 277*0Sstevel@tonic-gate } 278*0Sstevel@tonic-gate #ifdef DEBUG 279*0Sstevel@tonic-gate fprintf(stderr, "netname = %s\n, map=%s\n key=%s\n", 280*0Sstevel@tonic-gate netname, args.mapname, args.key.yp_buf_val); 281*0Sstevel@tonic-gate #endif 282*0Sstevel@tonic-gate rslt = update(netname, args.mapname, op, 283*0Sstevel@tonic-gate args.key.yp_buf_len, args.key.yp_buf_val, 284*0Sstevel@tonic-gate args.datum.yp_buf_len, args.datum.yp_buf_val); 285*0Sstevel@tonic-gate if (!svc_sendreply(transp, xdr_u_int, (char *)&rslt)) { 286*0Sstevel@tonic-gate debug("svc_sendreply failed"); 287*0Sstevel@tonic-gate } 288*0Sstevel@tonic-gate if (!svc_freeargs(transp, xdr_ypupdate_args, (char *)&args)) { 289*0Sstevel@tonic-gate debug("svc_freeargs failed"); 290*0Sstevel@tonic-gate } 291*0Sstevel@tonic-gate } 292*0Sstevel@tonic-gate 293*0Sstevel@tonic-gate /* 294*0Sstevel@tonic-gate * Determine if requester is allowed to update the given map, 295*0Sstevel@tonic-gate * and update it if so. Returns the yp status, which is zero 296*0Sstevel@tonic-gate * if there is no access violation. 297*0Sstevel@tonic-gate */ 298*0Sstevel@tonic-gate static 299*0Sstevel@tonic-gate update(requester, mapname, op, keylen, key, datalen, data) 300*0Sstevel@tonic-gate char *requester; 301*0Sstevel@tonic-gate char *mapname; 302*0Sstevel@tonic-gate uint_t op; 303*0Sstevel@tonic-gate uint_t keylen; 304*0Sstevel@tonic-gate char *key; 305*0Sstevel@tonic-gate uint_t datalen; 306*0Sstevel@tonic-gate char *data; 307*0Sstevel@tonic-gate { 308*0Sstevel@tonic-gate char updater[MAXMAPNAMELEN + 40]; 309*0Sstevel@tonic-gate FILE *childargs; 310*0Sstevel@tonic-gate FILE *childrslt; 311*0Sstevel@tonic-gate int status; 312*0Sstevel@tonic-gate int yperrno = 0; 313*0Sstevel@tonic-gate int pid; 314*0Sstevel@tonic-gate 315*0Sstevel@tonic-gate sprintf(updater, "/usr/ccs/bin/make -s -f %s %s", UPDATEFILE, mapname); 316*0Sstevel@tonic-gate #ifdef DEBUG 317*0Sstevel@tonic-gate fprintf(stderr, "updater: %s\n", updater); 318*0Sstevel@tonic-gate fprintf(stderr, "requestor = %s, op = %d, key = %s\n", 319*0Sstevel@tonic-gate requester, op, key); 320*0Sstevel@tonic-gate fprintf(stderr, "data = %s\n", data); 321*0Sstevel@tonic-gate #endif 322*0Sstevel@tonic-gate pid = _openchild(updater, &childargs, &childrslt); 323*0Sstevel@tonic-gate if (pid < 0) { 324*0Sstevel@tonic-gate debug("openpipes failed"); 325*0Sstevel@tonic-gate return (YPERR_YPERR); 326*0Sstevel@tonic-gate } 327*0Sstevel@tonic-gate 328*0Sstevel@tonic-gate /* 329*0Sstevel@tonic-gate * Write to child 330*0Sstevel@tonic-gate */ 331*0Sstevel@tonic-gate fprintf(childargs, "%s\n", requester); 332*0Sstevel@tonic-gate fprintf(childargs, "%u\n", op); 333*0Sstevel@tonic-gate fprintf(childargs, "%u\n", keylen); 334*0Sstevel@tonic-gate fwrite(key, keylen, 1, childargs); 335*0Sstevel@tonic-gate fprintf(childargs, "\n"); 336*0Sstevel@tonic-gate fprintf(childargs, "%u\n", datalen); 337*0Sstevel@tonic-gate fwrite(data, datalen, 1, childargs); 338*0Sstevel@tonic-gate fprintf(childargs, "\n"); 339*0Sstevel@tonic-gate fclose(childargs); 340*0Sstevel@tonic-gate 341*0Sstevel@tonic-gate /* 342*0Sstevel@tonic-gate * Read from child 343*0Sstevel@tonic-gate */ 344*0Sstevel@tonic-gate fscanf(childrslt, "%d", &yperrno); 345*0Sstevel@tonic-gate fclose(childrslt); 346*0Sstevel@tonic-gate 347*0Sstevel@tonic-gate wait(&status); 348*0Sstevel@tonic-gate if (!WIFEXITED(status)) { 349*0Sstevel@tonic-gate return (YPERR_YPERR); 350*0Sstevel@tonic-gate } 351*0Sstevel@tonic-gate return (yperrno); 352*0Sstevel@tonic-gate } 353*0Sstevel@tonic-gate 354*0Sstevel@tonic-gate static void 355*0Sstevel@tonic-gate msgout(msg) 356*0Sstevel@tonic-gate char *msg; 357*0Sstevel@tonic-gate { 358*0Sstevel@tonic-gate if (_rpcpmstart) 359*0Sstevel@tonic-gate syslog(LOG_ERR, msg); 360*0Sstevel@tonic-gate else 361*0Sstevel@tonic-gate (void) fprintf(stderr, "%s\n", msg); 362*0Sstevel@tonic-gate } 363*0Sstevel@tonic-gate 364*0Sstevel@tonic-gate void 365*0Sstevel@tonic-gate closedown() 366*0Sstevel@tonic-gate { 367*0Sstevel@tonic-gate if (_rpcsvcdirty == 0) { 368*0Sstevel@tonic-gate int i, openfd; 369*0Sstevel@tonic-gate struct t_info tinfo; 370*0Sstevel@tonic-gate 371*0Sstevel@tonic-gate if (t_getinfo(0, tinfo) || (tinfo.servtype == T_CLTS)) 372*0Sstevel@tonic-gate exit(0); 373*0Sstevel@tonic-gate 374*0Sstevel@tonic-gate for (i = 0, openfd = 0; i < svc_max_pollfd && openfd < 2; i++) 375*0Sstevel@tonic-gate if (svc_pollfd[i].fd >= 0) 376*0Sstevel@tonic-gate openfd++; 377*0Sstevel@tonic-gate 378*0Sstevel@tonic-gate if (openfd <= 1) 379*0Sstevel@tonic-gate exit(0); 380*0Sstevel@tonic-gate } 381*0Sstevel@tonic-gate (void) alarm(_RPCSVC_CLOSEDOWN); 382*0Sstevel@tonic-gate } 383*0Sstevel@tonic-gate 384*0Sstevel@tonic-gate static int 385*0Sstevel@tonic-gate addr2netname(namebuf, transp) 386*0Sstevel@tonic-gate char *namebuf; 387*0Sstevel@tonic-gate SVCXPRT *transp; 388*0Sstevel@tonic-gate { 389*0Sstevel@tonic-gate struct nd_hostservlist *hostservs = NULL; 390*0Sstevel@tonic-gate struct netconfig *nconf; 391*0Sstevel@tonic-gate struct netbuf *who; 392*0Sstevel@tonic-gate 393*0Sstevel@tonic-gate who = svc_getrpccaller(transp); 394*0Sstevel@tonic-gate if ((who == NULL) || (who->len == 0)) 395*0Sstevel@tonic-gate return (-1); 396*0Sstevel@tonic-gate if ((nconf = getnetconfigent(transp->xp_netid)) 397*0Sstevel@tonic-gate == (struct netconfig *)NULL) 398*0Sstevel@tonic-gate return (-1); 399*0Sstevel@tonic-gate if (netdir_getbyaddr(nconf, &hostservs, who) != 0) { 400*0Sstevel@tonic-gate (void) freenetconfigent(nconf); 401*0Sstevel@tonic-gate return (-1); 402*0Sstevel@tonic-gate } 403*0Sstevel@tonic-gate if (hostservs == NULL) { 404*0Sstevel@tonic-gate msgout("ypupdated: netdir_getbyaddr failed\n"); 405*0Sstevel@tonic-gate } else { 406*0Sstevel@tonic-gate strcpy(namebuf, hostservs->h_hostservs->h_host); 407*0Sstevel@tonic-gate } 408*0Sstevel@tonic-gate (void) freenetconfigent(nconf); 409*0Sstevel@tonic-gate netdir_free((char *)hostservs, ND_HOSTSERVLIST); 410*0Sstevel@tonic-gate return (0); 411*0Sstevel@tonic-gate } 412