Windows: cm_BPlusDirNextEnumEntry return all errors
[openafs.git] / src / WINNT / afsd / afskfw-int.h
1 /*
2 * Copyright (c) 2004, 2005, 2006, 2007 Secure Endpoints Inc.
3 * Copyright (c) 2003 SkyRope, LLC
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are met:
8  *
9  * - Redistributions of source code must retain the above copyright notice,
10  *   this list of conditions and the following disclaimer.
11  * - Redistributions in binary form must reproduce the above copyright notice,
12  *   this list of conditions and the following disclaimer in the documentation
13  *   and/or other materials provided with the distribution.
14  * - Neither the name of Skyrope, LLC nor the names of its contributors may be
15  *   used to endorse or promote products derived from this software without
16  *   specific prior written permission from Skyrope, LLC.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
21  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
22  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  *
30  * Portions of this code are derived from portions of the MIT
31  * Leash Ticket Manager and LoadFuncs utilities.  For these portions the
32  * following copyright applies.
33  *
34  * Copyright (c) 2003,2004 by the Massachusetts Institute of Technology.
35  * All rights reserved.
36  *
37  * Export of this software from the United States of America may
38  *   require a specific license from the United States Government.
39  *   It is the responsibility of any person or organization contemplating
40  *   export to obtain such a license before exporting.
41  *
42  * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
43  * distribute this software and its documentation for any purpose and
44  * without fee is hereby granted, provided that the above copyright
45  * notice appear in all copies and that both that copyright notice and
46  * this permission notice appear in supporting documentation, and that
47  * the name of M.I.T. not be used in advertising or publicity pertaining
48  * to distribution of the software without specific, written prior
49  * permission.  Furthermore if you modify this software you must label
50  * your software as modified software and not distribute it in such a
51  * fashion that it might be confused with the original M.I.T. software.
52  * M.I.T. makes no representations about the suitability of
53  * this software for any purpose.  It is provided "as is" without express
54  * or implied warranty.
55  *
56  */
57
58 #ifndef AFSKRB5_INT_H
59 #define AFSKRB5_INT_H
60
61 #include <windows.h>
62 #ifdef USE_MS2MIT
63 #define SECURITY_WIN32
64 #include <security.h>
65 #if _WIN32_WINNT < 0x0501
66 #undef _WIN32_WINNT
67 #define _WIN32_WINNT 0x0501
68 #endif
69 #include <ntsecapi.h>
70 #endif /* USE_MS2MIT */
71 #include <stdio.h>
72 #include <string.h>
73 #include <time.h>
74 #include <winsock2.h>
75 #include <process.h>
76
77 #include <afs/stds.h>
78 #include <krb5.h>
79
80 #include <rxkad.h>
81
82 /* AFS has its own version of com_err.h */
83 typedef afs_int32 errcode_t;
84
85 // service definitions
86 #define SERVICE_DLL   "advapi32.dll"
87 typedef SC_HANDLE (WINAPI *FP_OpenSCManagerA)(char *, char *, DWORD);
88 typedef SC_HANDLE (WINAPI *FP_OpenServiceA)(SC_HANDLE, char *, DWORD);
89 typedef BOOL (WINAPI *FP_QueryServiceStatus)(SC_HANDLE, LPSERVICE_STATUS);
90 typedef BOOL (WINAPI *FP_CloseServiceHandle)(SC_HANDLE);
91
92 #define KRB5_DEFAULT_LIFE            60*60*10 /* 10 hours */
93 #define LSA_CCTYPE                   "MSLSA"
94 #define LSA_CCNAME                   LSA_CCTYPE ":"
95
96 #ifndef REALM_SZ
97 #define REALM_SZ     64
98 #endif
99
100 #ifndef KTC_ERROR
101 #define KTC_ERROR      11862784L
102 #define KTC_TOOBIG     11862785L
103 #define KTC_INVAL      11862786L
104 #define KTC_NOENT      11862787L
105 #define KTC_PIOCTLFAIL 11862788L
106 #define KTC_NOPIOCTL   11862789L
107 #define KTC_NOCELL     11862790L
108 #define KTC_NOCM       11862791L
109 #endif
110
111 /* User Query data structures and functions */
112
113 struct textField {
114     char * buf;                       /* Destination buffer address */
115     int    len;                       /* Destination buffer length */
116     char * label;                     /* Label for this field */
117     char * def;                       /* Default response for this field */
118     int    echo;                      /* 0 = no, 1 = yes, 2 = asterisks */
119 };
120
121 #define ID_TEXT       150
122 #define ID_MID_TEXT   300
123
124 struct principal_ccache_data {
125     struct principal_ccache_data * next;
126     char * principal;
127     char * ccache_name;
128     int    from_lsa;
129     int    expired;
130     int    expiration_time;
131     int    renew;
132 };
133
134 struct cell_principal_map {
135     struct cell_principal_map * next;
136     char * cell;
137     char * principal;
138     int    active;
139 };
140
141 /* Function Prototypes */
142 DWORD GetServiceStatus(LPSTR, LPSTR, DWORD *);
143
144 void KFW_AFS_error(LONG, LPCSTR);
145
146 int  KFW_get_ccache(krb5_context, krb5_principal, krb5_ccache *);
147
148 int  KFW_error(krb5_error_code, LPCSTR, int, krb5_context *, krb5_ccache *);
149
150 int  KFW_kinit(krb5_context, krb5_ccache, HWND, char *, char *, krb5_deltat,
151                DWORD, DWORD, krb5_deltat, DWORD, DWORD);
152
153 int  KFW_renew(krb5_context, krb5_ccache);
154
155 int  KFW_destroy(krb5_context, krb5_ccache);
156
157 BOOL KFW_ms2mit(krb5_context, krb5_ccache, BOOL);
158
159 int  KFW_AFS_unlog(void);
160
161 int  KFW_AFS_klog(krb5_context, krb5_ccache, char*, char*, char*, int, char*);
162
163 void KFW_import_ccache_data(void);
164
165 BOOL MSLSA_IsKerberosLogon();
166
167 char *afs_realm_of_cell(krb5_context, struct afsconf_cell *);
168
169 DWORD KFW_get_default_mslsa_import(krb5_context);
170
171 DWORD KFW_get_default_lifetime(krb5_context, const char *);
172
173 void KFW_enable_DES(krb5_context);
174
175 #endif /* AFSKFW_INT_H */