OpenAFS
OpenAFS distributed network file system
|
00001 /* 00002 * Copyright (c) 2005-2008 Secure Endpoints Inc. 00003 * 00004 * Permission is hereby granted, free of charge, to any person 00005 * obtaining a copy of this software and associated documentation 00006 * files (the "Software"), to deal in the Software without 00007 * restriction, including without limitation the rights to use, copy, 00008 * modify, merge, publish, distribute, sublicense, and/or sell copies 00009 * of the Software, and to permit persons to whom the Software is 00010 * furnished to do so, subject to the following conditions: 00011 * 00012 * The above copyright notice and this permission notice shall be 00013 * included in all copies or substantial portions of the Software. 00014 * 00015 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00016 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00017 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00018 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 00019 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 00020 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 00021 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 00022 * SOFTWARE. 00023 */ 00024 00025 /* $Id$ */ 00026 00027 #ifndef __KHIMAIRA_AFSCRED_H 00028 #define __KHIMAIRA_AFSCRED_H 00029 00030 #ifndef _WIN64 00031 #define _USE_32BIT_TIME_T 1 00032 #endif 00033 00034 #include <afsconfig.h> 00035 #include <afs/param.h> 00036 #include <roken.h> 00037 00038 #define _WINSOCKAPI_ 00039 #include<windows.h> 00040 #include<time.h> 00041 00042 #define KHERR_FACILITY L"AfsCred" 00043 #define KHERR_HMODULE hResModule 00044 #include<netidmgr.h> 00045 00046 #include<langres.h> 00047 00048 #include <afs/stds.h> 00049 #include <afs/cm_config.h> 00050 #include <afs/auth.h> 00051 #include <afs/ptserver.h> 00052 #include <afs/ptuser.h> 00053 00054 #include<afspext.h> 00055 00056 #include<afsfuncs.h> 00057 #include<afsnewcreds.h> 00058 00059 #ifndef NOSTRSAFE 00060 #include<strsafe.h> 00061 #endif 00062 00063 #define AFS_PLUGIN_NAME L"AfsCred" 00064 #define AFS_CREDTYPE_NAME L"AfsCred" 00065 00066 #define AFS_PLUGIN_DEPS L"Krb5Cred\0" 00067 00068 #define KRB5_CREDTYPE_NAME L"Krb5Cred" 00069 #define KRB4_CREDTYPE_NAME L"Krb4Cred" 00070 00071 #define AFS_TYPENAME_PRINCIPAL L"AFSPrincipal" 00072 #define AFS_TYPENAME_METHOD L"AFSTokenMethod" 00073 #define AFS_ATTRNAME_CLIENT_PRINC L"AFSClientPrinc" 00074 #define AFS_ATTRNAME_SERVER_PRINC L"AFSServerPrinc" 00075 #define AFS_ATTRNAME_CELL L"AFSCell" 00076 #define AFS_ATTRNAME_METHOD L"AFSMethod" 00077 #define AFS_ATTRNAME_REALM L"AFSRealm" 00078 00079 #define AFS_VALID_CELL_CHARS L"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-" 00080 #define AFS_VALID_REALM_CHARS AFS_VALID_CELL_CHARS 00081 00082 #define AFS_CONFIG_NODE_IDS L"AfsIdentities" 00083 #define AFS_CONFIG_NODE_ID L"AfsIdentity" 00084 #define AFS_CONFIG_NODE_MAIN L"AfsOptions" 00085 00086 #define AFS_HELPFILE L"afsplhlp.chm" 00087 00088 /* token acquisition methods provided by extensions begin with this 00089 ID */ 00090 #define AFS_TOKEN_USER 8 00091 00092 void init_afs(); 00093 void exit_afs(); 00094 KHMEXP khm_int32 KHMAPI init_module(kmm_module h_module); 00095 KHMEXP khm_int32 KHMAPI exit_module(kmm_module h_module); 00096 00097 /* globals */ 00098 extern kmm_module h_khModule; 00099 extern HMODULE hResModule; 00100 extern HINSTANCE hInstance; 00101 00102 extern khm_int32 afs_credtype_id; 00103 extern khm_int32 krb5_credtype_id; 00104 extern khm_int32 krb4_credtype_id; 00105 extern khm_int32 afs_msg_type_id; 00106 extern khm_handle afs_credset; 00107 00108 extern khm_int32 afs_type_principal; 00109 extern khm_int32 afs_attr_client_princ; 00110 extern khm_int32 afs_attr_server_princ; 00111 extern khm_int32 afs_attr_cell; 00112 extern khm_int32 afs_attr_method; 00113 extern khm_int32 afs_attr_realm; 00114 00115 /* Configuration spaces */ 00116 #define CSNAME_PLUGINS L"Plugins" 00117 #define CSNAME_AFSCRED L"AfsCred" 00118 #define CSNAME_PARAMS L"Parameters" 00119 00120 extern khm_handle csp_plugins; 00121 extern khm_handle csp_afscred; 00122 extern khm_handle csp_params; 00123 00124 extern khm_handle afs_sub; 00125 00126 /* defined in afsconfig.c which is generated from afsconfig.csv */ 00127 extern kconf_schema schema_afsconfig[]; 00128 00129 00130 /* plugin callback procedure */ 00131 khm_int32 KHMAPI 00132 afs_plugin_cb(khm_int32 msg_type, 00133 khm_int32 msg_subtype, 00134 khm_ui_4 uparam, 00135 void * vparam); 00136 00137 INT_PTR CALLBACK 00138 afs_cfg_ids_proc(HWND hwnd, 00139 UINT uMsg, 00140 WPARAM wParam, 00141 LPARAM lParam); 00142 00143 INT_PTR CALLBACK 00144 afs_cfg_id_proc(HWND hwnd, 00145 UINT uMsg, 00146 WPARAM wParam, 00147 LPARAM lParam); 00148 00149 INT_PTR CALLBACK 00150 afs_cfg_main_proc(HWND hwnd, 00151 UINT uMsg, 00152 WPARAM wParam, 00153 LPARAM lParam); 00154 00155 HWND 00156 afs_html_help(HWND caller, 00157 wchar_t * postfix, 00158 UINT cmd, 00159 DWORD_PTR data); 00160 00161 /* extensions */ 00162 typedef afs_msg_announce afs_extension; 00163 00164 /* not thread safe. only call from the plugin thread */ 00165 afs_extension * 00166 afs_find_extension(const wchar_t * name); 00167 00168 /* not thread safe. only call from the plugin thread */ 00169 afs_extension * 00170 afs_get_extension(khm_size i); 00171 00172 /* not thread safe. only call from the plugin thread */ 00173 afs_extension * 00174 afs_get_next_token_acq(afs_extension * f); 00175 00176 /* not thread safe. only call from the plugin thread */ 00177 khm_boolean 00178 afs_is_valid_method_id(afs_tk_method method); 00179 00180 afs_tk_method 00181 afs_get_next_method_id(afs_tk_method method); 00182 00183 afs_tk_method 00184 afs_get_method_id(wchar_t * name); 00185 00186 khm_boolean 00187 afs_get_method_name(afs_tk_method method, wchar_t * buf, khm_size cbbuf); 00188 00189 afs_extension * 00190 afs_get_method_ext(afs_tk_method method); 00191 00192 khm_boolean 00193 afs_method_describe(afs_tk_method method, khm_int32 flags, 00194 wchar_t * wbuf, khm_size cbbuf); 00195 00196 khm_boolean 00197 afs_ext_resolve_token(const wchar_t * cell, 00198 const struct ktc_token * token, 00199 const struct ktc_principal * serverp, 00200 const struct ktc_principal * clientp, 00201 khm_handle * pident, 00202 afs_tk_method * pmethod); 00203 00204 khm_boolean 00205 afs_ext_klog(afs_tk_method method, 00206 khm_handle identity, 00207 const char * service, 00208 const char * cell, 00209 const char * realm, 00210 const afs_conf_cell * cell_config, 00211 khm_int32 lifetime); 00212 00213 BOOL 00214 afs_cfg_get_afscreds_shortcut(wchar_t * wpath); 00215 00216 /* Notificaiton icon functions */ 00217 00218 enum notification_icon_state { 00219 AFSICON_REPORT_TOKENS, 00220 AFSICON_SERVICE_STOPPED, 00221 AFSICON_SERVICE_ERROR 00222 }; 00223 00224 void 00225 afs_icon_set_state(enum notification_icon_state state, 00226 khm_handle credset_with_tokens); 00227 00228 void 00229 afs_remove_icon(void); 00230 00231 00232 /* Compatibility */ 00233 #if KH_VERSION_API < 7 00234 00235 #ifdef _WIN64 00236 #define NIMDLLNAME L"nidmgr64.dll" 00237 #define API_khui_action_lock "khui_action_lock" 00238 #define API_khui_action_unlock "khui_action_unlock" 00239 #define API_khui_refresh_actions "khui_refresh_actions" 00240 #define API_khui_request_UI_callback "khui_request_UI_callback" 00241 #else 00242 #define NIMDLLNAME L"nidmgr32.dll" 00243 #define API_khui_action_lock "_khui_action_lock@0" 00244 #define API_khui_action_unlock "_khui_action_unlock@0" 00245 #define API_khui_refresh_actions "_khui_refresh_actions@0" 00246 #define API_khui_request_UI_callback "_khui_request_UI_callback@8" 00247 #endif 00248 00249 extern void 00250 (KHMAPI * pkhui_action_lock)(void); 00251 00252 extern void 00253 (KHMAPI * pkhui_action_unlock)(void); 00254 00255 extern void 00256 (KHMAPI * pkhui_refresh_actions)(void); 00257 00258 typedef khm_int32 00259 (KHMAPI * khm_ui_callback)(HWND hwnd_main_wnd, void * rock); 00260 00261 extern khm_int32 00262 (KHMAPI * pkhui_request_UI_callback)(khm_ui_callback cb, 00263 void * rock); 00264 00265 #define khui_action_lock (*pkhui_action_lock) 00266 #define khui_action_unlock (*pkhui_action_unlock) 00267 #define khui_refresh_actions (*pkhui_refresh_actions) 00268 #define khui_request_UI_callback (*pkhui_request_UI_callback) 00269 00270 #endif 00271 00272 #endif