msvcrt: Don't include MSVC 7.0+ exception functions in SOs for older DLLs.
[wine.git] / dlls / kerberos / krb5_ap.c
blob0134b94f6d0f8f7e5a3cf461327af22125ca40e3
1 /*
2 * Copyright 2017 Dmitry Timoshkov
4 * Kerberos5 Authentication Package
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "config.h"
22 #include "wine/port.h"
24 #include <stdarg.h>
25 #ifdef HAVE_KRB5_KRB5_H
26 #include <krb5/krb5.h>
27 #endif
29 #include "ntstatus.h"
30 #define WIN32_NO_STATUS
31 #include "windef.h"
32 #include "winbase.h"
33 #include "sspi.h"
34 #include "ntsecapi.h"
35 #include "ntsecpkg.h"
36 #include "winternl.h"
37 #include "wine/library.h"
38 #include "wine/debug.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(krb5);
42 static ULONG krb5_package_id;
43 static LSA_DISPATCH_TABLE lsa_dispatch;
45 #ifdef SONAME_LIBKRB5
47 static void *libkrb5_handle;
49 #define MAKE_FUNCPTR(f) static typeof(f) * p_##f
50 MAKE_FUNCPTR(krb5_init_context);
51 #undef MAKE_FUNCPTR
53 static void load_krb5(void)
55 if (!(libkrb5_handle = wine_dlopen(SONAME_LIBKRB5, RTLD_NOW, NULL, 0)))
57 WARN("Failed to load %s, Kerberos support will be disabled\n", SONAME_LIBKRB5);
58 return;
61 #define LOAD_FUNCPTR(f) \
62 if (!(p_##f = wine_dlsym(libkrb5_handle, #f, NULL, 0))) \
63 { \
64 ERR("Failed to load %s\n", #f); \
65 goto fail; \
68 LOAD_FUNCPTR(krb5_init_context)
69 #undef LOAD_FUNCPTR
71 return;
73 fail:
74 wine_dlclose(libkrb5_handle, NULL, 0);
75 libkrb5_handle = NULL;
78 #else /* SONAME_LIBKRB5 */
80 static void load_krb5(void)
82 WARN("Kerberos support was not provided at compile time\n");
85 #endif /* SONAME_LIBKRB5 */
87 static NTSTATUS NTAPI krb5_LsaApInitializePackage(ULONG package_id, PLSA_DISPATCH_TABLE dispatch,
88 PLSA_STRING database, PLSA_STRING confidentiality, PLSA_STRING *package_name)
90 char *krb5_name;
92 load_krb5();
94 krb5_package_id = package_id;
95 lsa_dispatch = *dispatch;
97 krb5_name = lsa_dispatch.AllocateLsaHeap(sizeof(MICROSOFT_KERBEROS_NAME_A));
98 if (!krb5_name) return STATUS_NO_MEMORY;
100 memcpy(krb5_name, MICROSOFT_KERBEROS_NAME_A, sizeof(MICROSOFT_KERBEROS_NAME_A));
102 *package_name = lsa_dispatch.AllocateLsaHeap(sizeof(**package_name));
103 if (!*package_name)
105 lsa_dispatch.FreeLsaHeap(krb5_name);
106 return STATUS_NO_MEMORY;
109 RtlInitString(*package_name, krb5_name);
111 return STATUS_SUCCESS;
114 static NTSTATUS NTAPI krb5_LsaApCallPackageUntrusted(PLSA_CLIENT_REQUEST request,
115 PVOID in_buffer, PVOID client_buffer_base, ULONG in_buffer_length,
116 PVOID *out_buffer, PULONG out_buffer_length, PNTSTATUS status)
118 FIXME("%p,%p,%p,%u,%p,%p,%p: stub\n", request, in_buffer, client_buffer_base,
119 in_buffer_length, out_buffer, out_buffer_length, status);
121 *status = STATUS_NOT_IMPLEMENTED;
122 return STATUS_NOT_IMPLEMENTED;
125 static SECPKG_FUNCTION_TABLE krb5_table =
127 krb5_LsaApInitializePackage, /* InitializePackage */
128 NULL, /* LsaLogonUser */
129 NULL, /* CallPackage */
130 NULL, /* LogonTerminated */
131 krb5_LsaApCallPackageUntrusted, /* CallPackageUntrusted */
132 NULL, /* CallPackagePassthrough */
133 NULL, /* LogonUserEx */
134 NULL, /* LogonUserEx2 */
135 NULL, /* Initialize */
136 NULL, /* Shutdown */
137 NULL, /* SpGetInfoUnified */
138 NULL, /* AcceptCredentials */
139 NULL, /* SpAcquireCredentialsHandle */
140 NULL, /* SpQueryCredentialsAttributes */
141 NULL, /* FreeCredentialsHandle */
142 NULL, /* SaveCredentials */
143 NULL, /* GetCredentials */
144 NULL, /* DeleteCredentials */
145 NULL, /* InitLsaModeContext */
146 NULL, /* AcceptLsaModeContext */
147 NULL, /* DeleteContext */
148 NULL, /* ApplyControlToken */
149 NULL, /* GetUserInfo */
150 NULL, /* GetExtendedInformation */
151 NULL, /* SpQueryContextAttributes */
152 NULL, /* SpAddCredentials */
153 NULL, /* SetExtendedInformation */
154 NULL, /* SetContextAttributes */
155 NULL, /* SetCredentialsAttributes */
156 NULL, /* ChangeAccountPassword */
157 NULL, /* QueryMetaData */
158 NULL, /* ExchangeMetaData */
159 NULL, /* GetCredUIContext */
160 NULL, /* UpdateCredentials */
161 NULL, /* ValidateTargetInfo */
162 NULL, /* PostLogonUser */
165 NTSTATUS NTAPI SpLsaModeInitialize(ULONG lsa_version, PULONG package_version,
166 PSECPKG_FUNCTION_TABLE *table, PULONG table_count)
168 TRACE("%#x,%p,%p,%p\n", lsa_version, package_version, table, table_count);
170 *package_version = SECPKG_INTERFACE_VERSION;
171 *table = &krb5_table;
172 *table_count = 1;
174 return STATUS_SUCCESS;