1 /* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1996.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If not,
17 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. */
25 #include <rpcsvc/nis.h>
26 #include <rpcsvc/yp.h>
27 #include <rpcsvc/ypclnt.h>
28 #include <rpcsvc/ypupd.h>
30 #include <bits/libc-lock.h>
32 /* This should only be defined on systems with a BSD compatible ypbind */
34 # define BINDINGDIR "/var/yp/binding"
39 struct dom_binding
*dom_pnext
;
40 char dom_domain
[YPMAXDOMAIN
+ 1];
41 struct sockaddr_in dom_server_addr
;
46 typedef struct dom_binding dom_binding
;
48 static struct timeval RPCTIMEOUT
= {25, 0};
49 static struct timeval UDPTIMEOUT
= {5, 0};
50 static int const MAXTRIES
= 5;
51 static char __ypdomainname
[NIS_MAXNAMELEN
+ 1] = "\0";
52 __libc_lock_define_initialized (static, ypbindlist_lock
)
53 static dom_binding
*__ypbindlist
= NULL
;
57 __yp_bind (const char *domain
, dom_binding
**ypdb
)
59 struct sockaddr_in clnt_saddr
;
60 struct ypbind_resp ypbr
;
61 dom_binding
*ysd
= NULL
;
67 if ((domain
== NULL
) || (domain
[0] == '\0'))
75 if (strcmp (domain
, ysd
->dom_domain
) == 0)
84 ysd
= (dom_binding
*) calloc (1, sizeof *ysd
);
102 if (ysd
->dom_vers
< 1 && try < 3)
104 char path
[sizeof (BINDINGDIR
) - 1 + strlen (domain
) + 10];
109 sprintf (path
, "%s/%s.%ld", BINDINGDIR
, domain
, YPBINDVERS
);
110 fd
= open (path
, O_RDONLY
);
113 /* We have a binding file and could save a RPC call */
114 vec
[0].iov_base
= &port
;
115 vec
[0].iov_len
= sizeof (port
);
116 vec
[1].iov_base
= &ypbr
;
117 vec
[1].iov_len
= sizeof (ypbr
);
119 if (readv (fd
, vec
, 2) == vec
[0].iov_len
+ vec
[1].iov_len
)
121 memset (&ysd
->dom_server_addr
, '\0',
122 sizeof ysd
->dom_server_addr
);
123 ysd
->dom_server_addr
.sin_family
= AF_INET
;
124 memcpy (&ysd
->dom_server_addr
.sin_port
,
125 ypbr
.ypbind_resp_u
.ypbind_bindinfo
.ypbind_binding_port
,
126 sizeof (ysd
->dom_server_addr
.sin_port
));
127 memcpy (&ysd
->dom_server_addr
.sin_addr
.s_addr
,
128 ypbr
.ypbind_resp_u
.ypbind_bindinfo
.ypbind_binding_addr
,
129 sizeof (ysd
->dom_server_addr
.sin_addr
.s_addr
));
130 ysd
->dom_vers
= YPVERS
;
131 strncpy (ysd
->dom_domain
, domain
, YPMAXDOMAIN
);
132 ysd
->dom_domain
[YPMAXDOMAIN
] = '\0';
137 #endif /* USE_BINDINGDIR */
139 if (ysd
->dom_vers
== -1)
143 clnt_destroy(ysd
->dom_client
);
144 ysd
->dom_client
= NULL
;
145 ysd
->dom_socket
= -1;
147 memset (&clnt_saddr
, '\0', sizeof clnt_saddr
);
148 clnt_saddr
.sin_family
= AF_INET
;
149 clnt_saddr
.sin_addr
.s_addr
= htonl (INADDR_LOOPBACK
);
150 clnt_sock
= RPC_ANYSOCK
;
151 client
= clnttcp_create (&clnt_saddr
, YPBINDPROG
, YPBINDVERS
,
160 ** Check the port number -- should be < IPPORT_RESERVED.
161 ** If not, it's possible someone has registered a bogus
162 ** ypbind with the portmapper and is trying to trick us.
164 if (ntohs (clnt_saddr
.sin_port
) >= IPPORT_RESERVED
)
166 clnt_destroy (client
);
172 if (clnt_call (client
, YPBINDPROC_DOMAIN
,
173 (xdrproc_t
) xdr_domainname
, (caddr_t
) &domain
,
174 (xdrproc_t
) xdr_ypbind_resp
,
175 (caddr_t
) &ypbr
, RPCTIMEOUT
) != RPC_SUCCESS
)
177 clnt_destroy (client
);
184 clnt_destroy (client
);
187 if (ypbr
.ypbind_status
!= YPBIND_SUCC_VAL
)
189 fprintf (stderr
, _("YPBINDPROC_DOMAIN: %s\n"),
190 ypbinderr_string (ypbr
.ypbind_resp_u
.ypbind_error
));
195 memset (&ysd
->dom_server_addr
, '\0', sizeof ysd
->dom_server_addr
);
196 ysd
->dom_server_addr
.sin_family
= AF_INET
;
197 memcpy (&ysd
->dom_server_addr
.sin_port
,
198 ypbr
.ypbind_resp_u
.ypbind_bindinfo
.ypbind_binding_port
,
199 sizeof (ysd
->dom_server_addr
.sin_port
));
200 memcpy (&ysd
->dom_server_addr
.sin_addr
.s_addr
,
201 ypbr
.ypbind_resp_u
.ypbind_bindinfo
.ypbind_binding_addr
,
202 sizeof (ysd
->dom_server_addr
.sin_addr
.s_addr
));
203 ysd
->dom_vers
= YPVERS
;
204 strncpy (ysd
->dom_domain
, domain
, YPMAXDOMAIN
);
205 ysd
->dom_domain
[YPMAXDOMAIN
] = '\0';
210 clnt_destroy (ysd
->dom_client
);
211 close (ysd
->dom_socket
);
213 ysd
->dom_socket
= RPC_ANYSOCK
;
214 ysd
->dom_client
= clntudp_create (&ysd
->dom_server_addr
, YPPROG
, YPVERS
,
215 UDPTIMEOUT
, &ysd
->dom_socket
);
216 if (ysd
->dom_client
== NULL
)
220 while (ysd
->dom_client
== NULL
);
222 /* If the program exists, close the socket */
223 if (fcntl (ysd
->dom_socket
, F_SETFD
, 1) == -1)
224 perror ("fcntl: F_SETFD");
226 if (is_new
&& ypdb
!= NULL
)
228 ysd
->dom_pnext
= *ypdb
;
232 return YPERR_SUCCESS
;
236 __yp_unbind (dom_binding
*ydb
)
238 clnt_destroy (ydb
->dom_client
);
239 ydb
->dom_client
= NULL
;
240 ydb
->dom_socket
= -1;
244 do_ypcall (const char *domain
, u_long prog
, xdrproc_t xargs
,
245 caddr_t req
, xdrproc_t xres
, caddr_t resp
)
247 dom_binding
*ydb
= NULL
;
248 bool_t use_ypbindlist
= FALSE
;
250 enum clnt_stat result
;
251 int saved_errno
= errno
;
254 status
= YPERR_YPERR
;
256 __libc_lock_lock (ypbindlist_lock
);
257 if (__ypbindlist
!= NULL
)
262 if (strcmp (domain
, ydb
->dom_domain
) == 0)
264 ydb
= ydb
->dom_pnext
;
267 use_ypbindlist
= TRUE
;
269 __libc_lock_unlock (ypbindlist_lock
);
272 __libc_lock_unlock (ypbindlist_lock
);
274 while (try < MAXTRIES
&& status
!= YPERR_SUCCESS
)
276 if (__yp_bind (domain
, &ydb
) != 0)
279 __libc_lock_unlock (ypbindlist_lock
);
280 __set_errno (saved_errno
);
284 result
= clnt_call (ydb
->dom_client
, prog
,
285 xargs
, req
, xres
, resp
, RPCTIMEOUT
);
287 if (result
!= RPC_SUCCESS
)
289 clnt_perror (ydb
->dom_client
, "do_ypcall: clnt_call");
300 status
= YPERR_SUCCESS
;
306 __libc_lock_unlock (ypbindlist_lock
);
307 use_ypbindlist
= FALSE
;
317 __set_errno (saved_errno
);
323 yp_bind (const char *indomain
)
327 __libc_lock_lock (ypbindlist_lock
);
329 status
= __yp_bind (indomain
, &__ypbindlist
);
331 __libc_lock_unlock (ypbindlist_lock
);
337 yp_unbind (const char *indomain
)
339 dom_binding
*ydbptr
, *ydbptr2
;
341 __libc_lock_lock (ypbindlist_lock
);
344 ydbptr
= __ypbindlist
;
345 while (ydbptr
!= NULL
)
347 if (strcmp (ydbptr
->dom_domain
, indomain
) == 0)
353 __ypbindlist
= __ypbindlist
->dom_pnext
;
355 ydbptr2
= ydbptr
->dom_pnext
;
361 ydbptr
= ydbptr
->dom_pnext
;
364 __libc_lock_unlock (ypbindlist_lock
);
369 __libc_lock_define_initialized (static, domainname_lock
)
372 yp_get_default_domain (char **outdomain
)
374 int result
= YPERR_SUCCESS
;;
377 __libc_lock_lock (domainname_lock
);
379 if (__ypdomainname
[0] == '\0')
381 if (getdomainname (__ypdomainname
, NIS_MAXNAMELEN
))
382 result
= YPERR_NODOM
;
383 else if (strcmp (__ypdomainname
, "(none)") == 0)
385 /* If domainname is not set, some Systems will return "(none)" */
386 __ypdomainname
[0] = '\0';
387 result
= YPERR_NODOM
;
390 *outdomain
= __ypdomainname
;
393 *outdomain
= __ypdomainname
;
395 __libc_lock_unlock (domainname_lock
);
401 __yp_check (char **domain
)
405 if (__ypdomainname
[0] == '\0')
406 if (yp_get_default_domain (&unused
))
410 *domain
= __ypdomainname
;
412 if (yp_bind (__ypdomainname
) == 0)
418 yp_match (const char *indomain
, const char *inmap
, const char *inkey
,
419 const int inkeylen
, char **outval
, int *outvallen
)
423 enum clnt_stat result
;
425 if (indomain
== NULL
|| indomain
[0] == '\0' ||
426 inmap
== NULL
|| inmap
[0] == '\0' ||
427 inkey
== NULL
|| inkey
[0] == '\0' || inkeylen
<= 0)
428 return YPERR_BADARGS
;
430 req
.domain
= (char *) indomain
;
431 req
.map
= (char *) inmap
;
432 req
.key
.keydat_val
= (char *) inkey
;
433 req
.key
.keydat_len
= inkeylen
;
437 memset (&resp
, '\0', sizeof (resp
));
439 result
= do_ypcall (indomain
, YPPROC_MATCH
, (xdrproc_t
) xdr_ypreq_key
,
440 (caddr_t
) & req
, (xdrproc_t
) xdr_ypresp_val
,
443 if (result
!= YPERR_SUCCESS
)
445 if (resp
.stat
!= YP_TRUE
)
446 return ypprot_err (resp
.stat
);
448 *outvallen
= resp
.val
.valdat_len
;
449 *outval
= malloc (*outvallen
+ 1);
450 memcpy (*outval
, resp
.val
.valdat_val
, *outvallen
);
451 (*outval
)[*outvallen
] = '\0';
453 xdr_free ((xdrproc_t
) xdr_ypresp_val
, (char *) &resp
);
455 return YPERR_SUCCESS
;
459 yp_first (const char *indomain
, const char *inmap
, char **outkey
,
460 int *outkeylen
, char **outval
, int *outvallen
)
464 enum clnt_stat result
;
466 if (indomain
== NULL
|| indomain
[0] == '\0' ||
467 inmap
== NULL
|| inmap
[0] == '\0')
468 return YPERR_BADARGS
;
470 req
.domain
= (char *) indomain
;
471 req
.map
= (char *) inmap
;
473 *outkey
= *outval
= NULL
;
474 *outkeylen
= *outvallen
= 0;
475 memset (&resp
, '\0', sizeof (resp
));
477 result
= do_ypcall (indomain
, YPPROC_FIRST
, (xdrproc_t
) xdr_ypreq_nokey
,
478 (caddr_t
) & req
, (xdrproc_t
) xdr_ypresp_key_val
,
481 if (result
!= RPC_SUCCESS
)
483 if (resp
.stat
!= YP_TRUE
)
484 return ypprot_err (resp
.stat
);
486 *outkeylen
= resp
.key
.keydat_len
;
487 *outkey
= malloc (*outkeylen
+ 1);
488 memcpy (*outkey
, resp
.key
.keydat_val
, *outkeylen
);
489 (*outkey
)[*outkeylen
] = '\0';
490 *outvallen
= resp
.val
.valdat_len
;
491 *outval
= malloc (*outvallen
+ 1);
492 memcpy (*outval
, resp
.val
.valdat_val
, *outvallen
);
493 (*outval
)[*outvallen
] = '\0';
495 xdr_free ((xdrproc_t
) xdr_ypresp_key_val
, (char *) &resp
);
497 return YPERR_SUCCESS
;
501 yp_next (const char *indomain
, const char *inmap
, const char *inkey
,
502 const int inkeylen
, char **outkey
, int *outkeylen
, char **outval
,
507 enum clnt_stat result
;
509 if (indomain
== NULL
|| indomain
[0] == '\0' ||
510 inmap
== NULL
|| inmap
[0] == '\0' ||
511 inkeylen
<= 0 || inkey
== NULL
|| inkey
[0] == '\0')
512 return YPERR_BADARGS
;
514 req
.domain
= (char *) indomain
;
515 req
.map
= (char *) inmap
;
516 req
.key
.keydat_val
= (char *) inkey
;
517 req
.key
.keydat_len
= inkeylen
;
519 *outkey
= *outval
= NULL
;
520 *outkeylen
= *outvallen
= 0;
521 memset (&resp
, '\0', sizeof (resp
));
523 result
= do_ypcall (indomain
, YPPROC_NEXT
, (xdrproc_t
) xdr_ypreq_key
,
524 (caddr_t
) & req
, (xdrproc_t
) xdr_ypresp_key_val
,
527 if (result
!= YPERR_SUCCESS
)
529 if (resp
.stat
!= YP_TRUE
)
530 return ypprot_err (resp
.stat
);
532 *outkeylen
= resp
.key
.keydat_len
;
533 *outkey
= malloc (*outkeylen
+ 1);
534 memcpy (*outkey
, resp
.key
.keydat_val
, *outkeylen
);
535 (*outkey
)[*outkeylen
] = '\0';
536 *outvallen
= resp
.val
.valdat_len
;
537 *outval
= malloc (*outvallen
+ 1);
538 memcpy (*outval
, resp
.val
.valdat_val
, *outvallen
);
539 (*outval
)[*outvallen
] = '\0';
541 xdr_free ((xdrproc_t
) xdr_ypresp_key_val
, (char *) &resp
);
543 return YPERR_SUCCESS
;
547 yp_master (const char *indomain
, const char *inmap
, char **outname
)
551 enum clnt_stat result
;
553 if (indomain
== NULL
|| indomain
[0] == '\0' ||
554 inmap
== NULL
|| inmap
[0] == '\0')
555 return YPERR_BADARGS
;
557 req
.domain
= (char *) indomain
;
558 req
.map
= (char *) inmap
;
560 memset (&resp
, '\0', sizeof (ypresp_master
));
562 result
= do_ypcall (indomain
, YPPROC_MASTER
, (xdrproc_t
) xdr_ypreq_nokey
,
563 (caddr_t
) & req
, (xdrproc_t
) xdr_ypresp_master
, (caddr_t
) & resp
);
565 if (result
!= YPERR_SUCCESS
)
567 if (resp
.stat
!= YP_TRUE
)
568 return ypprot_err (resp
.stat
);
570 *outname
= strdup (resp
.peer
);
571 xdr_free ((xdrproc_t
) xdr_ypresp_master
, (char *) &resp
);
573 return *outname
== NULL
? YPERR_YPERR
: YPERR_SUCCESS
;
577 yp_order (const char *indomain
, const char *inmap
, unsigned int *outorder
)
579 struct ypreq_nokey req
;
580 struct ypresp_order resp
;
581 enum clnt_stat result
;
583 if (indomain
== NULL
|| indomain
[0] == '\0' ||
584 inmap
== NULL
|| inmap
== '\0')
585 return YPERR_BADARGS
;
587 req
.domain
= (char *) indomain
;
588 req
.map
= (char *) inmap
;
590 memset (&resp
, '\0', sizeof (resp
));
592 result
= do_ypcall (indomain
, YPPROC_ORDER
, (xdrproc_t
) xdr_ypreq_nokey
,
593 (caddr_t
) & req
, (xdrproc_t
) xdr_ypresp_order
, (caddr_t
) & resp
);
595 if (result
!= YPERR_SUCCESS
)
597 if (resp
.stat
!= YP_TRUE
)
598 return ypprot_err (resp
.stat
);
600 *outorder
= resp
.ordernum
;
601 xdr_free ((xdrproc_t
) xdr_ypresp_order
, (char *) &resp
);
603 return YPERR_SUCCESS
;
606 static void *ypall_data
;
607 static int (*ypall_foreach
) __P ((int status
, char *key
, int keylen
,
608 char *val
, int vallen
, char *data
));
611 __xdr_ypresp_all (XDR
* xdrs
, u_long
* objp
)
615 struct ypresp_all resp
;
617 memset (&resp
, '\0', sizeof (struct ypresp_all
));
618 if (!xdr_ypresp_all (xdrs
, &resp
))
620 xdr_free ((xdrproc_t
) xdr_ypresp_all
, (char *) &resp
);
626 xdr_free ((xdrproc_t
) xdr_ypresp_all
, (char *) &resp
);
631 switch (resp
.ypresp_all_u
.val
.stat
)
635 char key
[resp
.ypresp_all_u
.val
.key
.keydat_len
+ 1];
636 char val
[resp
.ypresp_all_u
.val
.val
.valdat_len
+ 1];
637 int keylen
= resp
.ypresp_all_u
.val
.key
.keydat_len
;
638 int vallen
= resp
.ypresp_all_u
.val
.val
.valdat_len
;
641 memcpy (key
, resp
.ypresp_all_u
.val
.key
.keydat_val
, keylen
);
643 memcpy (val
, resp
.ypresp_all_u
.val
.val
.valdat_val
, vallen
);
645 xdr_free ((xdrproc_t
) xdr_ypresp_all
, (char *) &resp
);
646 if ((*ypall_foreach
) (*objp
, key
, keylen
,
647 val
, vallen
, ypall_data
))
653 xdr_free ((xdrproc_t
) xdr_ypresp_all
, (char *) &resp
);
657 *objp
= resp
.ypresp_all_u
.val
.stat
;
658 xdr_free ((xdrproc_t
) xdr_ypresp_all
, (char *) &resp
);
665 yp_all (const char *indomain
, const char *inmap
,
666 const struct ypall_callback
*incallback
)
668 struct ypreq_nokey req
;
669 dom_binding
*ydb
= NULL
;
671 enum clnt_stat result
;
672 struct sockaddr_in clnt_sin
;
674 unsigned long status
;
676 int saved_errno
= errno
;
678 if (indomain
== NULL
|| indomain
[0] == '\0' ||
679 inmap
== NULL
|| inmap
== '\0')
680 return YPERR_BADARGS
;
685 while (try < MAXTRIES
&& res
!= YPERR_SUCCESS
)
687 if (__yp_bind (indomain
, &ydb
) != 0)
689 __set_errno (saved_errno
);
693 /* YPPROC_ALL get its own TCP channel to ypserv */
694 clnt_sock
= RPC_ANYSOCK
;
695 clnt_sin
= ydb
->dom_server_addr
;
696 clnt_sin
.sin_port
= 0;
697 clnt
= clnttcp_create (&clnt_sin
, YPPROG
, YPVERS
, &clnt_sock
, 0, 0);
700 __set_errno (saved_errno
);
703 req
.domain
= (char *) indomain
;
704 req
.map
= (char *) inmap
;
706 ypall_foreach
= incallback
->foreach
;
707 ypall_data
= (void *) incallback
->data
;
709 result
= clnt_call (clnt
, YPPROC_ALL
, (xdrproc_t
) xdr_ypreq_nokey
,
710 (caddr_t
) &req
, (xdrproc_t
) __xdr_ypresp_all
,
711 (caddr_t
) &status
, RPCTIMEOUT
);
713 if (result
!= RPC_SUCCESS
)
715 clnt_perror (clnt
, "yp_all: clnt_call");
724 if (status
!= YP_NOMORE
)
726 __set_errno (saved_errno
);
727 return ypprot_err (status
);
732 __set_errno (saved_errno
);
738 yp_maplist (const char *indomain
, struct ypmaplist
**outmaplist
)
740 struct ypresp_maplist resp
;
741 enum clnt_stat result
;
743 if (indomain
== NULL
|| indomain
[0] == '\0')
744 return YPERR_BADARGS
;
746 memset (&resp
, '\0', sizeof (resp
));
748 result
= do_ypcall (indomain
, YPPROC_MAPLIST
, (xdrproc_t
) xdr_domainname
,
749 (caddr_t
) & indomain
, (xdrproc_t
) xdr_ypresp_maplist
, (caddr_t
) & resp
);
751 if (result
!= YPERR_SUCCESS
)
753 if (resp
.stat
!= YP_TRUE
)
754 return ypprot_err (resp
.stat
);
756 *outmaplist
= resp
.maps
;
757 /* We give the list not free, this will be done by ypserv
758 xdr_free((xdrproc_t)xdr_ypresp_maplist, (char *)&resp); */
760 return YPERR_SUCCESS
;
764 yperr_string (const int error
)
771 return _("Request arguments bad");
773 return _("RPC failure on NIS operation");
775 return _("Can't bind to server which serves this domain");
777 return _("No such map in server's domain");
779 return _("No such key in map");
781 return _("Internal NIS error");
783 return _("Local resource allocation failure");
785 return _("No more records in map database");
787 return _("Can't communicate with portmapper");
789 return _("Can't communicate with ypbind");
791 return _("Can't communicate with ypserv");
793 return _("Local domain name not set");
795 return _("NIS map database is bad");
797 return _("NIS client/server version mismatch - can't supply service");
799 return _("Permission denied");
801 return _("Database is busy");
803 return _("Unknown NIS error code");
807 ypprot_err (const int code
)
812 return YPERR_SUCCESS
;
830 return YPERR_BADARGS
;
838 ypbinderr_string (const int error
)
845 return _("Internal ypbind error");
846 case YPBIND_ERR_NOSERV
:
847 return _("Domain not bound");
848 case YPBIND_ERR_RESC
:
849 return _("System resource allocation failure");
851 return _("Unknown ypbind error");
859 yp_update (char *domain
, char *map
, unsigned ypop
,
860 char *key
, int keylen
, char *data
, int datalen
)
864 ypupdate_args update_args
;
865 ypdelete_args delete_args
;
868 xdrproc_t xdr_argument
;
872 struct sockaddr saddr
;
873 char servername
[MAXNETNAMELEN
+ 1];
876 if (!domain
|| !map
|| !key
|| (ypop
!= YPOP_DELETE
&& !data
))
877 return YPERR_BADARGS
;
879 args
.update_args
.mapname
= map
;
880 args
.update_args
.key
.yp_buf_len
= keylen
;
881 args
.update_args
.key
.yp_buf_val
= key
;
882 args
.update_args
.datum
.yp_buf_len
= datalen
;
883 args
.update_args
.datum
.yp_buf_val
= data
;
885 if ((r
= yp_master (domain
, map
, &master
)) != 0)
888 if (!host2netname (servername
, master
, domain
))
890 fputs (_("yp_update: cannot convert host to netname\n"), stderr
);
894 if ((clnt
= clnt_create (master
, YPU_PROG
, YPU_VERS
, "tcp")) == NULL
)
896 clnt_pcreateerror ("yp_update: clnt_create");
900 if (!clnt_control (clnt
, CLGET_SERVER_ADDR
, (char *) &saddr
))
902 fputs (_("yp_update: cannot get server address\n"), stderr
);
911 xdr_argument
= (xdrproc_t
) xdr_ypupdate_args
;
914 xdr_argument
= (xdrproc_t
) xdr_ypdelete_args
;
917 return YPERR_BADARGS
;
921 clnt
->cl_auth
= authdes_create (servername
, WINDOW
, &saddr
, NULL
);
923 if (clnt
->cl_auth
== NULL
)
924 clnt
->cl_auth
= authunix_create_default ();
927 r
= clnt_call (clnt
, ypop
, xdr_argument
, (caddr_t
) &args
,
928 (xdrproc_t
) xdr_u_int
, (caddr_t
) &res
, RPCTIMEOUT
);
930 if (r
== RPC_AUTHERROR
)
932 if (clnt
->cl_auth
->ah_cred
.oa_flavor
== AUTH_DES
)
934 clnt
->cl_auth
= authunix_create_default ();
940 if (r
!= RPC_SUCCESS
)
942 clnt_perror (clnt
, "yp_update: clnt_call");