summaryrefslogtreecommitdiff
path: root/source3/libads
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2008-10-11 03:12:21 +0200
committerJelmer Vernooij <jelmer@samba.org>2008-10-11 03:12:21 +0200
commit0fd0fc75c46b39a611c7f9a56081105714d73e36 (patch)
treeb93ef5e67e49a3aa49c37e13df3d6222b2df7095 /source3/libads
parent69d38a95c29498c0266cb98b911faa3e7240c787 (diff)
parent47f7ef8f39ba482a7d6578ab82c9e0670381c4f8 (diff)
downloadsamba-0fd0fc75c46b39a611c7f9a56081105714d73e36.tar.gz
samba-0fd0fc75c46b39a611c7f9a56081105714d73e36.tar.bz2
samba-0fd0fc75c46b39a611c7f9a56081105714d73e36.zip
Merge branch 'master' of ssh://git.samba.org/data/git/samba into selftest
Conflicts: selftest/selftest.pl
Diffstat (limited to 'source3/libads')
-rw-r--r--source3/libads/authdata.c14
-rw-r--r--source3/libads/cldap.c119
-rw-r--r--source3/libads/ldap.c3
-rw-r--r--source3/libads/util.c2
4 files changed, 31 insertions, 107 deletions
diff --git a/source3/libads/authdata.c b/source3/libads/authdata.c
index 0bde3e6984..40f051c851 100644
--- a/source3/libads/authdata.c
+++ b/source3/libads/authdata.c
@@ -108,7 +108,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 +124,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 +205,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 +215,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 +230,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 +239,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 +250,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);
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/ldap.c b/source3/libads/ldap.c
index eb45e3a0dd..40f052281d 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;
@@ -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;
diff --git a/source3/libads/util.c b/source3/libads/util.c
index 72f5dee80c..d23c36f326 100644
--- a/source3/libads/util.c
+++ b/source3/libads/util.c
@@ -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);
}