[862] | 1 | /*
|
---|
| 2 | Unix SMB/CIFS implementation.
|
---|
| 3 | simple kerberos5 routines for active directory
|
---|
| 4 | Copyright (C) Andrew Tridgell 2001
|
---|
| 5 | Copyright (C) Luke Howard 2002-2003
|
---|
| 6 | Copyright (C) Andrew Bartlett <abartlet@samba.org> 2005
|
---|
| 7 | Copyright (C) Guenther Deschner 2005-2009
|
---|
| 8 |
|
---|
| 9 | This program is free software; you can redistribute it and/or modify
|
---|
| 10 | it under the terms of the GNU General Public License as published by
|
---|
| 11 | the Free Software Foundation; either version 3 of the License, or
|
---|
| 12 | (at your option) any later version.
|
---|
| 13 |
|
---|
| 14 | This program is distributed in the hope that it will be useful,
|
---|
| 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 17 | GNU General Public License for more details.
|
---|
| 18 |
|
---|
| 19 | You should have received a copy of the GNU General Public License
|
---|
| 20 | along with this program. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 21 | */
|
---|
| 22 |
|
---|
| 23 | #include "includes.h"
|
---|
| 24 | #include "smb_krb5.h"
|
---|
| 25 | #include "../librpc/gen_ndr/krb5pac.h"
|
---|
| 26 | #include "../lib/util/asn1.h"
|
---|
| 27 | #include "libsmb/nmblib.h"
|
---|
| 28 |
|
---|
| 29 | #ifndef KRB5_AUTHDATA_WIN2K_PAC
|
---|
| 30 | #define KRB5_AUTHDATA_WIN2K_PAC 128
|
---|
| 31 | #endif
|
---|
| 32 |
|
---|
| 33 | #ifndef KRB5_AUTHDATA_IF_RELEVANT
|
---|
| 34 | #define KRB5_AUTHDATA_IF_RELEVANT 1
|
---|
| 35 | #endif
|
---|
| 36 |
|
---|
| 37 | #ifdef HAVE_KRB5
|
---|
| 38 |
|
---|
| 39 | #define GSSAPI_CHECKSUM 0x8003 /* Checksum type value for Kerberos */
|
---|
| 40 | #define GSSAPI_BNDLENGTH 16 /* Bind Length (rfc-1964 pg.3) */
|
---|
| 41 | #define GSSAPI_CHECKSUM_SIZE (4+GSSAPI_BNDLENGTH+4) /* Length of bind length,
|
---|
| 42 | bind field, flags field. */
|
---|
| 43 |
|
---|
| 44 | /* MIT krb5 1.7beta3 (in Ubuntu Karmic) is missing the prototype,
|
---|
| 45 | but still has the symbol */
|
---|
| 46 | #if !HAVE_DECL_KRB5_AUTH_CON_SET_REQ_CKSUMTYPE
|
---|
| 47 | krb5_error_code krb5_auth_con_set_req_cksumtype(
|
---|
| 48 | krb5_context context,
|
---|
| 49 | krb5_auth_context auth_context,
|
---|
| 50 | krb5_cksumtype cksumtype);
|
---|
| 51 | #endif
|
---|
| 52 |
|
---|
| 53 | /**************************************************************
|
---|
| 54 | Wrappers around kerberos string functions that convert from
|
---|
| 55 | utf8 -> unix charset and vica versa.
|
---|
| 56 | **************************************************************/
|
---|
| 57 |
|
---|
| 58 | /**************************************************************
|
---|
| 59 | krb5_parse_name that takes a UNIX charset.
|
---|
| 60 | **************************************************************/
|
---|
| 61 |
|
---|
| 62 | krb5_error_code smb_krb5_parse_name(krb5_context context,
|
---|
| 63 | const char *name, /* in unix charset */
|
---|
| 64 | krb5_principal *principal)
|
---|
| 65 | {
|
---|
| 66 | krb5_error_code ret;
|
---|
| 67 | char *utf8_name;
|
---|
| 68 | size_t converted_size;
|
---|
| 69 |
|
---|
| 70 | if (!push_utf8_talloc(talloc_tos(), &utf8_name, name, &converted_size)) {
|
---|
| 71 | return ENOMEM;
|
---|
| 72 | }
|
---|
| 73 |
|
---|
| 74 | ret = krb5_parse_name(context, utf8_name, principal);
|
---|
| 75 | TALLOC_FREE(utf8_name);
|
---|
| 76 | return ret;
|
---|
| 77 | }
|
---|
| 78 |
|
---|
| 79 | #ifdef HAVE_KRB5_PARSE_NAME_NOREALM
|
---|
| 80 | /**************************************************************
|
---|
| 81 | krb5_parse_name_norealm that takes a UNIX charset.
|
---|
| 82 | **************************************************************/
|
---|
| 83 |
|
---|
| 84 | static krb5_error_code smb_krb5_parse_name_norealm_conv(krb5_context context,
|
---|
| 85 | const char *name, /* in unix charset */
|
---|
| 86 | krb5_principal *principal)
|
---|
| 87 | {
|
---|
| 88 | krb5_error_code ret;
|
---|
| 89 | char *utf8_name;
|
---|
| 90 | size_t converted_size;
|
---|
| 91 |
|
---|
| 92 | *principal = NULL;
|
---|
| 93 | if (!push_utf8_talloc(talloc_tos(), &utf8_name, name, &converted_size)) {
|
---|
| 94 | return ENOMEM;
|
---|
| 95 | }
|
---|
| 96 |
|
---|
| 97 | ret = krb5_parse_name_norealm(context, utf8_name, principal);
|
---|
| 98 | TALLOC_FREE(utf8_name);
|
---|
| 99 | return ret;
|
---|
| 100 | }
|
---|
| 101 | #endif
|
---|
| 102 |
|
---|
| 103 | /**************************************************************
|
---|
| 104 | krb5_parse_name that returns a UNIX charset name. Must
|
---|
| 105 | be freed with talloc_free() call.
|
---|
| 106 | **************************************************************/
|
---|
| 107 |
|
---|
| 108 | krb5_error_code smb_krb5_unparse_name(TALLOC_CTX *mem_ctx,
|
---|
| 109 | krb5_context context,
|
---|
| 110 | krb5_const_principal principal,
|
---|
| 111 | char **unix_name)
|
---|
| 112 | {
|
---|
| 113 | krb5_error_code ret;
|
---|
| 114 | char *utf8_name;
|
---|
| 115 | size_t converted_size;
|
---|
| 116 |
|
---|
| 117 | *unix_name = NULL;
|
---|
| 118 | ret = krb5_unparse_name(context, principal, &utf8_name);
|
---|
| 119 | if (ret) {
|
---|
| 120 | return ret;
|
---|
| 121 | }
|
---|
| 122 |
|
---|
| 123 | if (!pull_utf8_talloc(mem_ctx, unix_name, utf8_name, &converted_size)) {
|
---|
| 124 | krb5_free_unparsed_name(context, utf8_name);
|
---|
| 125 | return ENOMEM;
|
---|
| 126 | }
|
---|
| 127 | krb5_free_unparsed_name(context, utf8_name);
|
---|
| 128 | return 0;
|
---|
| 129 | }
|
---|
| 130 |
|
---|
| 131 | #ifndef HAVE_KRB5_SET_REAL_TIME
|
---|
| 132 | /*
|
---|
| 133 | * This function is not in the Heimdal mainline.
|
---|
| 134 | */
|
---|
| 135 | krb5_error_code krb5_set_real_time(krb5_context context, int32_t seconds, int32_t microseconds)
|
---|
| 136 | {
|
---|
| 137 | krb5_error_code ret;
|
---|
| 138 | int32_t sec, usec;
|
---|
| 139 |
|
---|
| 140 | ret = krb5_us_timeofday(context, &sec, &usec);
|
---|
| 141 | if (ret)
|
---|
| 142 | return ret;
|
---|
| 143 |
|
---|
| 144 | context->kdc_sec_offset = seconds - sec;
|
---|
| 145 | context->kdc_usec_offset = microseconds - usec;
|
---|
| 146 |
|
---|
| 147 | return 0;
|
---|
| 148 | }
|
---|
| 149 | #endif
|
---|
| 150 |
|
---|
| 151 | #if !defined(HAVE_KRB5_SET_DEFAULT_TGS_KTYPES)
|
---|
| 152 |
|
---|
| 153 | #if defined(HAVE_KRB5_SET_DEFAULT_TGS_ENCTYPES)
|
---|
| 154 |
|
---|
| 155 | /* With MIT kerberos, we should use krb5_set_default_tgs_enctypes in preference
|
---|
| 156 | * to krb5_set_default_tgs_ktypes. See
|
---|
| 157 | * http://lists.samba.org/archive/samba-technical/2006-July/048271.html
|
---|
| 158 | *
|
---|
| 159 | * If the MIT libraries are not exporting internal symbols, we will end up in
|
---|
| 160 | * this branch, which is correct. Otherwise we will continue to use the
|
---|
| 161 | * internal symbol
|
---|
| 162 | */
|
---|
| 163 | krb5_error_code krb5_set_default_tgs_ktypes(krb5_context ctx, const krb5_enctype *enc)
|
---|
| 164 | {
|
---|
| 165 | return krb5_set_default_tgs_enctypes(ctx, enc);
|
---|
| 166 | }
|
---|
| 167 |
|
---|
| 168 | #elif defined(HAVE_KRB5_SET_DEFAULT_IN_TKT_ETYPES)
|
---|
| 169 |
|
---|
| 170 | /* Heimdal */
|
---|
| 171 | krb5_error_code krb5_set_default_tgs_ktypes(krb5_context ctx, const krb5_enctype *enc)
|
---|
| 172 | {
|
---|
| 173 | return krb5_set_default_in_tkt_etypes(ctx, enc);
|
---|
| 174 | }
|
---|
| 175 |
|
---|
| 176 | #endif /* HAVE_KRB5_SET_DEFAULT_TGS_ENCTYPES */
|
---|
| 177 |
|
---|
| 178 | #endif /* HAVE_KRB5_SET_DEFAULT_TGS_KTYPES */
|
---|
| 179 |
|
---|
| 180 | #if defined(HAVE_ADDR_TYPE_IN_KRB5_ADDRESS)
|
---|
| 181 | /* HEIMDAL */
|
---|
| 182 | bool setup_kaddr( krb5_address *pkaddr, struct sockaddr_storage *paddr)
|
---|
| 183 | {
|
---|
| 184 | memset(pkaddr, '\0', sizeof(krb5_address));
|
---|
| 185 | #if defined(HAVE_IPV6) && defined(KRB5_ADDRESS_INET6)
|
---|
| 186 | if (paddr->ss_family == AF_INET6) {
|
---|
| 187 | pkaddr->addr_type = KRB5_ADDRESS_INET6;
|
---|
| 188 | pkaddr->address.length = sizeof(((struct sockaddr_in6 *)paddr)->sin6_addr);
|
---|
| 189 | pkaddr->address.data = (char *)&(((struct sockaddr_in6 *)paddr)->sin6_addr);
|
---|
| 190 | return true;
|
---|
| 191 | }
|
---|
| 192 | #endif
|
---|
| 193 | if (paddr->ss_family == AF_INET) {
|
---|
| 194 | pkaddr->addr_type = KRB5_ADDRESS_INET;
|
---|
| 195 | pkaddr->address.length = sizeof(((struct sockaddr_in *)paddr)->sin_addr);
|
---|
| 196 | pkaddr->address.data = (char *)&(((struct sockaddr_in *)paddr)->sin_addr);
|
---|
| 197 | return true;
|
---|
| 198 | }
|
---|
| 199 | return false;
|
---|
| 200 | }
|
---|
| 201 | #elif defined(HAVE_ADDRTYPE_IN_KRB5_ADDRESS)
|
---|
| 202 | /* MIT */
|
---|
| 203 | bool setup_kaddr( krb5_address *pkaddr, struct sockaddr_storage *paddr)
|
---|
| 204 | {
|
---|
| 205 | memset(pkaddr, '\0', sizeof(krb5_address));
|
---|
| 206 | #if defined(HAVE_IPV6) && defined(ADDRTYPE_INET6)
|
---|
| 207 | if (paddr->ss_family == AF_INET6) {
|
---|
| 208 | pkaddr->addrtype = ADDRTYPE_INET6;
|
---|
| 209 | pkaddr->length = sizeof(((struct sockaddr_in6 *)paddr)->sin6_addr);
|
---|
| 210 | pkaddr->contents = (krb5_octet *)&(((struct sockaddr_in6 *)paddr)->sin6_addr);
|
---|
| 211 | return true;
|
---|
| 212 | }
|
---|
| 213 | #endif
|
---|
| 214 | if (paddr->ss_family == AF_INET) {
|
---|
| 215 | pkaddr->addrtype = ADDRTYPE_INET;
|
---|
| 216 | pkaddr->length = sizeof(((struct sockaddr_in *)paddr)->sin_addr);
|
---|
| 217 | pkaddr->contents = (krb5_octet *)&(((struct sockaddr_in *)paddr)->sin_addr);
|
---|
| 218 | return true;
|
---|
| 219 | }
|
---|
| 220 | return false;
|
---|
| 221 | }
|
---|
| 222 | #else
|
---|
| 223 | #error UNKNOWN_ADDRTYPE
|
---|
| 224 | #endif
|
---|
| 225 |
|
---|
| 226 | #if defined(HAVE_KRB5_PRINCIPAL2SALT) && defined(HAVE_KRB5_USE_ENCTYPE) && defined(HAVE_KRB5_STRING_TO_KEY) && defined(HAVE_KRB5_ENCRYPT_BLOCK)
|
---|
| 227 | static int create_kerberos_key_from_string_direct(krb5_context context,
|
---|
| 228 | krb5_principal host_princ,
|
---|
| 229 | krb5_data *password,
|
---|
| 230 | krb5_keyblock *key,
|
---|
| 231 | krb5_enctype enctype)
|
---|
| 232 | {
|
---|
| 233 | int ret = 0;
|
---|
| 234 | krb5_data salt;
|
---|
| 235 | krb5_encrypt_block eblock;
|
---|
| 236 |
|
---|
| 237 | ret = krb5_principal2salt(context, host_princ, &salt);
|
---|
| 238 | if (ret) {
|
---|
| 239 | DEBUG(1,("krb5_principal2salt failed (%s)\n", error_message(ret)));
|
---|
| 240 | return ret;
|
---|
| 241 | }
|
---|
| 242 | krb5_use_enctype(context, &eblock, enctype);
|
---|
| 243 | ret = krb5_string_to_key(context, &eblock, key, password, &salt);
|
---|
| 244 | SAFE_FREE(salt.data);
|
---|
| 245 |
|
---|
| 246 | return ret;
|
---|
| 247 | }
|
---|
| 248 | #elif defined(HAVE_KRB5_GET_PW_SALT) && defined(HAVE_KRB5_STRING_TO_KEY_SALT)
|
---|
| 249 | static int create_kerberos_key_from_string_direct(krb5_context context,
|
---|
| 250 | krb5_principal host_princ,
|
---|
| 251 | krb5_data *password,
|
---|
| 252 | krb5_keyblock *key,
|
---|
| 253 | krb5_enctype enctype)
|
---|
| 254 | {
|
---|
| 255 | int ret;
|
---|
| 256 | krb5_salt salt;
|
---|
| 257 |
|
---|
| 258 | ret = krb5_get_pw_salt(context, host_princ, &salt);
|
---|
| 259 | if (ret) {
|
---|
| 260 | DEBUG(1,("krb5_get_pw_salt failed (%s)\n", error_message(ret)));
|
---|
| 261 | return ret;
|
---|
| 262 | }
|
---|
| 263 |
|
---|
| 264 | ret = krb5_string_to_key_salt(context, enctype, (const char *)password->data, salt, key);
|
---|
| 265 | krb5_free_salt(context, salt);
|
---|
| 266 |
|
---|
| 267 | return ret;
|
---|
| 268 | }
|
---|
| 269 | #else
|
---|
| 270 | #error UNKNOWN_CREATE_KEY_FUNCTIONS
|
---|
| 271 | #endif
|
---|
| 272 |
|
---|
| 273 | int create_kerberos_key_from_string(krb5_context context,
|
---|
| 274 | krb5_principal host_princ,
|
---|
| 275 | krb5_data *password,
|
---|
| 276 | krb5_keyblock *key,
|
---|
| 277 | krb5_enctype enctype,
|
---|
| 278 | bool no_salt)
|
---|
| 279 | {
|
---|
| 280 | krb5_principal salt_princ = NULL;
|
---|
| 281 | int ret;
|
---|
| 282 | /*
|
---|
| 283 | * Check if we've determined that the KDC is salting keys for this
|
---|
| 284 | * principal/enctype in a non-obvious way. If it is, try to match
|
---|
| 285 | * its behavior.
|
---|
| 286 | */
|
---|
| 287 | if (no_salt) {
|
---|
| 288 | KRB5_KEY_DATA(key) = (KRB5_KEY_DATA_CAST *)SMB_MALLOC(password->length);
|
---|
| 289 | if (!KRB5_KEY_DATA(key)) {
|
---|
| 290 | return ENOMEM;
|
---|
| 291 | }
|
---|
| 292 | memcpy(KRB5_KEY_DATA(key), password->data, password->length);
|
---|
| 293 | KRB5_KEY_LENGTH(key) = password->length;
|
---|
| 294 | KRB5_KEY_TYPE(key) = enctype;
|
---|
| 295 | return 0;
|
---|
| 296 | }
|
---|
| 297 | salt_princ = kerberos_fetch_salt_princ_for_host_princ(context, host_princ, enctype);
|
---|
| 298 | ret = create_kerberos_key_from_string_direct(context, salt_princ ? salt_princ : host_princ, password, key, enctype);
|
---|
| 299 | if (salt_princ) {
|
---|
| 300 | krb5_free_principal(context, salt_princ);
|
---|
| 301 | }
|
---|
| 302 | return ret;
|
---|
| 303 | }
|
---|
| 304 |
|
---|
| 305 | #if defined(HAVE_KRB5_GET_PERMITTED_ENCTYPES)
|
---|
| 306 | krb5_error_code get_kerberos_allowed_etypes(krb5_context context,
|
---|
| 307 | krb5_enctype **enctypes)
|
---|
| 308 | {
|
---|
| 309 | return krb5_get_permitted_enctypes(context, enctypes);
|
---|
| 310 | }
|
---|
| 311 | #elif defined(HAVE_KRB5_GET_DEFAULT_IN_TKT_ETYPES)
|
---|
| 312 | krb5_error_code get_kerberos_allowed_etypes(krb5_context context,
|
---|
| 313 | krb5_enctype **enctypes)
|
---|
| 314 | {
|
---|
| 315 | return krb5_get_default_in_tkt_etypes(context, enctypes);
|
---|
| 316 | }
|
---|
| 317 | #else
|
---|
| 318 | #error UNKNOWN_GET_ENCTYPES_FUNCTIONS
|
---|
| 319 | #endif
|
---|
| 320 |
|
---|
| 321 | #if defined(HAVE_KRB5_AUTH_CON_SETKEY) && !defined(HAVE_KRB5_AUTH_CON_SETUSERUSERKEY)
|
---|
| 322 | krb5_error_code krb5_auth_con_setuseruserkey(krb5_context context,
|
---|
| 323 | krb5_auth_context auth_context,
|
---|
| 324 | krb5_keyblock *keyblock)
|
---|
| 325 | {
|
---|
| 326 | return krb5_auth_con_setkey(context, auth_context, keyblock);
|
---|
| 327 | }
|
---|
| 328 | #endif
|
---|
| 329 |
|
---|
| 330 | bool unwrap_edata_ntstatus(TALLOC_CTX *mem_ctx,
|
---|
| 331 | DATA_BLOB *edata,
|
---|
| 332 | DATA_BLOB *edata_out)
|
---|
| 333 | {
|
---|
| 334 | DATA_BLOB edata_contents;
|
---|
| 335 | ASN1_DATA *data;
|
---|
| 336 | int edata_type;
|
---|
| 337 |
|
---|
| 338 | if (!edata->length) {
|
---|
| 339 | return False;
|
---|
| 340 | }
|
---|
| 341 |
|
---|
| 342 | data = asn1_init(mem_ctx);
|
---|
| 343 | if (data == NULL) {
|
---|
| 344 | return false;
|
---|
| 345 | }
|
---|
| 346 |
|
---|
| 347 | asn1_load(data, *edata);
|
---|
| 348 | asn1_start_tag(data, ASN1_SEQUENCE(0));
|
---|
| 349 | asn1_start_tag(data, ASN1_CONTEXT(1));
|
---|
| 350 | asn1_read_Integer(data, &edata_type);
|
---|
| 351 |
|
---|
| 352 | if (edata_type != KRB5_PADATA_PW_SALT) {
|
---|
| 353 | DEBUG(0,("edata is not of required type %d but of type %d\n",
|
---|
| 354 | KRB5_PADATA_PW_SALT, edata_type));
|
---|
| 355 | asn1_free(data);
|
---|
| 356 | return False;
|
---|
| 357 | }
|
---|
| 358 |
|
---|
| 359 | asn1_start_tag(data, ASN1_CONTEXT(2));
|
---|
| 360 | asn1_read_OctetString(data, talloc_tos(), &edata_contents);
|
---|
| 361 | asn1_end_tag(data);
|
---|
| 362 | asn1_end_tag(data);
|
---|
| 363 | asn1_end_tag(data);
|
---|
| 364 | asn1_free(data);
|
---|
| 365 |
|
---|
| 366 | *edata_out = data_blob_talloc(mem_ctx, edata_contents.data, edata_contents.length);
|
---|
| 367 |
|
---|
| 368 | data_blob_free(&edata_contents);
|
---|
| 369 |
|
---|
| 370 | return True;
|
---|
| 371 | }
|
---|
| 372 |
|
---|
| 373 |
|
---|
| 374 | bool unwrap_pac(TALLOC_CTX *mem_ctx, DATA_BLOB *auth_data, DATA_BLOB *unwrapped_pac_data)
|
---|
| 375 | {
|
---|
| 376 | DATA_BLOB pac_contents;
|
---|
| 377 | ASN1_DATA *data;
|
---|
| 378 | int data_type;
|
---|
| 379 |
|
---|
| 380 | if (!auth_data->length) {
|
---|
| 381 | return False;
|
---|
| 382 | }
|
---|
| 383 |
|
---|
| 384 | data = asn1_init(mem_ctx);
|
---|
| 385 | if (data == NULL) {
|
---|
| 386 | return false;
|
---|
| 387 | }
|
---|
| 388 |
|
---|
| 389 | asn1_load(data, *auth_data);
|
---|
| 390 | asn1_start_tag(data, ASN1_SEQUENCE(0));
|
---|
| 391 | asn1_start_tag(data, ASN1_SEQUENCE(0));
|
---|
| 392 | asn1_start_tag(data, ASN1_CONTEXT(0));
|
---|
| 393 | asn1_read_Integer(data, &data_type);
|
---|
| 394 |
|
---|
| 395 | if (data_type != KRB5_AUTHDATA_WIN2K_PAC ) {
|
---|
| 396 | DEBUG(10,("authorization data is not a Windows PAC (type: %d)\n", data_type));
|
---|
| 397 | asn1_free(data);
|
---|
| 398 | return False;
|
---|
| 399 | }
|
---|
| 400 |
|
---|
| 401 | asn1_end_tag(data);
|
---|
| 402 | asn1_start_tag(data, ASN1_CONTEXT(1));
|
---|
| 403 | asn1_read_OctetString(data, talloc_tos(), &pac_contents);
|
---|
| 404 | asn1_end_tag(data);
|
---|
| 405 | asn1_end_tag(data);
|
---|
| 406 | asn1_end_tag(data);
|
---|
| 407 | asn1_free(data);
|
---|
| 408 |
|
---|
| 409 | *unwrapped_pac_data = data_blob_talloc(mem_ctx, pac_contents.data, pac_contents.length);
|
---|
| 410 |
|
---|
| 411 | data_blob_free(&pac_contents);
|
---|
| 412 |
|
---|
| 413 | return True;
|
---|
| 414 | }
|
---|
| 415 |
|
---|
| 416 | bool get_auth_data_from_tkt(TALLOC_CTX *mem_ctx, DATA_BLOB *auth_data, krb5_ticket *tkt)
|
---|
| 417 | {
|
---|
| 418 | DATA_BLOB auth_data_wrapped;
|
---|
| 419 | bool got_auth_data_pac = False;
|
---|
| 420 | int i;
|
---|
| 421 |
|
---|
| 422 | #if defined(HAVE_KRB5_TKT_ENC_PART2)
|
---|
| 423 | if (tkt->enc_part2 && tkt->enc_part2->authorization_data &&
|
---|
| 424 | tkt->enc_part2->authorization_data[0] &&
|
---|
| 425 | tkt->enc_part2->authorization_data[0]->length)
|
---|
| 426 | {
|
---|
| 427 | for (i = 0; tkt->enc_part2->authorization_data[i] != NULL; i++) {
|
---|
| 428 |
|
---|
| 429 | if (tkt->enc_part2->authorization_data[i]->ad_type !=
|
---|
| 430 | KRB5_AUTHDATA_IF_RELEVANT) {
|
---|
| 431 | DEBUG(10,("get_auth_data_from_tkt: ad_type is %d\n",
|
---|
| 432 | tkt->enc_part2->authorization_data[i]->ad_type));
|
---|
| 433 | continue;
|
---|
| 434 | }
|
---|
| 435 |
|
---|
| 436 | auth_data_wrapped = data_blob(tkt->enc_part2->authorization_data[i]->contents,
|
---|
| 437 | tkt->enc_part2->authorization_data[i]->length);
|
---|
| 438 |
|
---|
| 439 | /* check if it is a PAC */
|
---|
| 440 | got_auth_data_pac = unwrap_pac(mem_ctx, &auth_data_wrapped, auth_data);
|
---|
| 441 | data_blob_free(&auth_data_wrapped);
|
---|
| 442 |
|
---|
| 443 | if (got_auth_data_pac) {
|
---|
| 444 | return true;
|
---|
| 445 | }
|
---|
| 446 | }
|
---|
| 447 |
|
---|
| 448 | return got_auth_data_pac;
|
---|
| 449 | }
|
---|
| 450 |
|
---|
| 451 | #else
|
---|
| 452 | if (tkt->ticket.authorization_data &&
|
---|
| 453 | tkt->ticket.authorization_data->len)
|
---|
| 454 | {
|
---|
| 455 | for (i = 0; i < tkt->ticket.authorization_data->len; i++) {
|
---|
| 456 |
|
---|
| 457 | if (tkt->ticket.authorization_data->val[i].ad_type !=
|
---|
| 458 | KRB5_AUTHDATA_IF_RELEVANT) {
|
---|
| 459 | DEBUG(10,("get_auth_data_from_tkt: ad_type is %d\n",
|
---|
| 460 | tkt->ticket.authorization_data->val[i].ad_type));
|
---|
| 461 | continue;
|
---|
| 462 | }
|
---|
| 463 |
|
---|
| 464 | auth_data_wrapped = data_blob(tkt->ticket.authorization_data->val[i].ad_data.data,
|
---|
| 465 | tkt->ticket.authorization_data->val[i].ad_data.length);
|
---|
| 466 |
|
---|
| 467 | /* check if it is a PAC */
|
---|
| 468 | got_auth_data_pac = unwrap_pac(mem_ctx, &auth_data_wrapped, auth_data);
|
---|
| 469 | data_blob_free(&auth_data_wrapped);
|
---|
| 470 |
|
---|
| 471 | if (got_auth_data_pac) {
|
---|
| 472 | return true;
|
---|
| 473 | }
|
---|
| 474 | }
|
---|
| 475 |
|
---|
| 476 | return got_auth_data_pac;
|
---|
| 477 | }
|
---|
| 478 | #endif
|
---|
| 479 | return False;
|
---|
| 480 | }
|
---|
| 481 |
|
---|
| 482 | krb5_const_principal get_principal_from_tkt(krb5_ticket *tkt)
|
---|
| 483 | {
|
---|
| 484 | #if defined(HAVE_KRB5_TKT_ENC_PART2)
|
---|
| 485 | return tkt->enc_part2->client;
|
---|
| 486 | #else
|
---|
| 487 | return tkt->client;
|
---|
| 488 | #endif
|
---|
| 489 | }
|
---|
| 490 |
|
---|
| 491 | #if !defined(HAVE_KRB5_FREE_UNPARSED_NAME)
|
---|
| 492 | void krb5_free_unparsed_name(krb5_context context, char *val)
|
---|
| 493 | {
|
---|
| 494 | SAFE_FREE(val);
|
---|
| 495 | }
|
---|
| 496 | #endif
|
---|
| 497 |
|
---|
| 498 | void kerberos_free_data_contents(krb5_context context, krb5_data *pdata)
|
---|
| 499 | {
|
---|
| 500 | #if defined(HAVE_KRB5_FREE_DATA_CONTENTS)
|
---|
| 501 | if (pdata->data) {
|
---|
| 502 | krb5_free_data_contents(context, pdata);
|
---|
| 503 | }
|
---|
| 504 | #else
|
---|
| 505 | SAFE_FREE(pdata->data);
|
---|
| 506 | #endif
|
---|
| 507 | }
|
---|
| 508 |
|
---|
| 509 | void kerberos_set_creds_enctype(krb5_creds *pcreds, int enctype)
|
---|
| 510 | {
|
---|
| 511 | #if defined(HAVE_KRB5_KEYBLOCK_IN_CREDS)
|
---|
| 512 | KRB5_KEY_TYPE((&pcreds->keyblock)) = enctype;
|
---|
| 513 | #elif defined(HAVE_KRB5_SESSION_IN_CREDS)
|
---|
| 514 | KRB5_KEY_TYPE((&pcreds->session)) = enctype;
|
---|
| 515 | #else
|
---|
| 516 | #error UNKNOWN_KEYBLOCK_MEMBER_IN_KRB5_CREDS_STRUCT
|
---|
| 517 | #endif
|
---|
| 518 | }
|
---|
| 519 |
|
---|
| 520 | bool kerberos_compatible_enctypes(krb5_context context,
|
---|
| 521 | krb5_enctype enctype1,
|
---|
| 522 | krb5_enctype enctype2)
|
---|
| 523 | {
|
---|
| 524 | #if defined(HAVE_KRB5_C_ENCTYPE_COMPARE)
|
---|
| 525 | krb5_boolean similar = 0;
|
---|
| 526 |
|
---|
| 527 | krb5_c_enctype_compare(context, enctype1, enctype2, &similar);
|
---|
| 528 | return similar ? True : False;
|
---|
| 529 | #elif defined(HAVE_KRB5_ENCTYPES_COMPATIBLE_KEYS)
|
---|
| 530 | return krb5_enctypes_compatible_keys(context, enctype1, enctype2) ? True : False;
|
---|
| 531 | #endif
|
---|
| 532 | }
|
---|
| 533 |
|
---|
| 534 | static bool ads_cleanup_expired_creds(krb5_context context,
|
---|
| 535 | krb5_ccache ccache,
|
---|
| 536 | krb5_creds *credsp)
|
---|
| 537 | {
|
---|
| 538 | krb5_error_code retval;
|
---|
| 539 | const char *cc_type = krb5_cc_get_type(context, ccache);
|
---|
| 540 |
|
---|
| 541 | DEBUG(3, ("ads_cleanup_expired_creds: Ticket in ccache[%s:%s] expiration %s\n",
|
---|
| 542 | cc_type, krb5_cc_get_name(context, ccache),
|
---|
| 543 | http_timestring(talloc_tos(), credsp->times.endtime)));
|
---|
| 544 |
|
---|
| 545 | /* we will probably need new tickets if the current ones
|
---|
| 546 | will expire within 10 seconds.
|
---|
| 547 | */
|
---|
| 548 | if (credsp->times.endtime >= (time(NULL) + 10))
|
---|
| 549 | return False;
|
---|
| 550 |
|
---|
| 551 | /* heimdal won't remove creds from a file ccache, and
|
---|
| 552 | perhaps we shouldn't anyway, since internally we
|
---|
| 553 | use memory ccaches, and a FILE one probably means that
|
---|
| 554 | we're using creds obtained outside of our exectuable
|
---|
| 555 | */
|
---|
| 556 | if (strequal(cc_type, "FILE")) {
|
---|
| 557 | DEBUG(5, ("ads_cleanup_expired_creds: We do not remove creds from a %s ccache\n", cc_type));
|
---|
| 558 | return False;
|
---|
| 559 | }
|
---|
| 560 |
|
---|
| 561 | retval = krb5_cc_remove_cred(context, ccache, 0, credsp);
|
---|
| 562 | if (retval) {
|
---|
| 563 | DEBUG(1, ("ads_cleanup_expired_creds: krb5_cc_remove_cred failed, err %s\n",
|
---|
| 564 | error_message(retval)));
|
---|
| 565 | /* If we have an error in this, we want to display it,
|
---|
| 566 | but continue as though we deleted it */
|
---|
| 567 | }
|
---|
| 568 | return True;
|
---|
| 569 | }
|
---|
| 570 |
|
---|
| 571 | /* Allocate and setup the auth context into the state we need. */
|
---|
| 572 |
|
---|
| 573 | static krb5_error_code setup_auth_context(krb5_context context,
|
---|
| 574 | krb5_auth_context *auth_context)
|
---|
| 575 | {
|
---|
| 576 | krb5_error_code retval;
|
---|
| 577 |
|
---|
| 578 | retval = krb5_auth_con_init(context, auth_context );
|
---|
| 579 | if (retval) {
|
---|
| 580 | DEBUG(1,("krb5_auth_con_init failed (%s)\n",
|
---|
| 581 | error_message(retval)));
|
---|
| 582 | return retval;
|
---|
| 583 | }
|
---|
| 584 |
|
---|
| 585 | /* Ensure this is an addressless ticket. */
|
---|
| 586 | retval = krb5_auth_con_setaddrs(context, *auth_context, NULL, NULL);
|
---|
| 587 | if (retval) {
|
---|
| 588 | DEBUG(1,("krb5_auth_con_setaddrs failed (%s)\n",
|
---|
| 589 | error_message(retval)));
|
---|
| 590 | }
|
---|
| 591 |
|
---|
| 592 | return retval;
|
---|
| 593 | }
|
---|
| 594 |
|
---|
| 595 | static krb5_error_code create_gss_checksum(krb5_data *in_data, /* [inout] */
|
---|
| 596 | uint32_t gss_flags)
|
---|
| 597 | {
|
---|
| 598 | unsigned int orig_length = in_data->length;
|
---|
| 599 | unsigned int base_cksum_size = GSSAPI_CHECKSUM_SIZE;
|
---|
| 600 | char *gss_cksum = NULL;
|
---|
| 601 |
|
---|
| 602 | if (orig_length) {
|
---|
| 603 | /* Extra length field for delgated ticket. */
|
---|
| 604 | base_cksum_size += 4;
|
---|
| 605 | }
|
---|
| 606 |
|
---|
| 607 | if ((unsigned int)base_cksum_size + orig_length <
|
---|
| 608 | (unsigned int)base_cksum_size) {
|
---|
| 609 | return EINVAL;
|
---|
| 610 | }
|
---|
| 611 |
|
---|
| 612 | gss_cksum = (char *)SMB_MALLOC(base_cksum_size + orig_length);
|
---|
| 613 | if (gss_cksum == NULL) {
|
---|
| 614 | return ENOMEM;
|
---|
| 615 | }
|
---|
| 616 |
|
---|
| 617 | memset(gss_cksum, '\0', base_cksum_size + orig_length);
|
---|
| 618 | SIVAL(gss_cksum, 0, GSSAPI_BNDLENGTH);
|
---|
| 619 |
|
---|
| 620 | /*
|
---|
| 621 | * GSS_C_NO_CHANNEL_BINDINGS means 16 zero bytes.
|
---|
| 622 | * This matches the behavior of heimdal and mit.
|
---|
| 623 | *
|
---|
| 624 | * And it is needed to work against some closed source
|
---|
| 625 | * SMB servers.
|
---|
| 626 | *
|
---|
| 627 | * See bug #7883
|
---|
| 628 | */
|
---|
| 629 | memset(&gss_cksum[4], 0x00, GSSAPI_BNDLENGTH);
|
---|
| 630 |
|
---|
| 631 | SIVAL(gss_cksum, 20, gss_flags);
|
---|
| 632 |
|
---|
| 633 | if (orig_length) {
|
---|
| 634 | SSVAL(gss_cksum, 24, 1); /* The Delegation Option identifier */
|
---|
| 635 | SSVAL(gss_cksum, 26, orig_length);
|
---|
| 636 | /* Copy the kerberos KRB_CRED data */
|
---|
| 637 | memcpy(gss_cksum + 28, in_data->data, orig_length);
|
---|
| 638 | free(in_data->data);
|
---|
| 639 | in_data->data = NULL;
|
---|
| 640 | in_data->length = 0;
|
---|
| 641 | }
|
---|
| 642 | in_data->data = gss_cksum;
|
---|
| 643 | in_data->length = base_cksum_size + orig_length;
|
---|
| 644 | return 0;
|
---|
| 645 | }
|
---|
| 646 |
|
---|
| 647 | /*
|
---|
| 648 | we can't use krb5_mk_req because w2k wants the service to be in a particular format
|
---|
| 649 | */
|
---|
| 650 | static krb5_error_code ads_krb5_mk_req(krb5_context context,
|
---|
| 651 | krb5_auth_context *auth_context,
|
---|
| 652 | const krb5_flags ap_req_options,
|
---|
| 653 | const char *principal,
|
---|
| 654 | krb5_ccache ccache,
|
---|
| 655 | krb5_data *outbuf,
|
---|
| 656 | time_t *expire_time,
|
---|
| 657 | const char *impersonate_princ_s)
|
---|
| 658 | {
|
---|
| 659 | krb5_error_code retval;
|
---|
| 660 | krb5_principal server;
|
---|
| 661 | krb5_principal impersonate_princ = NULL;
|
---|
| 662 | krb5_creds * credsp;
|
---|
| 663 | krb5_creds creds;
|
---|
| 664 | krb5_data in_data;
|
---|
| 665 | bool creds_ready = False;
|
---|
| 666 | int i = 0, maxtries = 3;
|
---|
| 667 | uint32_t gss_flags = 0;
|
---|
| 668 |
|
---|
| 669 | ZERO_STRUCT(in_data);
|
---|
| 670 |
|
---|
| 671 | retval = smb_krb5_parse_name(context, principal, &server);
|
---|
| 672 | if (retval) {
|
---|
| 673 | DEBUG(1,("ads_krb5_mk_req: Failed to parse principal %s\n", principal));
|
---|
| 674 | return retval;
|
---|
| 675 | }
|
---|
| 676 |
|
---|
| 677 | if (impersonate_princ_s) {
|
---|
| 678 | retval = smb_krb5_parse_name(context, impersonate_princ_s,
|
---|
| 679 | &impersonate_princ);
|
---|
| 680 | if (retval) {
|
---|
| 681 | DEBUG(1,("ads_krb5_mk_req: Failed to parse principal %s\n", impersonate_princ_s));
|
---|
| 682 | goto cleanup_princ;
|
---|
| 683 | }
|
---|
| 684 | }
|
---|
| 685 |
|
---|
| 686 | /* obtain ticket & session key */
|
---|
| 687 | ZERO_STRUCT(creds);
|
---|
| 688 | if ((retval = krb5_copy_principal(context, server, &creds.server))) {
|
---|
| 689 | DEBUG(1,("ads_krb5_mk_req: krb5_copy_principal failed (%s)\n",
|
---|
| 690 | error_message(retval)));
|
---|
| 691 | goto cleanup_princ;
|
---|
| 692 | }
|
---|
| 693 |
|
---|
| 694 | if ((retval = krb5_cc_get_principal(context, ccache, &creds.client))) {
|
---|
| 695 | /* This can commonly fail on smbd startup with no ticket in the cache.
|
---|
| 696 | * Report at higher level than 1. */
|
---|
| 697 | DEBUG(3,("ads_krb5_mk_req: krb5_cc_get_principal failed (%s)\n",
|
---|
| 698 | error_message(retval)));
|
---|
| 699 | goto cleanup_creds;
|
---|
| 700 | }
|
---|
| 701 |
|
---|
| 702 | while (!creds_ready && (i < maxtries)) {
|
---|
| 703 |
|
---|
| 704 | if ((retval = smb_krb5_get_credentials(context, ccache,
|
---|
| 705 | creds.client,
|
---|
| 706 | creds.server,
|
---|
| 707 | impersonate_princ,
|
---|
| 708 | &credsp))) {
|
---|
| 709 | DEBUG(1,("ads_krb5_mk_req: smb_krb5_get_credentials failed for %s (%s)\n",
|
---|
| 710 | principal, error_message(retval)));
|
---|
| 711 | goto cleanup_creds;
|
---|
| 712 | }
|
---|
| 713 |
|
---|
| 714 | /* cope with ticket being in the future due to clock skew */
|
---|
| 715 | if ((unsigned)credsp->times.starttime > time(NULL)) {
|
---|
| 716 | time_t t = time(NULL);
|
---|
| 717 | int time_offset =(int)((unsigned)credsp->times.starttime-t);
|
---|
| 718 | DEBUG(4,("ads_krb5_mk_req: Advancing clock by %d seconds to cope with clock skew\n", time_offset));
|
---|
| 719 | krb5_set_real_time(context, t + time_offset + 1, 0);
|
---|
| 720 | }
|
---|
| 721 |
|
---|
| 722 | if (!ads_cleanup_expired_creds(context, ccache, credsp)) {
|
---|
| 723 | creds_ready = True;
|
---|
| 724 | }
|
---|
| 725 |
|
---|
| 726 | i++;
|
---|
| 727 | }
|
---|
| 728 |
|
---|
| 729 | DEBUG(10,("ads_krb5_mk_req: Ticket (%s) in ccache (%s:%s) is valid until: (%s - %u)\n",
|
---|
| 730 | principal, krb5_cc_get_type(context, ccache), krb5_cc_get_name(context, ccache),
|
---|
| 731 | http_timestring(talloc_tos(), (unsigned)credsp->times.endtime),
|
---|
| 732 | (unsigned)credsp->times.endtime));
|
---|
| 733 |
|
---|
| 734 | if (expire_time) {
|
---|
| 735 | *expire_time = (time_t)credsp->times.endtime;
|
---|
| 736 | }
|
---|
| 737 |
|
---|
| 738 | /* Allocate the auth_context. */
|
---|
| 739 | retval = setup_auth_context(context, auth_context);
|
---|
| 740 | if (retval) {
|
---|
| 741 | DEBUG(1,("setup_auth_context failed (%s)\n",
|
---|
| 742 | error_message(retval)));
|
---|
| 743 | goto cleanup_creds;
|
---|
| 744 | }
|
---|
| 745 |
|
---|
| 746 | #if defined(TKT_FLG_OK_AS_DELEGATE ) && defined(HAVE_KRB5_FWD_TGT_CREDS) && defined(HAVE_KRB5_AUTH_CON_SETUSERUSERKEY) && defined(KRB5_AUTH_CONTEXT_USE_SUBKEY) && defined(HAVE_KRB5_AUTH_CON_SET_REQ_CKSUMTYPE)
|
---|
| 747 | if( credsp->ticket_flags & TKT_FLG_OK_AS_DELEGATE ) {
|
---|
| 748 | /* Fetch a forwarded TGT from the KDC so that we can hand off a 2nd ticket
|
---|
| 749 | as part of the kerberos exchange. */
|
---|
| 750 |
|
---|
| 751 | DEBUG( 3, ("ads_krb5_mk_req: server marked as OK to delegate to, building forwardable TGT\n") );
|
---|
| 752 |
|
---|
| 753 | retval = krb5_auth_con_setuseruserkey(context,
|
---|
| 754 | *auth_context,
|
---|
| 755 | &credsp->keyblock );
|
---|
| 756 | if (retval) {
|
---|
| 757 | DEBUG(1,("krb5_auth_con_setuseruserkey failed (%s)\n",
|
---|
| 758 | error_message(retval)));
|
---|
| 759 | goto cleanup_creds;
|
---|
| 760 | }
|
---|
| 761 |
|
---|
| 762 | /* Must use a subkey for forwarded tickets. */
|
---|
| 763 | retval = krb5_auth_con_setflags(context,
|
---|
| 764 | *auth_context,
|
---|
| 765 | KRB5_AUTH_CONTEXT_USE_SUBKEY);
|
---|
| 766 | if (retval) {
|
---|
| 767 | DEBUG(1,("krb5_auth_con_setflags failed (%s)\n",
|
---|
| 768 | error_message(retval)));
|
---|
| 769 | goto cleanup_creds;
|
---|
| 770 | }
|
---|
| 771 |
|
---|
| 772 | retval = krb5_fwd_tgt_creds(context,/* Krb5 context [in] */
|
---|
| 773 | *auth_context, /* Authentication context [in] */
|
---|
| 774 | CONST_DISCARD(char *, KRB5_TGS_NAME), /* Ticket service name ("krbtgt") [in] */
|
---|
| 775 | credsp->client, /* Client principal for the tgt [in] */
|
---|
| 776 | credsp->server, /* Server principal for the tgt [in] */
|
---|
| 777 | ccache, /* Credential cache to use for storage [in] */
|
---|
| 778 | 1, /* Turn on for "Forwardable ticket" [in] */
|
---|
| 779 | &in_data ); /* Resulting response [out] */
|
---|
| 780 |
|
---|
| 781 | if (retval) {
|
---|
| 782 | DEBUG( 3, ("krb5_fwd_tgt_creds failed (%s)\n",
|
---|
| 783 | error_message( retval ) ) );
|
---|
| 784 |
|
---|
| 785 | /*
|
---|
| 786 | * This is not fatal. Delete the *auth_context and continue
|
---|
| 787 | * with krb5_mk_req_extended to get a non-forwardable ticket.
|
---|
| 788 | */
|
---|
| 789 |
|
---|
| 790 | if (in_data.data) {
|
---|
| 791 | free( in_data.data );
|
---|
| 792 | in_data.data = NULL;
|
---|
| 793 | in_data.length = 0;
|
---|
| 794 | }
|
---|
| 795 | krb5_auth_con_free(context, *auth_context);
|
---|
| 796 | *auth_context = NULL;
|
---|
| 797 | retval = setup_auth_context(context, auth_context);
|
---|
| 798 | if (retval) {
|
---|
| 799 | DEBUG(1,("setup_auth_context failed (%s)\n",
|
---|
| 800 | error_message(retval)));
|
---|
| 801 | goto cleanup_creds;
|
---|
| 802 | }
|
---|
| 803 | } else {
|
---|
| 804 | /* We got a delegated ticket. */
|
---|
| 805 | gss_flags |= GSS_C_DELEG_FLAG;
|
---|
| 806 | }
|
---|
| 807 | }
|
---|
| 808 |
|
---|
| 809 | /* Frees and reallocates in_data into a GSS checksum blob. */
|
---|
| 810 | retval = create_gss_checksum(&in_data, gss_flags);
|
---|
| 811 | if (retval) {
|
---|
| 812 | goto cleanup_data;
|
---|
| 813 | }
|
---|
| 814 |
|
---|
| 815 | /* We always want GSS-checksum types. */
|
---|
| 816 | retval = krb5_auth_con_set_req_cksumtype(context, *auth_context, GSSAPI_CHECKSUM );
|
---|
| 817 | if (retval) {
|
---|
| 818 | DEBUG(1,("krb5_auth_con_set_req_cksumtype failed (%s)\n",
|
---|
| 819 | error_message(retval)));
|
---|
| 820 | goto cleanup_data;
|
---|
| 821 | }
|
---|
| 822 | #endif
|
---|
| 823 |
|
---|
| 824 | retval = krb5_mk_req_extended(context, auth_context, ap_req_options,
|
---|
| 825 | &in_data, credsp, outbuf);
|
---|
| 826 | if (retval) {
|
---|
| 827 | DEBUG(1,("ads_krb5_mk_req: krb5_mk_req_extended failed (%s)\n",
|
---|
| 828 | error_message(retval)));
|
---|
| 829 | }
|
---|
| 830 |
|
---|
| 831 | cleanup_data:
|
---|
| 832 | if (in_data.data) {
|
---|
| 833 | free( in_data.data );
|
---|
| 834 | in_data.length = 0;
|
---|
| 835 | }
|
---|
| 836 |
|
---|
| 837 | krb5_free_creds(context, credsp);
|
---|
| 838 |
|
---|
| 839 | cleanup_creds:
|
---|
| 840 | krb5_free_cred_contents(context, &creds);
|
---|
| 841 |
|
---|
| 842 | cleanup_princ:
|
---|
| 843 | krb5_free_principal(context, server);
|
---|
| 844 | if (impersonate_princ) {
|
---|
| 845 | krb5_free_principal(context, impersonate_princ);
|
---|
| 846 | }
|
---|
| 847 |
|
---|
| 848 | return retval;
|
---|
| 849 | }
|
---|
| 850 |
|
---|
| 851 | /*
|
---|
| 852 | get a kerberos5 ticket for the given service
|
---|
| 853 | */
|
---|
| 854 | int cli_krb5_get_ticket(TALLOC_CTX *mem_ctx,
|
---|
| 855 | const char *principal, time_t time_offset,
|
---|
| 856 | DATA_BLOB *ticket, DATA_BLOB *session_key_krb5,
|
---|
| 857 | uint32_t extra_ap_opts, const char *ccname,
|
---|
| 858 | time_t *tgs_expire,
|
---|
| 859 | const char *impersonate_princ_s)
|
---|
| 860 |
|
---|
| 861 | {
|
---|
| 862 | krb5_error_code retval;
|
---|
| 863 | krb5_data packet;
|
---|
| 864 | krb5_context context = NULL;
|
---|
| 865 | krb5_ccache ccdef = NULL;
|
---|
| 866 | krb5_auth_context auth_context = NULL;
|
---|
| 867 | krb5_enctype enc_types[] = {
|
---|
| 868 | #ifdef HAVE_ENCTYPE_AES256_CTS_HMAC_SHA1_96
|
---|
| 869 | ENCTYPE_AES256_CTS_HMAC_SHA1_96,
|
---|
| 870 | #endif
|
---|
| 871 | #ifdef HAVE_ENCTYPE_AES128_CTS_HMAC_SHA1_96
|
---|
| 872 | ENCTYPE_AES128_CTS_HMAC_SHA1_96,
|
---|
| 873 | #endif
|
---|
| 874 | ENCTYPE_ARCFOUR_HMAC,
|
---|
| 875 | ENCTYPE_DES_CBC_MD5,
|
---|
| 876 | ENCTYPE_DES_CBC_CRC,
|
---|
| 877 | ENCTYPE_NULL};
|
---|
| 878 |
|
---|
| 879 | initialize_krb5_error_table();
|
---|
| 880 | retval = krb5_init_context(&context);
|
---|
| 881 | if (retval) {
|
---|
| 882 | DEBUG(1, ("krb5_init_context failed (%s)\n",
|
---|
| 883 | error_message(retval)));
|
---|
| 884 | goto failed;
|
---|
| 885 | }
|
---|
| 886 |
|
---|
| 887 | if (time_offset != 0) {
|
---|
| 888 | krb5_set_real_time(context, time(NULL) + time_offset, 0);
|
---|
| 889 | }
|
---|
| 890 |
|
---|
| 891 | if ((retval = krb5_cc_resolve(context, ccname ?
|
---|
| 892 | ccname : krb5_cc_default_name(context), &ccdef))) {
|
---|
| 893 | DEBUG(1, ("krb5_cc_default failed (%s)\n",
|
---|
| 894 | error_message(retval)));
|
---|
| 895 | goto failed;
|
---|
| 896 | }
|
---|
| 897 |
|
---|
| 898 | if ((retval = krb5_set_default_tgs_ktypes(context, enc_types))) {
|
---|
| 899 | DEBUG(1, ("krb5_set_default_tgs_ktypes failed (%s)\n",
|
---|
| 900 | error_message(retval)));
|
---|
| 901 | goto failed;
|
---|
| 902 | }
|
---|
| 903 |
|
---|
| 904 | retval = ads_krb5_mk_req(context, &auth_context,
|
---|
| 905 | AP_OPTS_USE_SUBKEY | (krb5_flags)extra_ap_opts,
|
---|
| 906 | principal, ccdef, &packet,
|
---|
| 907 | tgs_expire, impersonate_princ_s);
|
---|
| 908 | if (retval) {
|
---|
| 909 | goto failed;
|
---|
| 910 | }
|
---|
| 911 |
|
---|
| 912 | get_krb5_smb_session_key(mem_ctx, context, auth_context,
|
---|
| 913 | session_key_krb5, false);
|
---|
| 914 |
|
---|
| 915 | *ticket = data_blob_talloc(mem_ctx, packet.data, packet.length);
|
---|
| 916 |
|
---|
| 917 | kerberos_free_data_contents(context, &packet);
|
---|
| 918 |
|
---|
| 919 | failed:
|
---|
| 920 |
|
---|
| 921 | if (context) {
|
---|
| 922 | if (ccdef)
|
---|
| 923 | krb5_cc_close(context, ccdef);
|
---|
| 924 | if (auth_context)
|
---|
| 925 | krb5_auth_con_free(context, auth_context);
|
---|
| 926 | krb5_free_context(context);
|
---|
| 927 | }
|
---|
| 928 |
|
---|
| 929 | return retval;
|
---|
| 930 | }
|
---|
| 931 |
|
---|
| 932 | bool get_krb5_smb_session_key(TALLOC_CTX *mem_ctx,
|
---|
| 933 | krb5_context context,
|
---|
| 934 | krb5_auth_context auth_context,
|
---|
| 935 | DATA_BLOB *session_key, bool remote)
|
---|
| 936 | {
|
---|
| 937 | krb5_keyblock *skey = NULL;
|
---|
| 938 | krb5_error_code err = 0;
|
---|
| 939 | bool ret = false;
|
---|
| 940 |
|
---|
| 941 | if (remote) {
|
---|
| 942 | err = krb5_auth_con_getremotesubkey(context,
|
---|
| 943 | auth_context, &skey);
|
---|
| 944 | } else {
|
---|
| 945 | err = krb5_auth_con_getlocalsubkey(context,
|
---|
| 946 | auth_context, &skey);
|
---|
| 947 | }
|
---|
| 948 |
|
---|
| 949 | if (err || skey == NULL) {
|
---|
| 950 | DEBUG(10, ("KRB5 error getting session key %d\n", err));
|
---|
| 951 | goto done;
|
---|
| 952 | }
|
---|
| 953 |
|
---|
| 954 | DEBUG(10, ("Got KRB5 session key of length %d\n",
|
---|
| 955 | (int)KRB5_KEY_LENGTH(skey)));
|
---|
| 956 |
|
---|
| 957 | *session_key = data_blob_talloc(mem_ctx,
|
---|
| 958 | KRB5_KEY_DATA(skey),
|
---|
| 959 | KRB5_KEY_LENGTH(skey));
|
---|
| 960 | dump_data_pw("KRB5 Session Key:\n",
|
---|
| 961 | session_key->data,
|
---|
| 962 | session_key->length);
|
---|
| 963 |
|
---|
| 964 | ret = true;
|
---|
| 965 |
|
---|
| 966 | done:
|
---|
| 967 | if (skey) {
|
---|
| 968 | krb5_free_keyblock(context, skey);
|
---|
| 969 | }
|
---|
| 970 |
|
---|
| 971 | return ret;
|
---|
| 972 | }
|
---|
| 973 |
|
---|
| 974 |
|
---|
| 975 | #if defined(HAVE_KRB5_PRINCIPAL_GET_COMP_STRING) && !defined(HAVE_KRB5_PRINC_COMPONENT)
|
---|
| 976 | const krb5_data *krb5_princ_component(krb5_context context, krb5_principal principal, int i );
|
---|
| 977 |
|
---|
| 978 | const krb5_data *krb5_princ_component(krb5_context context, krb5_principal principal, int i )
|
---|
| 979 | {
|
---|
| 980 | static krb5_data kdata;
|
---|
| 981 |
|
---|
| 982 | kdata.data = (char *)krb5_principal_get_comp_string(context, principal, i);
|
---|
| 983 | kdata.length = strlen((const char *)kdata.data);
|
---|
| 984 | return &kdata;
|
---|
| 985 | }
|
---|
| 986 | #endif
|
---|
| 987 |
|
---|
| 988 | krb5_error_code smb_krb5_kt_free_entry(krb5_context context, krb5_keytab_entry *kt_entry)
|
---|
| 989 | {
|
---|
| 990 | /* Try krb5_free_keytab_entry_contents first, since
|
---|
| 991 | * MIT Kerberos >= 1.7 has both krb5_free_keytab_entry_contents and
|
---|
| 992 | * krb5_kt_free_entry but only has a prototype for the first, while the
|
---|
| 993 | * second is considered private.
|
---|
| 994 | */
|
---|
| 995 | #if defined(HAVE_KRB5_FREE_KEYTAB_ENTRY_CONTENTS)
|
---|
| 996 | return krb5_free_keytab_entry_contents(context, kt_entry);
|
---|
| 997 | #elif defined(HAVE_KRB5_KT_FREE_ENTRY)
|
---|
| 998 | return krb5_kt_free_entry(context, kt_entry);
|
---|
| 999 | #else
|
---|
| 1000 | #error UNKNOWN_KT_FREE_FUNCTION
|
---|
| 1001 | #endif
|
---|
| 1002 | }
|
---|
| 1003 |
|
---|
| 1004 | void smb_krb5_checksum_from_pac_sig(krb5_checksum *cksum,
|
---|
| 1005 | struct PAC_SIGNATURE_DATA *sig)
|
---|
| 1006 | {
|
---|
| 1007 | #ifdef HAVE_CHECKSUM_IN_KRB5_CHECKSUM
|
---|
| 1008 | cksum->cksumtype = (krb5_cksumtype)sig->type;
|
---|
| 1009 | cksum->checksum.length = sig->signature.length;
|
---|
| 1010 | cksum->checksum.data = sig->signature.data;
|
---|
| 1011 | #else
|
---|
| 1012 | cksum->checksum_type = (krb5_cksumtype)sig->type;
|
---|
| 1013 | cksum->length = sig->signature.length;
|
---|
| 1014 | cksum->contents = sig->signature.data;
|
---|
| 1015 | #endif
|
---|
| 1016 | }
|
---|
| 1017 |
|
---|
| 1018 | krb5_error_code smb_krb5_verify_checksum(krb5_context context,
|
---|
| 1019 | const krb5_keyblock *keyblock,
|
---|
| 1020 | krb5_keyusage usage,
|
---|
| 1021 | krb5_checksum *cksum,
|
---|
| 1022 | uint8 *data,
|
---|
| 1023 | size_t length)
|
---|
| 1024 | {
|
---|
| 1025 | krb5_error_code ret;
|
---|
| 1026 |
|
---|
| 1027 | /* verify the checksum */
|
---|
| 1028 |
|
---|
| 1029 | /* welcome to the wonderful world of samba's kerberos abstraction layer:
|
---|
| 1030 | *
|
---|
| 1031 | * function heimdal 0.6.1rc3 heimdal 0.7 MIT krb 1.4.2
|
---|
| 1032 | * -----------------------------------------------------------------------------
|
---|
| 1033 | * krb5_c_verify_checksum - works works
|
---|
| 1034 | * krb5_verify_checksum works (6 args) works (6 args) broken (7 args)
|
---|
| 1035 | */
|
---|
| 1036 |
|
---|
| 1037 | #if defined(HAVE_KRB5_C_VERIFY_CHECKSUM)
|
---|
| 1038 | {
|
---|
| 1039 | krb5_boolean checksum_valid = False;
|
---|
| 1040 | krb5_data input;
|
---|
| 1041 |
|
---|
| 1042 | input.data = (char *)data;
|
---|
| 1043 | input.length = length;
|
---|
| 1044 |
|
---|
| 1045 | ret = krb5_c_verify_checksum(context,
|
---|
| 1046 | keyblock,
|
---|
| 1047 | usage,
|
---|
| 1048 | &input,
|
---|
| 1049 | cksum,
|
---|
| 1050 | &checksum_valid);
|
---|
| 1051 | if (ret) {
|
---|
| 1052 | DEBUG(3,("smb_krb5_verify_checksum: krb5_c_verify_checksum() failed: %s\n",
|
---|
| 1053 | error_message(ret)));
|
---|
| 1054 | return ret;
|
---|
| 1055 | }
|
---|
| 1056 |
|
---|
| 1057 | if (!checksum_valid)
|
---|
| 1058 | ret = KRB5KRB_AP_ERR_BAD_INTEGRITY;
|
---|
| 1059 | }
|
---|
| 1060 |
|
---|
| 1061 | #elif KRB5_VERIFY_CHECKSUM_ARGS == 6 && defined(HAVE_KRB5_CRYPTO_INIT) && defined(HAVE_KRB5_CRYPTO) && defined(HAVE_KRB5_CRYPTO_DESTROY)
|
---|
| 1062 |
|
---|
| 1063 | /* Warning: MIT's krb5_verify_checksum cannot be used as it will use a key
|
---|
| 1064 | * without enctype and it ignores any key_usage types - Guenther */
|
---|
| 1065 |
|
---|
| 1066 | {
|
---|
| 1067 |
|
---|
| 1068 | krb5_crypto crypto;
|
---|
| 1069 | ret = krb5_crypto_init(context,
|
---|
| 1070 | keyblock,
|
---|
| 1071 | 0,
|
---|
| 1072 | &crypto);
|
---|
| 1073 | if (ret) {
|
---|
| 1074 | DEBUG(0,("smb_krb5_verify_checksum: krb5_crypto_init() failed: %s\n",
|
---|
| 1075 | error_message(ret)));
|
---|
| 1076 | return ret;
|
---|
| 1077 | }
|
---|
| 1078 |
|
---|
| 1079 | ret = krb5_verify_checksum(context,
|
---|
| 1080 | crypto,
|
---|
| 1081 | usage,
|
---|
| 1082 | data,
|
---|
| 1083 | length,
|
---|
| 1084 | cksum);
|
---|
| 1085 |
|
---|
| 1086 | krb5_crypto_destroy(context, crypto);
|
---|
| 1087 | }
|
---|
| 1088 |
|
---|
| 1089 | #else
|
---|
| 1090 | #error UNKNOWN_KRB5_VERIFY_CHECKSUM_FUNCTION
|
---|
| 1091 | #endif
|
---|
| 1092 |
|
---|
| 1093 | return ret;
|
---|
| 1094 | }
|
---|
| 1095 |
|
---|
| 1096 | time_t get_authtime_from_tkt(krb5_ticket *tkt)
|
---|
| 1097 | {
|
---|
| 1098 | #if defined(HAVE_KRB5_TKT_ENC_PART2)
|
---|
| 1099 | return tkt->enc_part2->times.authtime;
|
---|
| 1100 | #else
|
---|
| 1101 | return tkt->ticket.authtime;
|
---|
| 1102 | #endif
|
---|
| 1103 | }
|
---|
| 1104 |
|
---|
| 1105 | #ifdef HAVE_KRB5_DECODE_AP_REQ /* Heimdal */
|
---|
| 1106 | static int get_kvno_from_ap_req(krb5_ap_req *ap_req)
|
---|
| 1107 | {
|
---|
| 1108 | #ifdef HAVE_TICKET_POINTER_IN_KRB5_AP_REQ /* MIT */
|
---|
| 1109 | if (ap_req->ticket->enc_part.kvno)
|
---|
| 1110 | return ap_req->ticket->enc_part.kvno;
|
---|
| 1111 | #else /* Heimdal */
|
---|
| 1112 | if (ap_req->ticket.enc_part.kvno)
|
---|
| 1113 | return *ap_req->ticket.enc_part.kvno;
|
---|
| 1114 | #endif
|
---|
| 1115 | return 0;
|
---|
| 1116 | }
|
---|
| 1117 |
|
---|
| 1118 | static krb5_enctype get_enctype_from_ap_req(krb5_ap_req *ap_req)
|
---|
| 1119 | {
|
---|
| 1120 | #ifdef HAVE_ETYPE_IN_ENCRYPTEDDATA /* Heimdal */
|
---|
| 1121 | return ap_req->ticket.enc_part.etype;
|
---|
| 1122 | #else /* MIT */
|
---|
| 1123 | return ap_req->ticket->enc_part.enctype;
|
---|
| 1124 | #endif
|
---|
| 1125 | }
|
---|
| 1126 | #endif /* HAVE_KRB5_DECODE_AP_REQ */
|
---|
| 1127 |
|
---|
| 1128 | static krb5_error_code
|
---|
| 1129 | get_key_from_keytab(krb5_context context,
|
---|
| 1130 | krb5_const_principal server,
|
---|
| 1131 | krb5_enctype enctype,
|
---|
| 1132 | krb5_kvno kvno,
|
---|
| 1133 | krb5_keyblock **out_key)
|
---|
| 1134 | {
|
---|
| 1135 | krb5_keytab_entry entry;
|
---|
| 1136 | krb5_error_code ret;
|
---|
| 1137 | krb5_keytab keytab;
|
---|
| 1138 | char *name = NULL;
|
---|
| 1139 | krb5_keyblock *keyp;
|
---|
| 1140 |
|
---|
| 1141 | /* We have to open a new keytab handle here, as MIT does
|
---|
| 1142 | an implicit open/getnext/close on krb5_kt_get_entry. We
|
---|
| 1143 | may be in the middle of a keytab enumeration when this is
|
---|
| 1144 | called. JRA. */
|
---|
| 1145 |
|
---|
| 1146 | ret = smb_krb5_open_keytab(context, NULL, False, &keytab);
|
---|
| 1147 | if (ret) {
|
---|
| 1148 | DEBUG(1,("get_key_from_keytab: smb_krb5_open_keytab failed (%s)\n", error_message(ret)));
|
---|
| 1149 | return ret;
|
---|
| 1150 | }
|
---|
| 1151 |
|
---|
| 1152 | if ( DEBUGLEVEL >= 10 ) {
|
---|
| 1153 | if (smb_krb5_unparse_name(talloc_tos(), context, server, &name) == 0) {
|
---|
| 1154 | DEBUG(10,("get_key_from_keytab: will look for kvno %d, enctype %d and name: %s\n",
|
---|
| 1155 | kvno, enctype, name));
|
---|
| 1156 | TALLOC_FREE(name);
|
---|
| 1157 | }
|
---|
| 1158 | }
|
---|
| 1159 |
|
---|
| 1160 | ret = krb5_kt_get_entry(context,
|
---|
| 1161 | keytab,
|
---|
| 1162 | server,
|
---|
| 1163 | kvno,
|
---|
| 1164 | enctype,
|
---|
| 1165 | &entry);
|
---|
| 1166 |
|
---|
| 1167 | if (ret) {
|
---|
| 1168 | DEBUG(0,("get_key_from_keytab: failed to retrieve key: %s\n", error_message(ret)));
|
---|
| 1169 | goto out;
|
---|
| 1170 | }
|
---|
| 1171 |
|
---|
| 1172 | keyp = KRB5_KT_KEY(&entry);
|
---|
| 1173 |
|
---|
| 1174 | ret = krb5_copy_keyblock(context, keyp, out_key);
|
---|
| 1175 | if (ret) {
|
---|
| 1176 | DEBUG(0,("get_key_from_keytab: failed to copy key: %s\n", error_message(ret)));
|
---|
| 1177 | goto out;
|
---|
| 1178 | }
|
---|
| 1179 |
|
---|
| 1180 | smb_krb5_kt_free_entry(context, &entry);
|
---|
| 1181 |
|
---|
| 1182 | out:
|
---|
| 1183 | krb5_kt_close(context, keytab);
|
---|
| 1184 | return ret;
|
---|
| 1185 | }
|
---|
| 1186 |
|
---|
| 1187 | /* Prototypes */
|
---|
| 1188 |
|
---|
| 1189 | krb5_error_code smb_krb5_get_keyinfo_from_ap_req(krb5_context context,
|
---|
| 1190 | const krb5_data *inbuf,
|
---|
| 1191 | krb5_kvno *kvno,
|
---|
| 1192 | krb5_enctype *enctype)
|
---|
| 1193 | {
|
---|
| 1194 | #ifdef HAVE_KRB5_DECODE_AP_REQ /* Heimdal */
|
---|
| 1195 | {
|
---|
| 1196 | krb5_error_code ret;
|
---|
| 1197 | krb5_ap_req ap_req;
|
---|
| 1198 |
|
---|
| 1199 | ret = krb5_decode_ap_req(context, inbuf, &ap_req);
|
---|
| 1200 | if (ret)
|
---|
| 1201 | return ret;
|
---|
| 1202 |
|
---|
| 1203 | *kvno = get_kvno_from_ap_req(&ap_req);
|
---|
| 1204 | *enctype = get_enctype_from_ap_req(&ap_req);
|
---|
| 1205 |
|
---|
| 1206 | free_AP_REQ(&ap_req);
|
---|
| 1207 | return 0;
|
---|
| 1208 | }
|
---|
| 1209 | #endif
|
---|
| 1210 |
|
---|
| 1211 | /* Possibly not an appropriate error code. */
|
---|
| 1212 | return KRB5KDC_ERR_BADOPTION;
|
---|
| 1213 | }
|
---|
| 1214 |
|
---|
| 1215 | krb5_error_code krb5_rd_req_return_keyblock_from_keytab(krb5_context context,
|
---|
| 1216 | krb5_auth_context *auth_context,
|
---|
| 1217 | const krb5_data *inbuf,
|
---|
| 1218 | krb5_const_principal server,
|
---|
| 1219 | krb5_keytab keytab,
|
---|
| 1220 | krb5_flags *ap_req_options,
|
---|
| 1221 | krb5_ticket **ticket,
|
---|
| 1222 | krb5_keyblock **keyblock)
|
---|
| 1223 | {
|
---|
| 1224 | krb5_error_code ret;
|
---|
| 1225 | krb5_kvno kvno;
|
---|
| 1226 | krb5_enctype enctype;
|
---|
| 1227 | krb5_keyblock *local_keyblock;
|
---|
| 1228 |
|
---|
| 1229 | ret = krb5_rd_req(context,
|
---|
| 1230 | auth_context,
|
---|
| 1231 | inbuf,
|
---|
| 1232 | server,
|
---|
| 1233 | keytab,
|
---|
| 1234 | ap_req_options,
|
---|
| 1235 | ticket);
|
---|
| 1236 | if (ret) {
|
---|
| 1237 | return ret;
|
---|
| 1238 | }
|
---|
| 1239 |
|
---|
| 1240 | #ifdef KRB5_TICKET_HAS_KEYINFO
|
---|
| 1241 | enctype = (*ticket)->enc_part.enctype;
|
---|
| 1242 | kvno = (*ticket)->enc_part.kvno;
|
---|
| 1243 | #else
|
---|
| 1244 | ret = smb_krb5_get_keyinfo_from_ap_req(context, inbuf, &kvno, &enctype);
|
---|
| 1245 | if (ret) {
|
---|
| 1246 | return ret;
|
---|
| 1247 | }
|
---|
| 1248 | #endif
|
---|
| 1249 |
|
---|
| 1250 | ret = get_key_from_keytab(context,
|
---|
| 1251 | server,
|
---|
| 1252 | enctype,
|
---|
| 1253 | kvno,
|
---|
| 1254 | &local_keyblock);
|
---|
| 1255 | if (ret) {
|
---|
| 1256 | DEBUG(0,("krb5_rd_req_return_keyblock_from_keytab: failed to call get_key_from_keytab\n"));
|
---|
| 1257 | goto out;
|
---|
| 1258 | }
|
---|
| 1259 |
|
---|
| 1260 | out:
|
---|
| 1261 | if (ret && local_keyblock != NULL) {
|
---|
| 1262 | krb5_free_keyblock(context, local_keyblock);
|
---|
| 1263 | } else {
|
---|
| 1264 | *keyblock = local_keyblock;
|
---|
| 1265 | }
|
---|
| 1266 |
|
---|
| 1267 | return ret;
|
---|
| 1268 | }
|
---|
| 1269 |
|
---|
| 1270 | krb5_error_code smb_krb5_parse_name_norealm(krb5_context context,
|
---|
| 1271 | const char *name,
|
---|
| 1272 | krb5_principal *principal)
|
---|
| 1273 | {
|
---|
| 1274 | #ifdef HAVE_KRB5_PARSE_NAME_NOREALM
|
---|
| 1275 | return smb_krb5_parse_name_norealm_conv(context, name, principal);
|
---|
| 1276 | #endif
|
---|
| 1277 |
|
---|
| 1278 | /* we are cheating here because parse_name will in fact set the realm.
|
---|
| 1279 | * We don't care as the only caller of smb_krb5_parse_name_norealm
|
---|
| 1280 | * ignores the realm anyway when calling
|
---|
| 1281 | * smb_krb5_principal_compare_any_realm later - Guenther */
|
---|
| 1282 |
|
---|
| 1283 | return smb_krb5_parse_name(context, name, principal);
|
---|
| 1284 | }
|
---|
| 1285 |
|
---|
| 1286 | bool smb_krb5_principal_compare_any_realm(krb5_context context,
|
---|
| 1287 | krb5_const_principal princ1,
|
---|
| 1288 | krb5_const_principal princ2)
|
---|
| 1289 | {
|
---|
| 1290 | #ifdef HAVE_KRB5_PRINCIPAL_COMPARE_ANY_REALM
|
---|
| 1291 |
|
---|
| 1292 | return krb5_principal_compare_any_realm(context, princ1, princ2);
|
---|
| 1293 |
|
---|
| 1294 | /* krb5_princ_size is a macro in MIT */
|
---|
| 1295 | #elif defined(HAVE_KRB5_PRINC_SIZE) || defined(krb5_princ_size)
|
---|
| 1296 |
|
---|
| 1297 | int i, len1, len2;
|
---|
| 1298 | const krb5_data *p1, *p2;
|
---|
| 1299 |
|
---|
| 1300 | len1 = krb5_princ_size(context, princ1);
|
---|
| 1301 | len2 = krb5_princ_size(context, princ2);
|
---|
| 1302 |
|
---|
| 1303 | if (len1 != len2)
|
---|
| 1304 | return False;
|
---|
| 1305 |
|
---|
| 1306 | for (i = 0; i < len1; i++) {
|
---|
| 1307 |
|
---|
| 1308 | p1 = krb5_princ_component(context, CONST_DISCARD(krb5_principal, princ1), i);
|
---|
| 1309 | p2 = krb5_princ_component(context, CONST_DISCARD(krb5_principal, princ2), i);
|
---|
| 1310 |
|
---|
| 1311 | if (p1->length != p2->length || memcmp(p1->data, p2->data, p1->length))
|
---|
| 1312 | return False;
|
---|
| 1313 | }
|
---|
| 1314 |
|
---|
| 1315 | return True;
|
---|
| 1316 | #else
|
---|
| 1317 | #error NO_SUITABLE_PRINCIPAL_COMPARE_FUNCTION
|
---|
| 1318 | #endif
|
---|
| 1319 | }
|
---|
| 1320 |
|
---|
| 1321 | krb5_error_code smb_krb5_renew_ticket(const char *ccache_string, /* FILE:/tmp/krb5cc_0 */
|
---|
| 1322 | const char *client_string, /* gd@BER.SUSE.DE */
|
---|
| 1323 | const char *service_string, /* krbtgt/BER.SUSE.DE@BER.SUSE.DE */
|
---|
| 1324 | time_t *expire_time)
|
---|
| 1325 | {
|
---|
| 1326 | krb5_error_code ret;
|
---|
| 1327 | krb5_context context = NULL;
|
---|
| 1328 | krb5_ccache ccache = NULL;
|
---|
| 1329 | krb5_principal client = NULL;
|
---|
| 1330 | krb5_creds creds, creds_in, *creds_out = NULL;
|
---|
| 1331 |
|
---|
| 1332 | ZERO_STRUCT(creds);
|
---|
| 1333 | ZERO_STRUCT(creds_in);
|
---|
| 1334 |
|
---|
| 1335 | initialize_krb5_error_table();
|
---|
| 1336 | ret = krb5_init_context(&context);
|
---|
| 1337 | if (ret) {
|
---|
| 1338 | goto done;
|
---|
| 1339 | }
|
---|
| 1340 |
|
---|
| 1341 | if (!ccache_string) {
|
---|
| 1342 | ccache_string = krb5_cc_default_name(context);
|
---|
| 1343 | }
|
---|
| 1344 |
|
---|
| 1345 | if (!ccache_string) {
|
---|
| 1346 | ret = EINVAL;
|
---|
| 1347 | goto done;
|
---|
| 1348 | }
|
---|
| 1349 |
|
---|
| 1350 | DEBUG(10,("smb_krb5_renew_ticket: using %s as ccache\n", ccache_string));
|
---|
| 1351 |
|
---|
| 1352 | /* FIXME: we should not fall back to defaults */
|
---|
| 1353 | ret = krb5_cc_resolve(context, CONST_DISCARD(char *, ccache_string), &ccache);
|
---|
| 1354 | if (ret) {
|
---|
| 1355 | goto done;
|
---|
| 1356 | }
|
---|
| 1357 |
|
---|
| 1358 | if (client_string) {
|
---|
| 1359 | ret = smb_krb5_parse_name(context, client_string, &client);
|
---|
| 1360 | if (ret) {
|
---|
| 1361 | goto done;
|
---|
| 1362 | }
|
---|
| 1363 | } else {
|
---|
| 1364 | ret = krb5_cc_get_principal(context, ccache, &client);
|
---|
| 1365 | if (ret) {
|
---|
| 1366 | goto done;
|
---|
| 1367 | }
|
---|
| 1368 | }
|
---|
| 1369 |
|
---|
| 1370 | #ifdef HAVE_KRB5_GET_RENEWED_CREDS /* MIT */
|
---|
| 1371 | {
|
---|
| 1372 | ret = krb5_get_renewed_creds(context, &creds, client, ccache, CONST_DISCARD(char *, service_string));
|
---|
| 1373 | if (ret) {
|
---|
| 1374 | DEBUG(10,("smb_krb5_renew_ticket: krb5_get_kdc_cred failed: %s\n", error_message(ret)));
|
---|
| 1375 | goto done;
|
---|
| 1376 | }
|
---|
| 1377 | }
|
---|
| 1378 | #elif defined(HAVE_KRB5_GET_KDC_CRED) /* Heimdal */
|
---|
| 1379 | {
|
---|
| 1380 | krb5_kdc_flags flags;
|
---|
| 1381 | krb5_realm *client_realm = NULL;
|
---|
| 1382 |
|
---|
| 1383 | ret = krb5_copy_principal(context, client, &creds_in.client);
|
---|
| 1384 | if (ret) {
|
---|
| 1385 | goto done;
|
---|
| 1386 | }
|
---|
| 1387 |
|
---|
| 1388 | if (service_string) {
|
---|
| 1389 | ret = smb_krb5_parse_name(context, service_string, &creds_in.server);
|
---|
| 1390 | if (ret) {
|
---|
| 1391 | goto done;
|
---|
| 1392 | }
|
---|
| 1393 | } else {
|
---|
| 1394 | /* build tgt service by default */
|
---|
| 1395 | client_realm = krb5_princ_realm(context, creds_in.client);
|
---|
| 1396 | if (!client_realm) {
|
---|
| 1397 | ret = ENOMEM;
|
---|
| 1398 | goto done;
|
---|
| 1399 | }
|
---|
| 1400 | ret = krb5_make_principal(context, &creds_in.server, *client_realm, KRB5_TGS_NAME, *client_realm, NULL);
|
---|
| 1401 | if (ret) {
|
---|
| 1402 | goto done;
|
---|
| 1403 | }
|
---|
| 1404 | }
|
---|
| 1405 |
|
---|
| 1406 | flags.i = 0;
|
---|
| 1407 | flags.b.renewable = flags.b.renew = True;
|
---|
| 1408 |
|
---|
| 1409 | ret = krb5_get_kdc_cred(context, ccache, flags, NULL, NULL, &creds_in, &creds_out);
|
---|
| 1410 | if (ret) {
|
---|
| 1411 | DEBUG(10,("smb_krb5_renew_ticket: krb5_get_kdc_cred failed: %s\n", error_message(ret)));
|
---|
| 1412 | goto done;
|
---|
| 1413 | }
|
---|
| 1414 |
|
---|
| 1415 | creds = *creds_out;
|
---|
| 1416 | }
|
---|
| 1417 | #else
|
---|
| 1418 | #error NO_SUITABLE_KRB5_TICKET_RENEW_FUNCTION_AVAILABLE
|
---|
| 1419 | #endif
|
---|
| 1420 |
|
---|
| 1421 | /* hm, doesn't that create a new one if the old one wasn't there? - Guenther */
|
---|
| 1422 | ret = krb5_cc_initialize(context, ccache, client);
|
---|
| 1423 | if (ret) {
|
---|
| 1424 | goto done;
|
---|
| 1425 | }
|
---|
| 1426 |
|
---|
| 1427 | ret = krb5_cc_store_cred(context, ccache, &creds);
|
---|
| 1428 |
|
---|
| 1429 | if (expire_time) {
|
---|
| 1430 | *expire_time = (time_t) creds.times.endtime;
|
---|
| 1431 | }
|
---|
| 1432 |
|
---|
| 1433 | done:
|
---|
| 1434 | krb5_free_cred_contents(context, &creds_in);
|
---|
| 1435 |
|
---|
| 1436 | if (creds_out) {
|
---|
| 1437 | krb5_free_creds(context, creds_out);
|
---|
| 1438 | } else {
|
---|
| 1439 | krb5_free_cred_contents(context, &creds);
|
---|
| 1440 | }
|
---|
| 1441 |
|
---|
| 1442 | if (client) {
|
---|
| 1443 | krb5_free_principal(context, client);
|
---|
| 1444 | }
|
---|
| 1445 | if (ccache) {
|
---|
| 1446 | krb5_cc_close(context, ccache);
|
---|
| 1447 | }
|
---|
| 1448 | if (context) {
|
---|
| 1449 | krb5_free_context(context);
|
---|
| 1450 | }
|
---|
| 1451 |
|
---|
| 1452 | return ret;
|
---|
| 1453 | }
|
---|
| 1454 |
|
---|
| 1455 | krb5_error_code smb_krb5_free_addresses(krb5_context context, smb_krb5_addresses *addr)
|
---|
| 1456 | {
|
---|
| 1457 | krb5_error_code ret = 0;
|
---|
| 1458 | if (addr == NULL) {
|
---|
| 1459 | return ret;
|
---|
| 1460 | }
|
---|
| 1461 | #if defined(HAVE_MAGIC_IN_KRB5_ADDRESS) && defined(HAVE_ADDRTYPE_IN_KRB5_ADDRESS) /* MIT */
|
---|
| 1462 | krb5_free_addresses(context, addr->addrs);
|
---|
| 1463 | #elif defined(HAVE_ADDR_TYPE_IN_KRB5_ADDRESS) /* Heimdal */
|
---|
| 1464 | ret = krb5_free_addresses(context, addr->addrs);
|
---|
| 1465 | SAFE_FREE(addr->addrs);
|
---|
| 1466 | #endif
|
---|
| 1467 | SAFE_FREE(addr);
|
---|
| 1468 | addr = NULL;
|
---|
| 1469 | return ret;
|
---|
| 1470 | }
|
---|
| 1471 |
|
---|
| 1472 | krb5_error_code smb_krb5_gen_netbios_krb5_address(smb_krb5_addresses **kerb_addr)
|
---|
| 1473 | {
|
---|
| 1474 | krb5_error_code ret = 0;
|
---|
| 1475 | nstring buf;
|
---|
| 1476 | #if defined(HAVE_MAGIC_IN_KRB5_ADDRESS) && defined(HAVE_ADDRTYPE_IN_KRB5_ADDRESS) /* MIT */
|
---|
| 1477 | krb5_address **addrs = NULL;
|
---|
| 1478 | #elif defined(HAVE_ADDR_TYPE_IN_KRB5_ADDRESS) /* Heimdal */
|
---|
| 1479 | krb5_addresses *addrs = NULL;
|
---|
| 1480 | #endif
|
---|
| 1481 |
|
---|
| 1482 | *kerb_addr = (smb_krb5_addresses *)SMB_MALLOC(sizeof(smb_krb5_addresses));
|
---|
| 1483 | if (*kerb_addr == NULL) {
|
---|
| 1484 | return ENOMEM;
|
---|
| 1485 | }
|
---|
| 1486 |
|
---|
| 1487 | put_name(buf, global_myname(), ' ', 0x20);
|
---|
| 1488 |
|
---|
| 1489 | #if defined(HAVE_MAGIC_IN_KRB5_ADDRESS) && defined(HAVE_ADDRTYPE_IN_KRB5_ADDRESS) /* MIT */
|
---|
| 1490 | {
|
---|
| 1491 | int num_addr = 2;
|
---|
| 1492 |
|
---|
| 1493 | addrs = (krb5_address **)SMB_MALLOC(sizeof(krb5_address *) * num_addr);
|
---|
| 1494 | if (addrs == NULL) {
|
---|
| 1495 | SAFE_FREE(*kerb_addr);
|
---|
| 1496 | return ENOMEM;
|
---|
| 1497 | }
|
---|
| 1498 |
|
---|
| 1499 | memset(addrs, 0, sizeof(krb5_address *) * num_addr);
|
---|
| 1500 |
|
---|
| 1501 | addrs[0] = (krb5_address *)SMB_MALLOC(sizeof(krb5_address));
|
---|
| 1502 | if (addrs[0] == NULL) {
|
---|
| 1503 | SAFE_FREE(addrs);
|
---|
| 1504 | SAFE_FREE(*kerb_addr);
|
---|
| 1505 | return ENOMEM;
|
---|
| 1506 | }
|
---|
| 1507 |
|
---|
| 1508 | addrs[0]->magic = KV5M_ADDRESS;
|
---|
| 1509 | addrs[0]->addrtype = KRB5_ADDR_NETBIOS;
|
---|
| 1510 | addrs[0]->length = MAX_NETBIOSNAME_LEN;
|
---|
| 1511 | addrs[0]->contents = (unsigned char *)SMB_MALLOC(addrs[0]->length);
|
---|
| 1512 | if (addrs[0]->contents == NULL) {
|
---|
| 1513 | SAFE_FREE(addrs[0]);
|
---|
| 1514 | SAFE_FREE(addrs);
|
---|
| 1515 | SAFE_FREE(*kerb_addr);
|
---|
| 1516 | return ENOMEM;
|
---|
| 1517 | }
|
---|
| 1518 |
|
---|
| 1519 | memcpy(addrs[0]->contents, buf, addrs[0]->length);
|
---|
| 1520 |
|
---|
| 1521 | addrs[1] = NULL;
|
---|
| 1522 | }
|
---|
| 1523 | #elif defined(HAVE_ADDR_TYPE_IN_KRB5_ADDRESS) /* Heimdal */
|
---|
| 1524 | {
|
---|
| 1525 | addrs = (krb5_addresses *)SMB_MALLOC(sizeof(krb5_addresses));
|
---|
| 1526 | if (addrs == NULL) {
|
---|
| 1527 | SAFE_FREE(*kerb_addr);
|
---|
| 1528 | return ENOMEM;
|
---|
| 1529 | }
|
---|
| 1530 |
|
---|
| 1531 | memset(addrs, 0, sizeof(krb5_addresses));
|
---|
| 1532 |
|
---|
| 1533 | addrs->len = 1;
|
---|
| 1534 | addrs->val = (krb5_address *)SMB_MALLOC(sizeof(krb5_address));
|
---|
| 1535 | if (addrs->val == NULL) {
|
---|
| 1536 | SAFE_FREE(addrs);
|
---|
| 1537 | SAFE_FREE(kerb_addr);
|
---|
| 1538 | return ENOMEM;
|
---|
| 1539 | }
|
---|
| 1540 |
|
---|
| 1541 | addrs->val[0].addr_type = KRB5_ADDR_NETBIOS;
|
---|
| 1542 | addrs->val[0].address.length = MAX_NETBIOSNAME_LEN;
|
---|
| 1543 | addrs->val[0].address.data = (unsigned char *)SMB_MALLOC(addrs->val[0].address.length);
|
---|
| 1544 | if (addrs->val[0].address.data == NULL) {
|
---|
| 1545 | SAFE_FREE(addrs->val);
|
---|
| 1546 | SAFE_FREE(addrs);
|
---|
| 1547 | SAFE_FREE(*kerb_addr);
|
---|
| 1548 | return ENOMEM;
|
---|
| 1549 | }
|
---|
| 1550 |
|
---|
| 1551 | memcpy(addrs->val[0].address.data, buf, addrs->val[0].address.length);
|
---|
| 1552 | }
|
---|
| 1553 | #else
|
---|
| 1554 | #error UNKNOWN_KRB5_ADDRESS_FORMAT
|
---|
| 1555 | #endif
|
---|
| 1556 | (*kerb_addr)->addrs = addrs;
|
---|
| 1557 |
|
---|
| 1558 | return ret;
|
---|
| 1559 | }
|
---|
| 1560 |
|
---|
| 1561 | void smb_krb5_free_error(krb5_context context, krb5_error *krberror)
|
---|
| 1562 | {
|
---|
| 1563 | #ifdef HAVE_KRB5_FREE_ERROR_CONTENTS /* Heimdal */
|
---|
| 1564 | krb5_free_error_contents(context, krberror);
|
---|
| 1565 | #else /* MIT */
|
---|
| 1566 | krb5_free_error(context, krberror);
|
---|
| 1567 | #endif
|
---|
| 1568 | }
|
---|
| 1569 |
|
---|
| 1570 | krb5_error_code handle_krberror_packet(krb5_context context,
|
---|
| 1571 | krb5_data *packet)
|
---|
| 1572 | {
|
---|
| 1573 | krb5_error_code ret;
|
---|
| 1574 | bool got_error_code = False;
|
---|
| 1575 |
|
---|
| 1576 | DEBUG(10,("handle_krberror_packet: got error packet\n"));
|
---|
| 1577 |
|
---|
| 1578 | #ifdef HAVE_E_DATA_POINTER_IN_KRB5_ERROR /* Heimdal */
|
---|
| 1579 | {
|
---|
| 1580 | krb5_error krberror;
|
---|
| 1581 |
|
---|
| 1582 | if ((ret = krb5_rd_error(context, packet, &krberror))) {
|
---|
| 1583 | DEBUG(10,("handle_krberror_packet: krb5_rd_error failed with: %s\n",
|
---|
| 1584 | error_message(ret)));
|
---|
| 1585 | return ret;
|
---|
| 1586 | }
|
---|
| 1587 |
|
---|
| 1588 | if (krberror.e_data == NULL || krberror.e_data->data == NULL) {
|
---|
| 1589 | ret = (krb5_error_code) krberror.error_code;
|
---|
| 1590 | got_error_code = True;
|
---|
| 1591 | }
|
---|
| 1592 |
|
---|
| 1593 | smb_krb5_free_error(context, &krberror);
|
---|
| 1594 | }
|
---|
| 1595 | #else /* MIT */
|
---|
| 1596 | {
|
---|
| 1597 | krb5_error *krberror;
|
---|
| 1598 |
|
---|
| 1599 | if ((ret = krb5_rd_error(context, packet, &krberror))) {
|
---|
| 1600 | DEBUG(10,("handle_krberror_packet: krb5_rd_error failed with: %s\n",
|
---|
| 1601 | error_message(ret)));
|
---|
| 1602 | return ret;
|
---|
| 1603 | }
|
---|
| 1604 |
|
---|
| 1605 | if (krberror->e_data.data == NULL) {
|
---|
| 1606 | #if defined(ERROR_TABLE_BASE_krb5)
|
---|
| 1607 | ret = ERROR_TABLE_BASE_krb5 + (krb5_error_code) krberror->error;
|
---|
| 1608 | #else
|
---|
| 1609 | ret = (krb5_error_code)krberror->error;
|
---|
| 1610 | #endif
|
---|
| 1611 | got_error_code = True;
|
---|
| 1612 | }
|
---|
| 1613 | smb_krb5_free_error(context, krberror);
|
---|
| 1614 | }
|
---|
| 1615 | #endif
|
---|
| 1616 | if (got_error_code) {
|
---|
| 1617 | DEBUG(5,("handle_krberror_packet: got KERBERR from kpasswd: %s (%d)\n",
|
---|
| 1618 | error_message(ret), ret));
|
---|
| 1619 | }
|
---|
| 1620 | return ret;
|
---|
| 1621 | }
|
---|
| 1622 |
|
---|
| 1623 | krb5_error_code smb_krb5_get_init_creds_opt_alloc(krb5_context context,
|
---|
| 1624 | krb5_get_init_creds_opt **opt)
|
---|
| 1625 | {
|
---|
| 1626 | #ifdef HAVE_KRB5_GET_INIT_CREDS_OPT_ALLOC
|
---|
| 1627 | /* Heimdal or modern MIT version */
|
---|
| 1628 | return krb5_get_init_creds_opt_alloc(context, opt);
|
---|
| 1629 | #else
|
---|
| 1630 | /* Historical MIT version */
|
---|
| 1631 | krb5_get_init_creds_opt *my_opt;
|
---|
| 1632 |
|
---|
| 1633 | *opt = NULL;
|
---|
| 1634 |
|
---|
| 1635 | if ((my_opt = SMB_MALLOC_P(krb5_get_init_creds_opt)) == NULL) {
|
---|
| 1636 | return ENOMEM;
|
---|
| 1637 | }
|
---|
| 1638 |
|
---|
| 1639 | krb5_get_init_creds_opt_init(my_opt);
|
---|
| 1640 |
|
---|
| 1641 | *opt = my_opt;
|
---|
| 1642 | return 0;
|
---|
| 1643 | #endif /* HAVE_KRB5_GET_INIT_CREDS_OPT_ALLOC */
|
---|
| 1644 | }
|
---|
| 1645 |
|
---|
| 1646 | void smb_krb5_get_init_creds_opt_free(krb5_context context,
|
---|
| 1647 | krb5_get_init_creds_opt *opt)
|
---|
| 1648 | {
|
---|
| 1649 | #ifdef HAVE_KRB5_GET_INIT_CREDS_OPT_FREE
|
---|
| 1650 |
|
---|
| 1651 | #ifdef KRB5_CREDS_OPT_FREE_REQUIRES_CONTEXT
|
---|
| 1652 | /* Modern MIT or Heimdal version */
|
---|
| 1653 | krb5_get_init_creds_opt_free(context, opt);
|
---|
| 1654 | #else
|
---|
| 1655 | /* Heimdal version */
|
---|
| 1656 | krb5_get_init_creds_opt_free(opt);
|
---|
| 1657 | #endif /* KRB5_CREDS_OPT_FREE_REQUIRES_CONTEXT */
|
---|
| 1658 |
|
---|
| 1659 | #else /* HAVE_KRB5_GET_INIT_CREDS_OPT_FREE */
|
---|
| 1660 | /* Historical MIT version */
|
---|
| 1661 | SAFE_FREE(opt);
|
---|
| 1662 | opt = NULL;
|
---|
| 1663 | #endif /* HAVE_KRB5_GET_INIT_CREDS_OPT_FREE */
|
---|
| 1664 | }
|
---|
| 1665 |
|
---|
| 1666 | krb5_enctype smb_get_enctype_from_kt_entry(krb5_keytab_entry *kt_entry)
|
---|
| 1667 | {
|
---|
| 1668 | return KRB5_KEY_TYPE(KRB5_KT_KEY(kt_entry));
|
---|
| 1669 | }
|
---|
| 1670 |
|
---|
| 1671 |
|
---|
| 1672 | /* caller needs to free etype_s */
|
---|
| 1673 | krb5_error_code smb_krb5_enctype_to_string(krb5_context context,
|
---|
| 1674 | krb5_enctype enctype,
|
---|
| 1675 | char **etype_s)
|
---|
| 1676 | {
|
---|
| 1677 | #ifdef HAVE_KRB5_ENCTYPE_TO_STRING_WITH_KRB5_CONTEXT_ARG
|
---|
| 1678 | return krb5_enctype_to_string(context, enctype, etype_s); /* Heimdal */
|
---|
| 1679 | #elif defined(HAVE_KRB5_ENCTYPE_TO_STRING_WITH_SIZE_T_ARG)
|
---|
| 1680 | char buf[256];
|
---|
| 1681 | krb5_error_code ret = krb5_enctype_to_string(enctype, buf, 256); /* MIT */
|
---|
| 1682 | if (ret) {
|
---|
| 1683 | return ret;
|
---|
| 1684 | }
|
---|
| 1685 | *etype_s = SMB_STRDUP(buf);
|
---|
| 1686 | if (!*etype_s) {
|
---|
| 1687 | return ENOMEM;
|
---|
| 1688 | }
|
---|
| 1689 | return ret;
|
---|
| 1690 | #else
|
---|
| 1691 | #error UNKNOWN_KRB5_ENCTYPE_TO_STRING_FUNCTION
|
---|
| 1692 | #endif
|
---|
| 1693 | }
|
---|
| 1694 |
|
---|
| 1695 | krb5_error_code smb_krb5_mk_error(krb5_context context,
|
---|
| 1696 | krb5_error_code error_code,
|
---|
| 1697 | const krb5_principal server,
|
---|
| 1698 | krb5_data *reply)
|
---|
| 1699 | {
|
---|
| 1700 | #ifdef HAVE_SHORT_KRB5_MK_ERROR_INTERFACE /* MIT */
|
---|
| 1701 | /*
|
---|
| 1702 | * The MIT interface is *terrible*.
|
---|
| 1703 | * We have to construct this ourselves...
|
---|
| 1704 | */
|
---|
| 1705 | krb5_error e;
|
---|
| 1706 |
|
---|
| 1707 | memset(&e, 0, sizeof(e));
|
---|
| 1708 | krb5_us_timeofday(context, &e.stime, &e.susec);
|
---|
| 1709 | e.server = server;
|
---|
| 1710 | #if defined(krb5_err_base)
|
---|
| 1711 | e.error = error_code - krb5_err_base;
|
---|
| 1712 | #elif defined(ERROR_TABLE_BASE_krb5)
|
---|
| 1713 | e.error = error_code - ERROR_TABLE_BASE_krb5;
|
---|
| 1714 | #else
|
---|
| 1715 | e.error = error_code; /* Almost certainly wrong, but what can we do... ? */
|
---|
| 1716 | #endif
|
---|
| 1717 |
|
---|
| 1718 | return krb5_mk_error(context, &e, reply);
|
---|
| 1719 | #else /* Heimdal. */
|
---|
| 1720 | return krb5_mk_error(context,
|
---|
| 1721 | error_code,
|
---|
| 1722 | NULL,
|
---|
| 1723 | NULL, /* e_data */
|
---|
| 1724 | NULL,
|
---|
| 1725 | server,
|
---|
| 1726 | NULL,
|
---|
| 1727 | NULL,
|
---|
| 1728 | reply);
|
---|
| 1729 | #endif
|
---|
| 1730 | }
|
---|
| 1731 |
|
---|
| 1732 | /**********************************************************************
|
---|
| 1733 | * Open a krb5 keytab with flags, handles readonly or readwrite access and
|
---|
| 1734 | * allows to process non-default keytab names.
|
---|
| 1735 | * @param context krb5_context
|
---|
| 1736 | * @param keytab_name_req string
|
---|
| 1737 | * @param write_access bool if writable keytab is required
|
---|
| 1738 | * @param krb5_keytab pointer to krb5_keytab (close with krb5_kt_close())
|
---|
| 1739 | * @return krb5_error_code
|
---|
| 1740 | **********************************************************************/
|
---|
| 1741 |
|
---|
| 1742 | /* This MAX_NAME_LEN is a constant defined in krb5.h */
|
---|
| 1743 | #ifndef MAX_KEYTAB_NAME_LEN
|
---|
| 1744 | #define MAX_KEYTAB_NAME_LEN 1100
|
---|
| 1745 | #endif
|
---|
| 1746 |
|
---|
| 1747 | krb5_error_code smb_krb5_open_keytab(krb5_context context,
|
---|
| 1748 | const char *keytab_name_req,
|
---|
| 1749 | bool write_access,
|
---|
| 1750 | krb5_keytab *keytab)
|
---|
| 1751 | {
|
---|
| 1752 | krb5_error_code ret = 0;
|
---|
| 1753 | TALLOC_CTX *mem_ctx;
|
---|
| 1754 | char keytab_string[MAX_KEYTAB_NAME_LEN];
|
---|
| 1755 | char *kt_str = NULL;
|
---|
| 1756 | bool found_valid_name = False;
|
---|
| 1757 | const char *pragma = "FILE";
|
---|
| 1758 | const char *tmp = NULL;
|
---|
| 1759 |
|
---|
| 1760 | if (!write_access && !keytab_name_req) {
|
---|
| 1761 | /* caller just wants to read the default keytab readonly, so be it */
|
---|
| 1762 | return krb5_kt_default(context, keytab);
|
---|
| 1763 | }
|
---|
| 1764 |
|
---|
| 1765 | mem_ctx = talloc_init("smb_krb5_open_keytab");
|
---|
| 1766 | if (!mem_ctx) {
|
---|
| 1767 | return ENOMEM;
|
---|
| 1768 | }
|
---|
| 1769 |
|
---|
| 1770 | #ifdef HAVE_WRFILE_KEYTAB
|
---|
| 1771 | if (write_access) {
|
---|
| 1772 | pragma = "WRFILE";
|
---|
| 1773 | }
|
---|
| 1774 | #endif
|
---|
| 1775 |
|
---|
| 1776 | if (keytab_name_req) {
|
---|
| 1777 |
|
---|
| 1778 | if (strlen(keytab_name_req) > MAX_KEYTAB_NAME_LEN) {
|
---|
| 1779 | ret = KRB5_CONFIG_NOTENUFSPACE;
|
---|
| 1780 | goto out;
|
---|
| 1781 | }
|
---|
| 1782 |
|
---|
| 1783 | if ((strncmp(keytab_name_req, "WRFILE:/", 8) == 0) ||
|
---|
| 1784 | (strncmp(keytab_name_req, "FILE:/", 6) == 0)) {
|
---|
| 1785 | tmp = keytab_name_req;
|
---|
| 1786 | goto resolve;
|
---|
| 1787 | }
|
---|
| 1788 |
|
---|
| 1789 | if (keytab_name_req[0] != '/') {
|
---|
| 1790 | ret = KRB5_KT_BADNAME;
|
---|
| 1791 | goto out;
|
---|
| 1792 | }
|
---|
| 1793 |
|
---|
| 1794 | tmp = talloc_asprintf(mem_ctx, "%s:%s", pragma, keytab_name_req);
|
---|
| 1795 | if (!tmp) {
|
---|
| 1796 | ret = ENOMEM;
|
---|
| 1797 | goto out;
|
---|
| 1798 | }
|
---|
| 1799 |
|
---|
| 1800 | goto resolve;
|
---|
| 1801 | }
|
---|
| 1802 |
|
---|
| 1803 | /* we need to handle more complex keytab_strings, like:
|
---|
| 1804 | * "ANY:FILE:/etc/krb5.keytab,krb4:/etc/srvtab" */
|
---|
| 1805 |
|
---|
| 1806 | ret = krb5_kt_default_name(context, &keytab_string[0], MAX_KEYTAB_NAME_LEN - 2);
|
---|
| 1807 | if (ret) {
|
---|
| 1808 | goto out;
|
---|
| 1809 | }
|
---|
| 1810 |
|
---|
| 1811 | DEBUG(10,("smb_krb5_open_keytab: krb5_kt_default_name returned %s\n", keytab_string));
|
---|
| 1812 |
|
---|
| 1813 | tmp = talloc_strdup(mem_ctx, keytab_string);
|
---|
| 1814 | if (!tmp) {
|
---|
| 1815 | ret = ENOMEM;
|
---|
| 1816 | goto out;
|
---|
| 1817 | }
|
---|
| 1818 |
|
---|
| 1819 | if (strncmp(tmp, "ANY:", 4) == 0) {
|
---|
| 1820 | tmp += 4;
|
---|
| 1821 | }
|
---|
| 1822 |
|
---|
| 1823 | memset(&keytab_string, '\0', sizeof(keytab_string));
|
---|
| 1824 |
|
---|
| 1825 | while (next_token_talloc(mem_ctx, &tmp, &kt_str, ",")) {
|
---|
| 1826 | if (strncmp(kt_str, "WRFILE:", 7) == 0) {
|
---|
| 1827 | found_valid_name = True;
|
---|
| 1828 | tmp = kt_str;
|
---|
| 1829 | tmp += 7;
|
---|
| 1830 | }
|
---|
| 1831 |
|
---|
| 1832 | if (strncmp(kt_str, "FILE:", 5) == 0) {
|
---|
| 1833 | found_valid_name = True;
|
---|
| 1834 | tmp = kt_str;
|
---|
| 1835 | tmp += 5;
|
---|
| 1836 | }
|
---|
| 1837 |
|
---|
| 1838 | if (tmp[0] == '/') {
|
---|
| 1839 | /* Treat as a FILE: keytab definition. */
|
---|
| 1840 | found_valid_name = true;
|
---|
| 1841 | }
|
---|
| 1842 |
|
---|
| 1843 | if (found_valid_name) {
|
---|
| 1844 | if (tmp[0] != '/') {
|
---|
| 1845 | ret = KRB5_KT_BADNAME;
|
---|
| 1846 | goto out;
|
---|
| 1847 | }
|
---|
| 1848 |
|
---|
| 1849 | tmp = talloc_asprintf(mem_ctx, "%s:%s", pragma, tmp);
|
---|
| 1850 | if (!tmp) {
|
---|
| 1851 | ret = ENOMEM;
|
---|
| 1852 | goto out;
|
---|
| 1853 | }
|
---|
| 1854 | break;
|
---|
| 1855 | }
|
---|
| 1856 | }
|
---|
| 1857 |
|
---|
| 1858 | if (!found_valid_name) {
|
---|
| 1859 | ret = KRB5_KT_UNKNOWN_TYPE;
|
---|
| 1860 | goto out;
|
---|
| 1861 | }
|
---|
| 1862 |
|
---|
| 1863 | resolve:
|
---|
| 1864 | DEBUG(10,("smb_krb5_open_keytab: resolving: %s\n", tmp));
|
---|
| 1865 | ret = krb5_kt_resolve(context, tmp, keytab);
|
---|
| 1866 |
|
---|
| 1867 | out:
|
---|
| 1868 | TALLOC_FREE(mem_ctx);
|
---|
| 1869 | return ret;
|
---|
| 1870 | }
|
---|
| 1871 |
|
---|
| 1872 | krb5_error_code smb_krb5_keytab_name(TALLOC_CTX *mem_ctx,
|
---|
| 1873 | krb5_context context,
|
---|
| 1874 | krb5_keytab keytab,
|
---|
| 1875 | const char **keytab_name)
|
---|
| 1876 | {
|
---|
| 1877 | char keytab_string[MAX_KEYTAB_NAME_LEN];
|
---|
| 1878 | krb5_error_code ret = 0;
|
---|
| 1879 |
|
---|
| 1880 | ret = krb5_kt_get_name(context, keytab,
|
---|
| 1881 | keytab_string, MAX_KEYTAB_NAME_LEN - 2);
|
---|
| 1882 | if (ret) {
|
---|
| 1883 | return ret;
|
---|
| 1884 | }
|
---|
| 1885 |
|
---|
| 1886 | *keytab_name = talloc_strdup(mem_ctx, keytab_string);
|
---|
| 1887 | if (!*keytab_name) {
|
---|
| 1888 | return ENOMEM;
|
---|
| 1889 | }
|
---|
| 1890 |
|
---|
| 1891 | return ret;
|
---|
| 1892 | }
|
---|
| 1893 |
|
---|
| 1894 | #if defined(HAVE_KRB5_GET_CREDS_OPT_SET_IMPERSONATE) && \
|
---|
| 1895 | defined(HAVE_KRB5_GET_CREDS_OPT_ALLOC) && \
|
---|
| 1896 | defined(HAVE_KRB5_GET_CREDS)
|
---|
| 1897 | static krb5_error_code smb_krb5_get_credentials_for_user_opt(krb5_context context,
|
---|
| 1898 | krb5_ccache ccache,
|
---|
| 1899 | krb5_principal me,
|
---|
| 1900 | krb5_principal server,
|
---|
| 1901 | krb5_principal impersonate_princ,
|
---|
| 1902 | krb5_creds **out_creds)
|
---|
| 1903 | {
|
---|
| 1904 | krb5_error_code ret;
|
---|
| 1905 | krb5_get_creds_opt opt;
|
---|
| 1906 |
|
---|
| 1907 | ret = krb5_get_creds_opt_alloc(context, &opt);
|
---|
| 1908 | if (ret) {
|
---|
| 1909 | goto done;
|
---|
| 1910 | }
|
---|
| 1911 | krb5_get_creds_opt_add_options(context, opt, KRB5_GC_FORWARDABLE);
|
---|
| 1912 |
|
---|
| 1913 | if (impersonate_princ) {
|
---|
| 1914 | ret = krb5_get_creds_opt_set_impersonate(context, opt,
|
---|
| 1915 | impersonate_princ);
|
---|
| 1916 | if (ret) {
|
---|
| 1917 | goto done;
|
---|
| 1918 | }
|
---|
| 1919 | }
|
---|
| 1920 |
|
---|
| 1921 | ret = krb5_get_creds(context, opt, ccache, server, out_creds);
|
---|
| 1922 | if (ret) {
|
---|
| 1923 | goto done;
|
---|
| 1924 | }
|
---|
| 1925 |
|
---|
| 1926 | done:
|
---|
| 1927 | if (opt) {
|
---|
| 1928 | krb5_get_creds_opt_free(context, opt);
|
---|
| 1929 | }
|
---|
| 1930 | return ret;
|
---|
| 1931 | }
|
---|
| 1932 | #endif /* HAVE_KRB5_GET_CREDS_OPT_SET_IMPERSONATE */
|
---|
| 1933 |
|
---|
| 1934 | #ifdef HAVE_KRB5_GET_CREDENTIALS_FOR_USER
|
---|
| 1935 | static krb5_error_code smb_krb5_get_credentials_for_user(krb5_context context,
|
---|
| 1936 | krb5_ccache ccache,
|
---|
| 1937 | krb5_principal me,
|
---|
| 1938 | krb5_principal server,
|
---|
| 1939 | krb5_principal impersonate_princ,
|
---|
| 1940 | krb5_creds **out_creds)
|
---|
| 1941 | {
|
---|
| 1942 | krb5_error_code ret;
|
---|
| 1943 | krb5_creds in_creds;
|
---|
| 1944 |
|
---|
| 1945 | #if !HAVE_DECL_KRB5_GET_CREDENTIALS_FOR_USER
|
---|
| 1946 | krb5_error_code KRB5_CALLCONV
|
---|
| 1947 | krb5_get_credentials_for_user(krb5_context context, krb5_flags options,
|
---|
| 1948 | krb5_ccache ccache, krb5_creds *in_creds,
|
---|
| 1949 | krb5_data *subject_cert,
|
---|
| 1950 | krb5_creds **out_creds);
|
---|
| 1951 | #endif /* !HAVE_DECL_KRB5_GET_CREDENTIALS_FOR_USER */
|
---|
| 1952 |
|
---|
| 1953 | ZERO_STRUCT(in_creds);
|
---|
| 1954 |
|
---|
| 1955 | if (impersonate_princ) {
|
---|
| 1956 |
|
---|
| 1957 | in_creds.server = me;
|
---|
| 1958 | in_creds.client = impersonate_princ;
|
---|
| 1959 |
|
---|
| 1960 | ret = krb5_get_credentials_for_user(context,
|
---|
| 1961 | 0, /* krb5_flags options */
|
---|
| 1962 | ccache,
|
---|
| 1963 | &in_creds,
|
---|
| 1964 | NULL, /* krb5_data *subject_cert */
|
---|
| 1965 | out_creds);
|
---|
| 1966 | } else {
|
---|
| 1967 | in_creds.client = me;
|
---|
| 1968 | in_creds.server = server;
|
---|
| 1969 |
|
---|
| 1970 | ret = krb5_get_credentials(context, 0, ccache,
|
---|
| 1971 | &in_creds, out_creds);
|
---|
| 1972 | }
|
---|
| 1973 |
|
---|
| 1974 | return ret;
|
---|
| 1975 | }
|
---|
| 1976 | #endif /* HAVE_KRB5_GET_CREDENTIALS_FOR_USER */
|
---|
| 1977 |
|
---|
| 1978 | /*
|
---|
| 1979 | * smb_krb5_get_credentials
|
---|
| 1980 | *
|
---|
| 1981 | * @brief Get krb5 credentials for a server
|
---|
| 1982 | *
|
---|
| 1983 | * @param[in] context An initialized krb5_context
|
---|
| 1984 | * @param[in] ccache An initialized krb5_ccache
|
---|
| 1985 | * @param[in] me The krb5_principal of the caller
|
---|
| 1986 | * @param[in] server The krb5_principal of the requested service
|
---|
| 1987 | * @param[in] impersonate_princ The krb5_principal of a user to impersonate as (optional)
|
---|
| 1988 | * @param[out] out_creds The returned krb5_creds structure
|
---|
| 1989 | * @return krb5_error_code
|
---|
| 1990 | *
|
---|
| 1991 | */
|
---|
| 1992 | krb5_error_code smb_krb5_get_credentials(krb5_context context,
|
---|
| 1993 | krb5_ccache ccache,
|
---|
| 1994 | krb5_principal me,
|
---|
| 1995 | krb5_principal server,
|
---|
| 1996 | krb5_principal impersonate_princ,
|
---|
| 1997 | krb5_creds **out_creds)
|
---|
| 1998 | {
|
---|
| 1999 | krb5_error_code ret;
|
---|
| 2000 | krb5_creds *creds = NULL;
|
---|
| 2001 |
|
---|
| 2002 | *out_creds = NULL;
|
---|
| 2003 |
|
---|
| 2004 | if (impersonate_princ) {
|
---|
| 2005 | #ifdef HAVE_KRB5_GET_CREDS_OPT_SET_IMPERSONATE /* Heimdal */
|
---|
| 2006 | ret = smb_krb5_get_credentials_for_user_opt(context, ccache, me, server, impersonate_princ, &creds);
|
---|
| 2007 | #elif defined(HAVE_KRB5_GET_CREDENTIALS_FOR_USER) /* MIT */
|
---|
| 2008 | ret = smb_krb5_get_credentials_for_user(context, ccache, me, server, impersonate_princ, &creds);
|
---|
| 2009 | #else
|
---|
| 2010 | ret = ENOTSUP;
|
---|
| 2011 | #endif
|
---|
| 2012 | } else {
|
---|
| 2013 | krb5_creds in_creds;
|
---|
| 2014 |
|
---|
| 2015 | ZERO_STRUCT(in_creds);
|
---|
| 2016 |
|
---|
| 2017 | in_creds.client = me;
|
---|
| 2018 | in_creds.server = server;
|
---|
| 2019 |
|
---|
| 2020 | ret = krb5_get_credentials(context, 0, ccache,
|
---|
| 2021 | &in_creds, &creds);
|
---|
| 2022 | }
|
---|
| 2023 | if (ret) {
|
---|
| 2024 | goto done;
|
---|
| 2025 | }
|
---|
| 2026 |
|
---|
| 2027 | if (out_creds) {
|
---|
| 2028 | *out_creds = creds;
|
---|
| 2029 | }
|
---|
| 2030 |
|
---|
| 2031 | done:
|
---|
| 2032 | if (creds && ret) {
|
---|
| 2033 | krb5_free_creds(context, creds);
|
---|
| 2034 | }
|
---|
| 2035 |
|
---|
| 2036 | return ret;
|
---|
| 2037 | }
|
---|
| 2038 |
|
---|
| 2039 | /*
|
---|
| 2040 | * smb_krb5_get_creds
|
---|
| 2041 | *
|
---|
| 2042 | * @brief Get krb5 credentials for a server
|
---|
| 2043 | *
|
---|
| 2044 | * @param[in] server_s The string name of the service
|
---|
| 2045 | * @param[in] time_offset The offset to the KDCs time in seconds (optional)
|
---|
| 2046 | * @param[in] cc The krb5 credential cache string name (optional)
|
---|
| 2047 | * @param[in] impersonate_princ_s The string principal name to impersonate (optional)
|
---|
| 2048 | * @param[out] creds_p The returned krb5_creds structure
|
---|
| 2049 | * @return krb5_error_code
|
---|
| 2050 | *
|
---|
| 2051 | */
|
---|
| 2052 | krb5_error_code smb_krb5_get_creds(const char *server_s,
|
---|
| 2053 | time_t time_offset,
|
---|
| 2054 | const char *cc,
|
---|
| 2055 | const char *impersonate_princ_s,
|
---|
| 2056 | krb5_creds **creds_p)
|
---|
| 2057 | {
|
---|
| 2058 | krb5_error_code ret;
|
---|
| 2059 | krb5_context context = NULL;
|
---|
| 2060 | krb5_principal me = NULL;
|
---|
| 2061 | krb5_principal server = NULL;
|
---|
| 2062 | krb5_principal impersonate_princ = NULL;
|
---|
| 2063 | krb5_creds *creds = NULL;
|
---|
| 2064 | krb5_ccache ccache = NULL;
|
---|
| 2065 |
|
---|
| 2066 | *creds_p = NULL;
|
---|
| 2067 |
|
---|
| 2068 | initialize_krb5_error_table();
|
---|
| 2069 | ret = krb5_init_context(&context);
|
---|
| 2070 | if (ret) {
|
---|
| 2071 | goto done;
|
---|
| 2072 | }
|
---|
| 2073 |
|
---|
| 2074 | if (time_offset != 0) {
|
---|
| 2075 | krb5_set_real_time(context, time(NULL) + time_offset, 0);
|
---|
| 2076 | }
|
---|
| 2077 |
|
---|
| 2078 | ret = krb5_cc_resolve(context, cc ? cc :
|
---|
| 2079 | krb5_cc_default_name(context), &ccache);
|
---|
| 2080 | if (ret) {
|
---|
| 2081 | goto done;
|
---|
| 2082 | }
|
---|
| 2083 |
|
---|
| 2084 | ret = krb5_cc_get_principal(context, ccache, &me);
|
---|
| 2085 | if (ret) {
|
---|
| 2086 | goto done;
|
---|
| 2087 | }
|
---|
| 2088 |
|
---|
| 2089 | ret = smb_krb5_parse_name(context, server_s, &server);
|
---|
| 2090 | if (ret) {
|
---|
| 2091 | goto done;
|
---|
| 2092 | }
|
---|
| 2093 |
|
---|
| 2094 | if (impersonate_princ_s) {
|
---|
| 2095 | ret = smb_krb5_parse_name(context, impersonate_princ_s,
|
---|
| 2096 | &impersonate_princ);
|
---|
| 2097 | if (ret) {
|
---|
| 2098 | goto done;
|
---|
| 2099 | }
|
---|
| 2100 | }
|
---|
| 2101 |
|
---|
| 2102 | ret = smb_krb5_get_credentials(context, ccache,
|
---|
| 2103 | me, server, impersonate_princ,
|
---|
| 2104 | &creds);
|
---|
| 2105 | if (ret) {
|
---|
| 2106 | goto done;
|
---|
| 2107 | }
|
---|
| 2108 |
|
---|
| 2109 | ret = krb5_cc_store_cred(context, ccache, creds);
|
---|
| 2110 | if (ret) {
|
---|
| 2111 | goto done;
|
---|
| 2112 | }
|
---|
| 2113 |
|
---|
| 2114 | if (creds_p) {
|
---|
| 2115 | *creds_p = creds;
|
---|
| 2116 | }
|
---|
| 2117 |
|
---|
| 2118 | DEBUG(1,("smb_krb5_get_creds: got ticket for %s\n",
|
---|
| 2119 | server_s));
|
---|
| 2120 |
|
---|
| 2121 | if (impersonate_princ_s) {
|
---|
| 2122 | char *client = NULL;
|
---|
| 2123 |
|
---|
| 2124 | ret = smb_krb5_unparse_name(talloc_tos(), context, creds->client, &client);
|
---|
| 2125 | if (ret) {
|
---|
| 2126 | goto done;
|
---|
| 2127 | }
|
---|
| 2128 | DEBUGADD(1,("smb_krb5_get_creds: using S4U2SELF impersonation as %s\n",
|
---|
| 2129 | client));
|
---|
| 2130 | TALLOC_FREE(client);
|
---|
| 2131 | }
|
---|
| 2132 |
|
---|
| 2133 | done:
|
---|
| 2134 | if (!context) {
|
---|
| 2135 | return ret;
|
---|
| 2136 | }
|
---|
| 2137 |
|
---|
| 2138 | if (creds && ret) {
|
---|
| 2139 | krb5_free_creds(context, creds);
|
---|
| 2140 | }
|
---|
| 2141 | if (server) {
|
---|
| 2142 | krb5_free_principal(context, server);
|
---|
| 2143 | }
|
---|
| 2144 | if (me) {
|
---|
| 2145 | krb5_free_principal(context, me);
|
---|
| 2146 | }
|
---|
| 2147 | if (impersonate_princ) {
|
---|
| 2148 | krb5_free_principal(context, impersonate_princ);
|
---|
| 2149 | }
|
---|
| 2150 | if (ccache) {
|
---|
| 2151 | krb5_cc_close(context, ccache);
|
---|
| 2152 | }
|
---|
| 2153 | krb5_free_context(context);
|
---|
| 2154 |
|
---|
| 2155 | return ret;
|
---|
| 2156 | }
|
---|
| 2157 |
|
---|
| 2158 | /*
|
---|
| 2159 | * smb_krb5_principal_get_realm
|
---|
| 2160 | *
|
---|
| 2161 | * @brief Get realm of a principal
|
---|
| 2162 | *
|
---|
| 2163 | * @param[in] context The krb5_context
|
---|
| 2164 | * @param[in] principal The principal
|
---|
| 2165 | * @return pointer to the realm
|
---|
| 2166 | *
|
---|
| 2167 | */
|
---|
| 2168 |
|
---|
| 2169 | char *smb_krb5_principal_get_realm(krb5_context context,
|
---|
| 2170 | krb5_principal principal)
|
---|
| 2171 | {
|
---|
| 2172 | #ifdef HAVE_KRB5_PRINCIPAL_GET_REALM /* Heimdal */
|
---|
| 2173 | return krb5_principal_get_realm(context, principal);
|
---|
| 2174 | #elif defined(krb5_princ_realm) /* MIT */
|
---|
| 2175 | krb5_data *realm;
|
---|
| 2176 | realm = krb5_princ_realm(context, principal);
|
---|
| 2177 | return (char *)realm->data;
|
---|
| 2178 | #else
|
---|
| 2179 | return NULL;
|
---|
| 2180 | #endif
|
---|
| 2181 | }
|
---|
| 2182 |
|
---|
| 2183 | #else /* HAVE_KRB5 */
|
---|
| 2184 | /* this saves a few linking headaches */
|
---|
| 2185 | int cli_krb5_get_ticket(TALLOC_CTX *mem_ctx,
|
---|
| 2186 | const char *principal, time_t time_offset,
|
---|
| 2187 | DATA_BLOB *ticket, DATA_BLOB *session_key_krb5,
|
---|
| 2188 | uint32_t extra_ap_opts,
|
---|
| 2189 | const char *ccname, time_t *tgs_expire,
|
---|
| 2190 | const char *impersonate_princ_s)
|
---|
| 2191 | {
|
---|
| 2192 | DEBUG(0,("NO KERBEROS SUPPORT\n"));
|
---|
| 2193 | return 1;
|
---|
| 2194 | }
|
---|
| 2195 |
|
---|
| 2196 | bool unwrap_pac(TALLOC_CTX *mem_ctx, DATA_BLOB *auth_data, DATA_BLOB *unwrapped_pac_data)
|
---|
| 2197 | {
|
---|
| 2198 | DEBUG(0,("NO KERBEROS SUPPORT\n"));
|
---|
| 2199 | return false;
|
---|
| 2200 | }
|
---|
| 2201 |
|
---|
| 2202 | #endif /* HAVE_KRB5 */
|
---|