No empty .Rs/.Re
[netbsd-mini2440.git] / crypto / dist / heimdal / lib / kadm5 / init_s.c
blob00cba1701a62bf8a363f9c9a40b66d86787a06df
1 /*
2 * Copyright (c) 1997 - 2000 Kungliga Tekniska Högskolan
3 * (Royal Institute of Technology, Stockholm, Sweden).
4 * All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * 3. Neither the name of the Institute nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
34 #include "kadm5_locl.h"
36 __RCSID("$Heimdal: init_s.c 9441 2000-12-31 08:01:16Z assar $"
37 "$NetBSD$");
40 static kadm5_ret_t
41 kadm5_s_init_with_context(krb5_context context,
42 const char *client_name,
43 const char *service_name,
44 kadm5_config_params *realm_params,
45 unsigned long struct_version,
46 unsigned long api_version,
47 void **server_handle)
49 kadm5_ret_t ret;
50 kadm5_server_context *ctx;
51 ret = _kadm5_s_init_context(&ctx, realm_params, context);
52 if(ret)
53 return ret;
55 assert(ctx->config.dbname != NULL);
56 assert(ctx->config.stash_file != NULL);
57 assert(ctx->config.acl_file != NULL);
58 assert(ctx->log_context.log_file != NULL);
59 assert(ctx->log_context.socket_name.sun_path[0] != '\0');
61 ret = hdb_create(ctx->context, &ctx->db, ctx->config.dbname);
62 if(ret)
63 return ret;
64 ret = hdb_set_master_keyfile (ctx->context,
65 ctx->db, ctx->config.stash_file);
66 if(ret)
67 return ret;
69 ctx->log_context.log_fd = -1;
71 ctx->log_context.socket_fd = socket (AF_UNIX, SOCK_DGRAM, 0);
73 ret = krb5_parse_name(ctx->context, client_name, &ctx->caller);
74 if(ret)
75 return ret;
77 ret = _kadm5_acl_init(ctx);
78 if(ret)
79 return ret;
81 *server_handle = ctx;
82 return 0;
85 kadm5_ret_t
86 kadm5_s_init_with_password_ctx(krb5_context context,
87 const char *client_name,
88 const char *password,
89 const char *service_name,
90 kadm5_config_params *realm_params,
91 unsigned long struct_version,
92 unsigned long api_version,
93 void **server_handle)
95 return kadm5_s_init_with_context(context,
96 client_name,
97 service_name,
98 realm_params,
99 struct_version,
100 api_version,
101 server_handle);
104 kadm5_ret_t
105 kadm5_s_init_with_password(const char *client_name,
106 const char *password,
107 const char *service_name,
108 kadm5_config_params *realm_params,
109 unsigned long struct_version,
110 unsigned long api_version,
111 void **server_handle)
113 krb5_context context;
114 kadm5_ret_t ret;
115 kadm5_server_context *ctx;
117 ret = krb5_init_context(&context);
118 if (ret)
119 return ret;
120 ret = kadm5_s_init_with_password_ctx(context,
121 client_name,
122 password,
123 service_name,
124 realm_params,
125 struct_version,
126 api_version,
127 server_handle);
128 if(ret){
129 krb5_free_context(context);
130 return ret;
132 ctx = *server_handle;
133 ctx->my_context = 1;
134 return 0;
137 kadm5_ret_t
138 kadm5_s_init_with_skey_ctx(krb5_context context,
139 const char *client_name,
140 const char *keytab,
141 const char *service_name,
142 kadm5_config_params *realm_params,
143 unsigned long struct_version,
144 unsigned long api_version,
145 void **server_handle)
147 return kadm5_s_init_with_context(context,
148 client_name,
149 service_name,
150 realm_params,
151 struct_version,
152 api_version,
153 server_handle);
156 kadm5_ret_t
157 kadm5_s_init_with_skey(const char *client_name,
158 const char *keytab,
159 const char *service_name,
160 kadm5_config_params *realm_params,
161 unsigned long struct_version,
162 unsigned long api_version,
163 void **server_handle)
165 krb5_context context;
166 kadm5_ret_t ret;
167 kadm5_server_context *ctx;
169 ret = krb5_init_context(&context);
170 if (ret)
171 return ret;
172 ret = kadm5_s_init_with_skey_ctx(context,
173 client_name,
174 keytab,
175 service_name,
176 realm_params,
177 struct_version,
178 api_version,
179 server_handle);
180 if(ret){
181 krb5_free_context(context);
182 return ret;
184 ctx = *server_handle;
185 ctx->my_context = 1;
186 return 0;
189 kadm5_ret_t
190 kadm5_s_init_with_creds_ctx(krb5_context context,
191 const char *client_name,
192 krb5_ccache ccache,
193 const char *service_name,
194 kadm5_config_params *realm_params,
195 unsigned long struct_version,
196 unsigned long api_version,
197 void **server_handle)
199 return kadm5_s_init_with_context(context,
200 client_name,
201 service_name,
202 realm_params,
203 struct_version,
204 api_version,
205 server_handle);
208 kadm5_ret_t
209 kadm5_s_init_with_creds(const char *client_name,
210 krb5_ccache ccache,
211 const char *service_name,
212 kadm5_config_params *realm_params,
213 unsigned long struct_version,
214 unsigned long api_version,
215 void **server_handle)
217 krb5_context context;
218 kadm5_ret_t ret;
219 kadm5_server_context *ctx;
221 ret = krb5_init_context(&context);
222 if (ret)
223 return ret;
224 ret = kadm5_s_init_with_creds_ctx(context,
225 client_name,
226 ccache,
227 service_name,
228 realm_params,
229 struct_version,
230 api_version,
231 server_handle);
232 if(ret){
233 krb5_free_context(context);
234 return ret;
236 ctx = *server_handle;
237 ctx->my_context = 1;
238 return 0;