mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
s3:libads: Allocate ads->auth.user_name under ADS_STRUCT talloc context
Signed-off-by: Samuel Cabrero <scabrero@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
parent
d64335eaef
commit
633ccc55c0
@ -229,12 +229,16 @@ static PyObject* py_ads_connect(ADS *self,
|
||||
PyErr_SetString(PyExc_RuntimeError, "Uninitialized");
|
||||
return NULL;
|
||||
}
|
||||
SAFE_FREE(self->ads_ptr->auth.user_name);
|
||||
TALLOC_FREE(self->ads_ptr->auth.user_name);
|
||||
TALLOC_FREE(self->ads_ptr->auth.password);
|
||||
TALLOC_FREE(self->ads_ptr->auth.realm);
|
||||
if (self->cli_creds) {
|
||||
self->ads_ptr->auth.user_name =
|
||||
SMB_STRDUP(cli_credentials_get_username(self->cli_creds));
|
||||
self->ads_ptr->auth.user_name = talloc_strdup(self->ads_ptr,
|
||||
cli_credentials_get_username(self->cli_creds));
|
||||
if (self->ads_ptr->auth.user_name == NULL) {
|
||||
PyErr_NoMemory();
|
||||
goto err;
|
||||
}
|
||||
self->ads_ptr->auth.password = talloc_strdup(self->ads_ptr,
|
||||
cli_credentials_get_password(self->cli_creds));
|
||||
if (self->ads_ptr->auth.password == NULL) {
|
||||
@ -251,16 +255,17 @@ static PyObject* py_ads_connect(ADS *self,
|
||||
status = ads_connect_user_creds(self->ads_ptr);
|
||||
} else {
|
||||
char *passwd = NULL;
|
||||
int ret;
|
||||
|
||||
if (!secrets_init()) {
|
||||
PyErr_SetString(PyExc_RuntimeError,
|
||||
"secrets_init() failed");
|
||||
goto err;
|
||||
}
|
||||
|
||||
ret = asprintf(&(self->ads_ptr->auth.user_name), "%s$",
|
||||
self->ads_ptr->auth.user_name = talloc_asprintf(self->ads_ptr,
|
||||
"%s$",
|
||||
lp_netbios_name());
|
||||
if (ret == -1) {
|
||||
if (self->ads_ptr->auth.user_name == NULL) {
|
||||
PyErr_NoMemory();
|
||||
goto err;
|
||||
}
|
||||
|
@ -434,15 +434,23 @@ WERROR NetGetJoinableOUs_l(struct libnetapi_ctx *ctx,
|
||||
goto out;
|
||||
}
|
||||
|
||||
SAFE_FREE(ads->auth.user_name);
|
||||
TALLOC_FREE(ads->auth.user_name);
|
||||
if (r->in.account) {
|
||||
ads->auth.user_name = SMB_STRDUP(r->in.account);
|
||||
ads->auth.user_name = talloc_strdup(ads, r->in.account);
|
||||
if (ads->auth.user_name == NULL) {
|
||||
ret = WERR_NOT_ENOUGH_MEMORY;
|
||||
goto out;
|
||||
}
|
||||
} else {
|
||||
const char *username = NULL;
|
||||
|
||||
libnetapi_get_username(ctx, &username);
|
||||
if (username != NULL) {
|
||||
ads->auth.user_name = SMB_STRDUP(username);
|
||||
ads->auth.user_name = talloc_strdup(ads, username);
|
||||
if (ads->auth.user_name == NULL) {
|
||||
ret = WERR_NOT_ENOUGH_MEMORY;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -130,7 +130,6 @@ static void ads_destroy(ADS_STRUCT **ads)
|
||||
#ifdef HAVE_LDAP
|
||||
ads_disconnect(*ads);
|
||||
#endif
|
||||
SAFE_FREE((*ads)->auth.user_name);
|
||||
SAFE_FREE((*ads)->auth.kdc_server);
|
||||
SAFE_FREE((*ads)->auth.ccache_name);
|
||||
|
||||
|
@ -713,10 +713,13 @@ got_connection:
|
||||
if (!ads->auth.user_name) {
|
||||
/* Must use the userPrincipalName value here or sAMAccountName
|
||||
and not servicePrincipalName; found by Guenther Deschner */
|
||||
|
||||
if (asprintf(&ads->auth.user_name, "%s$", lp_netbios_name() ) == -1) {
|
||||
DEBUG(0,("ads_connect: asprintf fail.\n"));
|
||||
ads->auth.user_name = NULL;
|
||||
ads->auth.user_name = talloc_asprintf(ads,
|
||||
"%s$",
|
||||
lp_netbios_name());
|
||||
if (ads->auth.user_name == NULL) {
|
||||
DBG_ERR("talloc_asprintf failed\n");
|
||||
status = ADS_ERROR_NT(NT_STATUS_NO_MEMORY);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -171,8 +171,12 @@ static ADS_STATUS libnet_connect_ads(const char *dns_domain_name,
|
||||
}
|
||||
|
||||
if (user_name) {
|
||||
SAFE_FREE(my_ads->auth.user_name);
|
||||
my_ads->auth.user_name = SMB_STRDUP(user_name);
|
||||
TALLOC_FREE(my_ads->auth.user_name);
|
||||
my_ads->auth.user_name = talloc_strdup(my_ads, user_name);
|
||||
if (my_ads->auth.user_name == NULL) {
|
||||
status = ADS_ERROR_NT(NT_STATUS_NO_MEMORY);
|
||||
goto out;
|
||||
}
|
||||
if ((cp = strchr_m(my_ads->auth.user_name, '@'))!=0) {
|
||||
*cp++ = '\0';
|
||||
TALLOC_FREE(my_ads->auth.realm);
|
||||
|
@ -667,8 +667,12 @@ retry:
|
||||
}
|
||||
}
|
||||
|
||||
SAFE_FREE(ads->auth.user_name);
|
||||
ads->auth.user_name = smb_xstrdup(c->opt_user_name);
|
||||
TALLOC_FREE(ads->auth.user_name);
|
||||
ads->auth.user_name = talloc_strdup(ads, c->opt_user_name);
|
||||
if (ads->auth.user_name == NULL) {
|
||||
TALLOC_FREE(ads);
|
||||
return ADS_ERROR_NT(NT_STATUS_NO_MEMORY);
|
||||
}
|
||||
|
||||
ads->auth.flags |= auth_flags;
|
||||
|
||||
|
@ -284,8 +284,10 @@ void net_ads_join_dns_updates(struct net_context *c, TALLOC_CTX *ctx, struct lib
|
||||
|
||||
use_in_memory_ccache();
|
||||
|
||||
ret = asprintf(&ads_dns->auth.user_name, "%s$", lp_netbios_name());
|
||||
if (ret == -1) {
|
||||
ads_dns->auth.user_name = talloc_asprintf(ads_dns,
|
||||
"%s$",
|
||||
lp_netbios_name());
|
||||
if (ads_dns->auth.user_name == NULL) {
|
||||
d_fprintf(stderr, _("DNS update failed: out of memory\n"));
|
||||
goto done;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user