mirror of
https://github.com/samba-team/samba.git
synced 2025-08-04 08:22:08 +03:00
Fix bug #5568 net rpc trustdom add broken !
net rpc trustdom add was broken. The default 10second timeout can be too short to create an account on a Samba DC (calling out to a script), error message reporting was poor, and more importantly the new marshalling code for user_info23 was broken (maps onto a user_info21 but doesn't clear the user_info23 struct before marshalling, leaving an uninitialized size field - give "alloc failure"). Jeremy.
This commit is contained in:
@ -413,6 +413,7 @@ void init_samr_user_info23(struct samr_UserInfo23 *r,
|
|||||||
uint8_t data[516],
|
uint8_t data[516],
|
||||||
uint8_t pw_len)
|
uint8_t pw_len)
|
||||||
{
|
{
|
||||||
|
memset(r, '\0', sizeof(*r));
|
||||||
init_samr_user_info21(&r->info,
|
init_samr_user_info21(&r->info,
|
||||||
last_logon,
|
last_logon,
|
||||||
last_logoff,
|
last_logoff,
|
||||||
|
@ -5645,6 +5645,7 @@ static NTSTATUS rpc_trustdom_add_internals(struct net_context *c,
|
|||||||
uint32 user_rid;
|
uint32 user_rid;
|
||||||
uint32_t access_granted = 0;
|
uint32_t access_granted = 0;
|
||||||
union samr_UserInfo info;
|
union samr_UserInfo info;
|
||||||
|
unsigned int orig_timeout;
|
||||||
|
|
||||||
if (argc != 2) {
|
if (argc != 2) {
|
||||||
d_printf("Usage: net rpc trustdom add <domain_name> <trust password>\n")
|
d_printf("Usage: net rpc trustdom add <domain_name> <trust password>\n")
|
||||||
@ -5682,6 +5683,11 @@ static NTSTATUS rpc_trustdom_add_internals(struct net_context *c,
|
|||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* This call can take a long time - allow the server to time out.
|
||||||
|
* 35 seconds should do it. */
|
||||||
|
|
||||||
|
orig_timeout = cli_set_timeout(pipe_hnd->cli, 35000);
|
||||||
|
|
||||||
/* Create trusting domain's account */
|
/* Create trusting domain's account */
|
||||||
acb_info = ACB_NORMAL;
|
acb_info = ACB_NORMAL;
|
||||||
acct_flags = SEC_GENERIC_READ | SEC_GENERIC_WRITE | SEC_GENERIC_EXECUTE |
|
acct_flags = SEC_GENERIC_READ | SEC_GENERIC_WRITE | SEC_GENERIC_EXECUTE |
|
||||||
@ -5698,7 +5704,13 @@ static NTSTATUS rpc_trustdom_add_internals(struct net_context *c,
|
|||||||
&user_pol,
|
&user_pol,
|
||||||
&access_granted,
|
&access_granted,
|
||||||
&user_rid);
|
&user_rid);
|
||||||
|
|
||||||
|
/* And restore our original timeout. */
|
||||||
|
cli_set_timeout(pipe_hnd->cli, orig_timeout);
|
||||||
|
|
||||||
if (!NT_STATUS_IS_OK(result)) {
|
if (!NT_STATUS_IS_OK(result)) {
|
||||||
|
d_printf("net rpc trustdom add: create user %s failed %s\n",
|
||||||
|
acct_name, nt_errstr(result));
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5851,6 +5863,8 @@ static NTSTATUS rpc_trustdom_del_internals(struct net_context *c,
|
|||||||
&name_types);
|
&name_types);
|
||||||
|
|
||||||
if (!NT_STATUS_IS_OK(result)) {
|
if (!NT_STATUS_IS_OK(result)) {
|
||||||
|
d_printf("net rpc trustdom del: LookupNames on user %s failed %s\n",
|
||||||
|
acct_name, nt_errstr(result) );
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5861,6 +5875,8 @@ static NTSTATUS rpc_trustdom_del_internals(struct net_context *c,
|
|||||||
&user_pol);
|
&user_pol);
|
||||||
|
|
||||||
if (!NT_STATUS_IS_OK(result)) {
|
if (!NT_STATUS_IS_OK(result)) {
|
||||||
|
d_printf("net rpc trustdom del: OpenUser on user %s failed %s\n",
|
||||||
|
acct_name, nt_errstr(result) );
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5876,6 +5892,8 @@ static NTSTATUS rpc_trustdom_del_internals(struct net_context *c,
|
|||||||
&user_pol,
|
&user_pol,
|
||||||
&trust_acct_sid);
|
&trust_acct_sid);
|
||||||
if (!NT_STATUS_IS_OK(result)) {
|
if (!NT_STATUS_IS_OK(result)) {
|
||||||
|
d_printf("net rpc trustdom del: RemoveMemberFromForeignDomain on user %s failed %s\n",
|
||||||
|
acct_name, nt_errstr(result) );
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5885,13 +5903,15 @@ static NTSTATUS rpc_trustdom_del_internals(struct net_context *c,
|
|||||||
&user_pol);
|
&user_pol);
|
||||||
|
|
||||||
if (!NT_STATUS_IS_OK(result)) {
|
if (!NT_STATUS_IS_OK(result)) {
|
||||||
|
d_printf("net rpc trustdom del: DeleteUser on user %s failed %s\n",
|
||||||
|
acct_name, nt_errstr(result) );
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!NT_STATUS_IS_OK(result)) {
|
if (!NT_STATUS_IS_OK(result)) {
|
||||||
DEBUG(0,("Could not set trust account password: %s\n",
|
d_printf("Could not set trust account password: %s\n",
|
||||||
nt_errstr(result)));
|
nt_errstr(result));
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
Reference in New Issue
Block a user