diff options
Diffstat (limited to 'source3/libads')
-rw-r--r-- | source3/libads/authdata.c | 19 | ||||
-rw-r--r-- | source3/libads/cldap.c | 119 | ||||
-rw-r--r-- | source3/libads/disp_sec.c | 8 | ||||
-rw-r--r-- | source3/libads/krb5_setpw.c | 8 | ||||
-rw-r--r-- | source3/libads/ldap.c | 13 | ||||
-rw-r--r-- | source3/libads/ldap_schema.c | 15 | ||||
-rw-r--r-- | source3/libads/util.c | 4 |
7 files changed, 60 insertions, 126 deletions
diff --git a/source3/libads/authdata.c b/source3/libads/authdata.c index 0bde3e6984..9f0f68ed7b 100644 --- a/source3/libads/authdata.c +++ b/source3/libads/authdata.c @@ -23,6 +23,7 @@ */ #include "includes.h" +#include "librpc/gen_ndr/ndr_krb5pac.h" #ifdef HAVE_KRB5 @@ -108,7 +109,7 @@ static krb5_error_code check_pac_checksum(TALLOC_CTX *mem_ctx, } ndr_err = ndr_pull_struct_blob(pac_data_blob, pac_data, - pac_data, + NULL, pac_data, (ndr_pull_flags_fn_t)ndr_pull_PAC_DATA); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { status = ndr_map_error2ntstatus(ndr_err); @@ -124,7 +125,7 @@ static krb5_error_code check_pac_checksum(TALLOC_CTX *mem_ctx, } ndr_err = ndr_pull_struct_blob(pac_data_blob, pac_data_raw, - pac_data_raw, + NULL, pac_data_raw, (ndr_pull_flags_fn_t)ndr_pull_PAC_DATA_RAW); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { status = ndr_map_error2ntstatus(ndr_err); @@ -205,7 +206,7 @@ static krb5_error_code check_pac_checksum(TALLOC_CTX *mem_ctx, /* We find the data blobs above, now we parse them to get at the exact portion we should zero */ ndr_err = ndr_pull_struct_blob(kdc_sig_blob, kdc_sig_wipe, - kdc_sig_wipe, + NULL, kdc_sig_wipe, (ndr_pull_flags_fn_t)ndr_pull_PAC_SIGNATURE_DATA); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { status = ndr_map_error2ntstatus(ndr_err); @@ -215,7 +216,7 @@ static krb5_error_code check_pac_checksum(TALLOC_CTX *mem_ctx, } ndr_err = ndr_pull_struct_blob(srv_sig_blob, srv_sig_wipe, - srv_sig_wipe, + NULL, srv_sig_wipe, (ndr_pull_flags_fn_t)ndr_pull_PAC_SIGNATURE_DATA); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { status = ndr_map_error2ntstatus(ndr_err); @@ -230,7 +231,7 @@ static krb5_error_code check_pac_checksum(TALLOC_CTX *mem_ctx, /* and reencode, back into the same place it came from */ ndr_err = ndr_push_struct_blob(kdc_sig_blob, pac_data_raw, - kdc_sig_wipe, + NULL, kdc_sig_wipe, (ndr_push_flags_fn_t)ndr_push_PAC_SIGNATURE_DATA); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { status = ndr_map_error2ntstatus(ndr_err); @@ -239,7 +240,7 @@ static krb5_error_code check_pac_checksum(TALLOC_CTX *mem_ctx, return status; } ndr_err = ndr_push_struct_blob(srv_sig_blob, pac_data_raw, - srv_sig_wipe, + NULL, srv_sig_wipe, (ndr_push_flags_fn_t)ndr_push_PAC_SIGNATURE_DATA); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { status = ndr_map_error2ntstatus(ndr_err); @@ -250,7 +251,7 @@ static krb5_error_code check_pac_checksum(TALLOC_CTX *mem_ctx, /* push out the whole structure, but now with zero'ed signatures */ ndr_err = ndr_push_struct_blob(&modified_pac_blob, pac_data_raw, - pac_data_raw, + NULL, pac_data_raw, (ndr_push_flags_fn_t)ndr_push_PAC_DATA_RAW); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { status = ndr_map_error2ntstatus(ndr_err); @@ -403,12 +404,12 @@ NTSTATUS kerberos_return_pac(TALLOC_CTX *mem_ctx, DEBUG(10,("got TGT for %s in %s\n", auth_princ, cc)); if (expire_time) { DEBUGADD(10,("\tvalid until: %s (%d)\n", - http_timestring(*expire_time), + http_timestring(talloc_tos(), *expire_time), (int)*expire_time)); } if (renew_till_time) { DEBUGADD(10,("\trenewable till: %s (%d)\n", - http_timestring(*renew_till_time), + http_timestring(talloc_tos(), *renew_till_time), (int)*renew_till_time)); } diff --git a/source3/libads/cldap.c b/source3/libads/cldap.c index 11565065af..c37220c903 100644 --- a/source3/libads/cldap.c +++ b/source3/libads/cldap.c @@ -119,8 +119,8 @@ static void gotalarm_sig(void) */ static int recv_cldap_netlogon(TALLOC_CTX *mem_ctx, int sock, - uint32_t *nt_version, - union nbt_cldap_netlogon **reply) + uint32_t nt_version, + struct netlogon_samlogon_response **reply) { int ret; ASN1_DATA data; @@ -131,7 +131,8 @@ static int recv_cldap_netlogon(TALLOC_CTX *mem_ctx, int i1; /* half the time of a regular ldap timeout, not less than 3 seconds. */ unsigned int al_secs = MAX(3,lp_ldap_timeout()/2); - union nbt_cldap_netlogon *r = NULL; + struct netlogon_samlogon_response *r = NULL; + NTSTATUS status; blob = data_blob(NULL, 8192); if (blob.data == NULL) { @@ -185,7 +186,7 @@ static int recv_cldap_netlogon(TALLOC_CTX *mem_ctx, return -1; } - r = TALLOC_ZERO_P(mem_ctx, union nbt_cldap_netlogon); + r = TALLOC_ZERO_P(mem_ctx, struct netlogon_samlogon_response); if (!r) { errno = ENOMEM; data_blob_free(&os1); @@ -195,7 +196,8 @@ static int recv_cldap_netlogon(TALLOC_CTX *mem_ctx, return -1; } - if (!pull_mailslot_cldap_reply(mem_ctx, &os3, r, nt_version)) { + status = pull_netlogon_samlogon_response(&os3, mem_ctx, NULL, r); + if (!NT_STATUS_IS_OK(status)) { data_blob_free(&os1); data_blob_free(&os2); data_blob_free(&os3); @@ -204,6 +206,8 @@ static int recv_cldap_netlogon(TALLOC_CTX *mem_ctx, return -1; } + map_netlogon_samlogon_response(r); + data_blob_free(&os1); data_blob_free(&os2); data_blob_free(&os3); @@ -227,8 +231,8 @@ static int recv_cldap_netlogon(TALLOC_CTX *mem_ctx, bool ads_cldap_netlogon(TALLOC_CTX *mem_ctx, const char *server, const char *realm, - uint32_t *nt_version, - union nbt_cldap_netlogon **reply) + uint32_t nt_version, + struct netlogon_samlogon_response **reply) { int sock; int ret; @@ -240,7 +244,7 @@ bool ads_cldap_netlogon(TALLOC_CTX *mem_ctx, return False; } - ret = send_cldap_netlogon(sock, realm, global_myname(), *nt_version); + ret = send_cldap_netlogon(sock, realm, global_myname(), nt_version); if (ret != 0) { close(sock); return False; @@ -262,107 +266,24 @@ bool ads_cldap_netlogon(TALLOC_CTX *mem_ctx, bool ads_cldap_netlogon_5(TALLOC_CTX *mem_ctx, const char *server, const char *realm, - struct nbt_cldap_netlogon_5 *reply5) + struct NETLOGON_SAM_LOGON_RESPONSE_EX *reply5) { - uint32_t nt_version = NETLOGON_VERSION_5 | NETLOGON_VERSION_5EX; - union nbt_cldap_netlogon *reply = NULL; + uint32_t nt_version = NETLOGON_NT_VERSION_5 | NETLOGON_NT_VERSION_5EX; + struct netlogon_samlogon_response *reply = NULL; bool ret; - ret = ads_cldap_netlogon(mem_ctx, server, realm, &nt_version, &reply); + ret = ads_cldap_netlogon(mem_ctx, server, realm, nt_version, &reply); if (!ret) { return false; } - if (nt_version != (NETLOGON_VERSION_5 | NETLOGON_VERSION_5EX)) { + if (reply->ntver != NETLOGON_NT_VERSION_5EX) { + DEBUG(0,("ads_cldap_netlogon_5: nt_version mismatch: 0x%08x\n", + reply->ntver)); return false; } - *reply5 = reply->logon5; - - return true; -} - -/**************************************************************** -****************************************************************/ - -bool pull_mailslot_cldap_reply(TALLOC_CTX *mem_ctx, - const DATA_BLOB *blob, - union nbt_cldap_netlogon *r, - uint32_t *nt_version) -{ - enum ndr_err_code ndr_err; - uint32_t nt_version_query = ((*nt_version) & 0x0000001f); - uint16_t command = 0; - - ndr_err = ndr_pull_struct_blob(blob, mem_ctx, &command, - (ndr_pull_flags_fn_t)ndr_pull_uint16); - if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - return false; - } - - switch (command) { - case 0x13: /* 19 */ - case 0x15: /* 21 */ - case 0x17: /* 23 */ - case 0x19: /* 25 */ - break; - default: - DEBUG(1,("got unexpected command: %d (0x%08x)\n", - command, command)); - return false; - } - - ndr_err = ndr_pull_union_blob_all(blob, mem_ctx, r, nt_version_query, - (ndr_pull_flags_fn_t)ndr_pull_nbt_cldap_netlogon); - if (NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - goto done; - } - - /* when the caller requested just those nt_version bits that the server - * was able to reply to, we are fine and all done. otherwise we need to - * assume downgraded replies which are painfully parsed here - gd */ - - if (nt_version_query & NETLOGON_VERSION_WITH_CLOSEST_SITE) { - nt_version_query &= ~NETLOGON_VERSION_WITH_CLOSEST_SITE; - } - ndr_err = ndr_pull_union_blob_all(blob, mem_ctx, r, nt_version_query, - (ndr_pull_flags_fn_t)ndr_pull_nbt_cldap_netlogon); - if (NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - goto done; - } - if (nt_version_query & NETLOGON_VERSION_5EX_WITH_IP) { - nt_version_query &= ~NETLOGON_VERSION_5EX_WITH_IP; - } - ndr_err = ndr_pull_union_blob_all(blob, mem_ctx, r, nt_version_query, - (ndr_pull_flags_fn_t)ndr_pull_nbt_cldap_netlogon); - if (NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - goto done; - } - if (nt_version_query & NETLOGON_VERSION_5EX) { - nt_version_query &= ~NETLOGON_VERSION_5EX; - } - ndr_err = ndr_pull_union_blob_all(blob, mem_ctx, r, nt_version_query, - (ndr_pull_flags_fn_t)ndr_pull_nbt_cldap_netlogon); - if (NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - goto done; - } - if (nt_version_query & NETLOGON_VERSION_5) { - nt_version_query &= ~NETLOGON_VERSION_5; - } - ndr_err = ndr_pull_union_blob_all(blob, mem_ctx, r, nt_version_query, - (ndr_pull_flags_fn_t)ndr_pull_nbt_cldap_netlogon); - if (NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - goto done; - } - - return false; - - done: - if (DEBUGLEVEL >= 10) { - NDR_PRINT_UNION_DEBUG(nbt_cldap_netlogon, nt_version_query, r); - } - - *nt_version = nt_version_query; + *reply5 = reply->data.nt5_ex; return true; } diff --git a/source3/libads/disp_sec.c b/source3/libads/disp_sec.c index f4c68638df..a5e04a4a6c 100644 --- a/source3/libads/disp_sec.c +++ b/source3/libads/disp_sec.c @@ -114,15 +114,15 @@ static void ads_disp_sec_ace_object(ADS_STRUCT *ads, { if (object->flags & SEC_ACE_OBJECT_PRESENT) { printf("Object type: SEC_ACE_OBJECT_PRESENT\n"); - printf("Object GUID: %s (%s)\n", smb_uuid_string(mem_ctx, - object->type.type), + printf("Object GUID: %s (%s)\n", GUID_string(mem_ctx, + &object->type.type), ads_interprete_guid_from_object(ads, mem_ctx, &object->type.type)); } if (object->flags & SEC_ACE_OBJECT_INHERITED_PRESENT) { printf("Object type: SEC_ACE_OBJECT_INHERITED_PRESENT\n"); - printf("Object GUID: %s (%s)\n", smb_uuid_string(mem_ctx, - object->inherited_type.inherited_type), + printf("Object GUID: %s (%s)\n", GUID_string(mem_ctx, + &object->inherited_type.inherited_type), ads_interprete_guid_from_object(ads, mem_ctx, &object->inherited_type.inherited_type)); } diff --git a/source3/libads/krb5_setpw.c b/source3/libads/krb5_setpw.c index 719f3bd3ec..0ff9f2ba32 100644 --- a/source3/libads/krb5_setpw.c +++ b/source3/libads/krb5_setpw.c @@ -285,7 +285,7 @@ static krb5_error_code parse_setpw_reply(krb5_context context, return KRB5KRB_AP_ERR_MODIFIED; } - p = packet->data; + p = (char *)packet->data; /* ** see if it is an error */ @@ -368,7 +368,7 @@ static krb5_error_code parse_setpw_reply(krb5_context context, return KRB5KRB_AP_ERR_MODIFIED; } - p = clearresult.data; + p = (char *)clearresult.data; res_code = RSVAL(p, 0); @@ -687,10 +687,10 @@ kerb_prompter(krb5_context ctx, void *data, memset(prompts[0].reply->data, 0, prompts[0].reply->length); if (prompts[0].reply->length > 0) { if (data) { - strncpy(prompts[0].reply->data, + strncpy((char *)prompts[0].reply->data, (const char *)data, prompts[0].reply->length-1); - prompts[0].reply->length = strlen(prompts[0].reply->data); + prompts[0].reply->length = strlen((const char *)prompts[0].reply->data); } else { prompts[0].reply->length = 0; } diff --git a/source3/libads/ldap.c b/source3/libads/ldap.c index eb45e3a0dd..2dcd1fd6ae 100644 --- a/source3/libads/ldap.c +++ b/source3/libads/ldap.c @@ -176,7 +176,7 @@ bool ads_closest_dc(ADS_STRUCT *ads) static bool ads_try_connect(ADS_STRUCT *ads, const char *server, bool gc) { char *srv; - struct nbt_cldap_netlogon_5 cldap_reply; + struct NETLOGON_SAM_LOGON_RESPONSE_EX cldap_reply; TALLOC_CTX *mem_ctx = NULL; bool ret = false; @@ -801,7 +801,7 @@ static ADS_STATUS ads_do_paged_search_args(ADS_STRUCT *ads, int *count, struct berval **cookie) { int rc, i, version; - char *utf8_expr, *utf8_path, **search_attrs; + char *utf8_expr, *utf8_path, **search_attrs = NULL; size_t converted_size; LDAPControl PagedResults, NoReferrals, ExternalCtrl, *controls[4], **rcontrols; BerElement *cookie_be = NULL; @@ -832,7 +832,7 @@ static ADS_STATUS ads_do_paged_search_args(ADS_STRUCT *ads, else { /* This would be the utf8-encoded version...*/ /* if (!(search_attrs = ads_push_strvals(ctx, attrs))) */ - if (!(str_list_copy(talloc_tos(), &search_attrs, attrs))) { + if (!(search_attrs = str_list_copy(talloc_tos(), attrs))) { rc = LDAP_NO_MEMORY; goto done; } @@ -1144,7 +1144,7 @@ ADS_STATUS ads_do_search_all_fn(ADS_STRUCT *ads, const char *bind_path, else { /* This would be the utf8-encoded version...*/ /* if (!(search_attrs = ads_push_strvals(ctx, attrs))) */ - if (!(str_list_copy(talloc_tos(), &search_attrs, attrs))) + if (!(search_attrs = str_list_copy(talloc_tos(), attrs))) { DEBUG(1,("ads_do_search: str_list_copy() failed!")); rc = LDAP_NO_MEMORY; @@ -2062,7 +2062,7 @@ static void dump_guid(ADS_STRUCT *ads, const char *field, struct berval **values memcpy(guid.info, values[i]->bv_val, sizeof(guid.info)); smb_uuid_unpack(guid, &tmp); - printf("%s: %s\n", field, smb_uuid_string(talloc_tos(), tmp)); + printf("%s: %s\n", field, GUID_string(talloc_tos(), &tmp)); } } @@ -2828,6 +2828,7 @@ ADS_STATUS ads_domain_func_level(ADS_STRUCT *ads, uint32 *val) if ( (ads_s = ads_init( ads->server.realm, ads->server.workgroup, ads->server.ldap_server )) == NULL ) { + status = ADS_ERROR_NT(NT_STATUS_NO_MEMORY); goto done; } ads_s->auth.flags = ADS_AUTH_ANON_BIND; @@ -3747,7 +3748,7 @@ const char *ads_get_extended_right_name_by_guid(ADS_STRUCT *ads, } expr = talloc_asprintf(mem_ctx, "(rightsGuid=%s)", - smb_uuid_string(mem_ctx, *rights_guid)); + GUID_string(mem_ctx, rights_guid)); if (!expr) { goto done; } diff --git a/source3/libads/ldap_schema.c b/source3/libads/ldap_schema.c index ff41ccc861..b5d2d35889 100644 --- a/source3/libads/ldap_schema.c +++ b/source3/libads/ldap_schema.c @@ -246,19 +246,22 @@ ADS_STATUS ads_check_posix_schema_mapping(TALLOC_CTX *mem_ctx, ADS_ATTR_SFU_GIDNUMBER_OID, ADS_ATTR_SFU_HOMEDIR_OID, ADS_ATTR_SFU_SHELL_OID, - ADS_ATTR_SFU_GECOS_OID}; + ADS_ATTR_SFU_GECOS_OID, + ADS_ATTR_SFU_UID_OID }; const char *oids_sfu20[] = { ADS_ATTR_SFU20_UIDNUMBER_OID, ADS_ATTR_SFU20_GIDNUMBER_OID, ADS_ATTR_SFU20_HOMEDIR_OID, ADS_ATTR_SFU20_SHELL_OID, - ADS_ATTR_SFU20_GECOS_OID}; + ADS_ATTR_SFU20_GECOS_OID, + ADS_ATTR_SFU20_UID_OID }; const char *oids_rfc2307[] = { ADS_ATTR_RFC2307_UIDNUMBER_OID, ADS_ATTR_RFC2307_GIDNUMBER_OID, ADS_ATTR_RFC2307_HOMEDIR_OID, ADS_ATTR_RFC2307_SHELL_OID, - ADS_ATTR_RFC2307_GECOS_OID }; + ADS_ATTR_RFC2307_GECOS_OID, + ADS_ATTR_RFC2307_UID_OID }; DEBUG(10,("ads_check_posix_schema_mapping for schema mode: %d\n", map_type)); @@ -359,6 +362,12 @@ ADS_STATUS ads_check_posix_schema_mapping(TALLOC_CTX *mem_ctx, strequal(ADS_ATTR_SFU20_GECOS_OID, oids_out[i])) { schema->posix_gecos_attr = talloc_strdup(schema, names_out[i]); } + + if (strequal(ADS_ATTR_RFC2307_UID_OID, oids_out[i]) || + strequal(ADS_ATTR_SFU_UID_OID, oids_out[i]) || + strequal(ADS_ATTR_SFU20_UID_OID, oids_out[i])) { + schema->posix_uid_attr = talloc_strdup(schema, names_out[i]); + } } if (!schema->posix_uidnumber_attr || diff --git a/source3/libads/util.c b/source3/libads/util.c index 72f5dee80c..9866a15285 100644 --- a/source3/libads/util.c +++ b/source3/libads/util.c @@ -33,7 +33,7 @@ ADS_STATUS ads_change_trust_account_password(ADS_STRUCT *ads, char *host_princip return ADS_ERROR_SYSTEM(ENOENT); } - new_password = generate_random_str(DEFAULT_TRUST_ACCOUNT_PASSWORD_LENGTH); + new_password = generate_random_str(talloc_tos(), DEFAULT_TRUST_ACCOUNT_PASSWORD_LENGTH); ret = kerberos_set_password(ads->auth.kdc_server, host_principal, password, host_principal, new_password, ads->auth.time_offset); @@ -86,6 +86,8 @@ ADS_STATUS ads_guess_service_principal(ADS_STRUCT *ads, server_realm = SMB_STRDUP(ads->config.realm); if (!server || !server_realm) { + SAFE_FREE(server); + SAFE_FREE(server_realm); return ADS_ERROR(LDAP_NO_MEMORY); } |