1 /* $NetBSD: kcm_locl.h,v 1.1.1.2 2011/04/14 14:08:11 elric Exp $ */
4 * Copyright (c) 2005, PADL Software Pty Ltd.
7 * Portions Copyright (c) 2009 Apple Inc. All rights reserved.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
20 * 3. Neither the name of PADL Software nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY PADL SOFTWARE AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL PADL SOFTWARE OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
41 #ifndef __KCM_LOCL_H__
42 #define __KCM_LOCL_H__
48 #define KCM_LOG_REQUEST(_context, _client, _opcode) do { \
49 kcm_log(1, "%s request by process %d/uid %d", \
50 kcm_op2string(_opcode), (_client)->pid, (_client)->uid); \
53 #define KCM_LOG_REQUEST_NAME(_context, _client, _opcode, _name) do { \
54 kcm_log(1, "%s request for cache %s by process %d/uid %d", \
55 kcm_op2string(_opcode), (_name), (_client)->pid, (_client)->uid); \
58 /* Cache management */
60 #define KCM_FLAGS_VALID 0x0001
61 #define KCM_FLAGS_USE_KEYTAB 0x0002
62 #define KCM_FLAGS_RENEWABLE 0x0004
63 #define KCM_FLAGS_OWNER_IS_SYSTEM 0x0008
64 #define KCM_FLAGS_USE_CACHED_KEY 0x0010
66 #define KCM_MASK_KEY_PRESENT ( KCM_FLAGS_USE_KEYTAB | \
67 KCM_FLAGS_USE_CACHED_KEY )
69 struct kcm_ccache_data
;
72 struct kcm_default_cache
{
74 pid_t session
; /* really au_asid_t */
76 struct kcm_default_cache
*next
;
79 extern struct kcm_default_cache
*default_caches
;
84 struct kcm_creds
*next
;
87 typedef struct kcm_ccache_data
{
95 pid_t session
; /* really au_asid_t */
96 krb5_principal client
; /* primary client principal */
97 krb5_principal server
; /* primary server principal (TGS if NULL) */
98 struct kcm_creds
*creds
;
100 krb5_deltat renew_life
;
104 krb5_keyblock keyblock
;
107 struct kcm_ccache_data
*next
;
110 #define KCM_ASSERT_VALID(_ccache) do { \
111 if (((_ccache)->flags & KCM_FLAGS_VALID) == 0) \
112 krb5_abortx(context, "kcm_free_ccache_data: ccache invalid"); \
113 else if ((_ccache)->refcnt == 0) \
114 krb5_abortx(context, "kcm_free_ccache_data: ccache refcnt == 0"); \
117 typedef kcm_ccache_data
*kcm_ccache
;
119 /* Event management */
121 typedef struct kcm_event
{
129 KCM_EVENT_ACQUIRE_CREDS
,
130 KCM_EVENT_RENEW_CREDS
,
131 KCM_EVENT_DESTROY_CREDS
,
132 KCM_EVENT_DESTROY_EMPTY_CACHE
135 struct kcm_event
*next
;
138 /* wakeup interval for event queue */
139 #define KCM_EVENT_QUEUE_INTERVAL 60
140 #define KCM_EVENT_DEFAULT_BACKOFF_TIME 5
141 #define KCM_EVENT_MAX_BACKOFF_TIME (12 * 60 * 60)
144 /* Request format is LENGTH | MAJOR | MINOR | OPERATION | request */
145 /* Response format is LENGTH | STATUS | response */
147 typedef struct kcm_client
{
154 #define CLIENT_IS_ROOT(client) ((client)->uid == 0)
157 /* passed in OPERATION | ... ; returns STATUS | ... */
158 typedef krb5_error_code (*kcm_method
)(krb5_context
, kcm_client
*, kcm_operation
, krb5_storage
*, krb5_storage
*);
165 #define DEFAULT_LOG_DEST "0/FILE:" LOCALSTATEDIR "/log/kcmd.log"
166 #define _PATH_KCM_CONF SYSCONFDIR "/kcm.conf"
168 extern krb5_context kcm_context
;
169 extern char *socket_path
;
170 extern char *door_path
;
171 extern size_t max_request
;
172 extern sig_atomic_t exit_flag
;
173 extern int name_constraints
;
174 #ifdef SUPPORT_DETACH
175 extern int detach_from_console
;
177 extern int launchd_flag
;
178 extern int disallow_getting_krbtgt
;
181 extern const krb5_cc_ops krb5_kcmss_ops
;
184 void kcm_service(void *, const heim_idata
*, const heim_icred
,
185 heim_ipc_complete
, heim_sipc_call
);
187 #include <krb5/kcm-protos.h>
189 #endif /* __KCM_LOCL_H__ */