OpenAFS
OpenAFS distributed network file system
|
00001 /* 00002 * Copyright (c) 2004, 2005, 2006, 2007 Secure Endpoints Inc. 00003 * Copyright (c) 2003 SkyRope, LLC 00004 * All rights reserved. 00005 * 00006 * Redistribution and use in source and binary forms, with or without 00007 * modification, are permitted provided that the following conditions are met: 00008 * 00009 * - Redistributions of source code must retain the above copyright notice, 00010 * this list of conditions and the following disclaimer. 00011 * - Redistributions in binary form must reproduce the above copyright notice, 00012 * this list of conditions and the following disclaimer in the documentation 00013 * and/or other materials provided with the distribution. 00014 * - Neither the name of Skyrope, LLC nor the names of its contributors may be 00015 * used to endorse or promote products derived from this software without 00016 * specific prior written permission from Skyrope, LLC. 00017 * 00018 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00019 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 00020 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 00021 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 00022 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00023 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00024 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00025 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00026 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00027 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00028 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00029 * 00030 * Portions of this code are derived from portions of the MIT 00031 * Leash Ticket Manager and LoadFuncs utilities. For these portions the 00032 * following copyright applies. 00033 * 00034 * Copyright (c) 2003,2004 by the Massachusetts Institute of Technology. 00035 * All rights reserved. 00036 * 00037 * Export of this software from the United States of America may 00038 * require a specific license from the United States Government. 00039 * It is the responsibility of any person or organization contemplating 00040 * export to obtain such a license before exporting. 00041 * 00042 * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and 00043 * distribute this software and its documentation for any purpose and 00044 * without fee is hereby granted, provided that the above copyright 00045 * notice appear in all copies and that both that copyright notice and 00046 * this permission notice appear in supporting documentation, and that 00047 * the name of M.I.T. not be used in advertising or publicity pertaining 00048 * to distribution of the software without specific, written prior 00049 * permission. Furthermore if you modify this software you must label 00050 * your software as modified software and not distribute it in such a 00051 * fashion that it might be confused with the original M.I.T. software. 00052 * M.I.T. makes no representations about the suitability of 00053 * this software for any purpose. It is provided "as is" without express 00054 * or implied warranty. 00055 * 00056 */ 00057 00058 #ifndef AFSKRB5_INT_H 00059 #define AFSKRB5_INT_H 00060 00061 #include <windows.h> 00062 #ifdef USE_MS2MIT 00063 #define SECURITY_WIN32 00064 #include <security.h> 00065 #if _WIN32_WINNT < 0x0501 00066 #undef _WIN32_WINNT 00067 #define _WIN32_WINNT 0x0501 00068 #endif 00069 #include <ntsecapi.h> 00070 #endif /* USE_MS2MIT */ 00071 #include <stdio.h> 00072 #include <string.h> 00073 #include <time.h> 00074 #include <winsock2.h> 00075 #include <process.h> 00076 00077 #include <afs/stds.h> 00078 #include <krb5.h> 00079 00080 #include <rxkad.h> 00081 00082 /* AFS has its own version of com_err.h */ 00083 typedef afs_int32 errcode_t; 00084 00085 // service definitions 00086 #define SERVICE_DLL "advapi32.dll" 00087 typedef SC_HANDLE (WINAPI *FP_OpenSCManagerA)(char *, char *, DWORD); 00088 typedef SC_HANDLE (WINAPI *FP_OpenServiceA)(SC_HANDLE, char *, DWORD); 00089 typedef BOOL (WINAPI *FP_QueryServiceStatus)(SC_HANDLE, LPSERVICE_STATUS); 00090 typedef BOOL (WINAPI *FP_CloseServiceHandle)(SC_HANDLE); 00091 00092 #define KRB5_DEFAULT_LIFE 60*60*10 /* 10 hours */ 00093 #define LSA_CCTYPE "MSLSA" 00094 #define LSA_CCNAME LSA_CCTYPE ":" 00095 00096 #ifndef REALM_SZ 00097 #define REALM_SZ 64 00098 #endif 00099 00100 #ifndef KTC_ERROR 00101 #define KTC_ERROR 11862784L 00102 #define KTC_TOOBIG 11862785L 00103 #define KTC_INVAL 11862786L 00104 #define KTC_NOENT 11862787L 00105 #define KTC_PIOCTLFAIL 11862788L 00106 #define KTC_NOPIOCTL 11862789L 00107 #define KTC_NOCELL 11862790L 00108 #define KTC_NOCM 11862791L 00109 #endif 00110 00111 /* User Query data structures and functions */ 00112 00113 struct textField { 00114 char * buf; /* Destination buffer address */ 00115 int len; /* Destination buffer length */ 00116 char * label; /* Label for this field */ 00117 char * def; /* Default response for this field */ 00118 int echo; /* 0 = no, 1 = yes, 2 = asterisks */ 00119 }; 00120 00121 #define ID_TEXT 150 00122 #define ID_MID_TEXT 300 00123 00124 struct principal_ccache_data { 00125 struct principal_ccache_data * next; 00126 char * principal; 00127 char * ccache_name; 00128 int from_lsa; 00129 int expired; 00130 int expiration_time; 00131 int renew; 00132 }; 00133 00134 struct cell_principal_map { 00135 struct cell_principal_map * next; 00136 char * cell; 00137 char * principal; 00138 int active; 00139 }; 00140 00141 /* Function Prototypes */ 00142 DWORD GetServiceStatus(LPSTR, LPSTR, DWORD *); 00143 00144 void KFW_AFS_error(LONG, LPCSTR); 00145 00146 int KFW_get_ccache(krb5_context, krb5_principal, krb5_ccache *); 00147 00148 int KFW_error(krb5_error_code, LPCSTR, int, krb5_context *, krb5_ccache *); 00149 00150 int KFW_kinit(krb5_context, krb5_ccache, HWND, char *, char *, krb5_deltat, 00151 DWORD, DWORD, krb5_deltat, DWORD, DWORD); 00152 00153 int KFW_renew(krb5_context, krb5_ccache); 00154 00155 int KFW_destroy(krb5_context, krb5_ccache); 00156 00157 BOOL KFW_ms2mit(krb5_context, krb5_ccache, BOOL); 00158 00159 int KFW_AFS_unlog(void); 00160 00161 int KFW_AFS_klog(krb5_context, krb5_ccache, char*, char*, char*, int, char*); 00162 00163 void KFW_import_ccache_data(void); 00164 00165 BOOL MSLSA_IsKerberosLogon(); 00166 00167 char *afs_realm_of_cell(krb5_context, struct afsconf_cell *); 00168 00169 DWORD KFW_get_default_mslsa_import(krb5_context); 00170 00171 DWORD KFW_get_default_lifetime(krb5_context, const char *); 00172 00173 void KFW_enable_DES(krb5_context); 00174 00175 #endif /* AFSKFW_INT_H */