mirror of
https://github.com/samba-team/samba.git
synced 2025-02-23 09:57:40 +03:00
Remove the explicit TALLOC_CTX * from cli_struct.
Make us very explicit about how long a talloc ctx should last. Jeremy. (This used to be commit ba9e2be2b5a59684e854609f9d82ea1633448c62)
This commit is contained in:
parent
42c87fe6e6
commit
d2cf97aeba
@ -135,7 +135,10 @@ struct cli_state {
|
||||
uint32 posix_capabilities;
|
||||
bool dfsroot;
|
||||
|
||||
TALLOC_CTX *mem_ctx;
|
||||
#if 0
|
||||
TALLOC_CTX *longterm_mem_ctx;
|
||||
TALLOC_CTX *call_mem_ctx;
|
||||
#endif
|
||||
|
||||
smb_sign_info sign_info;
|
||||
|
||||
@ -170,8 +173,8 @@ typedef struct file_info {
|
||||
struct timespec mtime_ts;
|
||||
struct timespec atime_ts;
|
||||
struct timespec ctime_ts;
|
||||
pstring name;
|
||||
pstring dir;
|
||||
char name[1024];
|
||||
char dir[1024]; /* Should use allocated PATH_MAX here.... */
|
||||
char short_name[13*3]; /* the *3 is to cope with multi-byte */
|
||||
} file_info;
|
||||
|
||||
|
@ -79,6 +79,7 @@ enum smb_read_errors {
|
||||
SMB_READ_ERROR,
|
||||
SMB_WRITE_ERROR, /* This error code can go into the client smb_rw_error. */
|
||||
SMB_READ_BAD_SIG,
|
||||
SMB_NO_MEMORY,
|
||||
SMB_DO_NOT_DO_TDIS /* cli_close_connection() check for this when smbfs wants to keep tree connected */
|
||||
};
|
||||
|
||||
|
@ -1181,17 +1181,17 @@ void cli_put_dos_date3(struct cli_state *cli, char *buf, int offset, time_t unix
|
||||
put_dos_date3(buf, offset, unixdate, cli->serverzone);
|
||||
}
|
||||
|
||||
time_t cli_make_unix_date(struct cli_state *cli, void *date_ptr)
|
||||
time_t cli_make_unix_date(struct cli_state *cli, const void *date_ptr)
|
||||
{
|
||||
return make_unix_date(date_ptr, cli->serverzone);
|
||||
}
|
||||
|
||||
time_t cli_make_unix_date2(struct cli_state *cli, void *date_ptr)
|
||||
time_t cli_make_unix_date2(struct cli_state *cli, const void *date_ptr)
|
||||
{
|
||||
return make_unix_date2(date_ptr, cli->serverzone);
|
||||
}
|
||||
|
||||
time_t cli_make_unix_date3(struct cli_state *cli, void *date_ptr)
|
||||
time_t cli_make_unix_date3(struct cli_state *cli, const void *date_ptr)
|
||||
{
|
||||
return make_unix_date3(date_ptr, cli->serverzone);
|
||||
}
|
||||
|
@ -1803,13 +1803,18 @@ struct cli_state *get_ipc_connect(char *server,
|
||||
* entire network browse list)
|
||||
*/
|
||||
|
||||
struct cli_state *get_ipc_connect_master_ip(struct ip_service *mb_ip, pstring workgroup, struct user_auth_info *user_info)
|
||||
struct cli_state *get_ipc_connect_master_ip(TALLOC_CTX *ctx,
|
||||
struct ip_service *mb_ip,
|
||||
struct user_auth_info *user_info,
|
||||
char **pp_workgroup_out)
|
||||
{
|
||||
char addr[INET6_ADDRSTRLEN];
|
||||
fstring name;
|
||||
struct cli_state *cli;
|
||||
struct sockaddr_storage server_ss;
|
||||
|
||||
*pp_workgroup_out = NULL;
|
||||
|
||||
print_sockaddr(addr, sizeof(addr), &mb_ip->ss);
|
||||
DEBUG(99, ("Looking up name of master browser %s\n",
|
||||
addr));
|
||||
@ -1838,7 +1843,7 @@ struct cli_state *get_ipc_connect_master_ip(struct ip_service *mb_ip, pstring wo
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pstrcpy(workgroup, name);
|
||||
*pp_workgroup_out = talloc_strdup(ctx, name);
|
||||
|
||||
DEBUG(4, ("found master browser %s, %s\n", name, addr));
|
||||
|
||||
@ -1853,12 +1858,16 @@ struct cli_state *get_ipc_connect_master_ip(struct ip_service *mb_ip, pstring wo
|
||||
* connect to it.
|
||||
*/
|
||||
|
||||
struct cli_state *get_ipc_connect_master_ip_bcast(pstring workgroup, struct user_auth_info *user_info)
|
||||
struct cli_state *get_ipc_connect_master_ip_bcast(TALLOC_CTX *ctx,
|
||||
struct user_auth_info *user_info,
|
||||
char **pp_workgroup_out)
|
||||
{
|
||||
struct ip_service *ip_list;
|
||||
struct cli_state *cli;
|
||||
int i, count;
|
||||
|
||||
*pp_workgroup_out = NULL;
|
||||
|
||||
DEBUG(99, ("Do broadcast lookup for workgroups on local network\n"));
|
||||
|
||||
/* Go looking for workgroups by broadcasting on the local network */
|
||||
@ -1874,7 +1883,8 @@ struct cli_state *get_ipc_connect_master_ip_bcast(pstring workgroup, struct user
|
||||
print_sockaddr(addr, sizeof(addr), &ip_list[i].ss);
|
||||
DEBUG(99, ("Found master browser %s\n", addr));
|
||||
|
||||
cli = get_ipc_connect_master_ip(&ip_list[i], workgroup, user_info);
|
||||
cli = get_ipc_connect_master_ip(ctx, &ip_list[i],
|
||||
user_info, pp_workgroup_out);
|
||||
if (cli)
|
||||
return(cli);
|
||||
}
|
||||
|
@ -245,9 +245,12 @@ static struct cli_state *cli_cm_connect( const char *server,
|
||||
bool show_hdr)
|
||||
{
|
||||
struct client_connection *node;
|
||||
|
||||
node = SMB_XMALLOC_P( struct client_connection );
|
||||
|
||||
|
||||
node = SMB_CALLOC_ARRAY( struct client_connection, 1);
|
||||
if (!node) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
node->cli = do_connect( server, share, show_hdr );
|
||||
|
||||
if ( !node->cli ) {
|
||||
|
@ -492,9 +492,6 @@ struct cli_state *cli_initialise(void)
|
||||
if (!cli->outbuf || !cli->inbuf)
|
||||
goto error;
|
||||
|
||||
if ((cli->mem_ctx = talloc_init("cli based talloc")) == NULL)
|
||||
goto error;
|
||||
|
||||
memset(cli->outbuf, 0, cli->bufsize);
|
||||
memset(cli->inbuf, 0, cli->bufsize);
|
||||
|
||||
@ -605,11 +602,6 @@ void cli_shutdown(struct cli_state *cli)
|
||||
data_blob_free(&cli->secblob);
|
||||
data_blob_free(&cli->user_session_key);
|
||||
|
||||
if (cli->mem_ctx) {
|
||||
talloc_destroy(cli->mem_ctx);
|
||||
cli->mem_ctx = NULL;
|
||||
}
|
||||
|
||||
if (cli->fd != -1) {
|
||||
close(cli->fd);
|
||||
}
|
||||
|
@ -84,6 +84,8 @@ static NTSTATUS cli_smb_rw_error_to_ntstatus(struct cli_state *cli)
|
||||
return NT_STATUS_UNEXPECTED_NETWORK_ERROR;
|
||||
case SMB_READ_BAD_SIG:
|
||||
return NT_STATUS_INVALID_PARAMETER;
|
||||
case SMB_NO_MEMORY:
|
||||
return NT_STATUS_NO_MEMORY;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -133,6 +135,10 @@ const char *cli_errstr(struct cli_state *cli)
|
||||
slprintf(cli_error_message, sizeof(cli_error_message) - 1,
|
||||
"Server packet had invalid SMB signature!");
|
||||
break;
|
||||
case SMB_NO_MEMORY:
|
||||
slprintf(cli_error_message, sizeof(cli_error_message) - 1,
|
||||
"Out of memory");
|
||||
break;
|
||||
default:
|
||||
slprintf(cli_error_message, sizeof(cli_error_message) - 1,
|
||||
"Unknown error code %d\n", cli->smb_rw_error );
|
||||
|
@ -22,10 +22,11 @@
|
||||
/****************************************************************************
|
||||
send an ack for an oplock break request
|
||||
****************************************************************************/
|
||||
|
||||
bool cli_oplock_ack(struct cli_state *cli, int fnum, unsigned char level)
|
||||
{
|
||||
char *oldbuf = cli->outbuf;
|
||||
pstring buf;
|
||||
char buf[smb_size+16];
|
||||
bool ret;
|
||||
|
||||
cli->outbuf = buf;
|
||||
@ -47,7 +48,7 @@ bool cli_oplock_ack(struct cli_state *cli, int fnum, unsigned char level)
|
||||
SSVAL(buf,smb_vwv6,0); /* unlockcount */
|
||||
SSVAL(buf,smb_vwv7,0); /* lockcount */
|
||||
|
||||
ret = cli_send_smb(cli);
|
||||
ret = cli_send_smb(cli);
|
||||
|
||||
cli->outbuf = oldbuf;
|
||||
|
||||
|
@ -1,18 +1,18 @@
|
||||
/*
|
||||
/*
|
||||
Unix SMB/CIFS implementation.
|
||||
client print routines
|
||||
Copyright (C) Andrew Tridgell 1994-1998
|
||||
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
@ -21,13 +21,14 @@
|
||||
|
||||
/*****************************************************************************
|
||||
Convert a character pointer in a cli_call_api() response to a form we can use.
|
||||
This function contains code to prevent core dumps if the server returns
|
||||
This function contains code to prevent core dumps if the server returns
|
||||
invalid data.
|
||||
*****************************************************************************/
|
||||
static const char *fix_char_ptr(unsigned int datap, unsigned int converter,
|
||||
static const char *fix_char_ptr(unsigned int datap, unsigned int converter,
|
||||
char *rdata, int rdrcnt)
|
||||
{
|
||||
if (datap == 0) { /* turn NULL pointers into zero length strings */
|
||||
if (datap == 0) {
|
||||
/* turn NULL pointers into zero length strings */
|
||||
return "";
|
||||
} else {
|
||||
unsigned int offset = datap - converter;
|
||||
@ -42,41 +43,41 @@ static const char *fix_char_ptr(unsigned int datap, unsigned int converter,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
call fn() on each entry in a print queue
|
||||
****************************************************************************/
|
||||
int cli_print_queue(struct cli_state *cli,
|
||||
|
||||
int cli_print_queue(struct cli_state *cli,
|
||||
void (*fn)(struct print_job_info *))
|
||||
{
|
||||
char *rparam = NULL;
|
||||
char *rdata = NULL;
|
||||
char *p;
|
||||
unsigned int rdrcnt, rprcnt;
|
||||
pstring param;
|
||||
char param[1024];
|
||||
int result_code=0;
|
||||
int i = -1;
|
||||
|
||||
|
||||
memset(param,'\0',sizeof(param));
|
||||
|
||||
p = param;
|
||||
SSVAL(p,0,76); /* API function number 76 (DosPrintJobEnum) */
|
||||
p += 2;
|
||||
pstrcpy_base(p,"zWrLeh", param); /* parameter description? */
|
||||
safe_strcpy_base(p,"zWrLeh", param, sizeof(param)); /* parameter description? */
|
||||
p = skip_string(param,sizeof(param),p);
|
||||
pstrcpy_base(p,"WWzWWDDzz", param); /* returned data format */
|
||||
safe_strcpy_base(p,"WWzWWDDzz", param, sizeof(param)); /* returned data format */
|
||||
p = skip_string(param,sizeof(param),p);
|
||||
pstrcpy_base(p,cli->share, param); /* name of queue */
|
||||
safe_strcpy_base(p,cli->share, param, sizeof(param)); /* name of queue */
|
||||
p = skip_string(param,sizeof(param),p);
|
||||
SSVAL(p,0,2); /* API function level 2, PRJINFO_2 data structure */
|
||||
SSVAL(p,2,1000); /* size of bytes of returned data buffer */
|
||||
p += 4;
|
||||
pstrcpy_base(p,"", param); /* subformat */
|
||||
safe_strcpy_base(p,"", param,sizeof(param)); /* subformat */
|
||||
p = skip_string(param,sizeof(param),p);
|
||||
|
||||
DEBUG(4,("doing cli_print_queue for %s\n", cli->share));
|
||||
|
||||
if (cli_api(cli,
|
||||
if (cli_api(cli,
|
||||
param, PTR_DIFF(p,param), 1024, /* Param, length, maxlen */
|
||||
NULL, 0, CLI_BUFFER_SIZE, /* data, length, maxlen */
|
||||
&rparam, &rprcnt, /* return params, length */
|
||||
@ -87,21 +88,21 @@ int cli_print_queue(struct cli_state *cli,
|
||||
|
||||
if (result_code == 0) {
|
||||
struct print_job_info job;
|
||||
|
||||
p = rdata;
|
||||
|
||||
p = rdata;
|
||||
|
||||
for (i = 0; i < SVAL(rparam,4); ++i) {
|
||||
job.id = SVAL(p,0);
|
||||
job.priority = SVAL(p,2);
|
||||
fstrcpy(job.user,
|
||||
fix_char_ptr(SVAL(p,4), converter,
|
||||
fix_char_ptr(SVAL(p,4), converter,
|
||||
rdata, rdrcnt));
|
||||
job.t = cli_make_unix_date3(cli, p + 12);
|
||||
job.size = IVAL(p,16);
|
||||
fstrcpy(job.name,fix_char_ptr(SVAL(p,24),
|
||||
converter,
|
||||
fstrcpy(job.name,fix_char_ptr(SVAL(p,24),
|
||||
converter,
|
||||
rdata, rdrcnt));
|
||||
fn(&job);
|
||||
fn(&job);
|
||||
p += 28;
|
||||
}
|
||||
}
|
||||
@ -117,6 +118,7 @@ int cli_print_queue(struct cli_state *cli,
|
||||
/****************************************************************************
|
||||
cancel a print job
|
||||
****************************************************************************/
|
||||
|
||||
int cli_printjob_del(struct cli_state *cli, int job)
|
||||
{
|
||||
char *rparam = NULL;
|
||||
@ -124,21 +126,21 @@ int cli_printjob_del(struct cli_state *cli, int job)
|
||||
char *p;
|
||||
unsigned int rdrcnt,rprcnt;
|
||||
int ret = -1;
|
||||
pstring param;
|
||||
char param[1024];
|
||||
|
||||
memset(param,'\0',sizeof(param));
|
||||
|
||||
p = param;
|
||||
SSVAL(p,0,81); /* DosPrintJobDel() */
|
||||
p += 2;
|
||||
pstrcpy_base(p,"W", param);
|
||||
safe_strcpy_base(p,"W", param,sizeof(param));
|
||||
p = skip_string(param,sizeof(param),p);
|
||||
pstrcpy_base(p,"", param);
|
||||
safe_strcpy_base(p,"", param,sizeof(param));
|
||||
p = skip_string(param,sizeof(param),p);
|
||||
SSVAL(p,0,job);
|
||||
SSVAL(p,0,job);
|
||||
p += 2;
|
||||
|
||||
if (cli_api(cli,
|
||||
|
||||
if (cli_api(cli,
|
||||
param, PTR_DIFF(p,param), 1024, /* Param, length, maxlen */
|
||||
NULL, 0, CLI_BUFFER_SIZE, /* data, length, maxlen */
|
||||
&rparam, &rprcnt, /* return params, length */
|
||||
@ -178,7 +180,7 @@ int cli_spl_open(struct cli_state *cli, const char *fname, int flags, int share_
|
||||
accessmode |= 2;
|
||||
} else if ((flags & O_ACCMODE) == O_WRONLY) {
|
||||
accessmode |= 1;
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(O_SYNC)
|
||||
if ((flags & O_SYNC) == O_SYNC) {
|
||||
@ -213,7 +215,7 @@ int cli_spl_open(struct cli_state *cli, const char *fname, int flags, int share_
|
||||
FLAG_REQUEST_OPLOCK|FLAG_REQUEST_BATCH_OPLOCK);
|
||||
SSVAL(cli->outbuf,smb_vwv2,SVAL(cli->outbuf,smb_vwv2) | 6);
|
||||
}
|
||||
|
||||
|
||||
p = smb_buf(cli->outbuf);
|
||||
p += clistr_push(cli, p, fname, -1, STR_TERMINATE);
|
||||
|
||||
@ -256,5 +258,3 @@ bool cli_spl_close(struct cli_state *cli, int fnum)
|
||||
|
||||
return !cli_is_error(cli);
|
||||
}
|
||||
|
||||
|
||||
|
@ -399,7 +399,7 @@ bool cli_qpathinfo(struct cli_state *cli, const char *fname,
|
||||
char *rparam=NULL, *rdata=NULL;
|
||||
int count=8;
|
||||
bool ret;
|
||||
time_t (*date_fn)(struct cli_state *, void *);
|
||||
time_t (*date_fn)(struct cli_state *, const void *);
|
||||
char *p;
|
||||
|
||||
p = param;
|
||||
|
@ -1008,7 +1008,7 @@ smbc_attr_server(SMBCCTX *context,
|
||||
|
||||
nt_status = rpccli_lsa_open_policy(
|
||||
pipe_hnd,
|
||||
ipc_srv->cli->mem_ctx,
|
||||
talloc_tos(),
|
||||
True,
|
||||
GENERIC_EXECUTE_ACCESS,
|
||||
pol);
|
||||
@ -1964,7 +1964,7 @@ smbc_lseek_ctx(SMBCCTX *context,
|
||||
fstring server, share, user, password;
|
||||
pstring path, targetpath;
|
||||
struct cli_state *targetcli;
|
||||
TALLOC_CTX *frame = talloc_tos();
|
||||
TALLOC_CTX *frame = talloc_stackframe();
|
||||
|
||||
if (!context || !context->internal ||
|
||||
!context->internal->_initialized) {
|
||||
@ -2767,18 +2767,23 @@ smbc_opendir_ctx(SMBCCTX *context,
|
||||
|
||||
for (i = 0; i < count && i < max_lmb_count; i++) {
|
||||
char addr[INET6_ADDRSTRLEN];
|
||||
char *wg_ptr = NULL;
|
||||
|
||||
print_sockaddr(addr, sizeof(addr), &ip_list[i].ss);
|
||||
DEBUG(99, ("Found master browser %d of %d: %s\n",
|
||||
i+1, MAX(count, max_lmb_count),
|
||||
addr));
|
||||
|
||||
cli = get_ipc_connect_master_ip(&ip_list[i],
|
||||
workgroup, &u_info);
|
||||
cli = get_ipc_connect_master_ip(talloc_tos(),
|
||||
&ip_list[i],
|
||||
&u_info,
|
||||
&wg_ptr);
|
||||
/* cli == NULL is the master browser refused to talk or
|
||||
could not be found */
|
||||
if ( !cli )
|
||||
continue;
|
||||
|
||||
pstrcpy(workgroup, wg_ptr);
|
||||
fstrcpy(server, cli->desthost);
|
||||
cli_shutdown(cli);
|
||||
|
||||
@ -3089,7 +3094,7 @@ static int
|
||||
smbc_closedir_ctx(SMBCCTX *context,
|
||||
SMBCFILE *dir)
|
||||
{
|
||||
TALLOC_CTX *frame = talloc_tos();
|
||||
TALLOC_CTX *frame = talloc_stackframe();
|
||||
|
||||
if (!context || !context->internal ||
|
||||
!context->internal->_initialized) {
|
||||
@ -4025,6 +4030,8 @@ convert_sid_to_string(struct cli_state *ipc_cli,
|
||||
char **names = NULL;
|
||||
enum lsa_SidType *types = NULL;
|
||||
struct rpc_pipe_client *pipe_hnd = find_lsa_pipe_hnd(ipc_cli);
|
||||
TALLOC_CTX *ctx;
|
||||
|
||||
sid_to_string(str, sid);
|
||||
|
||||
if (numeric) {
|
||||
@ -4037,13 +4044,17 @@ convert_sid_to_string(struct cli_state *ipc_cli,
|
||||
|
||||
/* Ask LSA to convert the sid to a name */
|
||||
|
||||
if (!NT_STATUS_IS_OK(rpccli_lsa_lookup_sids(pipe_hnd, ipc_cli->mem_ctx,
|
||||
ctx = talloc_stackframe();
|
||||
|
||||
if (!NT_STATUS_IS_OK(rpccli_lsa_lookup_sids(pipe_hnd, ctx,
|
||||
pol, 1, sid, &domains,
|
||||
&names, &types)) ||
|
||||
!domains || !domains[0] || !names || !names[0]) {
|
||||
TALLOC_FREE(ctx);
|
||||
return;
|
||||
}
|
||||
|
||||
TALLOC_FREE(ctx);
|
||||
/* Converted OK */
|
||||
|
||||
slprintf(str, sizeof(fstring) - 1, "%s%s%s",
|
||||
@ -4062,6 +4073,7 @@ convert_string_to_sid(struct cli_state *ipc_cli,
|
||||
enum lsa_SidType *types = NULL;
|
||||
DOM_SID *sids = NULL;
|
||||
bool result = True;
|
||||
TALLOC_CTX *ctx;
|
||||
struct rpc_pipe_client *pipe_hnd = find_lsa_pipe_hnd(ipc_cli);
|
||||
|
||||
if (!pipe_hnd) {
|
||||
@ -4077,7 +4089,8 @@ convert_string_to_sid(struct cli_state *ipc_cli,
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (!NT_STATUS_IS_OK(rpccli_lsa_lookup_names(pipe_hnd, ipc_cli->mem_ctx,
|
||||
ctx = talloc_stackframe();
|
||||
if (!NT_STATUS_IS_OK(rpccli_lsa_lookup_names(pipe_hnd, ctx,
|
||||
pol, 1, &str, NULL, 1, &sids,
|
||||
&types))) {
|
||||
result = False;
|
||||
@ -4087,6 +4100,7 @@ convert_string_to_sid(struct cli_state *ipc_cli,
|
||||
sid_copy(sid, &sids[0]);
|
||||
done:
|
||||
|
||||
TALLOC_FREE(ctx);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -177,7 +177,7 @@ NTSTATUS remote_password_change(const char *remote_machine, const char *user_nam
|
||||
}
|
||||
}
|
||||
|
||||
if (NT_STATUS_IS_OK(result = rpccli_samr_chgpasswd_user(pipe_hnd, cli->mem_ctx, user_name,
|
||||
if (NT_STATUS_IS_OK(result = rpccli_samr_chgpasswd_user(pipe_hnd, pipe_hnd->mem_ctx, user_name,
|
||||
new_passwd, old_passwd))) {
|
||||
/* Great - it all worked! */
|
||||
cli_shutdown(cli);
|
||||
@ -207,7 +207,7 @@ NTSTATUS remote_password_change(const char *remote_machine, const char *user_nam
|
||||
|
||||
if ( pipe_hnd &&
|
||||
(NT_STATUS_IS_OK(result = rpccli_samr_chgpasswd_user(pipe_hnd,
|
||||
cli->mem_ctx,
|
||||
pipe_hnd->mem_ctx,
|
||||
user_name,
|
||||
new_passwd,
|
||||
old_passwd)))) {
|
||||
|
@ -1975,7 +1975,7 @@ static NTSTATUS rpc_finish_spnego_ntlmssp_bind(struct rpc_pipe_client *cli,
|
||||
|
||||
/* Initialize the returning data struct. */
|
||||
prs_mem_free(rbuf);
|
||||
prs_init(rbuf, 0, cli->cli->mem_ctx, UNMARSHALL);
|
||||
prs_init(rbuf, 0, cli->mem_ctx, UNMARSHALL);
|
||||
|
||||
nt_status = rpc_api_pipe(cli, &rpc_out, rbuf, RPC_ALTCONTRESP);
|
||||
if (!NT_STATUS_IS_OK(nt_status)) {
|
||||
@ -2048,7 +2048,7 @@ static NTSTATUS rpc_pipe_bind(struct rpc_pipe_client *cli,
|
||||
return NT_STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
prs_init(&rpc_out, 0, cli->cli->mem_ctx, MARSHALL);
|
||||
prs_init(&rpc_out, 0, cli->mem_ctx, MARSHALL);
|
||||
|
||||
rpc_call_id = get_rpc_call_id();
|
||||
|
||||
@ -2064,7 +2064,7 @@ static NTSTATUS rpc_pipe_bind(struct rpc_pipe_client *cli,
|
||||
}
|
||||
|
||||
/* Initialize the incoming data struct. */
|
||||
prs_init(&rbuf, 0, cli->cli->mem_ctx, UNMARSHALL);
|
||||
prs_init(&rbuf, 0, cli->mem_ctx, UNMARSHALL);
|
||||
|
||||
/* send data on \PIPE\. receive a response */
|
||||
status = rpc_api_pipe(cli, &rpc_out, &rbuf, RPC_BINDACK);
|
||||
@ -2745,7 +2745,7 @@ struct rpc_pipe_client *cli_rpc_pipe_open_krb5(struct cli_state *cli,
|
||||
}
|
||||
}
|
||||
|
||||
result->auth.a_u.kerberos_auth = TALLOC_ZERO_P(cli->mem_ctx, struct kerberos_auth_struct);
|
||||
result->auth.a_u.kerberos_auth = TALLOC_ZERO_P(result->mem_ctx, struct kerberos_auth_struct);
|
||||
if (!result->auth.a_u.kerberos_auth) {
|
||||
cli_rpc_pipe_close(result);
|
||||
*perr = NT_STATUS_NO_MEMORY;
|
||||
@ -2769,30 +2769,3 @@ struct rpc_pipe_client *cli_rpc_pipe_open_krb5(struct cli_state *cli,
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if 0 /* Moved to libsmb/clientgen.c */
|
||||
/****************************************************************************
|
||||
External interface.
|
||||
Close an open named pipe over SMB. Free any authentication data.
|
||||
****************************************************************************/
|
||||
|
||||
void cli_rpc_pipe_close(struct rpc_pipe_client *cli)
|
||||
{
|
||||
if (!cli_close(cli->cli, cli->fnum)) {
|
||||
DEBUG(0,("cli_rpc_pipe_close: cli_close failed on pipe %s "
|
||||
"to machine %s. Error was %s\n",
|
||||
cli->pipe_name),
|
||||
cli->cli->desthost,
|
||||
cli_errstr(cli->cli)));
|
||||
}
|
||||
|
||||
if (cli->auth.cli_auth_data_free_func) {
|
||||
(*cli->auth.cli_auth_data_free_func)(&cli->auth);
|
||||
}
|
||||
DEBUG(10,("cli_rpc_pipe_close: closed pipe %s to machine %s\n",
|
||||
cli->pipe_name, cli->cli->desthost ));
|
||||
|
||||
DLIST_REMOVE(cli->cli->pipe_list, cli);
|
||||
talloc_destroy(cli->mem_ctx);
|
||||
}
|
||||
#endif
|
||||
|
@ -153,7 +153,9 @@ static void srv_spoolss_replycloseprinter(int snum, POLICY_HND *handle)
|
||||
return;
|
||||
}
|
||||
|
||||
result = rpccli_spoolss_reply_close_printer(notify_cli_pipe, notify_cli_pipe->cli->mem_ctx, handle);
|
||||
result = rpccli_spoolss_reply_close_printer(notify_cli_pipe,
|
||||
talloc_tos(),
|
||||
handle);
|
||||
|
||||
if (!W_ERROR_IS_OK(result))
|
||||
DEBUG(0,("srv_spoolss_replycloseprinter: reply_close_printer failed [%s].\n",
|
||||
@ -2639,8 +2641,12 @@ static bool srv_spoolss_replyopenprinter(int snum, const char *printer,
|
||||
|
||||
smb_connections++;
|
||||
|
||||
result = rpccli_spoolss_reply_open_printer(notify_cli_pipe, notify_cli_pipe->cli->mem_ctx, printer, localprinter,
|
||||
type, handle);
|
||||
result = rpccli_spoolss_reply_open_printer(notify_cli_pipe,
|
||||
talloc_tos(),
|
||||
printer,
|
||||
localprinter,
|
||||
type,
|
||||
handle);
|
||||
|
||||
if (!W_ERROR_IS_OK(result))
|
||||
DEBUG(5,("srv_spoolss_reply_open_printer: Client RPC returned [%s]\n",
|
||||
|
@ -82,7 +82,7 @@ NTSTATUS change_trust_account_password( const char *domain, const char *remote_m
|
||||
goto failed;
|
||||
}
|
||||
|
||||
nt_status = trust_pw_find_change_and_store_it(netlogon_pipe, cli->mem_ctx, domain);
|
||||
nt_status = trust_pw_find_change_and_store_it(netlogon_pipe, netlogon_pipe->mem_ctx, domain);
|
||||
|
||||
cli_shutdown(cli);
|
||||
cli = NULL;
|
||||
|
@ -62,7 +62,7 @@ static bool cli_open_policy_hnd(void)
|
||||
/* Some systems don't support SEC_RIGHTS_MAXIMUM_ALLOWED,
|
||||
but NT sends 0x2000000 so we might as well do it too. */
|
||||
|
||||
if (!NT_STATUS_IS_OK(rpccli_lsa_open_policy(global_pipe_hnd, cli_ipc->mem_ctx, True,
|
||||
if (!NT_STATUS_IS_OK(rpccli_lsa_open_policy(global_pipe_hnd, talloc_tos(), True,
|
||||
GENERIC_EXECUTE_ACCESS, &pol))) {
|
||||
return False;
|
||||
}
|
||||
@ -87,7 +87,7 @@ static void SidToString(fstring str, DOM_SID *sid, bool _numeric)
|
||||
/* Ask LSA to convert the sid to a name */
|
||||
|
||||
if (!cli_open_policy_hnd() ||
|
||||
!NT_STATUS_IS_OK(rpccli_lsa_lookup_sids(global_pipe_hnd, cli_ipc->mem_ctx,
|
||||
!NT_STATUS_IS_OK(rpccli_lsa_lookup_sids(global_pipe_hnd, talloc_tos(),
|
||||
&pol, 1, sid, &domains,
|
||||
&names, &types)) ||
|
||||
!domains || !domains[0] || !names || !names[0]) {
|
||||
@ -114,7 +114,7 @@ static bool StringToSid(DOM_SID *sid, const char *str)
|
||||
}
|
||||
|
||||
if (!cli_open_policy_hnd() ||
|
||||
!NT_STATUS_IS_OK(rpccli_lsa_lookup_names(global_pipe_hnd, cli_ipc->mem_ctx,
|
||||
!NT_STATUS_IS_OK(rpccli_lsa_lookup_names(global_pipe_hnd, talloc_tos(),
|
||||
&pol, 1, &str, NULL, 1, &sids,
|
||||
&types))) {
|
||||
result = False;
|
||||
@ -559,4 +559,3 @@ FSQFLAGS:QUOTA_ENABLED/DENY_DISK/LOG_SOFTLIMIT/LOG_HARD_LIMIT", "SETSTRING" },
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -71,13 +71,17 @@ static bool get_workgroups(struct user_auth_info *user_info)
|
||||
{
|
||||
struct cli_state *cli;
|
||||
struct sockaddr_storage server_ss;
|
||||
pstring master_workgroup;
|
||||
TALLOC_CTX *ctx = talloc_tos();
|
||||
char *master_workgroup = NULL;
|
||||
|
||||
/* Try to connect to a #1d name of our current workgroup. If that
|
||||
doesn't work broadcast for a master browser and then jump off
|
||||
that workgroup. */
|
||||
|
||||
pstrcpy(master_workgroup, lp_workgroup());
|
||||
master_workgroup = talloc_strdup(ctx, lp_workgroup());
|
||||
if (!master_workgroup) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!use_bcast && !find_master_ip(lp_workgroup(), &server_ss)) {
|
||||
DEBUG(4, ("Unable to find master browser for workgroup %s, falling back to broadcast\n",
|
||||
@ -90,7 +94,9 @@ static bool get_workgroups(struct user_auth_info *user_info)
|
||||
return False;
|
||||
}
|
||||
|
||||
if (!(cli = get_ipc_connect_master_ip_bcast(master_workgroup, user_info))) {
|
||||
if (!(cli = get_ipc_connect_master_ip_bcast(talloc_tos(),
|
||||
user_info,
|
||||
&master_workgroup))) {
|
||||
DEBUG(4, ("Unable to find master browser by "
|
||||
"broadcast\n"));
|
||||
return False;
|
||||
|
@ -1744,6 +1744,13 @@ static void set_dc_type_and_flags_connect( struct winbindd_domain *domain )
|
||||
return;
|
||||
}
|
||||
|
||||
mem_ctx = talloc_init("set_dc_type_and_flags on domain %s\n",
|
||||
domain->name);
|
||||
if (!mem_ctx) {
|
||||
DEBUG(1, ("set_dc_type_and_flags_connect: talloc_init() failed\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
DEBUG(5, ("set_dc_type_and_flags_connect: domain %s\n", domain->name ));
|
||||
|
||||
cli = cli_rpc_pipe_open_noauth(domain->conn.cli, PI_LSARPC_DS,
|
||||
@ -1761,7 +1768,7 @@ static void set_dc_type_and_flags_connect( struct winbindd_domain *domain )
|
||||
goto no_lsarpc_ds;
|
||||
}
|
||||
|
||||
result = rpccli_ds_getprimarydominfo(cli, cli->cli->mem_ctx,
|
||||
result = rpccli_ds_getprimarydominfo(cli, mem_ctx,
|
||||
DsRolePrimaryDomainInfoBasic,
|
||||
&ctr);
|
||||
cli_rpc_pipe_close(cli);
|
||||
@ -1780,6 +1787,7 @@ static void set_dc_type_and_flags_connect( struct winbindd_domain *domain )
|
||||
goto no_lsarpc_ds;
|
||||
}
|
||||
|
||||
TALLOC_FREE(mem_ctx);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1798,14 +1806,7 @@ no_lsarpc_ds:
|
||||
"PI_LSARPC on domain %s: (%s)\n",
|
||||
domain->name, nt_errstr(result)));
|
||||
cli_rpc_pipe_close(cli);
|
||||
return;
|
||||
}
|
||||
|
||||
mem_ctx = talloc_init("set_dc_type_and_flags on domain %s\n",
|
||||
domain->name);
|
||||
if (!mem_ctx) {
|
||||
DEBUG(1, ("set_dc_type_and_flags_connect: talloc_init() failed\n"));
|
||||
cli_rpc_pipe_close(cli);
|
||||
TALLOC_FREE(mem_ctx);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1866,8 +1867,8 @@ done:
|
||||
domain->name, domain->active_directory ? "" : "NOT "));
|
||||
|
||||
cli_rpc_pipe_close(cli);
|
||||
|
||||
talloc_destroy(mem_ctx);
|
||||
|
||||
TALLOC_FREE(mem_ctx);
|
||||
|
||||
domain->initialized = True;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user