| 1 | /* |
| 2 | * Copyright (c) 2005, PADL Software Pty Ltd. |
| 3 | * All rights reserved. |
| 4 | * |
| 5 | * Portions Copyright (c) 2009 Apple Inc. All rights reserved. |
| 6 | * |
| 7 | * Redistribution and use in source and binary forms, with or without |
| 8 | * modification, are permitted provided that the following conditions |
| 9 | * are met: |
| 10 | * |
| 11 | * 1. Redistributions of source code must retain the above copyright |
| 12 | * notice, this list of conditions and the following disclaimer. |
| 13 | * |
| 14 | * 2. Redistributions in binary form must reproduce the above copyright |
| 15 | * notice, this list of conditions and the following disclaimer in the |
| 16 | * documentation and/or other materials provided with the distribution. |
| 17 | * |
| 18 | * 3. Neither the name of PADL Software nor the names of its contributors |
| 19 | * may be used to endorse or promote products derived from this software |
| 20 | * without specific prior written permission. |
| 21 | * |
| 22 | * THIS SOFTWARE IS PROVIDED BY PADL SOFTWARE AND CONTRIBUTORS ``AS IS'' AND |
| 23 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 25 | * ARE DISCLAIMED. IN NO EVENT SHALL PADL SOFTWARE OR CONTRIBUTORS BE LIABLE |
| 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 32 | * SUCH DAMAGE. |
| 33 | */ |
| 34 | |
| 35 | /* |
| 36 | * $Id$ |
| 37 | */ |
| 38 | |
| 39 | #ifndef __KCM_LOCL_H__ |
| 40 | #define __KCM_LOCL_H__cxx . . $ `kcm/kcm_locl.h:40:9`! |
| 41 | |
| 42 | #include "headers.h"cxx . . $ `<file>/kcm/headers.h`/ |
| 43 | |
| 44 | #include <kcm.h>cxx . . $ `<file>/lib/krb5/kcm.h`/ |
| 45 | |
| 46 | #define KCM_LOG_REQUESTcxx . . $ `kcm/kcm_locl.h:46:9`!(_context, _client, _opcode) do { \ |
| 47 | kcm_log(1, "%s request by process %d/uid %d", \ |
| 48 | kcm_op2string(_opcode), (_client)->pid, (_client)->uid); \ |
| 49 | } while (0) |
| 50 | |
| 51 | #define KCM_LOG_REQUEST_NAMEcxx . . $ `kcm/kcm_locl.h:51:9`!(_context, _client, _opcode, _name) do { \ |
| 52 | kcm_log(1, "%s request for cache %s by process %d/uid %d", \ |
| 53 | kcm_op2string(_opcode), (_name), (_client)->pid, (_client)->uid); \ |
| 54 | } while (0) |
| 55 | |
| 56 | /* Cache management */ |
| 57 | |
| 58 | #define KCM_FLAGS_VALIDcxx . . $ `kcm/kcm_locl.h:58:9`! 0x0001 |
| 59 | #define KCM_FLAGS_USE_KEYTABcxx . . $ `kcm/kcm_locl.h:59:9`! 0x0002 |
| 60 | #define KCM_FLAGS_RENEWABLEcxx . . $ `kcm/kcm_locl.h:60:9`! 0x0004 |
| 61 | #define KCM_FLAGS_OWNER_IS_SYSTEMcxx . . $ `kcm/kcm_locl.h:61:9`! 0x0008 |
| 62 | #define KCM_FLAGS_USE_CACHED_KEYcxx . . $ `kcm/kcm_locl.h:62:9`! 0x0010 |
| 63 | |
| 64 | #define KCM_MASK_KEY_PRESENTcxx . . $ `kcm/kcm_locl.h:64:9`! ( KCM_FLAGS_USE_KEYTAB | \ |
| 65 | KCM_FLAGS_USE_CACHED_KEY ) |
| 66 | |
| 67 | struct kcm_ccache_datacxx . . $ kcm_ccache_data#; |
| 68 | struct kcm_credscxx . . $ kcm_creds#; |
| 69 | |
| 70 | struct kcm_default_cachecxx . . $ kcm_default_cache# { |
| 71 | uid_tcxx . . $ uid_t# uidcxx . . $ kcm_default_cache#uid.; |
| 72 | pid_tcxx . . $ pid_t# sessioncxx . . $ kcm_default_cache#session.; /* really au_asid_t */ |
| 73 | char *namecxx . . $ kcm_default_cache#name.; |
| 74 | struct kcm_default_cachecxx . . $ kcm_default_cache# *nextcxx . . $ kcm_default_cache#next.; |
| 75 | }; |
| 76 | |
| 77 | extern struct kcm_default_cachecxx . . $ kcm_default_cache# *default_cachescxx . . $ default_caches.; |
| 78 | |
| 79 | struct kcm_credscxx . . $ kcm_creds# { |
| 80 | kcmuuid_tcxx . . $ kcmuuid_t# uuidcxx . . $ kcm_creds#uuid.; |
| 81 | krb5_credscxx . . $ krb5_creds# credcxx . . $ kcm_creds#cred.; |
| 82 | struct kcm_credscxx . . $ kcm_creds# *nextcxx . . $ kcm_creds#next.; |
| 83 | }; |
| 84 | |
| 85 | typedef struct kcm_ccache_datacxx . . $ kcm_ccache_data# { |
| 86 | char *namecxx . . $ kcm_ccache_data#name.; |
| 87 | kcmuuid_tcxx . . $ kcmuuid_t# uuidcxx . . $ kcm_ccache_data#uuid.; |
| 88 | unsigned refcntcxx . . $ kcm_ccache_data#refcnt.; |
| 89 | uint16_tcxx . . $ uint16_t# flagscxx . . $ kcm_ccache_data#flags.; |
| 90 | uint16_tcxx . . $ uint16_t# modecxx . . $ kcm_ccache_data#mode.; |
| 91 | uid_tcxx . . $ uid_t# uidcxx . . $ kcm_ccache_data#uid.; |
| 92 | gid_tcxx . . $ gid_t# gidcxx . . $ kcm_ccache_data#gid.; |
| 93 | pid_tcxx . . $ pid_t# sessioncxx . . $ kcm_ccache_data#session.; /* really au_asid_t */ |
| 94 | krb5_principalcxx . . $ krb5_principal# clientcxx . . $ kcm_ccache_data#client.; /* primary client principal */ |
| 95 | krb5_principalcxx . . $ krb5_principal# servercxx . . $ kcm_ccache_data#server.; /* primary server principal (TGS if NULL) */ |
| 96 | struct kcm_credscxx . . $ kcm_creds# *credscxx . . $ kcm_ccache_data#creds.; |
| 97 | krb5_deltatcxx . . $ krb5_deltat# tkt_lifecxx . . $ kcm_ccache_data#tkt_life.; |
| 98 | krb5_deltatcxx . . $ krb5_deltat# renew_lifecxx . . $ kcm_ccache_data#renew_life.; |
| 99 | int32_tcxx . . $ int32_t# kdc_offsetcxx . . $ kcm_ccache_data#kdc_offset.; |
| 100 | unioncxx . . $ kcm_ccache_data#$anonymous_type_0# { |
| 101 | krb5_keytabcxx . . $ krb5_keytab# keytabcxx . . $ kcm_ccache_data#$anonymous_type_0#keytab.; |
| 102 | krb5_keyblockcxx . . $ krb5_keyblock# keyblockcxx . . $ kcm_ccache_data#$anonymous_type_0#keyblock.; |
| 103 | } keycxx . . $ kcm_ccache_data#key.; |
| 104 | HEIMDAL_MUTEXcxx . . $ `include/heim_threads.h:109:9`! mutexcxx . . $ kcm_ccache_data#mutex.; |
| 105 | struct kcm_ccache_datacxx . . $ kcm_ccache_data# *nextcxx . . $ kcm_ccache_data#next.; |
| 106 | } kcm_ccache_datacxx . . $ kcm_ccache_data#; |
| 107 | |
| 108 | #define KCM_ASSERT_VALIDcxx . . $ `kcm/kcm_locl.h:108:9`!(_ccache) do { \ |
| 109 | if (((_ccache)->flags & KCM_FLAGS_VALIDcxx . . $ `kcm/kcm_locl.h:58:9`!) == 0) \ |
| 110 | krb5_abortx(context, "kcm_free_ccache_data: ccache invalid"); \ |
| 111 | else if ((_ccache)->refcnt == 0) \ |
| 112 | krb5_abortx(context, "kcm_free_ccache_data: ccache refcnt == 0"); \ |
| 113 | } while (0) |
| 114 | |
| 115 | typedef kcm_ccache_datacxx . . $ kcm_ccache_data# *kcm_ccachecxx . . $ kcm_ccache#; |
| 116 | |
| 117 | /* Event management */ |
| 118 | |
| 119 | typedef struct kcm_eventcxx . . $ kcm_event# { |
| 120 | int validcxx . . $ kcm_event#valid.; |
| 121 | time_tcxx . . $ time_t# fire_timecxx . . $ kcm_event#fire_time.; |
| 122 | unsigned fire_countcxx . . $ kcm_event#fire_count.; |
| 123 | time_tcxx . . $ time_t# expire_timecxx . . $ kcm_event#expire_time.; |
| 124 | time_tcxx . . $ time_t# backoff_timecxx . . $ kcm_event#backoff_time.; |
| 125 | enumcxx . . $ kcm_event#$anonymous_type_1# { |
| 126 | KCM_EVENT_NONEcxx . . $ kcm_event#KCM_EVENT_NONE. = 0, |
| 127 | KCM_EVENT_ACQUIRE_CREDScxx . . $ kcm_event#KCM_EVENT_ACQUIRE_CREDS., |
| 128 | KCM_EVENT_RENEW_CREDScxx . . $ kcm_event#KCM_EVENT_RENEW_CREDS., |
| 129 | KCM_EVENT_DESTROY_CREDScxx . . $ kcm_event#KCM_EVENT_DESTROY_CREDS., |
| 130 | KCM_EVENT_DESTROY_EMPTY_CACHEcxx . . $ kcm_event#KCM_EVENT_DESTROY_EMPTY_CACHE. |
| 131 | } actioncxx . . $ kcm_event#action.; |
| 132 | kcm_ccachecxx . . $ kcm_ccache# ccachecxx . . $ kcm_event#ccache.; |
| 133 | struct kcm_eventcxx . . $ kcm_event# *nextcxx . . $ kcm_event#next.; |
| 134 | } kcm_eventcxx . . $ kcm_event#; |
| 135 | |
| 136 | /* wakeup interval for event queue */ |
| 137 | #define KCM_EVENT_QUEUE_INTERVALcxx . . $ `kcm/kcm_locl.h:137:9`! 60 |
| 138 | #define KCM_EVENT_DEFAULT_BACKOFF_TIMEcxx . . $ `kcm/kcm_locl.h:138:9`! 5 |
| 139 | #define KCM_EVENT_MAX_BACKOFF_TIMEcxx . . $ `kcm/kcm_locl.h:139:9`! (12 * 60 * 60) |
| 140 | |
| 141 | |
| 142 | /* Request format is LENGTH | MAJOR | MINOR | OPERATION | request */ |
| 143 | /* Response format is LENGTH | STATUS | response */ |
| 144 | |
| 145 | typedef struct kcm_clientcxx . . $ kcm_client# { |
| 146 | pid_tcxx . . $ pid_t# pidcxx . . $ kcm_client#pid.; |
| 147 | uid_tcxx . . $ uid_t# uidcxx . . $ kcm_client#uid.; |
| 148 | gid_tcxx . . $ gid_t# gidcxx . . $ kcm_client#gid.; |
| 149 | pid_tcxx . . $ pid_t# sessioncxx . . $ kcm_client#session.; |
| 150 | } kcm_clientcxx . . $ kcm_client#; |
| 151 | |
| 152 | #define CLIENT_IS_ROOTcxx . . $ `kcm/kcm_locl.h:152:9`!(client) ((client)->uid == 0) |
| 153 | |
| 154 | /* Dispatch table */ |
| 155 | /* passed in OPERATION | ... ; returns STATUS | ... */ |
| 156 | typedef krb5_error_codecxx . . $ krb5_error_code# (*kcm_methodcxx . . $ kcm_method#)(krb5_contextcxx . . $ krb5_context#, kcm_clientcxx . . $ kcm_client# *, kcm_operationcxx . . $ kcm_operation#, krb5_storagecxx . . $ krb5_storage# *, krb5_storagecxx . . $ krb5_storage# *); |
| 157 | |
| 158 | struct kcm_opcxx . . $ kcm_op# { |
| 159 | const char *namecxx . . $ kcm_op#name.; |
| 160 | kcm_methodcxx . . $ kcm_method# methodcxx . . $ kcm_op#method.; |
| 161 | }; |
| 162 | |
| 163 | #define DEFAULT_LOG_DESTcxx . . $ `kcm/kcm_locl.h:163:9`! "0/FILE:" LOCALSTATEDIR "/log/kcmd.log" |
| 164 | #define _PATH_KCM_CONFcxx . . $ `kcm/kcm_locl.h:164:9`! SYSCONFDIR "/kcm.conf" |
| 165 | |
| 166 | extern krb5_contextcxx . . $ krb5_context# kcm_contextcxx . . $ kcm_context.; |
| 167 | extern char *socket_pathcxx . . $ socket_path.; |
| 168 | extern char *door_pathcxx . . $ door_path.; |
| 169 | extern size_t max_requestcxx . . $ max_request.; |
| 170 | extern sig_atomic_tcxx . . $ sig_atomic_t# exit_flagcxx . . $ exit_flag.; |
| 171 | extern int name_constraintscxx . . $ name_constraints.; |
| 172 | extern int detach_from_consolecxx . . $ detach_from_console.; |
| 173 | extern int daemon_childcxx . . $ daemon_child.; |
| 174 | extern int launchd_flagcxx . . $ launchd_flag.; |
| 175 | extern int disallow_getting_krbtgtcxx . . $ disallow_getting_krbtgt.; |
| 176 | |
| 177 | #if 0 |
| 178 | extern const krb5_cc_ops krb5_kcmss_ops; |
| 179 | #endif |
| 180 | |
| 181 | void kcm_servicecxx . . $ kcm_service(b197dd88575d52df).(void *, const heim_idatacxx . . $ heim_idata# *, const heim_icredcxx . . $ heim_icred#, |
| 182 | heim_ipc_completecxx . . $ heim_ipc_complete#, heim_sipc_callcxx . . $ heim_sipc_call#); |
| 183 | |
| 184 | #include <kcm-protos.h>cxx . . $ `<file>/kcm/kcm-protos.h`/ |
| 185 | |
| 186 | #endif /* __KCM_LOCL_H__ */ |
| 187 |