summaryrefslogtreecommitdiff
path: root/ctdb/server/eventscript.c
AgeCommit message (Collapse)AuthorFilesLines
2026-02-25ctdb-daemon: Remove helper variable CTDB_EVENTDMartin Schwenke1-8/+1
Simplify the initialisation of the path to eventd in eventd_context using path_helperdir_append(). Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Anoop C S <anoopcs@samba.org>
2024-03-06ctdb-daemon: Implement startipreallocate eventVinit Agnihotri1-0/+2
Signed-off-by: Vinit Agnihotri <vagnihotri@ddn.com> Reviewed-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Volker Lendecke <vl@samba.org>
2024-03-06ctdb-daemon: Use ctdb_event_to_string()Martin Schwenke1-5/+5
ctdb_eventscript_call_names() will be dropped so the mapping between events and strings is only maintained in one place. Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Volker Lendecke <vl@samba.org>
2022-05-31ctdb-daemon: Remove unused #includes of rb_tree.hMartin Schwenke1-1/+0
ctdb_takeover.c and eventscript.c no longer use this. ipalloc_common.c has never used it. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2022-01-17ctdb-daemon: Enable log reopening for event daemonMartin Schwenke1-0/+7
Add and call hook to pass on SIGHUP to eventd. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2019-07-05ctdb-daemon: Fix signed/unsigned comparisons by declaring as unsignedMartin Schwenke1-1/+1
Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2018-10-22ctdb-daemon: Fix valgrind hit in event codeMartin Schwenke1-1/+1
==25741== Syscall param write(buf) points to uninitialised byte(s) ==25741== at 0x4939291: write (write.c:27) ==25741== by 0x4868285: sys_write (sys_rw.c:68) ==25741== by 0x13915D: sock_queue_trigger (sock_io.c:316) ==25741== by 0x4DE6478: tevent_common_invoke_immediate_handler (in /usr/lib/x86_64-linux-gnu/libtevent.so.0.9.37) ==25741== by 0x4DE64A2: tevent_common_loop_immediate (in /usr/lib/x86_64-linux-gnu/libtevent.so.0.9.37) ==25741== by 0x4DEBE5A: ??? (in /usr/lib/x86_64-linux-gnu/libtevent.so.0.9.37) ==25741== by 0x4DEA2D6: ??? (in /usr/lib/x86_64-linux-gnu/libtevent.so.0.9.37) ==25741== by 0x4DE57E3: _tevent_loop_once (in /usr/lib/x86_64-linux-gnu/libtevent.so.0.9.37) ==25741== by 0x15D1BA: ctdb_event_script_args (eventscript.c:821) ==25741== by 0x13B437: ctdb_start_daemon (ctdb_daemon.c:1315) ==25741== by 0x110642: main (ctdbd.c:393) ==25741== Address 0x57888a4 is 100 bytes inside a block of size 144 alloc'd ==25741== at 0x48357BF: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==25741== by 0x4B9B7C0: talloc_named_const (in /usr/lib/x86_64-linux-gnu/libtalloc.so.2.1.14) ==25741== by 0x15CCC6: eventd_client_write (eventscript.c:430) ==25741== by 0x15CCC6: eventd_client_run (eventscript.c:556) ==25741== by 0x15CCC6: ctdb_event_script_run (eventscript.c:649) ==25741== by 0x15D198: ctdb_event_script_args (eventscript.c:812) ==25741== by 0x13B437: ctdb_start_daemon (ctdb_daemon.c:1315) ==25741== by 0x110642: main (ctdbd.c:393) ==25741== BUG: https://bugzilla.samba.org/show_bug.cgi?id=13659 Pair-programmed-with: Amitay Isaacs <amitay@gmail.com> Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com> Autobuild-User(master): Amitay Isaacs <amitay@samba.org> Autobuild-Date(master): Mon Oct 22 09:27:15 CEST 2018 on sn-devel-144
2018-10-22ctdb-daemon: Exit if eventd goes awayMartin Schwenke1-7/+2
ctdbd enters a broken state if eventd goes away. A clean shutdown is not possible because that involves running events. Restarting eventd is possible but this might mask a serious problem and it is possible that eventd might keep on disappearing. Just exit. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13659 Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2018-10-22ctdb-daemon: Return early when refusing to run an event scriptMartin Schwenke1-0/+1
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13659 Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2018-09-03ctdb-daemon: Log complete eventd startup commandMartin Schwenke1-2/+6
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13592 Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2018-08-30ctdb-daemon: Do not retry connection to eventdMartin Schwenke1-11/+3
Confirmation is now received from eventd that it is accepting connections, so this is no longer needed. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13592 Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2018-08-30ctdb-daemon: Wait for eventd to be ready before connectingMartin Schwenke1-3/+107
The current method of retrying the connection to eventd means that messages get logged for each failure. Instead, pass a pipe file descriptor to eventd and wait for it to write 0 to the pipe to indicate that it is ready to accept client connections. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13592 Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2018-08-30ctdb-daemon: Open eventd pipe earlierMartin Schwenke1-5/+9
The pipe will soon be needed earlier, so initialise it earlier. Ensure the file descriptors are closed on error. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13592 Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2018-08-30ctdb-daemon: Improve error handling consistencyMartin Schwenke1-0/+1
Other errors free argv, so do it here too. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13592 Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2018-07-28ctdb-daemon: Switch to using ETIMEDOUT instead of ETIMEAmitay Isaacs1-2/+2
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13520 Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
2018-07-05ctdb-daemon: Add client code to talk to new event daemonAmitay Isaacs1-22/+24
This fixes the build and now new eventd is integrated completely in CTDB. Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
2018-07-05ctdb-daemon: Switch to starting new event daemonAmitay Isaacs1-59/+9
From this patch onwards, CTDB daemon is broken till the client code for new eventd is integrated. This requires getting rid of the old eventd protocol and client code and then switching to the new eventd protocol and client code. Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
2017-09-01ctdb-protocol: Replace ctdb_event_header with sock_packet_headerAmitay Isaacs1-1/+2
This removes the static declaration and adds prototype declarations of ctdb_event_header marshalling functions to avoid compiler warnings. These functions will be removed. Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
2017-08-17ctdb-daemon: Fix a return valueMartin Schwenke1-1/+1
Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2017-02-17ctdb-daemon: Use sock_clean() to remove stale socketsAmitay Isaacs1-6/+1
Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net> Autobuild-User(master): Martin Schwenke <martins@samba.org> Autobuild-Date(master): Fri Feb 17 14:45:10 CET 2017 on sn-devel-144
2017-01-17ctdb-daemon: Remove stale eventd socketAmitay Isaacs1-0/+9
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12513 Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net> Autobuild-User(master): Martin Schwenke <martins@samba.org> Autobuild-Date(master): Tue Jan 17 15:00:15 CET 2017 on sn-devel-144
2016-12-18ctdb-daemon: Switch to using event daemonAmitay Isaacs1-818/+27
Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
2016-12-18ctdb-daemon: Add functions to talk to event daemonAmitay Isaacs1-0/+587
Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
2016-12-18ctdb-daemon: Refactor check for valid events during recoveryAmitay Isaacs1-20/+27
Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
2016-12-18ctdb-daemon: Drop implementation of eventscript controlsAmitay Isaacs1-233/+0
Following controls are now implemented by event daemon - RUN_EVENTSCRIPTS - GET_EVENT_SCRIPT_STATUS - ENABLE_SCRIPT - DISABLE_SCRIPT Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
2016-11-29ctdb-common: Drop CTDB's copy of sys_read() and sys_write()Martin Schwenke1-1/+1
Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com> Autobuild-User(master): Amitay Isaacs <amitay@samba.org> Autobuild-Date(master): Tue Nov 29 11:22:40 CET 2016 on sn-devel-144
2016-09-01ctdb-daemon: Don't steal control structure before synchronous replyMartin Schwenke1-2/+2
If *async_reply isn't set then the calling code will reply to the control and free the control structure. In some places the control structure pointer is stolen onto state before a synchronous exit due to an error condition. The error handling then frees state and returns an error. The calling code will access-after-free when trying to reply to the control. To make this easier to understand, the convention is that any (immediate) error results in a synchronous reply to the control via an error return code AND *async_reply not being set. In this case the control structure pointer should never be stolen onto state. State is never used for a synchronous reply, it is only ever used by a callback. Also initialise state->c to NULL so that any premature call to a callback (e.g. in an immediate error path) is more obvious. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12180 Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-09-01ctdb-daemon: Handle failure immediately, do housekeeping laterMartin Schwenke1-10/+9
The callback should never be called before an immediate return. The callback might reply to a control and the caller of ctdb_event_script_callback_v() may not have assigned/stolen the pointer to control structure into the private data. Therefore, calling the callback can dereference an uninitialised pointer to the control structure when attempting to reply. An event script isn't being run until the child has been forked. So update relevant state and set the destructor after this. If the child can't be forked then free the state and return with an error. The callback will not be called and the caller will process the error correctly. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12180 Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-09-01ctdb-daemon: Schedule running of callback if there are no event scriptsMartin Schwenke1-1/+63
The callback should never be called before an immediate return. The callback might reply to a control and the caller of ctdb_event_script_callback_v() may not have assigned/stolen the pointer to control structure into the private data. Therefore, calling the callback can dereference an uninitialised pointer to the control structure when attempting to reply. ctdb_event_script_callback_v() must succeed when there are no event scripts. On success the caller will mark the call as asynchronous and expect the callback to be called. Given that it can't be called before return then it needs to be scheduled. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12180 Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-08-10ctdb-daemon: Fix format-nonliteral warningAmitay Isaacs1-0/+8
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12137 Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Uri Simchoni <uri@samba.org>
2016-06-01ctdb:eventscript: timedout->timed out in ctdb_event_script_args()Michael Adam1-1/+1
Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2015-11-16ctdb-daemon: Reset script timeout count in monitor codeMartin Schwenke1-1/+0
This is the only place it is used. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-11-16ctdb-daemon: Do not bother printing script timeout countMartin Schwenke1-2/+2
It is only updated for monitor events, so it is meaningless here. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-11-16ctdb-server: Replace ctdb_logging.h with common/logging.hAmitay Isaacs1-1/+1
Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Michael Adam <obnox@samba.org>
2015-11-04ctdb-daemon: Rename struct ctdb_req_control to ctdb_req_control_oldAmitay Isaacs1-2/+2
Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
2015-11-04ctdb-daemon: Rename enum ctdb_eventscript_call to ctdb_eventAmitay Isaacs1-12/+12
Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
2015-11-04ctdb-daemon: Rename struct ctdb_scripts_wire to ctdb_script_list_oldAmitay Isaacs1-4/+6
Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
2015-11-04ctdb-daemon: Rename struct ctdb_script_wire to ctdb_scriptAmitay Isaacs1-7/+7
Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
2015-10-30ctdb-daemon: Separate prototypes for common client/server functionsAmitay Isaacs1-0/+1
This groups function prototypes for common client/server functions in common/common.h and removes them from ctdb_private.h. Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
2015-10-30ctdb-daemon: Remove dependency on includes.hAmitay Isaacs1-4/+15
Instead of includes.h, include the required header files explicitly. Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
2015-10-30ctdb-daemon: Stop using tevent compatibility definitionsAmitay Isaacs1-9/+17
Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
2015-10-30ctdb-daemon: Separate prototypes for system specific functionsAmitay Isaacs1-0/+1
This groups function prototypes for system specific functions in common/system.h and removes them from ctdb_private.h. Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
2015-07-14ctdb-daemon: Allow a new monitor event to cancel one already in progressMartin Schwenke1-2/+6
Before commit cbffbb7c2f406fc1d8ebad3c531cc2757232690e this was possible and some users depend on this behaviour. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-07-14ctdb-daemon: Improve error messages when eventscript control is cancelledMartin Schwenke1-2/+11
Warn specifically about cancellation instead of printing a generic error message. Also pass back an error message for the tool - it could just rely on the status but it already looks at the error message. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-07-14ctdb-daemon: Avoid double-free during monitor cancellationAmitay Isaacs1-1/+1
The eventscript state should never be freed externally, so it should never be allocated off a temporary context. It will either be freed by the handler or in the cancellation code. Signed-off-by: Amitay Isaacs <amitay@gmail.com> Pair-programmed-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Martin Schwenke <martin@meltin.net>
2015-05-10ctdb-daemon: Initialise eventscript status earlierMartin Schwenke1-4/+4
Don't initialise it after ctdb_event_script_callback_v() may have short-circuited. This can stop ctdb_event_script_args() from ever terminating. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-05-10ctdb-daemon: Make ctdb_event_script_args() terminate if no scriptsMartin Schwenke1-0/+1
status.done is never set to true unless event_script_callback() is invoked. The short-circuit in ctdb_event_script_callback_v() means that this doesn't happen. CTDB can't work very well without 00.ctdb (for tunable initialisation and the like) but it shouldn't get stuck. So call the callback when there are no scripts in event_script_callback(). Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-03-13ctdb: Fix CID 1125613 Destination buffer too smallVolker Lendecke1-1/+7
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Michael Adam <obnox@samba.org> Autobuild-User(master): Michael Adam <obnox@samba.org> Autobuild-Date(master): Fri Mar 13 19:14:20 CET 2015 on sn-devel-104
2015-03-13ctdb: Introduce a helper var in ctdb_get_script_listVolker Lendecke1-3/+5
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
2015-03-13ctdb: Fix memleak in ctdb_get_script_listVolker Lendecke1-2/+5
scandir allocates every name individually, see example code in susv4 or man scandir Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>