summaryrefslogtreecommitdiff
path: root/source4/ntvfs/posix
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-10-18 13:27:22 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:00:01 -0500
commit142d295aa8e70477c85d1835f2907f81c4c3c519 (patch)
treef7914d649c4d89e1845637d187eb9e29aef2faf2 /source4/ntvfs/posix
parent3406ac309252fc978fcfcbf39f85d7e9483b2758 (diff)
downloadsamba-142d295aa8e70477c85d1835f2907f81c4c3c519.tar.gz
samba-142d295aa8e70477c85d1835f2907f81c4c3c519.tar.bz2
samba-142d295aa8e70477c85d1835f2907f81c4c3c519.zip
r3039: This solves the problem of async handlers in ntvfs backends not being
in the right state when called. For example, when we use the unixuid handler in the chain of handlers, and a backend decides to continue a call asynchronously then we need to ensure that the continuation happens with the right security context. The solution is to add a new ntvfs operation ntvfs_async_setup(), which calls all the way down through the layers, setting up anything that is required, and takes a private pointer. The backend wanting to make a async calls can use ntvfs_async_setup() to ensure that the modules above it are called when doing async processing. (This used to be commit a256e71029727fa1659ade6257085df537308c7d)
Diffstat (limited to 'source4/ntvfs/posix')
-rw-r--r--source4/ntvfs/posix/pvfs_wait.c36
-rw-r--r--source4/ntvfs/posix/vfs_posix.c1
2 files changed, 34 insertions, 3 deletions
diff --git a/source4/ntvfs/posix/pvfs_wait.c b/source4/ntvfs/posix/pvfs_wait.c
index 5815b8edde..2a4a1d286b 100644
--- a/source4/ntvfs/posix/pvfs_wait.c
+++ b/source4/ntvfs/posix/pvfs_wait.c
@@ -31,8 +31,22 @@ struct pvfs_wait {
int msg_type;
void *msg_ctx;
struct event_context *ev;
+ struct smbsrv_request *req;
+ BOOL timed_out;
};
+/*
+ called from the ntvfs layer when we have requested setup of an async
+ call. this ensures that async calls runs with the right state of
+ previous ntvfs handlers in the chain (such as security context)
+*/
+NTSTATUS pvfs_async_setup(struct ntvfs_module_context *ntvfs,
+ struct smbsrv_request *req, void *private)
+{
+ struct pvfs_wait *pwait = private;
+ pwait->handler(pwait->private, pwait->timed_out);
+ return NT_STATUS_OK;
+}
/*
receive a completion message for a wait
@@ -41,6 +55,7 @@ static void pvfs_wait_dispatch(void *msg_ctx, void *private, uint32_t msg_type,
servid_t src, DATA_BLOB *data)
{
struct pvfs_wait *pwait = private;
+ struct smbsrv_request *req;
/* we need to check that this one is for us. This sender sends
the private pointer as the body of the message. This might
@@ -50,8 +65,16 @@ static void pvfs_wait_dispatch(void *msg_ctx, void *private, uint32_t msg_type,
*(void **)data->data != pwait->private) {
return;
}
-
- pwait->handler(pwait->private, False);
+ pwait->timed_out = False;
+ req = pwait->req;
+
+ /* the extra reference here is to ensure that the req
+ structure is not destroyed when the async request reply is
+ sent, which would cause problems with the other ntvfs
+ modules above us */
+ talloc_increase_ref_count(req);
+ ntvfs_async_setup(pwait->req, pwait);
+ talloc_free(req);
}
@@ -61,7 +84,13 @@ static void pvfs_wait_dispatch(void *msg_ctx, void *private, uint32_t msg_type,
static void pvfs_wait_timeout(struct event_context *ev, struct timed_event *te, time_t t)
{
struct pvfs_wait *pwait = te->private;
- pwait->handler(pwait->private, True);
+ struct smbsrv_request *req = pwait->req;
+
+ pwait->timed_out = True;
+
+ talloc_increase_ref_count(req);
+ ntvfs_async_setup(pwait->req, pwait);
+ talloc_free(req);
}
@@ -103,6 +132,7 @@ void *pvfs_wait_message(struct pvfs_state *pvfs,
pwait->msg_ctx = pvfs->tcon->smb_conn->connection->messaging_ctx;
pwait->ev = req->tcon->smb_conn->connection->event.ctx;
pwait->msg_type = msg_type;
+ pwait->req = req;
/* setup a timer */
te.next_event = end_time;
diff --git a/source4/ntvfs/posix/vfs_posix.c b/source4/ntvfs/posix/vfs_posix.c
index 6e6c8b4275..e989f8de67 100644
--- a/source4/ntvfs/posix/vfs_posix.c
+++ b/source4/ntvfs/posix/vfs_posix.c
@@ -237,6 +237,7 @@ NTSTATUS ntvfs_posix_init(void)
ops.search_close = pvfs_search_close;
ops.trans = pvfs_trans;
ops.logoff = pvfs_logoff;
+ ops.async_setup = pvfs_async_setup;
/* register ourselves with the NTVFS subsystem. We register
under the name 'default' as we wish to be the default