diff options
Diffstat (limited to 'source4')
-rw-r--r-- | source4/ntvfs/cifs/vfs_cifs.c | 42 | ||||
-rw-r--r-- | source4/ntvfs/ipc/ipc_rap.c | 10 | ||||
-rw-r--r-- | source4/ntvfs/ipc/rap_server.c | 6 | ||||
-rw-r--r-- | source4/ntvfs/ipc/vfs_ipc.c | 8 | ||||
-rw-r--r-- | source4/ntvfs/nbench/vfs_nbench.c | 2 | ||||
-rw-r--r-- | source4/ntvfs/ntvfs_generic.c | 14 | ||||
-rw-r--r-- | source4/ntvfs/posix/vfs_posix.c | 42 | ||||
-rw-r--r-- | source4/ntvfs/print/vfs_print.c | 2 | ||||
-rw-r--r-- | source4/ntvfs/simple/svfs_util.c | 4 | ||||
-rw-r--r-- | source4/ntvfs/simple/vfs_simple.c | 43 | ||||
-rw-r--r-- | source4/smb_server/conn.c | 8 | ||||
-rw-r--r-- | source4/smb_server/connection.c | 12 | ||||
-rw-r--r-- | source4/smb_server/negprot.c | 2 | ||||
-rw-r--r-- | source4/smb_server/nttrans.c | 8 | ||||
-rw-r--r-- | source4/smb_server/password.c | 2 | ||||
-rw-r--r-- | source4/smb_server/reply.c | 6 | ||||
-rw-r--r-- | source4/smb_server/request.c | 27 | ||||
-rw-r--r-- | source4/smb_server/search.c | 2 | ||||
-rw-r--r-- | source4/smb_server/service.c | 4 | ||||
-rw-r--r-- | source4/smb_server/sesssetup.c | 10 | ||||
-rw-r--r-- | source4/smb_server/smb_server.c | 9 | ||||
-rw-r--r-- | source4/smb_server/smb_server.h | 9 | ||||
-rw-r--r-- | source4/smb_server/trans2.c | 12 |
23 files changed, 139 insertions, 145 deletions
diff --git a/source4/ntvfs/cifs/vfs_cifs.c b/source4/ntvfs/cifs/vfs_cifs.c index 9020ba2bba..078075a11f 100644 --- a/source4/ntvfs/cifs/vfs_cifs.c +++ b/source4/ntvfs/cifs/vfs_cifs.c @@ -113,7 +113,7 @@ static NTSTATUS cvfs_connect(struct smbsrv_request *req, const char *sharename) return NT_STATUS_INVALID_PARAMETER; } - private = talloc(req->tcon->mem_ctx, sizeof(struct cvfs_private)); + private = talloc(req->tcon, sizeof(struct cvfs_private)); if (!private) { return NT_STATUS_NO_MEMORY; } @@ -136,18 +136,18 @@ static NTSTATUS cvfs_connect(struct smbsrv_request *req, const char *sharename) private->tree->session->pid = SVAL(req->in.hdr, HDR_PID); private->tcon = req->tcon; - tcon->fs_type = talloc_strdup(tcon->mem_ctx, "NTFS"); - tcon->dev_type = talloc_strdup(tcon->mem_ctx, "A:"); + tcon->fs_type = talloc_strdup(tcon, "NTFS"); + tcon->dev_type = talloc_strdup(tcon, "A:"); map_calls = lp_parm_string(req->tcon->service, "cifs", "map calls"); if (map_calls) { - private->map_calls = talloc_strdup(tcon->mem_ctx, map_calls); + private->map_calls = talloc_strdup(tcon, map_calls); } /* if we are mapping trans2, then we need to give a trans2 pointer in the operations structure */ if (private->map_calls && in_list("trans2", private->map_calls, True)) { - struct ntvfs_ops *ops = talloc_memdup(tcon->mem_ctx,tcon->ntvfs_ops,sizeof(*ops)); + struct ntvfs_ops *ops = talloc_memdup(tcon, tcon->ntvfs_ops,sizeof(*ops)); static NTSTATUS cvfs_trans2(struct smbsrv_request *,struct smb_trans2 *); if (!ops) { return NT_STATUS_NO_MEMORY; @@ -203,7 +203,7 @@ static void async_simple(struct smbcli_request *c_req) if (!c_req) return NT_STATUS_UNSUCCESSFUL; \ { \ struct async_info *async; \ - async = talloc(req->mem_ctx, sizeof(*async)); \ + async = talloc_p(req, struct async_info); \ if (!async) return NT_STATUS_NO_MEMORY; \ async->parms = io; \ async->req = req; \ @@ -243,7 +243,7 @@ static void async_ioctl(struct smbcli_request *c_req) { struct async_info *async = c_req->async.private; struct smbsrv_request *req = async->req; - req->async.status = smb_raw_ioctl_recv(c_req, req->mem_ctx, async->parms); + req->async.status = smb_raw_ioctl_recv(c_req, req, async->parms); req->async.send_fn(req); } @@ -258,7 +258,7 @@ static NTSTATUS cvfs_ioctl(struct smbsrv_request *req, union smb_ioctl *io) /* see if the front end will allow us to perform this function asynchronously. */ if (!req->async.send_fn) { - return smb_raw_ioctl(private->tree, req->mem_ctx, io); + return smb_raw_ioctl(private->tree, req, io); } c_req = smb_raw_ioctl_send(private->tree, io); @@ -290,7 +290,7 @@ static void async_qpathinfo(struct smbcli_request *c_req) { struct async_info *async = c_req->async.private; struct smbsrv_request *req = async->req; - req->async.status = smb_raw_pathinfo_recv(c_req, req->mem_ctx, async->parms); + req->async.status = smb_raw_pathinfo_recv(c_req, req, async->parms); req->async.send_fn(req); } @@ -303,7 +303,7 @@ static NTSTATUS cvfs_qpathinfo(struct smbsrv_request *req, union smb_fileinfo *i struct smbcli_request *c_req; if (!req->async.send_fn) { - return smb_raw_pathinfo(private->tree, req->mem_ctx, info); + return smb_raw_pathinfo(private->tree, req, info); } c_req = smb_raw_pathinfo_send(private->tree, info); @@ -318,7 +318,7 @@ static void async_qfileinfo(struct smbcli_request *c_req) { struct async_info *async = c_req->async.private; struct smbsrv_request *req = async->req; - req->async.status = smb_raw_fileinfo_recv(c_req, req->mem_ctx, async->parms); + req->async.status = smb_raw_fileinfo_recv(c_req, req, async->parms); req->async.send_fn(req); } @@ -331,7 +331,7 @@ static NTSTATUS cvfs_qfileinfo(struct smbsrv_request *req, union smb_fileinfo *i struct smbcli_request *c_req; if (!req->async.send_fn) { - return smb_raw_fileinfo(private->tree, req->mem_ctx, info); + return smb_raw_fileinfo(private->tree, req, info); } c_req = smb_raw_fileinfo_send(private->tree, info); @@ -365,7 +365,7 @@ static void async_open(struct smbcli_request *c_req) { struct async_info *async = c_req->async.private; struct smbsrv_request *req = async->req; - req->async.status = smb_raw_open_recv(c_req, req->mem_ctx, async->parms); + req->async.status = smb_raw_open_recv(c_req, req, async->parms); req->async.send_fn(req); } @@ -383,7 +383,7 @@ static NTSTATUS cvfs_open(struct smbsrv_request *req, union smb_open *io) } if (!req->async.send_fn) { - return smb_raw_open(private->tree, req->mem_ctx, io); + return smb_raw_open(private->tree, req, io); } c_req = smb_raw_open_send(private->tree, io); @@ -587,7 +587,7 @@ static void async_fsinfo(struct smbcli_request *c_req) { struct async_info *async = c_req->async.private; struct smbsrv_request *req = async->req; - req->async.status = smb_raw_fsinfo_recv(c_req, req->mem_ctx, async->parms); + req->async.status = smb_raw_fsinfo_recv(c_req, req, async->parms); req->async.send_fn(req); } @@ -600,10 +600,10 @@ static NTSTATUS cvfs_fsinfo(struct smbsrv_request *req, union smb_fsinfo *fs) struct smbcli_request *c_req; if (!req->async.send_fn) { - return smb_raw_fsinfo(private->tree, req->mem_ctx, fs); + return smb_raw_fsinfo(private->tree, req, fs); } - c_req = smb_raw_fsinfo_send(private->tree, req->mem_ctx, fs); + c_req = smb_raw_fsinfo_send(private->tree, req, fs); ASYNC_RECV_TAIL(fs, async_fsinfo); } @@ -625,7 +625,7 @@ static NTSTATUS cvfs_search_first(struct smbsrv_request *req, union smb_search_f { struct cvfs_private *private = req->tcon->ntvfs_private; - return smb_raw_search_first(private->tree, req->mem_ctx, io, search_private, callback); + return smb_raw_search_first(private->tree, req, io, search_private, callback); } /* continue a search */ @@ -635,7 +635,7 @@ static NTSTATUS cvfs_search_next(struct smbsrv_request *req, union smb_search_ne { struct cvfs_private *private = req->tcon->ntvfs_private; - return smb_raw_search_next(private->tree, req->mem_ctx, io, search_private, callback); + return smb_raw_search_next(private->tree, req, io, search_private, callback); } /* close a search */ @@ -653,7 +653,7 @@ static void async_trans2(struct smbcli_request *c_req) { struct async_info *async = c_req->async.private; struct smbsrv_request *req = async->req; - req->async.status = smb_raw_trans2_recv(c_req, req->mem_ctx, async->parms); + req->async.status = smb_raw_trans2_recv(c_req, req, async->parms); req->async.send_fn(req); } @@ -664,7 +664,7 @@ static NTSTATUS cvfs_trans2(struct smbsrv_request *req, struct smb_trans2 *trans struct smbcli_request *c_req; if (!req->async.send_fn) { - return smb_raw_trans2(private->tree, req->mem_ctx, trans2); + return smb_raw_trans2(private->tree, req, trans2); } c_req = smb_raw_trans2_send(private->tree, trans2); diff --git a/source4/ntvfs/ipc/ipc_rap.c b/source4/ntvfs/ipc/ipc_rap.c index 347ff39d97..32b2fa2181 100644 --- a/source4/ntvfs/ipc/ipc_rap.c +++ b/source4/ntvfs/ipc/ipc_rap.c @@ -395,7 +395,7 @@ NTSTATUS ipc_rap_call(struct smbsrv_request *req, struct smb_trans2 *trans) struct ndr_push *final_param; struct ndr_push *final_data; - call = new_rap_srv_call(req->mem_ctx, trans); + call = new_rap_srv_call(req, trans); if (call == NULL) return NT_STATUS_NO_MEMORY; @@ -406,8 +406,8 @@ NTSTATUS ipc_rap_call(struct smbsrv_request *req, struct smb_trans2 *trans) NDR_CHECK(ndr_pull_string(call->ndr_pull_param, NDR_SCALARS, &call->datadesc)); - call->ndr_push_param = ndr_push_init_ctx(req->mem_ctx); - call->ndr_push_data = ndr_push_init_ctx(req->mem_ctx); + call->ndr_push_param = ndr_push_init_ctx(req); + call->ndr_push_data = ndr_push_init_ctx(req); if ((call->ndr_push_param == NULL) || (call->ndr_push_data == NULL)) return NT_STATUS_NO_MEMORY; @@ -432,8 +432,8 @@ NTSTATUS ipc_rap_call(struct smbsrv_request *req, struct smb_trans2 *trans) result_param = ndr_push_blob(call->ndr_push_param); result_data = ndr_push_blob(call->ndr_push_data); - final_param = ndr_push_init_ctx(req->mem_ctx); - final_data = ndr_push_init_ctx(req->mem_ctx); + final_param = ndr_push_init_ctx(req); + final_data = ndr_push_init_ctx(req); if ((final_param == NULL) || (final_data == NULL)) return NT_STATUS_NO_MEMORY; diff --git a/source4/ntvfs/ipc/rap_server.c b/source4/ntvfs/ipc/rap_server.c index 4a7b2dd91b..4ab1915c81 100644 --- a/source4/ntvfs/ipc/rap_server.c +++ b/source4/ntvfs/ipc/rap_server.c @@ -29,18 +29,18 @@ NTSTATUS rap_netshareenum(struct smbsrv_request *req, { r->out.status = 0; r->out.available = 2; - r->out.info = talloc_array_p(req->mem_ctx, + r->out.info = talloc_array_p(req, union rap_shareenum_info, 2); strncpy(r->out.info[0].info1.name, "C$", 12); r->out.info[0].info1.pad = 0; r->out.info[0].info1.type = 0; - r->out.info[0].info1.comment = talloc_strdup(req->mem_ctx, "Bla"); + r->out.info[0].info1.comment = talloc_strdup(req, "Bla"); strncpy(r->out.info[1].info1.name, "IPC$", 12); r->out.info[1].info1.pad = 0; r->out.info[1].info1.type = 1; - r->out.info[1].info1.comment = talloc_strdup(req->mem_ctx, "Blub"); + r->out.info[1].info1.comment = talloc_strdup(req, "Blub"); return NT_STATUS_OK; } diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 2e44b00c6b..053222460c 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -110,11 +110,11 @@ static NTSTATUS ipc_connect(struct smbsrv_request *req, const char *sharename) struct smbsrv_tcon *tcon = req->tcon; struct ipc_private *private; - tcon->fs_type = talloc_strdup(tcon->mem_ctx, "IPC"); - tcon->dev_type = talloc_strdup(tcon->mem_ctx, "IPC"); + tcon->fs_type = talloc_strdup(tcon, "IPC"); + tcon->dev_type = talloc_strdup(tcon, "IPC"); /* prepare the private state for this connection */ - private = talloc(tcon->mem_ctx, sizeof(struct ipc_private)); + private = talloc_p(tcon, struct ipc_private); if (!private) { return NT_STATUS_NO_MEMORY; } @@ -604,7 +604,7 @@ static NTSTATUS ipc_dcerpc_cmd(struct smbsrv_request *req, struct smb_trans2 *tr return NT_STATUS_INVALID_HANDLE; } - trans->out.data = data_blob_talloc(req->mem_ctx, NULL, trans->in.max_data); + trans->out.data = data_blob_talloc(req, NULL, trans->in.max_data); if (!trans->out.data.data) { return NT_STATUS_NO_MEMORY; } diff --git a/source4/ntvfs/nbench/vfs_nbench.c b/source4/ntvfs/nbench/vfs_nbench.c index e4e5af4171..549d1d893f 100644 --- a/source4/ntvfs/nbench/vfs_nbench.c +++ b/source4/ntvfs/nbench/vfs_nbench.c @@ -100,7 +100,7 @@ static NTSTATUS nbench_connect(struct smbsrv_request *req, const char *sharename NTSTATUS status; char *logname = NULL; - private = talloc_p(req->tcon->mem_ctx, struct nbench_private); + private = talloc_p(req->tcon, struct nbench_private); if (!private) { return NT_STATUS_NO_MEMORY; } diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index 36cbcabbd5..29f21b1863 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -472,7 +472,7 @@ NTSTATUS ntvfs_map_fileinfo(struct smbsrv_request *req, union smb_fileinfo *info case RAW_FILEINFO_STREAM_INFORMATION: info->stream_info.out.num_streams = info2->generic.out.num_streams; if (info->stream_info.out.num_streams > 0) { - info->stream_info.out.streams = talloc(req->mem_ctx, + info->stream_info.out.streams = talloc(req, info->stream_info.out.num_streams * sizeof(struct stream_struct)); if (!info->stream_info.out.streams) { DEBUG(2,("ntvfs_map_fileinfo: no memory for %d streams\n", @@ -482,7 +482,7 @@ NTSTATUS ntvfs_map_fileinfo(struct smbsrv_request *req, union smb_fileinfo *info for (i=0; i < info->stream_info.out.num_streams; i++) { info->stream_info.out.streams[i] = info2->generic.out.streams[i]; info->stream_info.out.streams[i].stream_name.s = - talloc_strdup(req->mem_ctx, info2->generic.out.streams[i].stream_name.s); + talloc_strdup(req, info2->generic.out.streams[i].stream_name.s); if (!info->stream_info.out.streams[i].stream_name.s) { DEBUG(2,("ntvfs_map_fileinfo: no memory for stream_name\n")); return NT_STATUS_NO_MEMORY; @@ -493,13 +493,13 @@ NTSTATUS ntvfs_map_fileinfo(struct smbsrv_request *req, union smb_fileinfo *info case RAW_FILEINFO_NAME_INFO: case RAW_FILEINFO_NAME_INFORMATION: - info->name_info.out.fname.s = talloc_strdup(req->mem_ctx, info2->generic.out.fname.s); + info->name_info.out.fname.s = talloc_strdup(req, info2->generic.out.fname.s); info->name_info.out.fname.private_length = info2->generic.out.fname.private_length; return NT_STATUS_OK; case RAW_FILEINFO_ALT_NAME_INFO: case RAW_FILEINFO_ALT_NAME_INFORMATION: - info->alt_name_info.out.fname.s = talloc_strdup(req->mem_ctx, info2->generic.out.alt_fname.s); + info->alt_name_info.out.fname.s = talloc_strdup(req, info2->generic.out.alt_fname.s); info->alt_name_info.out.fname.private_length = info2->generic.out.alt_fname.private_length; return NT_STATUS_OK; @@ -510,7 +510,7 @@ NTSTATUS ntvfs_map_fileinfo(struct smbsrv_request *req, union smb_fileinfo *info case RAW_FILEINFO_ALL_EAS: info->all_eas.out.num_eas = info2->generic.out.num_eas; if (info->all_eas.out.num_eas > 0) { - info->all_eas.out.eas = talloc(req->mem_ctx, + info->all_eas.out.eas = talloc(req, info->all_eas.out.num_eas * sizeof(struct ea_struct)); if (!info->all_eas.out.eas) { DEBUG(2,("ntvfs_map_fileinfo: no memory for %d eas\n", @@ -520,13 +520,13 @@ NTSTATUS ntvfs_map_fileinfo(struct smbsrv_request *req, union smb_fileinfo *info for (i = 0; i < info->all_eas.out.num_eas; i++) { info->all_eas.out.eas[i] = info2->generic.out.eas[i]; info->all_eas.out.eas[i].name.s = - talloc_strdup(req->mem_ctx, info2->generic.out.eas[i].name.s); + talloc_strdup(req, info2->generic.out.eas[i].name.s); if (!info->all_eas.out.eas[i].name.s) { DEBUG(2,("ntvfs_map_fileinfo: no memory for stream_name\n")); return NT_STATUS_NO_MEMORY; } info->all_eas.out.eas[i].value.data = - talloc_memdup(req->mem_ctx, + talloc_memdup(req, info2->generic.out.eas[i].value.data, info2->generic.out.eas[i].value.length); if (!info->all_eas.out.eas[i].value.data) { diff --git a/source4/ntvfs/posix/vfs_posix.c b/source4/ntvfs/posix/vfs_posix.c index 93cfbd74a9..8269f9bba7 100644 --- a/source4/ntvfs/posix/vfs_posix.c +++ b/source4/ntvfs/posix/vfs_posix.c @@ -1,8 +1,9 @@ /* Unix SMB/CIFS implementation. + POSIX NTVFS backend - Copyright (C) Andrew Tridgell 2003 - Copyright (C) Stefan (metze) Metzmacher 2004 + + Copyright (C) Andrew Tridgell 2004 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 @@ -24,6 +25,8 @@ */ #include "include/includes.h" +#include "vfs_posix.h" + /* connect to a share - used when a tree_connect operation comes @@ -33,16 +36,31 @@ */ static NTSTATUS pvfs_connect(struct smbsrv_request *req, const char *sharename) { - DEBUG(0, ("Connection to share [%s] ACCESS DENIED!\n", sharename)); - DEBUGADD(0,("This is because your using the 'ntvfs handler = default'.\n")); - DEBUGADD(0,("This backend is not functional at the moment.\n")); - DEBUGADD(0,("Please use one of the following backends:\n")); - DEBUGADD(0,("cifs - a proxy to another cifs-server\n")); - DEBUGADD(0,("simple - a very, very simple posix backend\n")); - DEBUGADD(0,(" all file acess is done as user 'root'\n")); - DEBUGADD(0,(" Please don't use this a sensitive data!!!\n")); - - return NT_STATUS_DEVICE_CONFIGURATION_ERROR; + struct smbsrv_tcon *tcon = req->tcon; + struct pvfs_state *pvfs; + struct stat st; + + DEBUG(0,("WARNING: the posix vfs handler is incomplete - you probably want \"ntvfs handler = simple\"\n")); + + pvfs = talloc_named(tcon, sizeof(struct pvfs_state), "pvfs_connect(%s)", sharename); + if (pvfs == NULL) { + return NT_STATUS_NO_MEMORY; + } + + pvfs->base_directory = talloc_strdup(pvfs, lp_pathname(tcon->service)); + + /* the directory must exist. Note that we deliberately don't + check that it is readable */ + if (stat(pvfs->base_directory, &st) != 0 || !S_ISDIR(st.st_mode)) { + DEBUG(0,("pvfs_connect: '%s' is not a directory, when connecting to [%s]\n", + pvfs->base_directory, sharename)); + return NT_STATUS_BAD_NETWORK_NAME; + } + + tcon->fs_type = talloc_strdup(tcon, "NTFS"); + tcon->dev_type = talloc_strdup(tcon, "A:"); + + return NT_STATUS_OK; } /* diff --git a/source4/ntvfs/print/vfs_print.c b/source4/ntvfs/print/vfs_print.c index fa5835843a..4b50e3e6e5 100644 --- a/source4/ntvfs/print/vfs_print.c +++ b/source4/ntvfs/print/vfs_print.c @@ -64,7 +64,7 @@ static NTSTATUS print_ioctl(struct smbsrv_request *req, union smb_ioctl *io) if (io->ioctl.in.request == IOCTL_QUERY_JOB_INFO) { /* a request for the print job id of an open print job */ - io->ioctl.out.blob = data_blob_talloc(req->mem_ctx, NULL, 32); + io->ioctl.out.blob = data_blob_talloc(req, NULL, 32); data_blob_clear(&io->ioctl.out.blob); diff --git a/source4/ntvfs/simple/svfs_util.c b/source4/ntvfs/simple/svfs_util.c index 14ffc6d19c..04165cadd9 100644 --- a/source4/ntvfs/simple/svfs_util.c +++ b/source4/ntvfs/simple/svfs_util.c @@ -35,9 +35,9 @@ char *svfs_unix_path(struct smbsrv_request *req, const char *name) char *ret; if (*name != '\\') { - ret = talloc_asprintf(req->mem_ctx, "%s/%s", private->connectpath, name); + ret = talloc_asprintf(req, "%s/%s", private->connectpath, name); } else { - ret = talloc_asprintf(req->mem_ctx, "%s%s", private->connectpath, name); + ret = talloc_asprintf(req, "%s%s", private->connectpath, name); } all_string_sub(ret, "\\", "/", 0); diff --git a/source4/ntvfs/simple/vfs_simple.c b/source4/ntvfs/simple/vfs_simple.c index 007095f44a..8bce111e9c 100644 --- a/source4/ntvfs/simple/vfs_simple.c +++ b/source4/ntvfs/simple/vfs_simple.c @@ -67,12 +67,12 @@ static NTSTATUS svfs_connect(struct smbsrv_request *req, const char *sharename) struct smbsrv_tcon *tcon = req->tcon; struct svfs_private *private; - tcon->ntvfs_private = talloc_p(tcon->mem_ctx, struct svfs_private); + tcon->ntvfs_private = talloc_p(tcon, struct svfs_private); private = tcon->ntvfs_private; private->next_search_handle = 0; - private->connectpath = talloc_strdup(tcon->mem_ctx, lp_pathname(tcon->service)); + private->connectpath = talloc_strdup(tcon, lp_pathname(tcon->service)); private->open_files = NULL; /* the directory must exist */ @@ -82,8 +82,8 @@ static NTSTATUS svfs_connect(struct smbsrv_request *req, const char *sharename) return NT_STATUS_BAD_NETWORK_NAME; } - tcon->fs_type = talloc_strdup(tcon->mem_ctx, "NTFS"); - tcon->dev_type = talloc_strdup(tcon->mem_ctx, "A:"); + tcon->fs_type = talloc_strdup(tcon, "NTFS"); + tcon->dev_type = talloc_strdup(tcon, "A:"); DEBUG(0,("WARNING: ntvfs simple: connect to share [%s] with ROOT privileges!!!\n",sharename)); @@ -183,7 +183,7 @@ static NTSTATUS svfs_map_fileinfo(struct smbsrv_request *req, union smb_fileinfo asprintf(&pattern, "%s:*", unix_path); if (pattern) { - dir = svfs_list_unix(req->mem_ctx, req, pattern); + dir = svfs_list_unix(req, req, pattern); } unix_to_nt_time(&info->generic.out.create_time, st->st_ctime); @@ -201,8 +201,8 @@ static NTSTATUS svfs_map_fileinfo(struct smbsrv_request *req, union smb_fileinfo info->generic.out.delete_pending = 0; info->generic.out.ea_size = 0; info->generic.out.num_eas = 0; - info->generic.out.fname.s = talloc_strdup(req->mem_ctx, short_name); - info->generic.out.alt_fname.s = talloc_strdup(req->mem_ctx, short_name); + info->generic.out.fname.s = talloc_strdup(req, short_name); + info->generic.out.alt_fname.s = talloc_strdup(req, short_name); info->generic.out.ex_attrib = 0; info->generic.out.compressed_size = 0; info->generic.out.format = 0; @@ -218,7 +218,7 @@ static NTSTATUS svfs_map_fileinfo(struct smbsrv_request *req, union smb_fileinfo info->generic.out.num_streams = 0; /* setup a single data stream */ info->generic.out.num_streams = 1 + (dir?dir->count:0); - info->generic.out.streams = talloc_array_p(req->mem_ctx, + info->generic.out.streams = talloc_array_p(req, struct stream_struct, info->generic.out.num_streams); if (!info->generic.out.streams) { @@ -226,7 +226,7 @@ static NTSTATUS svfs_map_fileinfo(struct smbsrv_request *req, union smb_fileinfo } info->generic.out.streams[0].size = st->st_size; info->generic.out.streams[0].alloc_size = st->st_size; - info->generic.out.streams[0].stream_name.s = talloc_strdup(req->mem_ctx,"::$DATA"); + info->generic.out.streams[0].stream_name.s = talloc_strdup(req,"::$DATA"); for (i=0;dir && i<dir->count;i++) { s = strchr(dir->files[i].name, ':'); @@ -376,9 +376,9 @@ do_open: return map_nt_error_from_unix(errno); } - f = talloc_p(req->tcon->mem_ctx, struct svfs_file); + f = talloc_p(req->tcon, struct svfs_file); f->fd = fd; - f->name = talloc_strdup(req->tcon->mem_ctx, unix_path); + f->name = talloc_strdup(req->tcon, unix_path); DLIST_ADD(private->open_files, f); @@ -690,7 +690,7 @@ static NTSTATUS svfs_fsinfo(struct smbsrv_request *req, union smb_fsinfo *fs) fs->generic.out.quota_soft = 0; fs->generic.out.quota_hard = 0; fs->generic.out.quota_flags = 0; - fs->generic.out.volume_name = talloc_strdup(req->mem_ctx, lp_servicename(req->tcon->service)); + fs->generic.out.volume_name = talloc_strdup(req, lp_servicename(req->tcon->service)); fs->generic.out.fs_type = req->tcon->fs_type; return NT_STATUS_OK; @@ -720,8 +720,8 @@ static NTSTATUS svfs_fsattr(struct smbsrv_request *req, union smb_fsattr *fs) FILE_PERSISTENT_ACLS; fs->generic.out.max_file_component_length = 255; fs->generic.out.serial_number = 1; - fs->generic.out.fs_type = talloc_strdup(req->mem_ctx, "NTFS"); - fs->generic.out.volume_name = talloc_strdup(req->mem_ctx, + fs->generic.out.fs_type = talloc_strdup(req, "NTFS"); + fs->generic.out.volume_name = talloc_strdup(req, lp_servicename(req->tcon->service)); return NT_STATUS_OK; @@ -755,22 +755,19 @@ static NTSTATUS svfs_search_first(struct smbsrv_request *req, union smb_search_f return NT_STATUS_NOT_SUPPORTED; } - mem_ctx = talloc_init("svfs_search"); - - search = talloc_zero(mem_ctx, sizeof(struct search_state)); + search = talloc_zero(private, sizeof(struct search_state)); if (!search) { return NT_STATUS_NO_MEMORY; } max_count = io->t2ffirst.in.max_count; - dir = svfs_list(mem_ctx, req, io->t2ffirst.in.pattern); + dir = svfs_list(private, req, io->t2ffirst.in.pattern); if (!dir) { talloc_free(mem_ctx); return NT_STATUS_FOOBAR; } - search->mem_ctx = mem_ctx; search->handle = private->next_search_handle; search->dir = dir; @@ -803,7 +800,7 @@ static NTSTATUS svfs_search_first(struct smbsrv_request *req, union smb_search_f /* work out if we are going to keep the search state */ if ((io->t2ffirst.in.flags & FLAG_TRANS2_FIND_CLOSE) || ((io->t2ffirst.in.flags & FLAG_TRANS2_FIND_CLOSE_IF_END) && (i == dir->count))) { - talloc_free(search->mem_ctx); + talloc_free(search); } else { private->next_search_handle++; DLIST_ADD(private->search, search); @@ -893,7 +890,7 @@ found: if ((io->t2fnext.in.flags & FLAG_TRANS2_FIND_CLOSE) || ((io->t2fnext.in.flags & FLAG_TRANS2_FIND_CLOSE_IF_END) && (i == dir->count))) { DLIST_REMOVE(private->search, search); - talloc_free(search->mem_ctx); + talloc_free(search); } return NT_STATUS_OK; @@ -915,7 +912,7 @@ static NTSTATUS svfs_search_close(struct smbsrv_request *req, union smb_search_c } DLIST_REMOVE(private->search, search); - talloc_free(search->mem_ctx); + talloc_free(search); return NT_STATUS_OK; } @@ -970,7 +967,7 @@ NTSTATUS ntvfs_simple_init(void) ops.trans = svfs_trans; /* register ourselves with the NTVFS subsystem. We register - under names 'simple' + under names 'simple' */ ops.name = "simple"; ret = register_backend("ntvfs", &ops); diff --git a/source4/smb_server/conn.c b/source4/smb_server/conn.c index 197d925f34..1872d9b9d4 100644 --- a/source4/smb_server/conn.c +++ b/source4/smb_server/conn.c @@ -78,7 +78,6 @@ thinking the server is still available. ****************************************************************************/ struct smbsrv_tcon *conn_new(struct smbsrv_connection *smb_conn) { - TALLOC_CTX *mem_ctx; struct smbsrv_tcon *tcon; int i; @@ -89,14 +88,11 @@ struct smbsrv_tcon *conn_new(struct smbsrv_connection *smb_conn) return NULL; } - mem_ctx = talloc_init("smbsrv_tcon[%d]", i); - - tcon = talloc_p(mem_ctx, struct smbsrv_tcon); + tcon = talloc_p(smb_conn, struct smbsrv_tcon); if (!tcon) return NULL; ZERO_STRUCTP(tcon); - tcon->mem_ctx = mem_ctx; tcon->cnum = i; tcon->smb_conn = smb_conn; @@ -152,6 +148,6 @@ void conn_free(struct smbsrv_connection *smb_conn, struct smbsrv_tcon *tcon) bitmap_clear(smb_conn->tree.bmap, tcon->cnum); smb_conn->tree.num_open--; - talloc_destroy(tcon->mem_ctx); + talloc_destroy(tcon); } diff --git a/source4/smb_server/connection.c b/source4/smb_server/connection.c index 4cb4f2168a..4badf00ce3 100644 --- a/source4/smb_server/connection.c +++ b/source4/smb_server/connection.c @@ -110,12 +110,16 @@ BOOL claim_connection(struct smbsrv_tcon *tcon, const char *name,int max_connect struct connections_data crec; TDB_DATA kbuf, dbuf; - if (!tdb) - tdb = tdb_open_log(lock_path(tcon->mem_ctx, "connections.tdb"), 0, TDB_CLEAR_IF_FIRST|TDB_DEFAULT, - O_RDWR | O_CREAT, 0644); + if (!tdb) { + char *lpath = lock_path(tcon, "connections.tdb"); + tdb = tdb_open_log(lpath, 0, TDB_CLEAR_IF_FIRST|TDB_DEFAULT, + O_RDWR | O_CREAT, 0644); + talloc_free(lpath); + } - if (!tdb) + if (!tdb) { return False; + } /* * Enforce the max connections parameter. diff --git a/source4/smb_server/negprot.c b/source4/smb_server/negprot.c index d81900107b..fa5553b5ce 100644 --- a/source4/smb_server/negprot.c +++ b/source4/smb_server/negprot.c @@ -328,7 +328,7 @@ static void reply_nt1(struct smbsrv_request *req, uint16_t choice) return; } - nt_status = gensec_update(gensec_security, req->mem_ctx, null_data_blob, &blob); + nt_status = gensec_update(gensec_security, req, null_data_blob, &blob); if (!NT_STATUS_IS_OK(nt_status) && !NT_STATUS_EQUAL(nt_status, NT_STATUS_MORE_PROCESSING_REQUIRED)) { DEBUG(0, ("Failed to get SPNEGO to give us the first token: %s\n", nt_errstr(nt_status))); diff --git a/source4/smb_server/nttrans.c b/source4/smb_server/nttrans.c index ddae725c4b..bd8c49c594 100644 --- a/source4/smb_server/nttrans.c +++ b/source4/smb_server/nttrans.c @@ -39,10 +39,10 @@ static void nttrans_setup_reply(struct smbsrv_request *req, { trans->out.setup_count = setup_count; if (setup_count != 0) { - trans->out.setup = talloc_zero(req->mem_ctx, sizeof(uint16_t) * setup_count); + trans->out.setup = talloc_zero(req, sizeof(uint16_t) * setup_count); } - trans->out.params = data_blob_talloc(req->mem_ctx, NULL, param_size); - trans->out.data = data_blob_talloc(req->mem_ctx, NULL, data_size); + trans->out.params = data_blob_talloc(req, NULL, param_size); + trans->out.data = data_blob_talloc(req, NULL, data_size); } @@ -163,7 +163,7 @@ void reply_nttrans(struct smbsrv_request *req) } /* parse out the setup words */ - trans.in.setup = talloc(req->mem_ctx, trans.in.setup_count * sizeof(uint16_t)); + trans.in.setup = talloc(req, trans.in.setup_count * sizeof(uint16_t)); if (!trans.in.setup) { req_reply_error(req, NT_STATUS_NO_MEMORY); return; diff --git a/source4/smb_server/password.c b/source4/smb_server/password.c index 492f5700ad..c302f65980 100644 --- a/source4/smb_server/password.c +++ b/source4/smb_server/password.c @@ -101,7 +101,7 @@ uint16_t smbsrv_register_session(struct smbsrv_connection *smb_conn, { struct smbsrv_session *sess = NULL; - sess = talloc_p(smb_conn->mem_ctx, struct smbsrv_session); + sess = talloc_p(smb_conn, struct smbsrv_session); if(sess == NULL) { DEBUG(0,("talloc_p(smb_conn->mem_ctx, struct smbsrv_session) failed\n")); return UID_FIELD_INVALID; diff --git a/source4/smb_server/reply.c b/source4/smb_server/reply.c index 915919e9d6..6874b4b25b 100644 --- a/source4/smb_server/reply.c +++ b/source4/smb_server/reply.c @@ -43,7 +43,7 @@ /* useful wrapper for talloc with NO_MEMORY reply */ #define REQ_TALLOC(ptr, size) do { \ - ptr = talloc(req->mem_ctx, size); \ + ptr = talloc(req, size); \ if (!ptr) { \ req_reply_error(req, NT_STATUS_NO_MEMORY); \ return; \ @@ -678,7 +678,7 @@ void reply_readbraw(struct smbsrv_request *req) /* before calling the backend we setup the raw buffer. This * saves a copy later */ req->out.size = io.readbraw.in.maxcnt + NBT_HDR_SIZE; - req->out.buffer = talloc(req->mem_ctx, req->out.size); + req->out.buffer = talloc(req, req->out.size); if (req->out.buffer == NULL) { goto failed; } @@ -702,7 +702,7 @@ void reply_readbraw(struct smbsrv_request *req) failed: /* any failure in readbraw is equivalent to reading zero bytes */ req->out.size = 4; - req->out.buffer = talloc(req->mem_ctx, req->out.size); + req->out.buffer = talloc(req, req->out.size); SIVAL(req->out.buffer, 0, 0); /* init NBT header */ req_send_reply_nosign(req); diff --git a/source4/smb_server/request.c b/source4/smb_server/request.c index 645ea105a2..fad1d25bba 100644 --- a/source4/smb_server/request.c +++ b/source4/smb_server/request.c @@ -38,7 +38,7 @@ void req_destroy(struct smbsrv_request *req) /* ahh, its so nice to destroy a complex structure in such a * simple way! */ - talloc_destroy(req->mem_ctx); + talloc_free(req); } /**************************************************************************** @@ -48,20 +48,10 @@ such as change notify and oplock break requests struct smbsrv_request *init_smb_request(struct smbsrv_connection *smb_conn) { struct smbsrv_request *req; - TALLOC_CTX *mem_ctx; - - /* each request gets its own talloc context. The request - structure itself is also allocated inside this context, so - we need to allocate it before we construct the request - */ - mem_ctx = talloc_init("request_context[%d]", smb_conn->connection->socket->pkt_count); - if (!mem_ctx) { - return NULL; - } smb_conn->connection->socket->pkt_count++; - req = talloc(mem_ctx, sizeof(*req)); + req = talloc_p(smb_conn, struct smbsrv_request); if (!req) { return NULL; } @@ -70,7 +60,6 @@ struct smbsrv_request *init_smb_request(struct smbsrv_connection *smb_conn) /* setup the request context */ req->smb_conn = smb_conn; - req->mem_ctx = mem_ctx; return req; } @@ -123,7 +112,7 @@ void req_setup_reply(struct smbsrv_request *req, uint_t wct, uint_t buflen) /* over allocate by a small amount */ req->out.allocated = req->out.size + REQ_OVER_ALLOCATION; - req->out.buffer = talloc(req->mem_ctx, req->out.allocated); + req->out.buffer = talloc(req, req->out.allocated); if (!req->out.buffer) { smbsrv_terminate_connection(req->smb_conn, "allocation failed"); } @@ -468,7 +457,7 @@ static size_t req_pull_ucs2(struct smbsrv_request *req, const char **dest, const src_len2 += 2; } - ret = convert_string_talloc(req->mem_ctx, CH_UTF16, CH_UNIX, src, src_len2, (const void **)dest); + ret = convert_string_talloc(req, CH_UTF16, CH_UNIX, src, src_len2, (const void **)dest); if (ret == -1) { *dest = NULL; @@ -515,7 +504,7 @@ static size_t req_pull_ascii(struct smbsrv_request *req, const char **dest, cons src_len2++; } - ret = convert_string_talloc(req->mem_ctx, CH_DOS, CH_UNIX, src, src_len2, (const void **)dest); + ret = convert_string_talloc(req, CH_DOS, CH_UNIX, src, src_len2, (const void **)dest); if (ret == -1) { *dest = NULL; @@ -564,7 +553,7 @@ size_t req_pull_ascii4(struct smbsrv_request *req, const char **dest, const char if (PTR_DIFF(src, req->in.data) + 1 > req->in.data_size) { /* win2000 treats this as the NULL string! */ - (*dest) = talloc_strdup(req->mem_ctx, ""); + (*dest) = talloc_strdup(req, ""); return 0; } @@ -575,7 +564,7 @@ size_t req_pull_ascii4(struct smbsrv_request *req, const char **dest, const char ret = req_pull_string(req, dest, src, -1, flags); if (ret == -1) { - (*dest) = talloc_strdup(req->mem_ctx, ""); + (*dest) = talloc_strdup(req, ""); return 1; } @@ -593,7 +582,7 @@ BOOL req_pull_blob(struct smbsrv_request *req, const char *src, int len, DATA_BL return False; } - (*blob) = data_blob_talloc(req->mem_ctx, src, len); + (*blob) = data_blob_talloc(req, src, len); return True; } diff --git a/source4/smb_server/search.c b/source4/smb_server/search.c index 26ad53fc80..e18ecda887 100644 --- a/source4/smb_server/search.c +++ b/source4/smb_server/search.c @@ -43,7 +43,7 @@ /* useful wrapper for talloc with NO_MEMORY reply */ #define REQ_TALLOC(ptr, size) do { \ - ptr = talloc(req->mem_ctx, size); \ + ptr = talloc(req, size); \ if (!ptr) { \ req_reply_error(req, NT_STATUS_NO_MEMORY); \ return; \ diff --git a/source4/smb_server/service.c b/source4/smb_server/service.c index 6b7c626dd5..8741898a9c 100644 --- a/source4/smb_server/service.c +++ b/source4/smb_server/service.c @@ -311,8 +311,8 @@ NTSTATUS tcon_backend(struct smbsrv_request *req, union smb_tcon *con) } con->tconx.out.cnum = req->tcon->cnum; - con->tconx.out.dev_type = talloc_strdup(req->mem_ctx, req->tcon->dev_type); - con->tconx.out.fs_type = talloc_strdup(req->mem_ctx, req->tcon->fs_type); + con->tconx.out.dev_type = talloc_strdup(req, req->tcon->dev_type); + con->tconx.out.fs_type = talloc_strdup(req, req->tcon->fs_type); con->tconx.out.options = SMB_SUPPORT_SEARCH_BITS | (lp_csc_policy(req->tcon->service) << 2); if (lp_msdfs_root(req->tcon->service) && lp_host_msdfs()) { con->tconx.out.options |= SMB_SHARE_IN_DFS; diff --git a/source4/smb_server/sesssetup.c b/source4/smb_server/sesssetup.c index 1c33686407..47b8082f3b 100644 --- a/source4/smb_server/sesssetup.c +++ b/source4/smb_server/sesssetup.c @@ -29,9 +29,9 @@ static void sesssetup_common_strings(struct smbsrv_request *req, char **os, char **lanman, char **domain) { - (*os) = talloc_asprintf(req->mem_ctx, "Unix"); - (*lanman) = talloc_asprintf(req->mem_ctx, "Samba %s", SAMBA_VERSION_STRING); - (*domain) = talloc_asprintf(req->mem_ctx, "%s", lp_workgroup()); + (*os) = talloc_asprintf(req, "Unix"); + (*lanman) = talloc_asprintf(req, "Samba %s", SAMBA_VERSION_STRING); + (*domain) = talloc_asprintf(req, "%s", lp_workgroup()); } @@ -205,7 +205,7 @@ static NTSTATUS sesssetup_spnego(struct smbsrv_request *req, union smb_sesssetup return NT_STATUS_ACCESS_DENIED; } - status = gensec_update(smb_sess->gensec_ctx, req->mem_ctx, sess->spnego.in.secblob, &sess->spnego.out.secblob); + status = gensec_update(smb_sess->gensec_ctx, req, sess->spnego.in.secblob, &sess->spnego.out.secblob); } else { status = gensec_server_start(&gensec_ctx); if (!NT_STATUS_IS_OK(status)) { @@ -221,7 +221,7 @@ static NTSTATUS sesssetup_spnego(struct smbsrv_request *req, union smb_sesssetup return status; } - status = gensec_update(gensec_ctx, req->mem_ctx, sess->spnego.in.secblob, &sess->spnego.out.secblob); + status = gensec_update(gensec_ctx, req, sess->spnego.in.secblob, &sess->spnego.out.secblob); } diff --git a/source4/smb_server/smb_server.c b/source4/smb_server/smb_server.c index d12915957e..a413a7dd4b 100644 --- a/source4/smb_server/smb_server.c +++ b/source4/smb_server/smb_server.c @@ -76,7 +76,7 @@ static struct smbsrv_request *receive_smb_request(struct smbsrv_connection *smb_ req->chained_fnum = -1; /* allocate the incoming buffer at the right size */ - req->in.buffer = talloc(req->mem_ctx, len + NBT_HDR_SIZE); + req->in.buffer = talloc(req, len + NBT_HDR_SIZE); /* fill in the already received header */ memcpy(req->in.buffer, header, 4); @@ -783,7 +783,7 @@ static void smbsrv_close(struct server_connection *conn, const char *reason) conn_close_all(smb_conn); - talloc_free(smb_conn->mem_ctx); + talloc_free(smb_conn); return; } @@ -822,19 +822,18 @@ void smbsrv_accept(struct server_connection *conn) mem_ctx = talloc_init("smbsrv_context"); - smb_conn = talloc_p(mem_ctx, struct smbsrv_connection); + smb_conn = talloc_p(conn, struct smbsrv_connection); if (!smb_conn) return; ZERO_STRUCTP(smb_conn); - smb_conn->mem_ctx = mem_ctx; smb_conn->pid = getpid(); sub_set_context(&smb_conn->substitute); /* set an initial client name based on its IP address. This will be replaced with the netbios name later if it gives us one */ - socket_addr = get_socket_addr(smb_conn->mem_ctx, conn->socket->fde->fd); + socket_addr = get_socket_addr(smb_conn, conn->socket->fde->fd); sub_set_remote_machine(socket_addr); /* now initialise a few default values associated with this smb socket */ diff --git a/source4/smb_server/smb_server.h b/source4/smb_server/smb_server.h index 4ff246c415..de96fae504 100644 --- a/source4/smb_server/smb_server.h +++ b/source4/smb_server/smb_server.h @@ -61,9 +61,6 @@ struct smbsrv_tcon { /* the server context that this was created on */ struct smbsrv_connection *smb_conn; - /* a talloc context for all data in this structure */ - TALLOC_CTX *mem_ctx; - /* a private structure used by the active NTVFS backend */ void *ntvfs_private; @@ -86,9 +83,6 @@ struct smbsrv_tcon { /* the context for a single SMB request. This is passed to any request-context functions */ struct smbsrv_request { - /* a talloc context for the lifetime of this request */ - TALLOC_CTX *mem_ctx; - /* the server_context contains all context specific to this SMB socket */ struct smbsrv_connection *smb_conn; @@ -173,9 +167,6 @@ struct substitute_context { * information associated with a SMB server connection */ struct smbsrv_connection { - /* a talloc context for all data in this structure */ - TALLOC_CTX *mem_ctx; - /* this is the context for a SMB socket associated with the socket itself */ struct { /* the open file descriptor */ diff --git a/source4/smb_server/trans2.c b/source4/smb_server/trans2.c index c8b73ca4c6..57a385fe27 100644 --- a/source4/smb_server/trans2.c +++ b/source4/smb_server/trans2.c @@ -73,10 +73,10 @@ static void trans2_setup_reply(struct smbsrv_request *req, { trans->out.setup_count = setup_count; if (setup_count != 0) { - trans->out.setup = talloc_zero(req->mem_ctx, sizeof(uint16_t) * setup_count); + trans->out.setup = talloc_zero(req, sizeof(uint16_t) * setup_count); } - trans->out.params = data_blob_talloc(req->mem_ctx, NULL, param_size); - trans->out.data = data_blob_talloc(req->mem_ctx, NULL, data_size); + trans->out.params = data_blob_talloc(req, NULL, param_size); + trans->out.data = data_blob_talloc(req, NULL, data_size); } @@ -371,7 +371,7 @@ static NTSTATUS trans2_qfsinfo(struct smbsrv_request *req, struct smb_trans2 *tr trans2_setup_reply(req, trans, 0, 64, 0); - status = ndr_push_struct_blob(&guid_blob, req->mem_ctx, + status = ndr_push_struct_blob(&guid_blob, req, &fsinfo.objectid_information.out.guid, (ndr_push_flags_fn_t)ndr_push_GUID); if (!NT_STATUS_IS_OK(status)) { @@ -722,7 +722,7 @@ static NTSTATUS trans2_parse_sfileinfo(struct smbsrv_request *req, DATA_BLOB blob2; blob2.data = blob->data+4; blob2.length = len-4; - len = ea_pull_struct(&blob2, req->mem_ctx, &st->ea_set.in.ea); + len = ea_pull_struct(&blob2, req, &st->ea_set.in.ea); } if (len == 0) { return NT_STATUS_INVALID_PARAMETER; @@ -1275,7 +1275,7 @@ void reply_trans_generic(struct smbsrv_request *req, uint8_t command) } /* parse out the setup words */ - trans.in.setup = talloc(req->mem_ctx, trans.in.setup_count * sizeof(uint16_t)); + trans.in.setup = talloc(req, trans.in.setup_count * sizeof(uint16_t)); if (trans.in.setup_count && !trans.in.setup) { req_reply_error(req, NT_STATUS_NO_MEMORY); return; |