4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
24 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
25 * Use is subject to license terms.
28 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
29 /* All Rights Reserved */
32 * Portions of this source code were derived from Berkeley
33 * under license from the Regents of the University of
37 #pragma ident "%Z%%M% %I% %E% SMI"
40 * YP updater interface
46 #include <rpcsvc/ypclnt.h>
47 #include <rpcsvc/ypupd.h>
48 #include <sys/types.h>
51 #define WINDOW (60*60)
52 #define TOTAL_TIMEOUT 300
56 #define debug(msg) (void) fprintf(stderr, "%s\n", msg);
61 extern AUTH
*authdes_seccreate();
64 yp_update(char *domain
, char *map
, unsigned op
, char *key
, int keylen
,
65 char *data
, int datalen
)
67 struct ypupdate_args args
;
72 char ypmastername
[MAXNETNAMELEN
+1];
90 return (YPERR_BADARGS
);
92 if (yp_master(domain
, map
, &ypmaster
) != 0) {
93 debug("no master found");
97 client
= clnt_create(ypmaster
, YPU_PROG
, YPU_VERS
, "circuit_n");
102 clnt_pcreateerror("client create failed");
109 if (!host2netname(ypmastername
, ypmaster
, domain
)) {
110 clnt_destroy(client
);
112 return (YPERR_BADARGS
);
114 client
->cl_auth
= authdes_seccreate(ypmastername
, WINDOW
,
117 if (client
->cl_auth
== NULL
) {
118 debug("auth create failed");
119 clnt_destroy(client
);
124 args
.key
.yp_buf_len
= keylen
;
125 args
.key
.yp_buf_val
= key
;
126 args
.datum
.yp_buf_len
= datalen
;
127 args
.datum
.yp_buf_val
= data
;
129 total
.tv_sec
= TOTAL_TIMEOUT
;
131 clnt_control(client
, CLSET_TIMEOUT
, (char *)&total
);
132 stat
= clnt_call(client
, proc
,
133 xdr_ypupdate_args
, (char *)&args
,
134 xdr_u_int
, (char *)&rslt
, total
);
136 if (stat
!= RPC_SUCCESS
) {
138 debug("ypupdate RPC call failed");
141 clnt_perror(client
, "ypupdate call failed");
145 auth_destroy(client
->cl_auth
);
146 clnt_destroy(client
);