From 998d58819201954a78eb123d6f9d2bc0c6bd579c Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 23 Dec 2008 03:24:39 +0100 Subject: python/tevent: Remove use of pytalloc.h. --- lib/tevent/pytevent.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'lib') diff --git a/lib/tevent/pytevent.c b/lib/tevent/pytevent.c index 4f18c87a90..54f6799845 100644 --- a/lib/tevent/pytevent.c +++ b/lib/tevent/pytevent.c @@ -19,9 +19,13 @@ #include #include #include -#include <../talloc/pytalloc.h> #include +typedef struct { + PyObject_HEAD + struct event_context *ev_ctx; +} PyEventContextObject; + PyAPI_DATA(PyTypeObject) PyEventContext; static PyObject *py_set_default_backend(PyObject *self, PyObject *args) @@ -62,6 +66,7 @@ static PyObject *py_event_ctx_new(PyTypeObject *type, PyObject *args, PyObject * const char *kwnames[] = { "name", NULL }; char *name = NULL; struct event_context *ev_ctx; + PyEventContextObject *ret; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|s", (char **)kwnames, &name)) return NULL; @@ -70,17 +75,19 @@ static PyObject *py_event_ctx_new(PyTypeObject *type, PyObject *args, PyObject * else ev_ctx = event_context_init_byname(NULL, name); - return py_talloc_import(&PyEventContext, ev_ctx); + ret = (PyEventContextObject *)type->tp_alloc(type, 0); + ret->ev_ctx = ev_ctx; + return (PyObject *)ret; } -static PyObject *py_event_ctx_loop_once(py_talloc_Object *self) +static PyObject *py_event_ctx_loop_once(PyEventContextObject *self) { - return PyInt_FromLong(event_loop_once(self->ptr)); + return PyInt_FromLong(event_loop_once(self->ev_ctx)); } -static PyObject *py_event_ctx_loop_wait(py_talloc_Object *self) +static PyObject *py_event_ctx_loop_wait(PyEventContextObject *self) { - return PyInt_FromLong(event_loop_wait(self->ptr)); + return PyInt_FromLong(event_loop_wait(self->ev_ctx)); } static PyMethodDef py_event_ctx_methods[] = { @@ -91,11 +98,17 @@ static PyMethodDef py_event_ctx_methods[] = { { NULL } }; +static void py_event_ctx_dealloc(PyEventContextObject * self) +{ + talloc_free(self->ev_ctx); + self->ob_type->tp_free(self); +} + PyTypeObject PyEventContext = { .tp_name = "EventContext", .tp_methods = py_event_ctx_methods, - .tp_basicsize = sizeof(py_talloc_Object), - .tp_dealloc = py_talloc_dealloc, + .tp_basicsize = sizeof(PyEventContextObject), + .tp_dealloc = (destructor)py_event_ctx_dealloc, .tp_flags = Py_TPFLAGS_DEFAULT, .tp_new = py_event_ctx_new, }; -- cgit From bbc95fb1a866e8aa822b70a7f5cdf74f1446b1f0 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 23 Dec 2008 04:18:31 +0100 Subject: ldb: Fix linking against tevent library (rather than events) replace: Fix copyright for dlfcn.c. --- lib/replace/dlfcn.c | 1 + 1 file changed, 1 insertion(+) (limited to 'lib') diff --git a/lib/replace/dlfcn.c b/lib/replace/dlfcn.c index 3b109d7e40..88431ed576 100644 --- a/lib/replace/dlfcn.c +++ b/lib/replace/dlfcn.c @@ -3,6 +3,7 @@ Samba system utilities Copyright (C) Andrew Tridgell 1992-1998 Copyright (C) Jeremy Allison 1998-2002 + Copyright (C) Jelmer Vernooij 2006 ** NOTE! The following LGPL license applies to the replace ** library. This does NOT imply that all of Samba is released -- cgit From aaea68791cfea45c6fa69abc93ad6d0e832d0283 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 22 Dec 2008 20:08:14 -0800 Subject: In gcc version 4.3.2 we get warnings for functions declared with attribute warn_unused_result. Start to fix these. Jeremy. --- lib/socket_wrapper/socket_wrapper.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/socket_wrapper/socket_wrapper.c b/lib/socket_wrapper/socket_wrapper.c index 9d61976950..dc0124bdb7 100644 --- a/lib/socket_wrapper/socket_wrapper.c +++ b/lib/socket_wrapper/socket_wrapper.c @@ -899,7 +899,10 @@ static int swrap_get_pcap_fd(const char *fname) file_hdr.frame_max_len = SWRAP_FRAME_LENGTH_MAX; file_hdr.link_type = 0x0065; /* 101 RAW IP */ - write(fd, &file_hdr, sizeof(file_hdr)); + if (write(fd, &file_hdr, sizeof(file_hdr)) != sizeof(file_hdr)) { + close(fd); + return -1; + } return fd; } @@ -1190,7 +1193,12 @@ static void swrap_dump_packet(struct socket_info *si, fd = swrap_get_pcap_fd(file_name); if (fd != -1) { - write(fd, packet, packet_len); + if (write(fd, packet, packet_len) != packet_len) { + close(fd); + free(packet); + return; + } + close(fd); } free(packet); -- cgit From 465f78021e609719bf25b7d2933c47b7ab1b6940 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 23 Dec 2008 19:28:22 +0100 Subject: Move Samba4-specific file out of common libtevent. --- lib/tevent/config.mk | 2 +- lib/tevent/tevent_s4.c | 72 -------------------------------------------------- 2 files changed, 1 insertion(+), 73 deletions(-) delete mode 100644 lib/tevent/tevent_s4.c (limited to 'lib') diff --git a/lib/tevent/config.mk b/lib/tevent/config.mk index bce92bb82d..01c628cd2c 100644 --- a/lib/tevent/config.mk +++ b/lib/tevent/config.mk @@ -41,7 +41,7 @@ CFLAGS = -I../lib/tevent # End SUBSYSTEM LIBTEVENT ################################################ -LIBTEVENT_OBJ_FILES = $(addprefix $(libteventsrcdir)/, tevent.o tevent_timed.o tevent_signal.o tevent_debug.o tevent_util.o tevent_s4.o) +LIBTEVENT_OBJ_FILES = $(addprefix $(libteventsrcdir)/, tevent.o tevent_timed.o tevent_signal.o tevent_debug.o tevent_util.o) PUBLIC_HEADERS += $(addprefix $(libteventsrcdir)/, tevent.h tevent_internal.h) diff --git a/lib/tevent/tevent_s4.c b/lib/tevent/tevent_s4.c deleted file mode 100644 index 80267fdd22..0000000000 --- a/lib/tevent/tevent_s4.c +++ /dev/null @@ -1,72 +0,0 @@ -/* - Unix SMB/CIFS implementation. - Copyright (C) Andrew Tridgell 2003 - - 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 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - 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, see . -*/ - -#include "includes.h" -#include "tevent.h" -#include "tevent_internal.h" - -/* - this is used to catch debug messages from events -*/ -static void ev_wrap_debug(void *context, enum ev_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, - const char *fmt, va_list ap) -{ - int samba_level = -1; - char *s = NULL; - switch (level) { - case EV_DEBUG_FATAL: - samba_level = 0; - break; - case EV_DEBUG_ERROR: - samba_level = 1; - break; - case EV_DEBUG_WARNING: - samba_level = 2; - break; - case EV_DEBUG_TRACE: - samba_level = 5; - break; - - }; - vasprintf(&s, fmt, ap); - if (!s) return; - DEBUG(samba_level, ("events: %s\n", s)); - free(s); -} - -/* - create a event_context structure. This must be the first events - call, and all subsequent calls pass this event_context as the first - element. Event handlers also receive this as their first argument. - - This samba4 specific call sets the samba4 debug handler. -*/ -struct event_context *s4_event_context_init(TALLOC_CTX *mem_ctx) -{ - struct event_context *ev; - - ev = event_context_init_byname(mem_ctx, NULL); - if (ev) { - ev_set_debug(ev, ev_wrap_debug, NULL); - } - return ev; -} - -- cgit From 22703bf3ffc3692a719d6bd593d3705697045bea Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 23 Dec 2008 19:39:52 +0100 Subject: standalone: Use more variables, preparing to include these files from main Samba 4 makefile. --- lib/talloc/talloc.mk | 9 +++++---- lib/tdb/tdb.mk | 11 ++++++----- lib/tevent/tevent.mk | 11 ++++++----- 3 files changed, 17 insertions(+), 14 deletions(-) (limited to 'lib') diff --git a/lib/talloc/talloc.mk b/lib/talloc/talloc.mk index 7f0afed560..ce7784c8a2 100644 --- a/lib/talloc/talloc.mk +++ b/lib/talloc/talloc.mk @@ -2,20 +2,21 @@ TALLOC_OBJ = $(tallocdir)/talloc.o TALLOC_SOLIB = libtalloc.$(SHLIBEXT).$(PACKAGE_VERSION) TALLOC_SONAME = libtalloc.$(SHLIBEXT).1 +TALLOC_STLIB = libtalloc.a -all:: libtalloc.a $(TALLOC_SOLIB) testsuite +all:: $(TALLOC_STLIB) $(TALLOC_SOLIB) testsuite testsuite:: $(LIBOBJ) testsuite.o testsuite_main.o $(CC) $(CFLAGS) -o testsuite testsuite.o testsuite_main.o $(LIBOBJ) $(LIBS) -libtalloc.a: $(LIBOBJ) +$(TALLOC_STLIB): $(LIBOBJ) ar -rv $@ $(LIBOBJ) @-ranlib $@ install:: all ${INSTALLCMD} -d $(DESTDIR)$(libdir) ${INSTALLCMD} -d $(DESTDIR)$(libdir)/pkgconfig - ${INSTALLCMD} -m 755 libtalloc.a $(DESTDIR)$(libdir) + ${INSTALLCMD} -m 755 $(TALLOC_STLIB) $(DESTDIR)$(libdir) ${INSTALLCMD} -m 755 $(TALLOC_SOLIB) $(DESTDIR)$(libdir) ${INSTALLCMD} -d $(DESTDIR)${includedir} ${INSTALLCMD} -m 644 $(srcdir)/talloc.h $(DESTDIR)$(includedir) @@ -28,7 +29,7 @@ install:: all doc:: talloc.3 talloc.3.html clean:: - rm -f *~ $(LIBOBJ) $(TALLOC_SOLIB) libtalloc.a testsuite testsuite.o testsuite_main.o *.gc?? talloc.3 talloc.3.html + rm -f *~ $(LIBOBJ) $(TALLOC_SOLIB) $(TALLOC_STLIB) testsuite testsuite.o testsuite_main.o *.gc?? talloc.3 talloc.3.html test:: testsuite ./testsuite diff --git a/lib/tdb/tdb.mk b/lib/tdb/tdb.mk index 72f44e7211..b786bdbf54 100644 --- a/lib/tdb/tdb.mk +++ b/lib/tdb/tdb.mk @@ -7,8 +7,9 @@ ALL_PROGS = $(PROGS) $(PROGS_NOINSTALL) TDB_SONAME = libtdb.$(SHLIBEXT).1 TDB_SOLIB = libtdb.$(SHLIBEXT).$(PACKAGE_VERSION) +TDB_STLIB = libtdb.a -TDB_LIB = libtdb.a +TDB_LIB = $(TDB_STLIB) bin/tdbtest$(EXEEXT): tools/tdbtest.o $(TDB_LIB) $(CC) $(CFLAGS) $(LDFLAGS) -o bin/tdbtest tools/tdbtest.o -L. -ltdb -lgdbm @@ -30,7 +31,7 @@ test:: bin/tdbtorture$(EXEEXT) $(TDB_SONAME) clean:: rm -f test.db test.tdb torture.tdb test.gdbm - rm -f $(TDB_SONAME) $(TDB_SOLIB) libtdb.a libtdb.$(SHLIBEXT) + rm -f $(TDB_SONAME) $(TDB_SOLIB) $(TDB_STLIB) libtdb.$(SHLIBEXT) rm -f $(ALL_PROGS) tdb.pc build-python:: tdb.$(SHLIBEXT) @@ -68,10 +69,10 @@ installheaders:: installdirs installlibs:: all installdirs cp tdb.pc $(DESTDIR)$(libdir)/pkgconfig - cp libtdb.a $(TDB_SOLIB) $(DESTDIR)$(libdir) + cp $(TDB_STLIB) $(TDB_SOLIB) $(DESTDIR)$(libdir) -libtdb.a: $(TDB_OBJ) - ar -rv libtdb.a $(TDB_OBJ) +$(TDB_STLIB): $(TDB_OBJ) + ar -rv $(TDB_STLIB) $(TDB_OBJ) libtdb.$(SHLIBEXT): $(TDB_SOLIB) ln -fs $< $@ diff --git a/lib/tevent/tevent.mk b/lib/tevent/tevent.mk index 8b4c6ed27e..2e4d5a96af 100644 --- a/lib/tevent/tevent.mk +++ b/lib/tevent/tevent.mk @@ -1,8 +1,9 @@ TEVENT_SONAME = libtevent.$(SHLIBEXT).0 TEVENT_SOLIB = libtevent.$(SHLIBEXT).$(PACKAGE_VERSION) +TEVENT_STLIB = libtevent.a -libtevent.a: $(TEVENT_OBJ) - ar -rv libtevent.a $(TEVENT_OBJ) +$(TEVENT_STLIB): $(TEVENT_OBJ) + ar -rv $(TEVENT_STLIB) $(TEVENT_OBJ) libtevent.$(SHLIBEXT): $(TEVENT_SOLIB) ln -fs $< $@ @@ -23,14 +24,14 @@ installheaders:: installdirs installlibs:: installdirs cp tevent.pc $(DESTDIR)$(libdir)/pkgconfig - cp libtevent.a $(TEVENT_SOLIB) $(DESTDIR)$(libdir) + cp $(TEVENT_STLIB) $(TEVENT_SOLIB) $(DESTDIR)$(libdir) install:: all installdirs installheaders installlibs $(PYTHON_INSTALL_TARGET) clean:: - rm -f $(TEVENT_SONAME) $(TEVENT_SOLIB) libtevent.a libtevent.$(SHLIBEXT) + rm -f $(TEVENT_SONAME) $(TEVENT_SOLIB) $(TEVENT_STLIB) libtevent.$(SHLIBEXT) rm -f tevent.pc - rm -f _libtevent.$(SHLIBEXT) + rm -f tevent.$(SHLIBEXT) #python stuff -- cgit From 8b24da201b78ddda3738564f2d69c96ab4ed9919 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 23 Dec 2008 19:59:57 +0100 Subject: Allow using external libtevent. --- lib/tevent/config.mk | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'lib') diff --git a/lib/tevent/config.mk b/lib/tevent/config.mk index 01c628cd2c..e4fb9a8088 100644 --- a/lib/tevent/config.mk +++ b/lib/tevent/config.mk @@ -44,14 +44,3 @@ CFLAGS = -I../lib/tevent LIBTEVENT_OBJ_FILES = $(addprefix $(libteventsrcdir)/, tevent.o tevent_timed.o tevent_signal.o tevent_debug.o tevent_util.o) PUBLIC_HEADERS += $(addprefix $(libteventsrcdir)/, tevent.h tevent_internal.h) - -# TODO: Change python stuff to tevent -[PYTHON::swig_events] -LIBRARY_REALNAME = tevent.$(SHLIBEXT) -PRIVATE_DEPENDENCIES = LIBTEVENT PYTALLOC LIBSAMBA-UTIL - -swig_events_OBJ_FILES = $(libteventsrcdir)/pytevent.o - -$(swig_events_OBJ_FILES): CFLAGS+=$(CFLAG_NO_CAST_QUAL) - -PC_FILES += $(libteventsrcdir)/tevent.pc -- cgit From 31dc07ee2868c99792e0f71239f79ba49062e7e2 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 23 Dec 2008 20:13:17 +0100 Subject: pytevent: Add missing file. --- lib/tevent/python.mk | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 lib/tevent/python.mk (limited to 'lib') diff --git a/lib/tevent/python.mk b/lib/tevent/python.mk new file mode 100644 index 0000000000..d48c4f5b9c --- /dev/null +++ b/lib/tevent/python.mk @@ -0,0 +1,10 @@ +# TODO: Change python stuff to tevent +[PYTHON::swig_events] +LIBRARY_REALNAME = tevent.$(SHLIBEXT) +PRIVATE_DEPENDENCIES = LIBTEVENT PYTALLOC LIBSAMBA-UTIL + +swig_events_OBJ_FILES = $(libteventsrcdir)/pytevent.o + +$(swig_events_OBJ_FILES): CFLAGS+=$(CFLAG_NO_CAST_QUAL) + +PC_FILES += $(libteventsrcdir)/tevent.pc -- cgit From ef80d1b794a209ee446c7a586530a5fdd51175f2 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 23 Dec 2008 22:10:34 +0100 Subject: Fix use of "time offset" parameter, and add test to make sure I don't break it again :-) --- lib/util/tests/time.c | 16 ++++++++++++++++ lib/util/time.c | 5 ++++- lib/util/time.h | 3 +++ 3 files changed, 23 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/util/tests/time.c b/lib/util/tests/time.c index 4a31566b42..e24c5fe5ef 100644 --- a/lib/util/tests/time.c +++ b/lib/util/tests/time.c @@ -58,6 +58,21 @@ static bool test_timestring(struct torture_context *tctx) return true; } +static bool test_get_time_zone(struct torture_context *tctx) +{ + time_t t = time(NULL); + int old_extra_time_offset = extra_time_offset; + int old_offset, new_offset; + /* test that extra_time_offset works */ + + old_offset = get_time_zone(t); + extra_time_offset = 42; + new_offset = get_time_zone(t); + extra_time_offset = old_extra_time_offset; + torture_assert_int_equal(tctx, old_offset+60*42, new_offset, + "time offset not used"); + return true; +} struct torture_suite *torture_local_util_time(TALLOC_CTX *mem_ctx) @@ -65,6 +80,7 @@ struct torture_suite *torture_local_util_time(TALLOC_CTX *mem_ctx) struct torture_suite *suite = torture_suite_create(mem_ctx, "TIME"); torture_suite_add_simple_test(suite, "null_time", test_null_time); + torture_suite_add_simple_test(suite, "get_time_zone", test_get_time_zone); torture_suite_add_simple_test(suite, "null_nttime", test_null_nttime); torture_suite_add_simple_test(suite, "http_timestring", test_http_timestring); diff --git a/lib/util/time.c b/lib/util/time.c index a001e5f66e..eadafe4562 100644 --- a/lib/util/time.c +++ b/lib/util/time.c @@ -628,6 +628,9 @@ static int tm_diff(struct tm *a, struct tm *b) return seconds; } + +int extra_time_offset=0; + /** return the UTC offset in seconds west of UTC, or 0 if it cannot be determined */ @@ -641,7 +644,7 @@ _PUBLIC_ int get_time_zone(time_t t) tm = localtime(&t); if (!tm) return 0; - return tm_diff(&tm_utc,tm); + return tm_diff(&tm_utc,tm)+60*extra_time_offset; } struct timespec nt_time_to_unix_timespec(NTTIME *nt) diff --git a/lib/util/time.h b/lib/util/time.h index 42644a3954..e40de2de3d 100644 --- a/lib/util/time.h +++ b/lib/util/time.h @@ -239,4 +239,7 @@ struct timespec convert_time_t_to_timespec(time_t t); bool null_timespec(struct timespec ts); +/** Extra minutes to add to the normal GMT to local time conversion. */ +extern int extra_time_offset; + #endif /* _SAMBA_TIME_H_ */ -- cgit