xref: /titanic_51/usr/src/cmd/krb5/kwarn/kwarnd_clnt_stubs.c (revision fe54a78e1aacf39261ad56e9903bce02e3fb6d21)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #pragma ident	"%Z%%M%	%I%	%E% SMI"
28 
29 /*
30  *  stub module for kwarnd.
31  */
32 
33 #include <stdio.h>
34 #include <stdlib.h>
35 #include "kwarnd.h"
36 #include <rpc/rpc.h>
37 
38 #include <sys/types.h>
39 #include <sys/devops.h>
40 #include <sys/open.h>
41 #include <sys/stat.h>
42 #include <sys/conf.h>
43 #include <sys/ddi.h>
44 #include <sys/sunddi.h>
45 #include <sys/uio.h>
46 #include <syslog.h>
47 
48 CLIENT  *clnt, *getkwarnd_handle(void);
49 
50 OM_UINT32
51 kwarn_add_warning(WARNING_NAME_T warning_name, int cred_exp_time)
52 {
53 	kwarn_add_warning_arg args;
54 	kwarn_add_warning_res res;
55 
56 	/* check the input/output parameters */
57 	if (warning_name == NULL || cred_exp_time == 0)
58 		return (1);
59 
60 	/* get the client handle to kwarnd */
61 	if ((clnt = getkwarnd_handle()) == NULL) {
62 		/*
63 		 * Let app output if an error occurs but we'll syslog to
64 		 * DEBUG to get error details if needed.
65 		 */
66 		syslog(LOG_DEBUG, "%s",
67 		    clnt_spcreateerror("getkwarnd_handle"));
68 		return (1);
69 	}
70 
71 	/* set the rpc parameters */
72 	args.cred_exp_time = cred_exp_time;
73 	args.warning_name = warning_name;
74 
75 	/* call the remote procedure */
76 	memset(&res, 0, sizeof (res));
77 	if (kwarn_add_warning_1(&args, &res, clnt) != RPC_SUCCESS) {
78 		return (1);
79 	}
80 
81 	/* nothing to free */
82 
83 	return (res.status);
84 }
85 
86 OM_UINT32
87 kwarn_del_warning(WARNING_NAME_T warning_name)
88 {
89 	kwarn_del_warning_arg args;
90 	kwarn_del_warning_res res;
91 
92 
93 	/* check the output parameters */
94 	if (warning_name == NULL)
95 		return (1);
96 
97 	/* get the client GSSD handle */
98 	if ((clnt = getkwarnd_handle()) == NULL) {
99 		/*
100 		 * Let app output if an error occurs but we'll syslog to
101 		 * DEBUG to get error details if needed.
102 		 */
103 		syslog(LOG_DEBUG, "%s",
104 		    clnt_spcreateerror("getkwarnd_handle"));
105 		return (1);
106 	}
107 
108 	/* set the input parameters */
109 	args.warning_name = warning_name;
110 
111 	/* call the remote procedure */
112 	memset(&res, 0, sizeof (res));
113 	if (kwarn_del_warning_1(&args, &res, clnt) != RPC_SUCCESS) {
114 		return (1);
115 	}
116 
117 	/* nothing to free */
118 
119 	return (res.status);
120 }
121