summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2009-01-04 22:48:23 +0100
committerJelmer Vernooij <jelmer@samba.org>2009-01-04 22:48:23 +0100
commitaf744e0954bbe9ddfa2e3da173e79de65e640a4c (patch)
tree78b98c28e6d54c5339c12f2f942883d5088fda84 /source4
parentce47b69d8e318bbb3642d27aa0451e2914c92be7 (diff)
parent2c0faaf5d921fe57a88d3b999067458e8774c6f6 (diff)
downloadsamba-af744e0954bbe9ddfa2e3da173e79de65e640a4c.tar.gz
samba-af744e0954bbe9ddfa2e3da173e79de65e640a4c.tar.bz2
samba-af744e0954bbe9ddfa2e3da173e79de65e640a4c.zip
Merge branch 'master' of ssh://git.samba.org/data/git/samba
Diffstat (limited to 'source4')
-rw-r--r--source4/auth/kerberos/config.mk2
-rw-r--r--source4/auth/kerberos/krb5_init_context.c34
-rw-r--r--source4/build/m4/public.m48
-rw-r--r--source4/configure.ac9
-rw-r--r--source4/headermap.txt3
-rw-r--r--source4/lib/events/config.mk2
-rw-r--r--source4/lib/events/events.h2
-rw-r--r--source4/lib/events/events_internal.h5
-rw-r--r--source4/lib/events/tevent_s4.c38
-rw-r--r--source4/lib/registry/pyregistry.c2
-rw-r--r--source4/lib/registry/regf.c4
-rw-r--r--source4/lib/registry/tools/common.c2
-rw-r--r--source4/lib/registry/tools/regtree.c13
-rw-r--r--source4/lib/socket/socket.c9
-rw-r--r--source4/lib/socket/socket.h6
-rw-r--r--source4/libcli/ldap/config.mk2
-rw-r--r--source4/libcli/ldap/ldap_client.c33
-rw-r--r--source4/ntvfs/posix/config.m43
-rw-r--r--source4/ntvfs/posix/config.mk2
-rw-r--r--source4/ntvfs/sysdep/inotify.c20
-rwxr-xr-xsource4/selftest/tests.sh2
-rw-r--r--source4/smbd/config.mk3
-rw-r--r--source4/smbd/server.c20
-rw-r--r--source4/smbd/service_named_pipe.c6
-rw-r--r--source4/smbd/service_stream.c55
-rw-r--r--source4/smbd/service_task.c1
-rw-r--r--source4/torture/util_smb.c5
-rw-r--r--source4/winbind/wb_init_domain.c3
-rw-r--r--source4/winbind/wb_samba3_cmd.c2
29 files changed, 178 insertions, 118 deletions
diff --git a/source4/auth/kerberos/config.mk b/source4/auth/kerberos/config.mk
index b724b8df37..822bf398a7 100644
--- a/source4/auth/kerberos/config.mk
+++ b/source4/auth/kerberos/config.mk
@@ -2,7 +2,7 @@
# Start SUBSYSTEM KERBEROS
[SUBSYSTEM::KERBEROS]
PUBLIC_DEPENDENCIES = HEIMDAL_KRB5 NDR_KRB5PAC samba_socket LIBCLI_RESOLVE
-PRIVATE_DEPENDENCIES = ASN1_UTIL auth_sam_reply LIBPACKET LIBNDR
+PRIVATE_DEPENDENCIES = ASN1_UTIL auth_sam_reply LIBTEVENT LIBPACKET LIBNDR
# End SUBSYSTEM KERBEROS
#################################
diff --git a/source4/auth/kerberos/krb5_init_context.c b/source4/auth/kerberos/krb5_init_context.c
index 2f0a2317a0..6e885842f3 100644
--- a/source4/auth/kerberos/krb5_init_context.c
+++ b/source4/auth/kerberos/krb5_init_context.c
@@ -22,11 +22,11 @@
#include "includes.h"
#include "system/kerberos.h"
+#include <tevent.h>
#include "auth/kerberos/kerberos.h"
#include "lib/socket/socket.h"
#include "lib/stream/packet.h"
#include "system/network.h"
-#include "lib/events/events.h"
#include "param/param.h"
#include "libcli/resolve/resolve.h"
@@ -159,9 +159,9 @@ static void smb_krb5_socket_send(struct smb_krb5_socket *smb_krb5)
if (!NT_STATUS_IS_OK(status)) return;
- EVENT_FD_READABLE(smb_krb5->fde);
+ TEVENT_FD_READABLE(smb_krb5->fde);
- EVENT_FD_NOT_WRITEABLE(smb_krb5->fde);
+ TEVENT_FD_NOT_WRITEABLE(smb_krb5->fde);
return;
}
@@ -175,22 +175,22 @@ static void smb_krb5_socket_handler(struct tevent_context *ev, struct tevent_fd
struct smb_krb5_socket *smb_krb5 = talloc_get_type(private, struct smb_krb5_socket);
switch (smb_krb5->hi->proto) {
case KRB5_KRBHST_UDP:
- if (flags & EVENT_FD_READ) {
+ if (flags & TEVENT_FD_READ) {
smb_krb5_socket_recv(smb_krb5);
return;
}
- if (flags & EVENT_FD_WRITE) {
+ if (flags & TEVENT_FD_WRITE) {
smb_krb5_socket_send(smb_krb5);
return;
}
/* not reached */
return;
case KRB5_KRBHST_TCP:
- if (flags & EVENT_FD_READ) {
+ if (flags & TEVENT_FD_READ) {
packet_recv(smb_krb5->packet);
return;
}
- if (flags & EVENT_FD_WRITE) {
+ if (flags & TEVENT_FD_WRITE) {
packet_queue_run(smb_krb5->packet);
return;
}
@@ -284,24 +284,24 @@ krb5_error_code smb_krb5_send_and_recv_func(krb5_context context,
* drop) and mark as AUTOCLOSE along with the fde */
/* Ths is equivilant to EVENT_FD_READABLE(smb_krb5->fde) */
- smb_krb5->fde = event_add_fd(ev, smb_krb5->sock,
- socket_get_fd(smb_krb5->sock),
- EVENT_FD_READ|EVENT_FD_AUTOCLOSE,
- smb_krb5_socket_handler, smb_krb5);
+ smb_krb5->fde = tevent_add_fd(ev, smb_krb5->sock,
+ socket_get_fd(smb_krb5->sock),
+ TEVENT_FD_READ,
+ smb_krb5_socket_handler, smb_krb5);
/* its now the job of the event layer to close the socket */
+ tevent_fd_set_close_fn(smb_krb5->fde, socket_tevent_fd_close_fn);
socket_set_flags(smb_krb5->sock, SOCKET_FLAG_NOCLOSE);
- event_add_timed(ev, smb_krb5,
- timeval_current_ofs(timeout, 0),
- smb_krb5_request_timeout, smb_krb5);
+ tevent_add_timer(ev, smb_krb5,
+ timeval_current_ofs(timeout, 0),
+ smb_krb5_request_timeout, smb_krb5);
-
smb_krb5->status = NT_STATUS_OK;
smb_krb5->reply = data_blob(NULL, 0);
switch (hi->proto) {
case KRB5_KRBHST_UDP:
- EVENT_FD_WRITEABLE(smb_krb5->fde);
+ TEVENT_FD_WRITEABLE(smb_krb5->fde);
smb_krb5->request = send_blob;
break;
case KRB5_KRBHST_TCP:
@@ -329,7 +329,7 @@ krb5_error_code smb_krb5_send_and_recv_func(krb5_context context,
return EINVAL;
}
while ((NT_STATUS_IS_OK(smb_krb5->status)) && !smb_krb5->reply.length) {
- if (event_loop_once(ev) != 0) {
+ if (tevent_loop_once(ev) != 0) {
talloc_free(smb_krb5);
return EINVAL;
}
diff --git a/source4/build/m4/public.m4 b/source4/build/m4/public.m4
index 5be4189e06..e51a8ac146 100644
--- a/source4/build/m4/public.m4
+++ b/source4/build/m4/public.m4
@@ -155,6 +155,14 @@ SMB_INFO_ENABLES="$SMB_INFO_ENABLES
\$enabled{$1} = \"$2\";"
])
+dnl SMB_MAKE_SETTINGS(text)
+AC_DEFUN([SMB_MAKE_SETTINGS],
+[
+MAKE_SETTINGS="$MAKE_SETTINGS
+$1
+"
+])
+
dnl SMB_WRITE_MAKEVARS(path, skip_vars)
AC_DEFUN([SMB_WRITE_MAKEVARS],
[
diff --git a/source4/configure.ac b/source4/configure.ac
index debdc39d58..6c8fb0efc2 100644
--- a/source4/configure.ac
+++ b/source4/configure.ac
@@ -60,13 +60,8 @@ SMB_EXT_LIB_FROM_PKGCONFIG(LIBTDB, tdb >= 1.1.3,
SMB_INCLUDE_MK(../lib/tdb/python.mk)
-SMB_EXT_LIB_FROM_PKGCONFIG(LIBTEVENT, tevent >= 0.9.0,
- [],
- [
- m4_include(../lib/tevent/libtevent.m4)
- SMB_INCLUDE_MK(../lib/tevent/config.mk)
- AC_CONFIG_FILES(../lib/tevent/tevent.pc)
- ]
+SMB_EXT_LIB_FROM_PKGCONFIG(LIBTEVENT, tevent >= 0.9.2,
+ [],[m4_include(../lib/tevent/samba.m4)]
)
SMB_INCLUDE_MK(../lib/tevent/python.mk)
diff --git a/source4/headermap.txt b/source4/headermap.txt
index d5e70a7304..c27ec2f2de 100644
--- a/source4/headermap.txt
+++ b/source4/headermap.txt
@@ -49,11 +49,8 @@ param/share.h: share.h
../lib/util/util_tdb.h: util_tdb.h
../lib/util/util_ldb.h: util_ldb.h
../lib/util/wrap_xattr.h: wrap_xattr.h
-lib/events/events.h: events/events.h
-lib/events/events_internal.h: events/events_internal.h
libcli/ldap/ldap_ndr.h: ldap_ndr.h
lib/events/events.h: events.h
-lib/events/events_internal.h: events_internal.h
../lib/tevent/tevent.h: tevent.h
../lib/tevent/tevent_internal.h: tevent_internal.h
auth/session.h: samba/session.h
diff --git a/source4/lib/events/config.mk b/source4/lib/events/config.mk
index a1b2cd218a..c07a21bc75 100644
--- a/source4/lib/events/config.mk
+++ b/source4/lib/events/config.mk
@@ -4,4 +4,4 @@ CFLAGS = -Ilib/events
LIBEVENTS_OBJ_FILES = $(addprefix $(libeventssrcdir)/, tevent_s4.o)
-PUBLIC_HEADERS += $(addprefix $(libeventssrcdir)/, events.h events_internal.h)
+PUBLIC_HEADERS += $(addprefix $(libeventssrcdir)/, events.h)
diff --git a/source4/lib/events/events.h b/source4/lib/events/events.h
index 698ff2919b..1b2dbde32b 100644
--- a/source4/lib/events/events.h
+++ b/source4/lib/events/events.h
@@ -3,5 +3,5 @@
#define TEVENT_COMPAT_DEFINES 1
#include <../lib/tevent/tevent.h>
struct tevent_context *s4_event_context_init(TALLOC_CTX *mem_ctx);
-struct tevent_context *event_context_find(TALLOC_CTX *mem_ctx);
+struct tevent_context *event_context_find(TALLOC_CTX *mem_ctx) _DEPRECATED_;
#endif /* __LIB_EVENTS_H__ */
diff --git a/source4/lib/events/events_internal.h b/source4/lib/events/events_internal.h
deleted file mode 100644
index 055bfe1a92..0000000000
--- a/source4/lib/events/events_internal.h
+++ /dev/null
@@ -1,5 +0,0 @@
-#ifndef __LIB_EVENTS_INTERNAL_H__
-#define __LIB_EVENTS_INTERNAL_H__
-#define TEVENT_COMPAT_DEFINES 1
-#include <../lib/tevent/tevent_internal.h>
-#endif /* __LIB_EVENTS_INTERNAL_H__ */
diff --git a/source4/lib/events/tevent_s4.c b/source4/lib/events/tevent_s4.c
index b3de7e667a..34a34a8e0b 100644
--- a/source4/lib/events/tevent_s4.c
+++ b/source4/lib/events/tevent_s4.c
@@ -17,38 +17,37 @@
*/
#include "includes.h"
-#include <events.h>
-#include <events_internal.h>
+#include "lib/events/events.h"
/*
this is used to catch debug messages from events
*/
-static void ev_wrap_debug(void *context, enum ev_debug_level level,
+static void ev_wrap_debug(void *context, enum tevent_debug_level level,
const char *fmt, va_list ap) PRINTF_ATTRIBUTE(3,0);
-static void ev_wrap_debug(void *context, enum ev_debug_level level,
+static void ev_wrap_debug(void *context, enum tevent_debug_level level,
const char *fmt, va_list ap)
{
int samba_level = -1;
char *s = NULL;
switch (level) {
- case EV_DEBUG_FATAL:
+ case TEVENT_DEBUG_FATAL:
samba_level = 0;
break;
- case EV_DEBUG_ERROR:
+ case TEVENT_DEBUG_ERROR:
samba_level = 1;
break;
- case EV_DEBUG_WARNING:
+ case TEVENT_DEBUG_WARNING:
samba_level = 2;
break;
- case EV_DEBUG_TRACE:
+ case TEVENT_DEBUG_TRACE:
samba_level = 5;
break;
};
vasprintf(&s, fmt, ap);
if (!s) return;
- DEBUG(samba_level, ("events: %s\n", s));
+ DEBUG(samba_level, ("tevent: %s\n", s));
free(s);
}
@@ -63,10 +62,27 @@ struct tevent_context *s4_event_context_init(TALLOC_CTX *mem_ctx)
{
struct tevent_context *ev;
- ev = event_context_init_byname(mem_ctx, NULL);
+ ev = tevent_context_init_byname(mem_ctx, NULL);
if (ev) {
- ev_set_debug(ev, ev_wrap_debug, NULL);
+ tevent_set_debug(ev, ev_wrap_debug, NULL);
}
return ev;
}
+/*
+ find an event context that is a parent of the given memory context,
+ or create a new event context as a child of the given context if
+ none is found
+
+ This should be used in preference to event_context_init() in places
+ where you would prefer to use the existing event context if possible
+ (which is most situations)
+*/
+struct tevent_context *event_context_find(TALLOC_CTX *mem_ctx)
+{
+ struct tevent_context *ev = talloc_find_parent_bytype(mem_ctx, struct tevent_context);
+ if (ev == NULL) {
+ ev = tevent_context_init(mem_ctx);
+ }
+ return ev;
+}
diff --git a/source4/lib/registry/pyregistry.c b/source4/lib/registry/pyregistry.c
index 2d2f2fb685..357305c4de 100644
--- a/source4/lib/registry/pyregistry.c
+++ b/source4/lib/registry/pyregistry.c
@@ -357,7 +357,7 @@ static PyObject *py_open_ldb_file(PyObject *self, PyObject *args, PyObject *kwar
session_info = NULL; /* FIXME */
result = reg_open_ldb_file(NULL, location, session_info, credentials,
- event_context_init(NULL), lp_ctx, &key);
+ tevent_context_init(NULL), lp_ctx, &key);
PyErr_WERROR_IS_ERR_RAISE(result);
return py_talloc_import(&PyHiveKey, key);
diff --git a/source4/lib/registry/regf.c b/source4/lib/registry/regf.c
index a869ed4440..4cbcb09a10 100644
--- a/source4/lib/registry/regf.c
+++ b/source4/lib/registry/regf.c
@@ -543,7 +543,7 @@ static WERROR regf_get_value(TALLOC_CTX *ctx, struct hive_key *key,
if (vk->data_length & 0x80000000) {
vk->data_length &=~0x80000000;
- data->data = (uint8_t *)&vk->data_offset;
+ data->data = talloc_memdup(ctx, (uint8_t *)&vk->data_offset, vk->data_length);
data->length = vk->data_length;
} else {
*data = hbin_get(regf, vk->data_offset);
@@ -2045,7 +2045,7 @@ WERROR reg_open_regf_file(TALLOC_CTX *parent_ctx, const char *location,
struct tdr_pull *pull;
int i;
- regf = (struct regf_data *)talloc_zero(NULL, struct regf_data);
+ regf = (struct regf_data *)talloc_zero(parent_ctx, struct regf_data);
regf->iconv_convenience = iconv_convenience;
diff --git a/source4/lib/registry/tools/common.c b/source4/lib/registry/tools/common.c
index c9f1248bf8..d997cb0fde 100644
--- a/source4/lib/registry/tools/common.c
+++ b/source4/lib/registry/tools/common.c
@@ -51,7 +51,7 @@ struct registry_key *reg_common_open_file(const char *path,
struct registry_context *h = NULL;
WERROR error;
- error = reg_open_hive(NULL, path, NULL, creds, ev_ctx, lp_ctx, &hive_root);
+ error = reg_open_hive(ev_ctx, path, NULL, creds, ev_ctx, lp_ctx, &hive_root);
if(!W_ERROR_IS_OK(error)) {
fprintf(stderr, "Unable to open '%s': %s \n",
diff --git a/source4/lib/registry/tools/regtree.c b/source4/lib/registry/tools/regtree.c
index cca009a0e2..948ed49312 100644
--- a/source4/lib/registry/tools/regtree.c
+++ b/source4/lib/registry/tools/regtree.c
@@ -55,13 +55,16 @@ static void print_tree(int level, struct registry_key *p,
&keyname,
NULL,
NULL)); i++) {
- SMB_ASSERT(strlen(keyname) > 0);
+
+ SMB_ASSERT(strlen(keyname) > 0);
if (!W_ERROR_IS_OK(reg_open_key(mem_ctx, p, keyname, &subkey)))
- continue;
+ continue;
+
print_tree(level+1, subkey, (fullpath && strlen(name))?
- talloc_asprintf(mem_ctx, "%s\\%s",
- name, keyname):
- keyname, fullpath, novals);
+ talloc_asprintf(mem_ctx, "%s\\%s",
+ name, keyname):
+ keyname, fullpath, novals);
+ talloc_free(subkey);
}
talloc_free(mem_ctx);
diff --git a/source4/lib/socket/socket.c b/source4/lib/socket/socket.c
index 26cdac99a3..9d30e0a77e 100644
--- a/source4/lib/socket/socket.c
+++ b/source4/lib/socket/socket.c
@@ -37,6 +37,15 @@ static int socket_destructor(struct socket_context *sock)
return 0;
}
+_PUBLIC_ void socket_tevent_fd_close_fn(struct tevent_context *ev,
+ struct tevent_fd *fde,
+ int fd,
+ void *private_data)
+{
+ /* this might be the socket_wrapper swrap_close() */
+ close(fd);
+}
+
_PUBLIC_ NTSTATUS socket_create_with_ops(TALLOC_CTX *mem_ctx, const struct socket_ops *ops,
struct socket_context **new_sock,
enum socket_type type, uint32_t flags)
diff --git a/source4/lib/socket/socket.h b/source4/lib/socket/socket.h
index 7a27e3070b..e9338127c4 100644
--- a/source4/lib/socket/socket.h
+++ b/source4/lib/socket/socket.h
@@ -21,6 +21,7 @@
#define _SAMBA_SOCKET_H
struct tevent_context;
+struct tevent_fd;
struct socket_context;
enum socket_type {
@@ -205,6 +206,11 @@ NTSTATUS socket_connect_multi(TALLOC_CTX *mem_ctx, const char *server_address,
void set_socket_options(int fd, const char *options);
void socket_set_flags(struct socket_context *socket, unsigned flags);
+void socket_tevent_fd_close_fn(struct tevent_context *ev,
+ struct tevent_fd *fde,
+ int fd,
+ void *private_data);
+
extern bool testnonblock;
#endif /* _SAMBA_SOCKET_H */
diff --git a/source4/libcli/ldap/config.mk b/source4/libcli/ldap/config.mk
index 2e50596dad..11157c5b63 100644
--- a/source4/libcli/ldap/config.mk
+++ b/source4/libcli/ldap/config.mk
@@ -1,5 +1,5 @@
[SUBSYSTEM::LIBCLI_LDAP]
-PUBLIC_DEPENDENCIES = LIBSAMBA-ERRORS LIBEVENTS LIBPACKET
+PUBLIC_DEPENDENCIES = LIBSAMBA-ERRORS LIBTEVENT LIBPACKET
PRIVATE_DEPENDENCIES = LIBCLI_COMPOSITE samba_socket NDR_SAMR LIBTLS ASN1_UTIL \
LDAP_ENCODE LIBNDR LP_RESOLVE gensec
diff --git a/source4/libcli/ldap/ldap_client.c b/source4/libcli/ldap/ldap_client.c
index 18784135cc..e30d5032fb 100644
--- a/source4/libcli/ldap/ldap_client.c
+++ b/source4/libcli/ldap/ldap_client.c
@@ -23,10 +23,10 @@
*/
#include "includes.h"
+#include <tevent.h>
+#include "lib/socket/socket.h"
#include "../lib/util/asn1.h"
#include "../lib/util/dlinklist.h"
-#include "lib/events/events.h"
-#include "lib/socket/socket.h"
#include "libcli/ldap/ldap.h"
#include "libcli/ldap/ldap_proto.h"
#include "libcli/ldap/ldap_client.h"
@@ -229,11 +229,11 @@ static void ldap_io_handler(struct tevent_context *ev, struct tevent_fd *fde,
{
struct ldap_connection *conn = talloc_get_type(private_data,
struct ldap_connection);
- if (flags & EVENT_FD_WRITE) {
+ if (flags & TEVENT_FD_WRITE) {
packet_queue_run(conn->packet);
if (!tls_enabled(conn->sock)) return;
}
- if (flags & EVENT_FD_READ) {
+ if (flags & TEVENT_FD_READ) {
ldap_read_io_handler(private_data, flags);
}
}
@@ -387,14 +387,15 @@ static void ldap_connect_got_sock(struct composite_context *ctx,
struct ldap_connection *conn)
{
/* setup a handler for events on this socket */
- conn->event.fde = event_add_fd(conn->event.event_ctx, conn->sock,
- socket_get_fd(conn->sock),
- EVENT_FD_READ | EVENT_FD_AUTOCLOSE, ldap_io_handler, conn);
+ conn->event.fde = tevent_add_fd(conn->event.event_ctx, conn->sock,
+ socket_get_fd(conn->sock),
+ TEVENT_FD_READ, ldap_io_handler, conn);
if (conn->event.fde == NULL) {
composite_error(ctx, NT_STATUS_INTERNAL_ERROR);
return;
}
+ tevent_fd_set_close_fn(conn->event.fde, socket_tevent_fd_close_fn);
socket_set_flags(conn->sock, SOCKET_FLAG_NOCLOSE);
talloc_steal(conn, conn->sock);
@@ -621,8 +622,8 @@ _PUBLIC_ struct ldap_request *ldap_request_send(struct ldap_connection *conn,
req->state = LDAP_REQUEST_DONE;
/* we can't call the async callback now, as it isn't setup, so
call it as next event */
- event_add_timed(conn->event.event_ctx, req, timeval_zero(),
- ldap_request_complete, req);
+ tevent_add_timer(conn->event.event_ctx, req, timeval_zero(),
+ ldap_request_complete, req);
return req;
}
@@ -630,17 +631,17 @@ _PUBLIC_ struct ldap_request *ldap_request_send(struct ldap_connection *conn,
DLIST_ADD(conn->pending, req);
/* put a timeout on the request */
- req->time_event = event_add_timed(conn->event.event_ctx, req,
- timeval_current_ofs(conn->timeout, 0),
- ldap_request_timeout, req);
+ req->time_event = tevent_add_timer(conn->event.event_ctx, req,
+ timeval_current_ofs(conn->timeout, 0),
+ ldap_request_timeout, req);
return req;
failed:
req->status = status;
req->state = LDAP_REQUEST_ERROR;
- event_add_timed(conn->event.event_ctx, req, timeval_zero(),
- ldap_request_complete, req);
+ tevent_add_timer(conn->event.event_ctx, req, timeval_zero(),
+ ldap_request_complete, req);
return req;
}
@@ -653,7 +654,7 @@ failed:
_PUBLIC_ NTSTATUS ldap_request_wait(struct ldap_request *req)
{
while (req->state < LDAP_REQUEST_DONE) {
- if (event_loop_once(req->conn->event.event_ctx) != 0) {
+ if (tevent_loop_once(req->conn->event.event_ctx) != 0) {
req->status = NT_STATUS_UNEXPECTED_NETWORK_ERROR;
break;
}
@@ -768,7 +769,7 @@ _PUBLIC_ NTSTATUS ldap_result_n(struct ldap_request *req, int n, struct ldap_mes
NT_STATUS_HAVE_NO_MEMORY(req);
while (req->state < LDAP_REQUEST_DONE && n >= req->num_replies) {
- if (event_loop_once(req->conn->event.event_ctx) != 0) {
+ if (tevent_loop_once(req->conn->event.event_ctx) != 0) {
return NT_STATUS_UNEXPECTED_NETWORK_ERROR;
}
}
diff --git a/source4/ntvfs/posix/config.m4 b/source4/ntvfs/posix/config.m4
index fe1997b437..a6f79dfbb3 100644
--- a/source4/ntvfs/posix/config.m4
+++ b/source4/ntvfs/posix/config.m4
@@ -30,8 +30,7 @@ if test x"$ac_cv_func_ext_blkid_get_cache" = x"yes"; then
SMB_ENABLE(BLKID,YES)
fi
-AC_CHECK_HEADERS(libaio.h)
SMB_ENABLE(pvfs_aio,NO)
-if test x"$ac_cv_header_libaio_h" = x"yes"; then
+if test x"$tevent_cv_aio_support" = x"yes"; then
SMB_ENABLE(pvfs_aio,YES)
fi
diff --git a/source4/ntvfs/posix/config.mk b/source4/ntvfs/posix/config.mk
index ec1cdf3659..1d7949214a 100644
--- a/source4/ntvfs/posix/config.mk
+++ b/source4/ntvfs/posix/config.mk
@@ -29,7 +29,7 @@ pvfs_acl_nfs4_OBJ_FILES = $(ntvfssrcdir)/posix/pvfs_acl_nfs4.o
################################################
[SUBSYSTEM::pvfs_aio]
-PRIVATE_DEPENDENCIES = LIBTEVENT LIBAIO_LINUX
+PRIVATE_DEPENDENCIES = LIBTEVENT LIBTEVENT_EXT
################################################
pvfs_aio_OBJ_FILES = $(ntvfssrcdir)/posix/pvfs_aio.o
diff --git a/source4/ntvfs/sysdep/inotify.c b/source4/ntvfs/sysdep/inotify.c
index f7aa91dd0e..42aac0b097 100644
--- a/source4/ntvfs/sysdep/inotify.c
+++ b/source4/ntvfs/sysdep/inotify.c
@@ -23,8 +23,8 @@
#include "includes.h"
#include "system/filesys.h"
+#include <tevent.h>
#include "ntvfs/sysdep/sys_notify.h"
-#include "lib/events/events.h"
#include "../lib/util/dlinklist.h"
#include "libcli/raw/smb.h"
#include "param/param.h"
@@ -249,8 +249,11 @@ static void inotify_handler(struct tevent_context *ev, struct tevent_fd *fde,
static NTSTATUS inotify_setup(struct sys_notify_context *ctx)
{
struct inotify_private *in;
+ struct tevent_fd *fde;
+
in = talloc(ctx, struct inotify_private);
NT_STATUS_HAVE_NO_MEMORY(in);
+
in->fd = inotify_init();
if (in->fd == -1) {
DEBUG(0,("Failed to init inotify - %s\n", strerror(errno)));
@@ -263,8 +266,19 @@ static NTSTATUS inotify_setup(struct sys_notify_context *ctx)
ctx->private_data = in;
/* add a event waiting for the inotify fd to be readable */
- event_add_fd(ctx->ev, in, in->fd, EVENT_FD_READ|EVENT_FD_AUTOCLOSE, inotify_handler, in);
-
+ fde = tevent_add_fd(ctx->ev, in, in->fd,
+ TEVENT_FD_READ, inotify_handler, in);
+ if (!fde) {
+ if (errno == 0) {
+ errno = ENOMEM;
+ }
+ DEBUG(0,("Failed to tevent_add_fd() - %s\n", strerror(errno)));
+ talloc_free(in);
+ return map_nt_error_from_unix(errno);
+ }
+
+ tevent_fd_set_auto_close(fde);
+
return NT_STATUS_OK;
}
diff --git a/source4/selftest/tests.sh b/source4/selftest/tests.sh
index 0a5bdf62cd..56cbacbdaf 100755
--- a/source4/selftest/tests.sh
+++ b/source4/selftest/tests.sh
@@ -401,7 +401,7 @@ plantest "samr.python" dc $SUBUNITRUN samba.tests.dcerpc.sam
plantest "dcerpc.bare.python" dc $SUBUNITRUN samba.tests.dcerpc.bare
plantest "unixinfo.python" dc $SUBUNITRUN samba.tests.dcerpc.unix
plantest "samdb.python" none $SUBUNITRUN samba.tests.samdb
-plantest "events.python" none PYTHONPATH="$PYTHONPATH:../lib/tevent" $SUBUNITRUN tests
+plantest "tevent.python" none PYTHONPATH="$PYTHONPATH:../lib/tevent" $SUBUNITRUN tests
plantest "messaging.python" none PYTHONPATH="$PYTHONPATH:lib/messaging/tests" $SUBUNITRUN bindings
plantest "samba3sam.python" none PYTHONPATH="$PYTHONPATH:dsdb/samdb/ldb_modules/tests" $SUBUNITRUN samba3sam
plantest "subunit.python" none $SUBUNITRUN subunit
diff --git a/source4/smbd/config.mk b/source4/smbd/config.mk
index e0b09f4b8c..a76d10cbe7 100644
--- a/source4/smbd/config.mk
+++ b/source4/smbd/config.mk
@@ -2,7 +2,7 @@
[SUBSYSTEM::service]
PRIVATE_DEPENDENCIES = \
- LIBEVENTS MESSAGING samba_socket NDR_NAMED_PIPE_AUTH
+ LIBTEVENT MESSAGING samba_socket NDR_NAMED_PIPE_AUTH
service_OBJ_FILES = $(addprefix $(smbdsrcdir)/, \
service.o \
@@ -21,6 +21,7 @@ $(eval $(call proto_header_template,$(smbdsrcdir)/pidfile.h,$(PIDFILE_OBJ_FILES:
[BINARY::samba]
INSTALLDIR = SBINDIR
PRIVATE_DEPENDENCIES = \
+ LIBEVENTS \
process_model \
service \
LIBSAMBA-HOSTCONFIG \
diff --git a/source4/smbd/server.c b/source4/smbd/server.c
index c1683a48dc..df970661f1 100644
--- a/source4/smbd/server.c
+++ b/source4/smbd/server.c
@@ -266,7 +266,7 @@ static int binary_smbd_main(const char *binary_name, int argc, const char *argv[
umask(0);
DEBUG(0,("%s version %s started.\n", binary_name, SAMBA_VERSION_STRING));
- DEBUGADD(0,("Copyright Andrew Tridgell and the Samba Team 1992-2008\n"));
+ DEBUGADD(0,("Copyright Andrew Tridgell and the Samba Team 1992-2009\n"));
if (sizeof(uint16_t) < 2 || sizeof(uint32_t) < 4 || sizeof(uint64_t) < 8) {
DEBUG(0,("ERROR: Samba is not configured correctly for the word size on your machine\n"));
@@ -323,7 +323,7 @@ static int binary_smbd_main(const char *binary_name, int argc, const char *argv[
if (opt_interactive) {
/* terminate when stdin goes away */
- stdin_event_flags = EVENT_FD_READ;
+ stdin_event_flags = TEVENT_FD_READ;
} else {
/* stay alive forever */
stdin_event_flags = 0;
@@ -333,15 +333,15 @@ static int binary_smbd_main(const char *binary_name, int argc, const char *argv[
#ifdef SIGTTIN
signal(SIGTTIN, SIG_IGN);
#endif
- event_add_fd(event_ctx, event_ctx, 0, stdin_event_flags,
- server_stdin_handler,
- discard_const(binary_name));
+ tevent_add_fd(event_ctx, event_ctx, 0, stdin_event_flags,
+ server_stdin_handler,
+ discard_const(binary_name));
if (max_runtime) {
- event_add_timed(event_ctx, event_ctx,
- timeval_current_ofs(max_runtime, 0),
- max_runtime_handler,
- discard_const(binary_name));
+ tevent_add_timer(event_ctx, event_ctx,
+ timeval_current_ofs(max_runtime, 0),
+ max_runtime_handler,
+ discard_const(binary_name));
}
DEBUG(0,("%s: using '%s' process model\n", binary_name, model));
@@ -354,7 +354,7 @@ static int binary_smbd_main(const char *binary_name, int argc, const char *argv[
/* wait for events - this is where smbd sits for most of its
life */
- event_loop_wait(event_ctx);
+ tevent_loop_wait(event_ctx);
/* as everything hangs off this event context, freeing it
should initiate a clean shutdown of all services */
diff --git a/source4/smbd/service_named_pipe.c b/source4/smbd/service_named_pipe.c
index 94fd501ffe..02b71de7c3 100644
--- a/source4/smbd/service_named_pipe.c
+++ b/source4/smbd/service_named_pipe.c
@@ -20,7 +20,7 @@
*/
#include "includes.h"
-#include "lib/events/events.h"
+#include <tevent.h>
#include "lib/socket/socket.h"
#include "smbd/service.h"
#include "param/param.h"
@@ -49,7 +49,7 @@ static void named_pipe_handover_connection(void *private_data)
private_data, struct named_pipe_connection);
struct stream_connection *conn = pipe_conn->connection;
- EVENT_FD_NOT_WRITEABLE(conn->event.fde);
+ TEVENT_FD_NOT_WRITEABLE(conn->event.fde);
if (!NT_STATUS_IS_OK(pipe_conn->status)) {
stream_terminate_connection(conn, nt_errstr(pipe_conn->status));
@@ -64,7 +64,7 @@ static void named_pipe_handover_connection(void *private_data)
talloc_free(pipe_conn);
/* we're now ready to start receiving events on this stream */
- EVENT_FD_READABLE(conn->event.fde);
+ TEVENT_FD_READABLE(conn->event.fde);
/*
* hand over to the real pipe implementation,
diff --git a/source4/smbd/service_stream.c b/source4/smbd/service_stream.c
index ef98919f93..6dff01f4f3 100644
--- a/source4/smbd/service_stream.c
+++ b/source4/smbd/service_stream.c
@@ -21,8 +21,8 @@
*/
#include "includes.h"
+#include <tevent.h>
#include "process_model.h"
-#include "lib/events/events.h"
#include "lib/socket/socket.h"
#include "smbd/service.h"
#include "smbd/service_stream.h"
@@ -72,7 +72,7 @@ void stream_terminate_connection(struct stream_connection *srv_conn, const char
*
* and we don't want to read or write to the connection...
*/
- event_set_fd_flags(srv_conn->event.fde, 0);
+ tevent_fd_set_flags(srv_conn->event.fde, 0);
return;
}
@@ -88,9 +88,9 @@ void stream_terminate_connection(struct stream_connection *srv_conn, const char
static void stream_io_handler(struct stream_connection *conn, uint16_t flags)
{
conn->processing++;
- if (flags & EVENT_FD_WRITE) {
+ if (flags & TEVENT_FD_WRITE) {
conn->ops->send_handler(conn, flags);
- } else if (flags & EVENT_FD_READ) {
+ } else if (flags & TEVENT_FD_READ) {
conn->ops->recv_handler(conn, flags);
}
conn->processing--;
@@ -144,9 +144,14 @@ NTSTATUS stream_new_connection_merge(struct tevent_context *ev,
srv_conn->msg_ctx = msg_ctx;
srv_conn->event.ctx = ev;
srv_conn->lp_ctx = lp_ctx;
- srv_conn->event.fde = event_add_fd(ev, srv_conn, socket_get_fd(sock),
- EVENT_FD_READ,
- stream_io_handler_fde, srv_conn);
+ srv_conn->event.fde = tevent_add_fd(ev, srv_conn, socket_get_fd(sock),
+ TEVENT_FD_READ,
+ stream_io_handler_fde, srv_conn);
+ if (!srv_conn->event.fde) {
+ talloc_free(srv_conn);
+ return NT_STATUS_NO_MEMORY;
+ }
+
*_srv_conn = srv_conn;
return NT_STATUS_OK;
}
@@ -179,14 +184,19 @@ static void stream_new_connection(struct tevent_context *ev,
srv_conn->ops = stream_socket->ops;
srv_conn->event.ctx = ev;
srv_conn->lp_ctx = lp_ctx;
- srv_conn->event.fde = event_add_fd(ev, srv_conn, socket_get_fd(sock),
- 0, stream_io_handler_fde, srv_conn);
if (!socket_check_access(sock, "smbd", lp_hostsallow(NULL, lp_default_service(lp_ctx)), lp_hostsdeny(NULL, lp_default_service(lp_ctx)))) {
stream_terminate_connection(srv_conn, "denied by access rules");
return;
}
+ srv_conn->event.fde = tevent_add_fd(ev, srv_conn, socket_get_fd(sock),
+ 0, stream_io_handler_fde, srv_conn);
+ if (!srv_conn->event.fde) {
+ stream_terminate_connection(srv_conn, "tevent_add_fd() failed");
+ return;
+ }
+
/* setup to receive internal messages on this connection */
srv_conn->msg_ctx = messaging_init(srv_conn,
lp_messaging_path(srv_conn, lp_ctx),
@@ -214,7 +224,7 @@ static void stream_new_connection(struct tevent_context *ev,
talloc_free(s);
/* we're now ready to start receiving events on this stream */
- EVENT_FD_READABLE(srv_conn->event.fde);
+ TEVENT_FD_READABLE(srv_conn->event.fde);
/* call the server specific accept code */
stream_socket->ops->accept_connection(srv_conn);
@@ -258,6 +268,7 @@ NTSTATUS stream_setup_socket(struct tevent_context *event_context,
NTSTATUS status;
struct stream_socket *stream_socket;
struct socket_address *socket_address;
+ struct tevent_fd *fde;
int i;
stream_socket = talloc_zero(event_context, struct stream_socket);
@@ -322,20 +333,24 @@ NTSTATUS stream_setup_socket(struct tevent_context *event_context,
return status;
}
- /* By specifying EVENT_FD_AUTOCLOSE below, we indicate that we
- * will close the socket using the events system. This avoids
- * nasty interactions with waiting for talloc to close the socket. */
-
- socket_set_flags(stream_socket->sock, SOCKET_FLAG_NOCLOSE);
-
/* Add the FD from the newly created socket into the event
* subsystem. it will call the accept handler whenever we get
* new connections */
- event_add_fd(event_context, stream_socket->sock,
- socket_get_fd(stream_socket->sock),
- EVENT_FD_READ|EVENT_FD_AUTOCLOSE,
- stream_accept_handler, stream_socket);
+ fde = tevent_add_fd(event_context, stream_socket->sock,
+ socket_get_fd(stream_socket->sock),
+ TEVENT_FD_READ,
+ stream_accept_handler, stream_socket);
+ if (!fde) {
+ DEBUG(0,("Failed to setup fd event\n"));
+ talloc_free(stream_socket);
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ /* we let events system to the close on the socket. This avoids
+ * nasty interactions with waiting for talloc to close the socket. */
+ tevent_fd_set_close_fn(fde, socket_tevent_fd_close_fn);
+ socket_set_flags(stream_socket->sock, SOCKET_FLAG_NOCLOSE);
stream_socket->private = talloc_reference(stream_socket, private);
stream_socket->ops = stream_ops;
diff --git a/source4/smbd/service_task.c b/source4/smbd/service_task.c
index 34ce755b93..d3951a4a9a 100644
--- a/source4/smbd/service_task.c
+++ b/source4/smbd/service_task.c
@@ -21,7 +21,6 @@
#include "includes.h"
#include "process_model.h"
-#include "lib/events/events.h"
#include "smbd/service.h"
#include "smbd/service_task.h"
#include "lib/messaging/irpc.h"
diff --git a/source4/torture/util_smb.c b/source4/torture/util_smb.c
index f88a641059..732b84af73 100644
--- a/source4/torture/util_smb.c
+++ b/source4/torture/util_smb.c
@@ -656,7 +656,10 @@ double torture_create_procs(struct torture_context *tctx,
pid_t mypid = getpid();
srandom(((int)mypid) ^ ((int)time(NULL)));
- asprintf(&myname, "CLIENT%d", i);
+ if (asprintf(&myname, "CLIENT%d", i) == -1) {
+ printf("asprintf failed\n");
+ return -1;
+ }
lp_set_cmdline(tctx->lp_ctx, "netbios name", myname);
free(myname);
diff --git a/source4/winbind/wb_init_domain.c b/source4/winbind/wb_init_domain.c
index 637cf10bb7..5953474c52 100644
--- a/source4/winbind/wb_init_domain.c
+++ b/source4/winbind/wb_init_domain.c
@@ -402,8 +402,7 @@ static void init_domain_recv_samr(struct composite_context *ctx)
talloc_steal(state->domain->libnet_ctx->samr.pipe, state->domain->samr_binding);
state->domain->libnet_ctx->samr.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
state->domain->libnet_ctx->samr.name = state->domain->info->name;
- state->domain->libnet_ctx->samr.sid = dom_sid_dup(state->ctx,
- state->domain->info->sid);
+ state->domain->libnet_ctx->samr.sid = state->domain->info->sid;
composite_done(state->ctx);
}
diff --git a/source4/winbind/wb_samba3_cmd.c b/source4/winbind/wb_samba3_cmd.c
index 6cad76b08b..6af92668a3 100644
--- a/source4/winbind/wb_samba3_cmd.c
+++ b/source4/winbind/wb_samba3_cmd.c
@@ -115,7 +115,7 @@ NTSTATUS wbsrv_samba3_priv_pipe_dir(struct wbsrv_samba3_call *s3call)
{
const char *path = s3call->wbconn->listen_socket->service->priv_socket_path;
s3call->response.result = WINBINDD_OK;
- WBSRV_SAMBA3_SET_STRING(s3call->response.extra_data.data, path);
+ s3call->response.extra_data.data = discard_const(path);
s3call->response.length += strlen(path) + 1;
return NT_STATUS_OK;