1 /* $NetBSD: init_s.c,v 1.1.1.2 2014/04/24 12:45:48 pettai Exp $ */
4 * Copyright (c) 1997 - 2000 Kungliga Tekniska Högskolan
5 * (Royal Institute of Technology, Stockholm, Sweden).
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * 3. Neither the name of the Institute nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 #include "kadm5_locl.h"
42 kadm5_s_init_with_context(krb5_context context
,
43 const char *client_name
,
44 const char *service_name
,
45 kadm5_config_params
*realm_params
,
46 unsigned long struct_version
,
47 unsigned long api_version
,
51 kadm5_server_context
*ctx
;
52 ret
= _kadm5_s_init_context(&ctx
, realm_params
, context
);
56 assert(ctx
->config
.dbname
!= NULL
);
57 assert(ctx
->config
.stash_file
!= NULL
);
58 assert(ctx
->config
.acl_file
!= NULL
);
59 assert(ctx
->log_context
.log_file
!= NULL
);
60 #ifndef NO_UNIX_SOCKETS
61 assert(ctx
->log_context
.socket_name
.sun_path
[0] != '\0');
63 assert(ctx
->log_context
.socket_info
!= NULL
);
66 ret
= hdb_create(ctx
->context
, &ctx
->db
, ctx
->config
.dbname
);
69 ret
= hdb_set_master_keyfile (ctx
->context
,
70 ctx
->db
, ctx
->config
.stash_file
);
74 ctx
->log_context
.log_fd
= -1;
76 #ifndef NO_UNIX_SOCKETS
77 ctx
->log_context
.socket_fd
= socket (AF_UNIX
, SOCK_DGRAM
, 0);
79 ctx
->log_context
.socket_fd
= socket (ctx
->log_context
.socket_info
->ai_family
,
80 ctx
->log_context
.socket_info
->ai_socktype
,
81 ctx
->log_context
.socket_info
->ai_protocol
);
84 ret
= krb5_parse_name(ctx
->context
, client_name
, &ctx
->caller
);
88 ret
= _kadm5_acl_init(ctx
);
97 kadm5_s_init_with_password_ctx(krb5_context context
,
98 const char *client_name
,
100 const char *service_name
,
101 kadm5_config_params
*realm_params
,
102 unsigned long struct_version
,
103 unsigned long api_version
,
104 void **server_handle
)
106 return kadm5_s_init_with_context(context
,
116 kadm5_s_init_with_password(const char *client_name
,
117 const char *password
,
118 const char *service_name
,
119 kadm5_config_params
*realm_params
,
120 unsigned long struct_version
,
121 unsigned long api_version
,
122 void **server_handle
)
124 krb5_context context
;
126 kadm5_server_context
*ctx
;
128 ret
= krb5_init_context(&context
);
131 ret
= kadm5_s_init_with_password_ctx(context
,
140 krb5_free_context(context
);
143 ctx
= *server_handle
;
149 kadm5_s_init_with_skey_ctx(krb5_context context
,
150 const char *client_name
,
152 const char *service_name
,
153 kadm5_config_params
*realm_params
,
154 unsigned long struct_version
,
155 unsigned long api_version
,
156 void **server_handle
)
158 return kadm5_s_init_with_context(context
,
168 kadm5_s_init_with_skey(const char *client_name
,
170 const char *service_name
,
171 kadm5_config_params
*realm_params
,
172 unsigned long struct_version
,
173 unsigned long api_version
,
174 void **server_handle
)
176 krb5_context context
;
178 kadm5_server_context
*ctx
;
180 ret
= krb5_init_context(&context
);
183 ret
= kadm5_s_init_with_skey_ctx(context
,
192 krb5_free_context(context
);
195 ctx
= *server_handle
;
201 kadm5_s_init_with_creds_ctx(krb5_context context
,
202 const char *client_name
,
204 const char *service_name
,
205 kadm5_config_params
*realm_params
,
206 unsigned long struct_version
,
207 unsigned long api_version
,
208 void **server_handle
)
210 return kadm5_s_init_with_context(context
,
220 kadm5_s_init_with_creds(const char *client_name
,
222 const char *service_name
,
223 kadm5_config_params
*realm_params
,
224 unsigned long struct_version
,
225 unsigned long api_version
,
226 void **server_handle
)
228 krb5_context context
;
230 kadm5_server_context
*ctx
;
232 ret
= krb5_init_context(&context
);
235 ret
= kadm5_s_init_with_creds_ctx(context
,
244 krb5_free_context(context
);
247 ctx
= *server_handle
;