parent
9e2dda7694
commit
72e842d37b
@ -1,2 +1,2 @@
|
||||
SOURCES/samba-4.20.2.tar.xz
|
||||
SOURCES/samba-4.21.1.tar.xz
|
||||
SOURCES/samba-pubkey_AA99442FB680B620.gpg
|
||||
|
@ -1,2 +1,2 @@
|
||||
607bea15c2306b165610ebe3f617f1b29ef7f133 SOURCES/samba-4.20.2.tar.xz
|
||||
b27af807fb5a38f97492b114fca9678cb57886c3 SOURCES/samba-4.21.1.tar.xz
|
||||
971f563c447eda8d144d6c9e743cd0f0488c0d9e SOURCES/samba-pubkey_AA99442FB680B620.gpg
|
||||
|
@ -1,102 +0,0 @@
|
||||
From dddbbec2cb10b05a6ec3b4f1fcc877d60a44080a Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Pavel=20Filipensk=C3=BD?= <pfilipensky@samba.org>
|
||||
Date: Thu, 4 Jul 2024 11:08:03 +0200
|
||||
Subject: [PATCH 1/2] .gitlab-ci-main.yml: Add safe.directory '*'
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
This is to fix the error when pushing to personal gitlab repo:
|
||||
|
||||
2024-07-04 08:16:05,460 Running: 'git clone --recursive --shared /builds/pfilipen/samba /builds/samba-testbase/master' in '/builds/pfilipen/samba'
|
||||
Cloning into '/builds/samba-testbase/master'...
|
||||
fatal: detected dubious ownership in repository at '/builds/pfilipen/samba/.git'
|
||||
To add an exception for this directory, call:
|
||||
git config --global --add safe.directory /builds/pfilipen/samba/.git
|
||||
fatal: Could not read from remote repository.
|
||||
|
||||
Instead of adding more and more explicit repositories
|
||||
we should just allow any, we're in an isolated environment...
|
||||
|
||||
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15660
|
||||
|
||||
Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>
|
||||
Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
|
||||
Signed-off-by: Stefan Metzmacher <metze@samba.org>
|
||||
Reviewed-by: Andreas Schneider <asn@samba.org>
|
||||
|
||||
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
|
||||
Autobuild-Date(master): Wed Jul 10 10:35:00 UTC 2024 on atb-devel-224
|
||||
|
||||
(cherry picked from commit 3a21b7d9a4e7e9814d0be8c0ebf72b9821a5dc36)
|
||||
---
|
||||
.gitlab-ci-main.yml | 3 +--
|
||||
1 file changed, 1 insertion(+), 2 deletions(-)
|
||||
|
||||
diff --git a/.gitlab-ci-main.yml b/.gitlab-ci-main.yml
|
||||
index face2103327..08865ca2c42 100644
|
||||
--- a/.gitlab-ci-main.yml
|
||||
+++ b/.gitlab-ci-main.yml
|
||||
@@ -146,8 +146,7 @@ include:
|
||||
- ccache -z -M 500M
|
||||
- ccache -s
|
||||
# We are already running .gitlab-ci directives from this repo, remove additional checks that break our CI
|
||||
- - git config --global --add safe.directory `pwd`
|
||||
- - git config --global --add safe.directory /builds/samba-team/devel/samba/.git
|
||||
+ - git config --global --add safe.directory '*'
|
||||
after_script:
|
||||
- mount
|
||||
- df -h
|
||||
--
|
||||
2.45.2
|
||||
|
||||
|
||||
From 1c69964d34d2cf66532b23ffde76a839a65b0db2 Mon Sep 17 00:00:00 2001
|
||||
From: Andreas Schneider <asn@samba.org>
|
||||
Date: Fri, 12 Jul 2024 14:18:26 +0200
|
||||
Subject: [PATCH 2/2] s3:printing: Allow to run samba-bgqd as a standalone
|
||||
systemd service
|
||||
|
||||
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15683
|
||||
|
||||
Signed-off-by: Andreas Schneider <asn@samba.org>
|
||||
Reviewed-by: Alexander Bokovoy <ab@samba.org>
|
||||
(cherry picked from commit 0a532378322661b23b3393eb2ebde29402a16e62)
|
||||
|
||||
Autobuild-User(v4-20-test): Jule Anger <janger@samba.org>
|
||||
Autobuild-Date(v4-20-test): Tue Jul 23 08:56:24 UTC 2024 on atb-devel-224
|
||||
|
||||
(cherry picked from commit 4cf9af9186d7829f11bd07c7d6e526a51dcf0d61)
|
||||
---
|
||||
source3/printing/samba-bgqd.c | 8 +++++++-
|
||||
1 file changed, 7 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/source3/printing/samba-bgqd.c b/source3/printing/samba-bgqd.c
|
||||
index 59ed0cc40db..9560fcf9e35 100644
|
||||
--- a/source3/printing/samba-bgqd.c
|
||||
+++ b/source3/printing/samba-bgqd.c
|
||||
@@ -253,7 +253,9 @@ int main(int argc, const char *argv[])
|
||||
log_stdout = (debug_get_log_type() == DEBUG_STDOUT);
|
||||
|
||||
/* main process will notify systemd */
|
||||
- daemon_sd_notifications(false);
|
||||
+ if (ready_signal_fd != -1 || watch_fd != -1) {
|
||||
+ daemon_sd_notifications(false);
|
||||
+ }
|
||||
|
||||
if (!cmdline_daemon_cfg->fork) {
|
||||
daemon_status(progname, "Starting process ... ");
|
||||
@@ -325,6 +327,10 @@ int main(int argc, const char *argv[])
|
||||
goto done;
|
||||
}
|
||||
|
||||
+ if (!cmdline_daemon_cfg->fork) {
|
||||
+ daemon_ready(progname);
|
||||
+ }
|
||||
+
|
||||
if (ready_signal_fd != -1) {
|
||||
pid_t pid = getpid();
|
||||
ssize_t written;
|
||||
--
|
||||
2.45.2
|
||||
|
@ -0,0 +1,513 @@
|
||||
From 2d9ab68f501f5796bdf4662a058a2adff30d497e Mon Sep 17 00:00:00 2001
|
||||
From: Andreas Schneider <asn@samba.org>
|
||||
Date: Mon, 22 Jul 2024 12:26:55 +0200
|
||||
Subject: [PATCH] s3:notifyd: Use a watcher per db record
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
This fixes a O(n²) performance regression in notifyd. The problem was
|
||||
that we had a watcher per notify instance. This changes the code to have
|
||||
a watcher per notify db entry.
|
||||
|
||||
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14430
|
||||
|
||||
Signed-off-by: Andreas Schneider <asn@samba.org>
|
||||
Reviewed-by: Stefan Metzmacher <metze@samba.org>
|
||||
(cherry picked from commit af011b987a4ad0d3753d83cc0b8d97ad64ba874a)
|
||||
---
|
||||
source3/smbd/notifyd/notifyd.c | 214 ++++++++++++++++++-------
|
||||
source3/smbd/notifyd/notifyd_db.c | 5 +-
|
||||
source3/smbd/notifyd/notifyd_entry.c | 51 ++++--
|
||||
source3/smbd/notifyd/notifyd_private.h | 46 ++++--
|
||||
4 files changed, 228 insertions(+), 88 deletions(-)
|
||||
|
||||
diff --git a/source3/smbd/notifyd/notifyd.c b/source3/smbd/notifyd/notifyd.c
|
||||
index 64dd26a7e11..0b07ab3e435 100644
|
||||
--- a/source3/smbd/notifyd/notifyd.c
|
||||
+++ b/source3/smbd/notifyd/notifyd.c
|
||||
@@ -337,6 +337,7 @@ static bool notifyd_apply_rec_change(
|
||||
struct messaging_context *msg_ctx)
|
||||
{
|
||||
struct db_record *rec = NULL;
|
||||
+ struct notifyd_watcher watcher = {};
|
||||
struct notifyd_instance *instances = NULL;
|
||||
size_t num_instances;
|
||||
size_t i;
|
||||
@@ -344,6 +345,7 @@ static bool notifyd_apply_rec_change(
|
||||
TDB_DATA value;
|
||||
NTSTATUS status;
|
||||
bool ok = false;
|
||||
+ bool new_watcher = false;
|
||||
|
||||
if (pathlen == 0) {
|
||||
DBG_WARNING("pathlen==0\n");
|
||||
@@ -374,8 +376,12 @@ static bool notifyd_apply_rec_change(
|
||||
value = dbwrap_record_get_value(rec);
|
||||
|
||||
if (value.dsize != 0) {
|
||||
- if (!notifyd_parse_entry(value.dptr, value.dsize, NULL,
|
||||
- &num_instances)) {
|
||||
+ ok = notifyd_parse_entry(value.dptr,
|
||||
+ value.dsize,
|
||||
+ &watcher,
|
||||
+ NULL,
|
||||
+ &num_instances);
|
||||
+ if (!ok) {
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
@@ -390,8 +396,22 @@ static bool notifyd_apply_rec_change(
|
||||
goto fail;
|
||||
}
|
||||
|
||||
- if (value.dsize != 0) {
|
||||
- memcpy(instances, value.dptr, value.dsize);
|
||||
+ if (num_instances > 0) {
|
||||
+ struct notifyd_instance *tmp = NULL;
|
||||
+ size_t num_tmp = 0;
|
||||
+
|
||||
+ ok = notifyd_parse_entry(value.dptr,
|
||||
+ value.dsize,
|
||||
+ NULL,
|
||||
+ &tmp,
|
||||
+ &num_tmp);
|
||||
+ if (!ok) {
|
||||
+ goto fail;
|
||||
+ }
|
||||
+
|
||||
+ memcpy(instances,
|
||||
+ tmp,
|
||||
+ sizeof(struct notifyd_instance) * num_tmp);
|
||||
}
|
||||
|
||||
for (i=0; i<num_instances; i++) {
|
||||
@@ -414,41 +434,106 @@ static bool notifyd_apply_rec_change(
|
||||
*instance = (struct notifyd_instance) {
|
||||
.client = *client,
|
||||
.instance = *chg,
|
||||
- .internal_filter = chg->filter,
|
||||
- .internal_subdir_filter = chg->subdir_filter
|
||||
};
|
||||
|
||||
num_instances += 1;
|
||||
}
|
||||
|
||||
- if ((instance->instance.filter != 0) ||
|
||||
- (instance->instance.subdir_filter != 0)) {
|
||||
- int ret;
|
||||
+ /*
|
||||
+ * Calculate an intersection of the instances filters for the watcher.
|
||||
+ */
|
||||
+ if (instance->instance.filter > 0) {
|
||||
+ uint32_t filter = instance->instance.filter;
|
||||
+
|
||||
+ if ((watcher.filter & filter) != filter) {
|
||||
+ watcher.filter |= filter;
|
||||
+
|
||||
+ new_watcher = true;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /*
|
||||
+ * Calculate an intersection of the instances subdir_filters for the
|
||||
+ * watcher.
|
||||
+ */
|
||||
+ if (instance->instance.subdir_filter > 0) {
|
||||
+ uint32_t subdir_filter = instance->instance.subdir_filter;
|
||||
|
||||
- TALLOC_FREE(instance->sys_watch);
|
||||
+ if ((watcher.subdir_filter & subdir_filter) != subdir_filter) {
|
||||
+ watcher.subdir_filter |= subdir_filter;
|
||||
|
||||
- ret = sys_notify_watch(entries, sys_notify_ctx, path,
|
||||
- &instance->internal_filter,
|
||||
- &instance->internal_subdir_filter,
|
||||
- notifyd_sys_callback, msg_ctx,
|
||||
- &instance->sys_watch);
|
||||
- if (ret != 0) {
|
||||
- DBG_WARNING("sys_notify_watch for [%s] returned %s\n",
|
||||
- path, strerror(errno));
|
||||
+ new_watcher = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ((instance->instance.filter == 0) &&
|
||||
(instance->instance.subdir_filter == 0)) {
|
||||
+ uint32_t tmp_filter = 0;
|
||||
+ uint32_t tmp_subdir_filter = 0;
|
||||
+
|
||||
/* This is a delete request */
|
||||
- TALLOC_FREE(instance->sys_watch);
|
||||
*instance = instances[num_instances-1];
|
||||
num_instances -= 1;
|
||||
+
|
||||
+ for (i = 0; i < num_instances; i++) {
|
||||
+ struct notifyd_instance *tmp = &instances[i];
|
||||
+
|
||||
+ tmp_filter |= tmp->instance.filter;
|
||||
+ tmp_subdir_filter |= tmp->instance.subdir_filter;
|
||||
+ }
|
||||
+
|
||||
+ /*
|
||||
+ * If the filter has changed, register a new watcher with the
|
||||
+ * changed filter.
|
||||
+ */
|
||||
+ if (watcher.filter != tmp_filter ||
|
||||
+ watcher.subdir_filter != tmp_subdir_filter)
|
||||
+ {
|
||||
+ watcher.filter = tmp_filter;
|
||||
+ watcher.subdir_filter = tmp_subdir_filter;
|
||||
+
|
||||
+ new_watcher = true;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (new_watcher) {
|
||||
+ /*
|
||||
+ * In case we removed all notify instances, we want to remove
|
||||
+ * the watcher. We won't register a new one, if no filters are
|
||||
+ * set anymore.
|
||||
+ */
|
||||
+
|
||||
+ TALLOC_FREE(watcher.sys_watch);
|
||||
+
|
||||
+ watcher.sys_filter = watcher.filter;
|
||||
+ watcher.sys_subdir_filter = watcher.subdir_filter;
|
||||
+
|
||||
+ /*
|
||||
+ * Only register a watcher if we have filter.
|
||||
+ */
|
||||
+ if (watcher.filter != 0 || watcher.subdir_filter != 0) {
|
||||
+ int ret = sys_notify_watch(entries,
|
||||
+ sys_notify_ctx,
|
||||
+ path,
|
||||
+ &watcher.sys_filter,
|
||||
+ &watcher.sys_subdir_filter,
|
||||
+ notifyd_sys_callback,
|
||||
+ msg_ctx,
|
||||
+ &watcher.sys_watch);
|
||||
+ if (ret != 0) {
|
||||
+ DBG_WARNING("sys_notify_watch for [%s] "
|
||||
+ "returned %s\n",
|
||||
+ path,
|
||||
+ strerror(errno));
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
|
||||
DBG_DEBUG("%s has %zu instances\n", path, num_instances);
|
||||
|
||||
if (num_instances == 0) {
|
||||
+ TALLOC_FREE(watcher.sys_watch);
|
||||
+
|
||||
status = dbwrap_record_delete(rec);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
DBG_WARNING("dbwrap_record_delete returned %s\n",
|
||||
@@ -456,13 +541,21 @@ static bool notifyd_apply_rec_change(
|
||||
goto fail;
|
||||
}
|
||||
} else {
|
||||
- value = make_tdb_data(
|
||||
- (uint8_t *)instances,
|
||||
- sizeof(struct notifyd_instance) * num_instances);
|
||||
+ struct TDB_DATA iov[2] = {
|
||||
+ {
|
||||
+ .dptr = (uint8_t *)&watcher,
|
||||
+ .dsize = sizeof(struct notifyd_watcher),
|
||||
+ },
|
||||
+ {
|
||||
+ .dptr = (uint8_t *)instances,
|
||||
+ .dsize = sizeof(struct notifyd_instance) *
|
||||
+ num_instances,
|
||||
+ },
|
||||
+ };
|
||||
|
||||
- status = dbwrap_record_store(rec, value, 0);
|
||||
+ status = dbwrap_record_storev(rec, iov, ARRAY_SIZE(iov), 0);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
- DBG_WARNING("dbwrap_record_store returned %s\n",
|
||||
+ DBG_WARNING("dbwrap_record_storev returned %s\n",
|
||||
nt_errstr(status));
|
||||
goto fail;
|
||||
}
|
||||
@@ -706,12 +799,18 @@ static void notifyd_trigger_parser(TDB_DATA key, TDB_DATA data,
|
||||
.when = tstate->msg->when };
|
||||
struct iovec iov[2];
|
||||
size_t path_len = key.dsize;
|
||||
+ struct notifyd_watcher watcher = {};
|
||||
struct notifyd_instance *instances = NULL;
|
||||
size_t num_instances = 0;
|
||||
size_t i;
|
||||
+ bool ok;
|
||||
|
||||
- if (!notifyd_parse_entry(data.dptr, data.dsize, &instances,
|
||||
- &num_instances)) {
|
||||
+ ok = notifyd_parse_entry(data.dptr,
|
||||
+ data.dsize,
|
||||
+ &watcher,
|
||||
+ &instances,
|
||||
+ &num_instances);
|
||||
+ if (!ok) {
|
||||
DBG_DEBUG("Could not parse notifyd_entry\n");
|
||||
return;
|
||||
}
|
||||
@@ -734,9 +833,11 @@ static void notifyd_trigger_parser(TDB_DATA key, TDB_DATA data,
|
||||
|
||||
if (tstate->covered_by_sys_notify) {
|
||||
if (tstate->recursive) {
|
||||
- i_filter = instance->internal_subdir_filter;
|
||||
+ i_filter = watcher.sys_subdir_filter &
|
||||
+ instance->instance.subdir_filter;
|
||||
} else {
|
||||
- i_filter = instance->internal_filter;
|
||||
+ i_filter = watcher.sys_filter &
|
||||
+ instance->instance.filter;
|
||||
}
|
||||
} else {
|
||||
if (tstate->recursive) {
|
||||
@@ -1146,46 +1247,39 @@ static int notifyd_add_proxy_syswatches(struct db_record *rec,
|
||||
struct db_context *db = dbwrap_record_get_db(rec);
|
||||
TDB_DATA key = dbwrap_record_get_key(rec);
|
||||
TDB_DATA value = dbwrap_record_get_value(rec);
|
||||
- struct notifyd_instance *instances = NULL;
|
||||
- size_t num_instances = 0;
|
||||
- size_t i;
|
||||
+ struct notifyd_watcher watcher = {};
|
||||
char path[key.dsize+1];
|
||||
bool ok;
|
||||
+ int ret;
|
||||
|
||||
memcpy(path, key.dptr, key.dsize);
|
||||
path[key.dsize] = '\0';
|
||||
|
||||
- ok = notifyd_parse_entry(value.dptr, value.dsize, &instances,
|
||||
- &num_instances);
|
||||
+ /* This is a remote database, we just need the watcher. */
|
||||
+ ok = notifyd_parse_entry(value.dptr, value.dsize, &watcher, NULL, NULL);
|
||||
if (!ok) {
|
||||
DBG_WARNING("Could not parse notifyd entry for %s\n", path);
|
||||
return 0;
|
||||
}
|
||||
|
||||
- for (i=0; i<num_instances; i++) {
|
||||
- struct notifyd_instance *instance = &instances[i];
|
||||
- uint32_t filter = instance->instance.filter;
|
||||
- uint32_t subdir_filter = instance->instance.subdir_filter;
|
||||
- int ret;
|
||||
+ watcher.sys_watch = NULL;
|
||||
+ watcher.sys_filter = watcher.filter;
|
||||
+ watcher.sys_subdir_filter = watcher.subdir_filter;
|
||||
|
||||
- /*
|
||||
- * This is a remote database. Pointers that we were
|
||||
- * given don't make sense locally. Initialize to NULL
|
||||
- * in case sys_notify_watch fails.
|
||||
- */
|
||||
- instances[i].sys_watch = NULL;
|
||||
-
|
||||
- ret = state->sys_notify_watch(
|
||||
- db, state->sys_notify_ctx, path,
|
||||
- &filter, &subdir_filter,
|
||||
- notifyd_sys_callback, state->msg_ctx,
|
||||
- &instance->sys_watch);
|
||||
- if (ret != 0) {
|
||||
- DBG_WARNING("inotify_watch returned %s\n",
|
||||
- strerror(errno));
|
||||
- }
|
||||
+ ret = state->sys_notify_watch(db,
|
||||
+ state->sys_notify_ctx,
|
||||
+ path,
|
||||
+ &watcher.filter,
|
||||
+ &watcher.subdir_filter,
|
||||
+ notifyd_sys_callback,
|
||||
+ state->msg_ctx,
|
||||
+ &watcher.sys_watch);
|
||||
+ if (ret != 0) {
|
||||
+ DBG_WARNING("inotify_watch returned %s\n", strerror(errno));
|
||||
}
|
||||
|
||||
+ memcpy(value.dptr, &watcher, sizeof(struct notifyd_watcher));
|
||||
+
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1193,21 +1287,17 @@ static int notifyd_db_del_syswatches(struct db_record *rec, void *private_data)
|
||||
{
|
||||
TDB_DATA key = dbwrap_record_get_key(rec);
|
||||
TDB_DATA value = dbwrap_record_get_value(rec);
|
||||
- struct notifyd_instance *instances = NULL;
|
||||
- size_t num_instances = 0;
|
||||
- size_t i;
|
||||
+ struct notifyd_watcher watcher = {};
|
||||
bool ok;
|
||||
|
||||
- ok = notifyd_parse_entry(value.dptr, value.dsize, &instances,
|
||||
- &num_instances);
|
||||
+ ok = notifyd_parse_entry(value.dptr, value.dsize, &watcher, NULL, NULL);
|
||||
if (!ok) {
|
||||
DBG_WARNING("Could not parse notifyd entry for %.*s\n",
|
||||
(int)key.dsize, (char *)key.dptr);
|
||||
return 0;
|
||||
}
|
||||
- for (i=0; i<num_instances; i++) {
|
||||
- TALLOC_FREE(instances[i].sys_watch);
|
||||
- }
|
||||
+ TALLOC_FREE(watcher.sys_watch);
|
||||
+
|
||||
return 0;
|
||||
}
|
||||
|
||||
diff --git a/source3/smbd/notifyd/notifyd_db.c b/source3/smbd/notifyd/notifyd_db.c
|
||||
index 18228619e9a..7dc3cd58081 100644
|
||||
--- a/source3/smbd/notifyd/notifyd_db.c
|
||||
+++ b/source3/smbd/notifyd/notifyd_db.c
|
||||
@@ -40,7 +40,10 @@ static bool notifyd_parse_db_parser(TDB_DATA key, TDB_DATA value,
|
||||
memcpy(path, key.dptr, key.dsize);
|
||||
path[key.dsize] = 0;
|
||||
|
||||
- ok = notifyd_parse_entry(value.dptr, value.dsize, &instances,
|
||||
+ ok = notifyd_parse_entry(value.dptr,
|
||||
+ value.dsize,
|
||||
+ NULL,
|
||||
+ &instances,
|
||||
&num_instances);
|
||||
if (!ok) {
|
||||
DBG_DEBUG("Could not parse entry for path %s\n", path);
|
||||
diff --git a/source3/smbd/notifyd/notifyd_entry.c b/source3/smbd/notifyd/notifyd_entry.c
|
||||
index 539010de03a..f3b0e908136 100644
|
||||
--- a/source3/smbd/notifyd/notifyd_entry.c
|
||||
+++ b/source3/smbd/notifyd/notifyd_entry.c
|
||||
@@ -21,22 +21,51 @@
|
||||
* Parse an entry in the notifyd_context->entries database
|
||||
*/
|
||||
|
||||
-bool notifyd_parse_entry(
|
||||
- uint8_t *buf,
|
||||
- size_t buflen,
|
||||
- struct notifyd_instance **instances,
|
||||
- size_t *num_instances)
|
||||
+/**
|
||||
+ * @brief Parse a notifyd database entry.
|
||||
+ *
|
||||
+ * The memory we pass down needs to be aligned. If it isn't aligned we can run
|
||||
+ * into obscure errors as we just point into the data buffer.
|
||||
+ *
|
||||
+ * @param data The data to parse
|
||||
+ * @param data_len The length of the data to parse
|
||||
+ * @param watcher A pointer to store the watcher data or NULL.
|
||||
+ * @param instances A pointer to store the array of notify instances or NULL.
|
||||
+ * @param pnum_instances The number of elements in the array. If you just want
|
||||
+ * the number of elements pass NULL for the watcher and instances pointers.
|
||||
+ *
|
||||
+ * @return true on success, false if an error occurred.
|
||||
+ */
|
||||
+bool notifyd_parse_entry(uint8_t *data,
|
||||
+ size_t data_len,
|
||||
+ struct notifyd_watcher *watcher,
|
||||
+ struct notifyd_instance **instances,
|
||||
+ size_t *pnum_instances)
|
||||
{
|
||||
- if ((buflen % sizeof(struct notifyd_instance)) != 0) {
|
||||
- DBG_WARNING("invalid buffer size: %zu\n", buflen);
|
||||
+ size_t ilen;
|
||||
+
|
||||
+ if (data_len < sizeof(struct notifyd_watcher)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
- if (instances != NULL) {
|
||||
- *instances = (struct notifyd_instance *)buf;
|
||||
+ if (watcher != NULL) {
|
||||
+ *watcher = *((struct notifyd_watcher *)(uintptr_t)data);
|
||||
}
|
||||
- if (num_instances != NULL) {
|
||||
- *num_instances = buflen / sizeof(struct notifyd_instance);
|
||||
+
|
||||
+ ilen = data_len - sizeof(struct notifyd_watcher);
|
||||
+ if ((ilen % sizeof(struct notifyd_instance)) != 0) {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ if (pnum_instances != NULL) {
|
||||
+ *pnum_instances = ilen / sizeof(struct notifyd_instance);
|
||||
}
|
||||
+ if (instances != NULL) {
|
||||
+ /* The (uintptr_t) cast removes a warning from -Wcast-align. */
|
||||
+ *instances =
|
||||
+ (struct notifyd_instance *)(uintptr_t)
|
||||
+ (data + sizeof(struct notifyd_watcher));
|
||||
+ }
|
||||
+
|
||||
return true;
|
||||
}
|
||||
diff --git a/source3/smbd/notifyd/notifyd_private.h b/source3/smbd/notifyd/notifyd_private.h
|
||||
index 36c08f47c54..db8e6e1c005 100644
|
||||
--- a/source3/smbd/notifyd/notifyd_private.h
|
||||
+++ b/source3/smbd/notifyd/notifyd_private.h
|
||||
@@ -20,30 +20,48 @@
|
||||
#include "lib/util/server_id.h"
|
||||
#include "notifyd.h"
|
||||
|
||||
+
|
||||
/*
|
||||
- * notifyd's representation of a notify instance
|
||||
+ * Representation of a watcher for a path
|
||||
+ *
|
||||
+ * This will be stored in the db.
|
||||
*/
|
||||
-struct notifyd_instance {
|
||||
- struct server_id client;
|
||||
- struct notify_instance instance;
|
||||
-
|
||||
- void *sys_watch; /* inotify/fam/etc handle */
|
||||
+struct notifyd_watcher {
|
||||
+ /*
|
||||
+ * This is an intersections of the filter the watcher is listening for.
|
||||
+ */
|
||||
+ uint32_t filter;
|
||||
+ uint32_t subdir_filter;
|
||||
|
||||
/*
|
||||
- * Filters after sys_watch took responsibility of some bits
|
||||
+ * Those are inout variables passed to the sys_watcher. The sys_watcher
|
||||
+ * will remove the bits it can't handle.
|
||||
*/
|
||||
- uint32_t internal_filter;
|
||||
- uint32_t internal_subdir_filter;
|
||||
+ uint32_t sys_filter;
|
||||
+ uint32_t sys_subdir_filter;
|
||||
+
|
||||
+ /* The handle for inotify/fam etc. */
|
||||
+ void *sys_watch;
|
||||
+};
|
||||
+
|
||||
+/*
|
||||
+ * Representation of a notifyd instance
|
||||
+ *
|
||||
+ * This will be stored in the db.
|
||||
+ */
|
||||
+struct notifyd_instance {
|
||||
+ struct server_id client;
|
||||
+ struct notify_instance instance;
|
||||
};
|
||||
|
||||
/*
|
||||
* Parse an entry in the notifyd_context->entries database
|
||||
*/
|
||||
|
||||
-bool notifyd_parse_entry(
|
||||
- uint8_t *buf,
|
||||
- size_t buflen,
|
||||
- struct notifyd_instance **instances,
|
||||
- size_t *num_instances);
|
||||
+bool notifyd_parse_entry(uint8_t *data,
|
||||
+ size_t data_len,
|
||||
+ struct notifyd_watcher *watcher,
|
||||
+ struct notifyd_instance **instances,
|
||||
+ size_t *num_instances);
|
||||
|
||||
#endif
|
||||
--
|
||||
2.46.1
|
||||
|
@ -1,16 +0,0 @@
|
||||
-----BEGIN PGP SIGNATURE-----
|
||||
|
||||
iQIzBAABCgAdFiEEgfXigyvSVFoYl7cTqplEL7aAtiAFAmZy684ACgkQqplEL7aA
|
||||
tiDXDw/+KleJ11LLq5ZlXMlj11niRCETErY8cuoZ9VX04lfRwRBnplpKKLSQuFit
|
||||
5HeY5ED65DhbpGzPfLPx7xOw4wyFc/bXhHPTgF3Ybj8TKkEcaMmkpD3V8FPa4NAt
|
||||
vNZ3alLQLP//kgRXnqeV9pfa4slx17G6WeBLbpd8b4SbgPMgokJt7hL3nWfBrFE9
|
||||
p6B+TKZcwfoCn9ufz1UxMpBFtpSK0yF0S7CQcdv3JrBNIYhULuXbnAnLCHcH1RqW
|
||||
xreoxZPnMx+SrYb0iHyKbkMsDujCqBKm9CyS13Yt9DjI49lv0pBwQFnaqtR4Xm/D
|
||||
BU2XIWLLInUecxtUOBtsa046h55fLQPgkb+WYob++iA9r91y4JAZIiAxdVrNLsxR
|
||||
BiFUxkL7EPtyptT84xNjpQ3CTZuw8tlHu/sJ1/XHRUFMtRGjiMqJp7ULsVQDfwET
|
||||
7T+HHrVHNstddb9A6WfM8qSItoMfGUlYyzTQ2d3OmrbGRnB0qf+zg9DI+vXv5Itx
|
||||
M23we8ljSadCnc/kqz3Z6gefI538WWDnbXIljRqDxuzwaSXhMd4heG+xIAAO0Of5
|
||||
ziyCVQ/n8gnyXQmC82Xlebc3mYki8UoyYWdbVNJZAOEo/LuBql1OkjOhkhMcBDmr
|
||||
qvD6f+0+MA4nydmVhI/q/pmo7nAUD3SAxmRKrVTwjpjcAnZ4IGw=
|
||||
=CGiK
|
||||
-----END PGP SIGNATURE-----
|
@ -0,0 +1,16 @@
|
||||
-----BEGIN PGP SIGNATURE-----
|
||||
|
||||
iQIzBAABCgAdFiEEgfXigyvSVFoYl7cTqplEL7aAtiAFAmcNARQACgkQqplEL7aA
|
||||
tiCgHw//Z+S3Q+bGXNSgAa7NfsYLOSuqMBir19xXTo1dXwefW7TtQCEDIy38+kpS
|
||||
zSvzViDyOqfObK7Jt5RDDybulHZQiMTGI9hL6TbpNBReMdPQO46YCDbP/j4RaiIp
|
||||
Gg5i4uxrYjrygMjW3nvlJPGLPt23bR3xsJzbF4k/sxcLdyJX1Ky9hgXy1qboL6cn
|
||||
NF2Oi+fwn3OI9hBFBKV9F3PlnyJyDkf6co9B4Y/ItlrD6APjB2bapjJJT+1RNpLa
|
||||
k2C26Sl0qTJmqbCm2Ckqb2+1Wnm5F5aUXxyCyJKVTT+NOvxOKE+9WrPVIHxNcN4O
|
||||
Cri/kGcabmPNFyvgTJld+17eBPeX+bwlQwtk2Fefca0COFYr+dTNnX/a6Zq7+F1H
|
||||
km3VBCEvHH01ABV0oau8NKGMHxT07FOijUz9qsolH8K00HYb25jHkGP75YE6NaGw
|
||||
EB45n84eoX2kyrcnYbX9D8Y6+zr0EZNvL8OCtsGgPmUxwfT3EOTs5nPSfc9/3bmR
|
||||
BOJqwjlJxEkwACwBwqslZn1dUExVEFzn8OMoFxR0K6lxeK9tXdmbpAacF11PvJQ1
|
||||
9hoSkkBiRGY56cpIBWTyf+0Dcg16RhD2X5MOUAJkFjYQCnQkiaiOoZukvYcZscyG
|
||||
If+qc4PK4Q3wJL2ryiBRuGfqjyNfqIOXgyIaNjdrXT+r2gdeTn8=
|
||||
=b4qd
|
||||
-----END PGP SIGNATURE-----
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue