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;
}
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;
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; \
{
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);
}
/* 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);
{
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);
}
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);
{
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);
}
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);
{
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);
}
}
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);
{
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);
}
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);
}
{
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 */
{
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 */
{
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);
}
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);
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;
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;
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;
{
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;
}
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;
}
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;
}
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;
}
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",
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;
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;
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",
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) {
/*
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
*/
#include "include/includes.h"
+#include "vfs_posix.h"
+
/*
connect to a share - used when a tree_connect operation comes
*/
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;
}
/*
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);
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);
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 */
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));
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);
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;
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) {
}
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, ':');
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);
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;
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;
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;
/* 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);
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;
}
DLIST_REMOVE(private->search, search);
- talloc_free(search->mem_ctx);
+ talloc_free(search);
return NT_STATUS_OK;
}
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);
****************************************************************************/
struct smbsrv_tcon *conn_new(struct smbsrv_connection *smb_conn)
{
- TALLOC_CTX *mem_ctx;
struct smbsrv_tcon *tcon;
int i;
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;
bitmap_clear(smb_conn->tree.bmap, tcon->cnum);
smb_conn->tree.num_open--;
- talloc_destroy(tcon->mem_ctx);
+ talloc_destroy(tcon);
}
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.
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)));
{
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);
}
}
/* 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;
{
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;
/* 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; \
/* 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;
}
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);
/* ahh, its so nice to destroy a complex structure in such a
* simple way! */
- talloc_destroy(req->mem_ctx);
+ talloc_free(req);
}
/****************************************************************************
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;
}
/* setup the request context */
req->smb_conn = smb_conn;
- req->mem_ctx = mem_ctx;
return req;
}
/* 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");
}
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;
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;
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;
}
ret = req_pull_string(req, dest, src, -1, flags);
if (ret == -1) {
- (*dest) = talloc_strdup(req->mem_ctx, "");
+ (*dest) = talloc_strdup(req, "");
return 1;
}
return False;
}
- (*blob) = data_blob_talloc(req->mem_ctx, src, len);
+ (*blob) = data_blob_talloc(req, src, len);
return True;
}
/* 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; \
}
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;
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());
}
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)) {
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);
}
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);
conn_close_all(smb_conn);
- talloc_free(smb_conn->mem_ctx);
+ talloc_free(smb_conn);
return;
}
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 */
/* 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;
/* 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;
* 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 */
{
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);
}
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)) {
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;
}
/* 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;