summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/include/proto.h12
-rw-r--r--source3/smbd/notify.c34
-rw-r--r--source3/smbd/nttrans.c13
3 files changed, 42 insertions, 17 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 05ef6fe00d..2b290116e4 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -6467,15 +6467,21 @@ void reply_negprot(struct smb_request *req);
void change_notify_reply(connection_struct *conn,
struct smb_request *req,
- NTSTATUS status,
+ NTSTATUS error_code,
uint32_t max_param,
- struct notify_change_buf *notify_buf);
+ struct notify_change_buf *notify_buf,
+ void (*reply_fn)(struct smb_request *req,
+ NTSTATUS error_code,
+ uint8_t *buf, size_t len));
NTSTATUS change_notify_create(struct files_struct *fsp, uint32 filter,
bool recursive);
NTSTATUS change_notify_add_request(struct smb_request *req,
uint32 max_param,
uint32 filter, bool recursive,
- struct files_struct *fsp);
+ struct files_struct *fsp,
+ void (*reply_fn)(struct smb_request *req,
+ NTSTATUS error_code,
+ uint8_t *buf, size_t len));
void remove_pending_change_notify_requests_by_mid(uint16 mid);
void remove_pending_change_notify_requests_by_fid(files_struct *fsp,
NTSTATUS status);
diff --git a/source3/smbd/notify.c b/source3/smbd/notify.c
index bf5846641c..ded888c021 100644
--- a/source3/smbd/notify.c
+++ b/source3/smbd/notify.c
@@ -28,6 +28,9 @@ struct notify_change_request {
struct smb_request *req;
uint32 filter;
uint32 max_param;
+ void (*reply_fn)(struct smb_request *req,
+ NTSTATUS error_code,
+ uint8_t *buf, size_t len);
struct notify_mid_map *mid_map;
void *backend_data;
};
@@ -139,19 +142,20 @@ void change_notify_reply(connection_struct *conn,
struct smb_request *req,
NTSTATUS error_code,
uint32_t max_param,
- struct notify_change_buf *notify_buf)
+ struct notify_change_buf *notify_buf,
+ void (*reply_fn)(struct smb_request *req,
+ NTSTATUS error_code,
+ uint8_t *buf, size_t len))
{
prs_struct ps;
if (!NT_STATUS_IS_OK(error_code)) {
- send_nt_replies(conn, req, error_code,
- NULL, 0, NULL, 0);
+ reply_fn(req, error_code, NULL, 0);
return;
}
if (max_param == 0 || notify_buf == NULL) {
- send_nt_replies(conn, req, NT_STATUS_OK,
- NULL, 0, NULL, 0);
+ reply_fn(req, NT_STATUS_OK, NULL, 0);
return;
}
@@ -167,8 +171,7 @@ void change_notify_reply(connection_struct *conn,
prs_init_empty(&ps, NULL, MARSHALL);
}
- send_nt_replies(conn, req, NT_STATUS_OK, prs_data_p(&ps),
- prs_offset(&ps), NULL, 0);
+ reply_fn(req, NT_STATUS_OK, (uint8_t *)prs_data_p(&ps), prs_offset(&ps));
prs_mem_free(&ps);
@@ -223,7 +226,10 @@ NTSTATUS change_notify_create(struct files_struct *fsp, uint32 filter,
NTSTATUS change_notify_add_request(struct smb_request *req,
uint32 max_param,
uint32 filter, bool recursive,
- struct files_struct *fsp)
+ struct files_struct *fsp,
+ void (*reply_fn)(struct smb_request *req,
+ NTSTATUS error_code,
+ uint8_t *buf, size_t len))
{
struct notify_change_request *request = NULL;
struct notify_mid_map *map = NULL;
@@ -245,6 +251,7 @@ NTSTATUS change_notify_add_request(struct smb_request *req,
request->max_param = max_param;
request->filter = filter;
request->fsp = fsp;
+ request->reply_fn = reply_fn;
request->backend_data = NULL;
DLIST_ADD_END(fsp->notify->requests, request,
@@ -305,7 +312,7 @@ void remove_pending_change_notify_requests_by_mid(uint16 mid)
}
change_notify_reply(map->req->fsp->conn, map->req->req,
- NT_STATUS_CANCELLED, 0, NULL);
+ NT_STATUS_CANCELLED, 0, NULL, map->req->reply_fn);
change_notify_remove_request(map->req);
}
@@ -322,7 +329,8 @@ void remove_pending_change_notify_requests_by_fid(files_struct *fsp,
while (fsp->notify->requests != NULL) {
change_notify_reply(fsp->conn, fsp->notify->requests->req,
- status, 0, NULL);
+ status, 0, NULL,
+ fsp->notify->requests->reply_fn);
change_notify_remove_request(fsp->notify->requests);
}
}
@@ -396,7 +404,8 @@ static void notify_fsp(files_struct *fsp, uint32 action, const char *name)
fsp->notify->requests->req,
NT_STATUS_OK,
fsp->notify->requests->max_param,
- fsp->notify);
+ fsp->notify,
+ fsp->notify->requests->reply_fn);
change_notify_remove_request(fsp->notify->requests);
}
return;
@@ -456,7 +465,8 @@ static void notify_fsp(files_struct *fsp, uint32 action, const char *name)
fsp->notify->requests->req,
NT_STATUS_OK,
fsp->notify->requests->max_param,
- fsp->notify);
+ fsp->notify,
+ fsp->notify->requests->reply_fn);
change_notify_remove_request(fsp->notify->requests);
}
diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c
index 9cd35d5ebb..c65cbf851b 100644
--- a/source3/smbd/nttrans.c
+++ b/source3/smbd/nttrans.c
@@ -1517,6 +1517,13 @@ void reply_ntrename(struct smb_request *req)
don't allow a directory to be opened.
****************************************************************************/
+static void smbd_smb1_notify_reply(struct smb_request *req,
+ NTSTATUS error_code,
+ uint8_t *buf, size_t len)
+{
+ send_nt_replies(req->conn, req, error_code, (char *)buf, len, NULL, 0);
+}
+
static void call_nt_transact_notify_change(connection_struct *conn,
struct smb_request *req,
uint16 **ppsetup,
@@ -1595,7 +1602,8 @@ static void call_nt_transact_notify_change(connection_struct *conn,
change_notify_reply(fsp->conn, req,
NT_STATUS_OK,
max_param_count,
- fsp->notify);
+ fsp->notify,
+ smbd_smb1_notify_reply);
/*
* change_notify_reply() above has independently sent its
@@ -1611,7 +1619,8 @@ static void call_nt_transact_notify_change(connection_struct *conn,
status = change_notify_add_request(req,
max_param_count,
filter,
- recursive, fsp);
+ recursive, fsp,
+ smbd_smb1_notify_reply);
if (!NT_STATUS_IS_OK(status)) {
reply_nterror(req, status);
}