10Sstevel@tonic-gate /*
26536Sgtb * CDDL HEADER START
36536Sgtb *
46536Sgtb * The contents of this file are subject to the terms of the
56536Sgtb * Common Development and Distribution License (the "License").
66536Sgtb * You may not use this file except in compliance with the License.
76536Sgtb *
86536Sgtb * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
96536Sgtb * or http://www.opensolaris.org/os/licensing.
106536Sgtb * See the License for the specific language governing permissions
116536Sgtb * and limitations under the License.
126536Sgtb *
136536Sgtb * When distributing Covered Code, include this CDDL HEADER in each
146536Sgtb * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
156536Sgtb * If applicable, add the following below this CDDL HEADER, with the
166536Sgtb * fields enclosed by brackets "[]" replaced with your own identifying
176536Sgtb * information: Portions Copyright [yyyy] [name of copyright owner]
186536Sgtb *
196536Sgtb * CDDL HEADER END
206536Sgtb */
216536Sgtb
226536Sgtb /*
236536Sgtb * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
246536Sgtb * Use is subject to license terms.
250Sstevel@tonic-gate */
260Sstevel@tonic-gate
270Sstevel@tonic-gate /*
280Sstevel@tonic-gate * stub module for kwarnd.
290Sstevel@tonic-gate */
300Sstevel@tonic-gate
310Sstevel@tonic-gate #include <stdio.h>
320Sstevel@tonic-gate #include <stdlib.h>
330Sstevel@tonic-gate #include "kwarnd.h"
340Sstevel@tonic-gate #include <rpc/rpc.h>
350Sstevel@tonic-gate
360Sstevel@tonic-gate #include <sys/types.h>
370Sstevel@tonic-gate #include <sys/devops.h>
380Sstevel@tonic-gate #include <sys/open.h>
390Sstevel@tonic-gate #include <sys/stat.h>
400Sstevel@tonic-gate #include <sys/conf.h>
410Sstevel@tonic-gate #include <sys/ddi.h>
420Sstevel@tonic-gate #include <sys/sunddi.h>
430Sstevel@tonic-gate #include <sys/uio.h>
446536Sgtb #include <syslog.h>
450Sstevel@tonic-gate
46*8438SShawn.Emery@Sun.COM extern CLIENT *getkwarnd_handle(void);
47*8438SShawn.Emery@Sun.COM extern void resetkwarnd_handle(void);
480Sstevel@tonic-gate
490Sstevel@tonic-gate OM_UINT32
kwarn_add_warning(WARNING_NAME_T warning_name,int cred_exp_time)500Sstevel@tonic-gate kwarn_add_warning(WARNING_NAME_T warning_name, int cred_exp_time)
510Sstevel@tonic-gate {
520Sstevel@tonic-gate kwarn_add_warning_arg args;
530Sstevel@tonic-gate kwarn_add_warning_res res;
54*8438SShawn.Emery@Sun.COM enum clnt_stat ret;
55*8438SShawn.Emery@Sun.COM boolean_t first = TRUE;
56*8438SShawn.Emery@Sun.COM CLIENT *clnt;
570Sstevel@tonic-gate
580Sstevel@tonic-gate /* check the input/output parameters */
590Sstevel@tonic-gate if (warning_name == NULL || cred_exp_time == 0)
600Sstevel@tonic-gate return (1);
610Sstevel@tonic-gate
62*8438SShawn.Emery@Sun.COM rebind:
630Sstevel@tonic-gate /* get the client handle to kwarnd */
640Sstevel@tonic-gate if ((clnt = getkwarnd_handle()) == NULL) {
656536Sgtb /*
666536Sgtb * Let app output if an error occurs but we'll syslog to
676536Sgtb * DEBUG to get error details if needed.
686536Sgtb */
696536Sgtb syslog(LOG_DEBUG, "%s",
706536Sgtb clnt_spcreateerror("getkwarnd_handle"));
710Sstevel@tonic-gate return (1);
720Sstevel@tonic-gate }
730Sstevel@tonic-gate
740Sstevel@tonic-gate /* set the rpc parameters */
750Sstevel@tonic-gate args.cred_exp_time = cred_exp_time;
760Sstevel@tonic-gate args.warning_name = warning_name;
770Sstevel@tonic-gate
780Sstevel@tonic-gate /* call the remote procedure */
790Sstevel@tonic-gate memset(&res, 0, sizeof (res));
80*8438SShawn.Emery@Sun.COM ret = kwarn_add_warning_1(&args, &res, clnt);
81*8438SShawn.Emery@Sun.COM if (ret != RPC_SUCCESS) {
82*8438SShawn.Emery@Sun.COM /*
83*8438SShawn.Emery@Sun.COM * Could have timed out due to the process restarting for
84*8438SShawn.Emery@Sun.COM * various reasons. Should attempt to rebind in the case
85*8438SShawn.Emery@Sun.COM * process is actually running.
86*8438SShawn.Emery@Sun.COM */
87*8438SShawn.Emery@Sun.COM if (ret == RPC_TIMEDOUT && first) {
88*8438SShawn.Emery@Sun.COM resetkwarnd_handle();
89*8438SShawn.Emery@Sun.COM first = FALSE;
90*8438SShawn.Emery@Sun.COM goto rebind;
91*8438SShawn.Emery@Sun.COM }
920Sstevel@tonic-gate return (1);
930Sstevel@tonic-gate }
940Sstevel@tonic-gate
950Sstevel@tonic-gate /* nothing to free */
960Sstevel@tonic-gate
970Sstevel@tonic-gate return (res.status);
980Sstevel@tonic-gate }
990Sstevel@tonic-gate
1000Sstevel@tonic-gate OM_UINT32
kwarn_del_warning(WARNING_NAME_T warning_name)1010Sstevel@tonic-gate kwarn_del_warning(WARNING_NAME_T warning_name)
1020Sstevel@tonic-gate {
1030Sstevel@tonic-gate kwarn_del_warning_arg args;
1040Sstevel@tonic-gate kwarn_del_warning_res res;
105*8438SShawn.Emery@Sun.COM enum clnt_stat ret;
106*8438SShawn.Emery@Sun.COM boolean_t first = TRUE;
107*8438SShawn.Emery@Sun.COM CLIENT *clnt;
1080Sstevel@tonic-gate
1090Sstevel@tonic-gate /* check the output parameters */
1100Sstevel@tonic-gate if (warning_name == NULL)
1110Sstevel@tonic-gate return (1);
1120Sstevel@tonic-gate
113*8438SShawn.Emery@Sun.COM rebind:
1140Sstevel@tonic-gate /* get the client GSSD handle */
1150Sstevel@tonic-gate if ((clnt = getkwarnd_handle()) == NULL) {
1166536Sgtb /*
1176536Sgtb * Let app output if an error occurs but we'll syslog to
1186536Sgtb * DEBUG to get error details if needed.
1196536Sgtb */
1206536Sgtb syslog(LOG_DEBUG, "%s",
1216536Sgtb clnt_spcreateerror("getkwarnd_handle"));
1220Sstevel@tonic-gate return (1);
1230Sstevel@tonic-gate }
1240Sstevel@tonic-gate
1250Sstevel@tonic-gate /* set the input parameters */
1260Sstevel@tonic-gate args.warning_name = warning_name;
1270Sstevel@tonic-gate
1280Sstevel@tonic-gate /* call the remote procedure */
1290Sstevel@tonic-gate memset(&res, 0, sizeof (res));
130*8438SShawn.Emery@Sun.COM ret = kwarn_del_warning_1(&args, &res, clnt);
131*8438SShawn.Emery@Sun.COM if (ret != RPC_SUCCESS) {
132*8438SShawn.Emery@Sun.COM /*
133*8438SShawn.Emery@Sun.COM * Could have timed out due to the process restarting for
134*8438SShawn.Emery@Sun.COM * various reasons. Should attempt to rebind in the case
135*8438SShawn.Emery@Sun.COM * process is actually running.
136*8438SShawn.Emery@Sun.COM */
137*8438SShawn.Emery@Sun.COM if (ret == RPC_TIMEDOUT && first) {
138*8438SShawn.Emery@Sun.COM resetkwarnd_handle();
139*8438SShawn.Emery@Sun.COM first = FALSE;
140*8438SShawn.Emery@Sun.COM goto rebind;
141*8438SShawn.Emery@Sun.COM }
1420Sstevel@tonic-gate return (1);
1430Sstevel@tonic-gate }
1440Sstevel@tonic-gate
1450Sstevel@tonic-gate /* nothing to free */
1460Sstevel@tonic-gate
1470Sstevel@tonic-gate return (res.status);
1480Sstevel@tonic-gate }
149