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
- the Free Software Foundation; either version 2 of the License, or
+ the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
#include "includes.h"
#include "system/filesys.h"
-#include "lib/tdb/include/tdb.h"
+#include "../tdb/include/tdb.h"
#include "lib/util/util_tdb.h"
#include "messaging/messaging.h"
-#include "db_wrap.h"
+#include "tdb_wrap.h"
#include "lib/messaging/irpc.h"
#include "librpc/gen_ndr/ndr_notify.h"
#include "lib/util/dlinklist.h"
#include "ntvfs/common/ntvfs_common.h"
#include "ntvfs/sysdep/sys_notify.h"
#include "cluster/cluster.h"
+#include "param/param.h"
struct notify_context {
struct tdb_wrap *w;
struct notify_array *array;
int seqnum;
struct sys_notify_context *sys_notify_ctx;
+ struct smb_iconv_convenience *iconv_convenience;
};
struct notify_list {
struct notify_list *next, *prev;
- void *private;
+ void *private_data;
void (*callback)(void *, const struct notify_event *);
void *sys_notify_handle;
int depth;
#define NOTIFY_KEY "notify array"
#define NOTIFY_ENABLE "notify:enable"
-#define NOTIFY_ENABLE_DEFAULT True
+#define NOTIFY_ENABLE_DEFAULT true
static NTSTATUS notify_remove_all(struct notify_context *notify);
-static void notify_handler(struct messaging_context *msg_ctx, void *private,
+static void notify_handler(struct messaging_context *msg_ctx, void *private_data,
uint32_t msg_type, struct server_id server_id, DATA_BLOB *data);
/*
*/
struct notify_context *notify_init(TALLOC_CTX *mem_ctx, struct server_id server,
struct messaging_context *messaging_ctx,
+ struct loadparm_context *lp_ctx,
struct event_context *ev,
struct share_config *scfg)
{
- char *path;
struct notify_context *notify;
- if (share_bool_option(scfg, NOTIFY_ENABLE, NOTIFY_ENABLE_DEFAULT) != True) {
+ if (share_bool_option(scfg, NOTIFY_ENABLE, NOTIFY_ENABLE_DEFAULT) != true) {
+ return NULL;
+ }
+
+ if (ev == NULL) {
return NULL;
}
return NULL;
}
- path = smbd_tmp_path(notify, "notify.tdb");
- notify->w = tdb_wrap_open(notify, path, 0,
- TDB_SEQNUM,
- O_RDWR|O_CREAT, 0600);
- talloc_free(path);
+ notify->w = cluster_tdb_tmp_open(notify, lp_ctx, "notify.tdb", TDB_SEQNUM);
if (notify->w == NULL) {
talloc_free(notify);
return NULL;
notify->messaging_ctx = messaging_ctx;
notify->list = NULL;
notify->array = NULL;
+ notify->iconv_convenience = lp_iconv_convenience(lp_ctx);
notify->seqnum = tdb_get_seqnum(notify->w->tdb);
talloc_set_destructor(notify, notify_destructor);
{
TDB_DATA dbuf;
DATA_BLOB blob;
- NTSTATUS status;
+ enum ndr_err_code ndr_err;
int seqnum;
seqnum = tdb_get_seqnum(notify->w->tdb);
blob.data = dbuf.dptr;
blob.length = dbuf.dsize;
- status = ndr_pull_struct_blob(&blob, notify->array, notify->array,
- (ndr_pull_flags_fn_t)ndr_pull_notify_array);
+ ndr_err = ndr_pull_struct_blob(&blob, notify->array, notify->iconv_convenience,
+ notify->array,
+ (ndr_pull_flags_fn_t)ndr_pull_notify_array);
free(dbuf.dptr);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ return ndr_map_error2ntstatus(ndr_err);
+ }
- return status;
+ return NT_STATUS_OK;
}
/*
{
TDB_DATA dbuf;
DATA_BLOB blob;
- NTSTATUS status;
+ enum ndr_err_code ndr_err;
int ret;
TALLOC_CTX *tmp_ctx;
}
tmp_ctx = talloc_new(notify);
+ NT_STATUS_HAVE_NO_MEMORY(tmp_ctx);
- status = ndr_push_struct_blob(&blob, tmp_ctx, notify->array,
- (ndr_push_flags_fn_t)ndr_push_notify_array);
- if (!NT_STATUS_IS_OK(status)) {
+ ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, notify->iconv_convenience, notify->array,
+ (ndr_push_flags_fn_t)ndr_push_notify_array);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
talloc_free(tmp_ctx);
- return status;
+ return ndr_map_error2ntstatus(ndr_err);
}
dbuf.dptr = blob.data;
/*
handle incoming notify messages
*/
-static void notify_handler(struct messaging_context *msg_ctx, void *private,
+static void notify_handler(struct messaging_context *msg_ctx, void *private_data,
uint32_t msg_type, struct server_id server_id, DATA_BLOB *data)
{
- struct notify_context *notify = talloc_get_type(private, struct notify_context);
- NTSTATUS status;
+ struct notify_context *notify = talloc_get_type(private_data, struct notify_context);
+ enum ndr_err_code ndr_err;
struct notify_event ev;
TALLOC_CTX *tmp_ctx = talloc_new(notify);
struct notify_list *listel;
- status = ndr_pull_struct_blob(data, tmp_ctx, &ev,
+ if (tmp_ctx == NULL) {
+ return;
+ }
+
+ ndr_err = ndr_pull_struct_blob(data, tmp_ctx, notify->iconv_convenience, &ev,
(ndr_pull_flags_fn_t)ndr_pull_notify_event);
- if (!NT_STATUS_IS_OK(status)) {
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
talloc_free(tmp_ctx);
return;
}
for (listel=notify->list;listel;listel=listel->next) {
- if (listel->private == ev.private) {
- listel->callback(listel->private, &ev);
+ if (listel->private_data == ev.private_data) {
+ listel->callback(listel->private_data, &ev);
break;
}
}
void *ptr, struct notify_event *ev)
{
struct notify_list *listel = talloc_get_type(ptr, struct notify_list);
- ev->private = listel;
- listel->callback(listel->private, ev);
+ ev->private_data = listel;
+ listel->callback(listel->private_data, ev);
}
/*
add an entry to the notify array
*/
static NTSTATUS notify_add_array(struct notify_context *notify, struct notify_entry *e,
- void *private, int depth)
+ void *private_data, int depth)
{
int i;
struct notify_depth *d;
d->entries = ee;
d->entries[d->num_entries] = *e;
- d->entries[d->num_entries].private = private;
+ d->entries[d->num_entries].private_data = private_data;
d->entries[d->num_entries].server = notify->server;
d->entries[d->num_entries].path_len = strlen(e->path);
d->num_entries++;
*/
NTSTATUS notify_add(struct notify_context *notify, struct notify_entry *e0,
void (*callback)(void *, const struct notify_event *),
- void *private)
+ void *private_data)
{
struct notify_entry e = *e0;
NTSTATUS status;
goto done;
}
- listel->private = private;
+ listel->private_data = private_data;
listel->callback = callback;
listel->depth = depth;
DLIST_ADD(notify->list, listel);
then we need to install it in the array used for the
intra-samba notify handling */
if (e.filter != 0 || e.subdir_filter != 0) {
- status = notify_add_array(notify, &e, private, depth);
+ status = notify_add_array(notify, &e, private_data, depth);
}
done:
/*
remove a notify watch. Called when the directory handle is closed
*/
-NTSTATUS notify_remove(struct notify_context *notify, void *private)
+NTSTATUS notify_remove(struct notify_context *notify, void *private_data)
{
NTSTATUS status;
struct notify_list *listel;
}
for (listel=notify->list;listel;listel=listel->next) {
- if (listel->private == private) {
+ if (listel->private_data == private_data) {
DLIST_REMOVE(notify->list, listel);
break;
}
d = ¬ify->array->depth[depth];
for (i=0;i<d->num_entries;i++) {
- if (private == d->entries[i].private &&
+ if (private_data == d->entries[i].private_data &&
cluster_id_equal(¬ify->server, &d->entries[i].server)) {
break;
}
struct notify_event ev;
DATA_BLOB data;
NTSTATUS status;
+ enum ndr_err_code ndr_err;
TALLOC_CTX *tmp_ctx;
ev.action = action;
ev.path = path;
- ev.private = e->private;
+ ev.private_data = e->private_data;
tmp_ctx = talloc_new(notify);
- status = ndr_push_struct_blob(&data, tmp_ctx, &ev,
- (ndr_push_flags_fn_t)ndr_push_notify_event);
- if (!NT_STATUS_IS_OK(status)) {
+ ndr_err = ndr_push_struct_blob(&data, tmp_ctx, notify->iconv_convenience, &ev, (ndr_push_flags_fn_t)ndr_push_notify_event);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
talloc_free(tmp_ctx);
return;
}