SAMBA_CLEANUP_PERIOD=10
}
-
-# autodetect use of winbind if not set in config file
-[ -z "$CTDB_MANAGES_WINBIND" ] && {
+# function to see if ctdb manages winbind
+check_ctdb_manages_winbind() {
+ [ -z "$CTDB_MANAGES_WINBIND" ] && {
secmode=`testparm -s --parameter-name=security 2> /dev/null`
case $secmode in
ADS|DOMAIN)
CTDB_MANAGES_WINBIND="no";
;;
esac
+ }
}
###########################
}
# restart the winbind service
+ check_ctdb_manages_winbind
[ "$CTDB_MANAGES_WINBIND" = "yes" ] && {
service winbind stop > /dev/null 2>&1
killall -0 -q winbindd && {
sleep 1
- # make absolutely sure winbindd is dead
+ # make absolutely sure winbindd is dead
killall -q -9 winbindd
}
service winbind start
service smb stop
# stop the winbind service
+ check_ctdb_manages_winbind
[ "$CTDB_MANAGES_WINBIND" = "yes" ] && {
service winbind stop
}
ctdb_check_tcp_ports "Samba" $smb_ports
# check winbind is OK
+ check_ctdb_manages_winbind
[ "$CTDB_MANAGES_WINBIND" = "yes" ] && {
ctdb_check_command "winbind" "wbinfo -p"
}
The first argument is the "event" and the rest of the arguments depend
on which event was triggered.
+All of the events except the 'shutdown' and 'startrecovery' events will be
+called with the ctdb daemon in NORMAL mode (ie. not in recovery)
+
The events currently implemented are
startup
This event does not take any additional arguments.
Before this event there will always be a 'startrecovery' event.
- This event will always be followed by a 'recovered' event onse
+ This event will always be followed by a 'recovered' event once
all ipaddresses have been reassigned to new nodes and the ctdb database
has been recovered.
If multiple ip addresses are reassigned during recovery it is
static void async_getcap_callback(struct ctdb_context *ctdb, uint32_t node_pnn, int32_t res, TDB_DATA outdata)
{
if ( (outdata.dsize != sizeof(uint32_t)) || (outdata.dptr == NULL) ) {
- DEBUG(DEBUG_ERR, (__location__ " Invalid lenght/pointer for getcap callback : %d %p\n", outdata.dsize, outdata.dptr));
+ DEBUG(DEBUG_ERR, (__location__ " Invalid lenght/pointer for getcap callback : %u %p\n",
+ (unsigned)outdata.dsize, outdata.dptr));
return;
}
ctdb->nodes[node_pnn]->capabilities = *((uint32_t *)outdata.dptr);
DEBUG(DEBUG_NOTICE, (__location__ " Recovery - updated flags\n"));
+ /* disable recovery mode */
+ ret = set_recovery_mode(ctdb, nodemap, CTDB_RECOVERY_NORMAL);
+ if (ret!=0) {
+ DEBUG(DEBUG_ERR, (__location__ " Unable to set recovery mode to normal on cluster\n"));
+ return -1;
+ }
+
+ DEBUG(DEBUG_NOTICE, (__location__ " Recovery - disabled recovery mode\n"));
+
/*
tell nodes to takeover their public IPs
*/
DEBUG(DEBUG_NOTICE, (__location__ " Recovery - finished the recovered event\n"));
- /* disable recovery mode */
- ret = set_recovery_mode(ctdb, nodemap, CTDB_RECOVERY_NORMAL);
- if (ret!=0) {
- DEBUG(DEBUG_ERR, (__location__ " Unable to set recovery mode to normal on cluster\n"));
- return -1;
- }
-
- DEBUG(DEBUG_NOTICE, (__location__ " Recovery - disabled recovery mode\n"));
-
/* send a message to all clients telling them that the cluster
has been reconfigured */
ctdb_send_message(ctdb, CTDB_BROADCAST_CONNECTED, CTDB_SRVID_RECONFIGURE, tdb_null);
{
char *options, *cmdstr;
int ret;
- va_list ap2;
struct stat st;
TALLOC_CTX *tmp_ctx = talloc_new(ctdb);
trbt_tree_t *tree;
struct dirent *de;
char *script;
+ options = talloc_vasprintf(tmp_ctx, fmt, ap);
+ CTDB_NO_MEMORY(ctdb, options);
+
+ if (ctdb->recovery_mode != CTDB_RECOVERY_NORMAL) {
+ /* we guarantee that only some specifically allowed event scripts are run
+ while in recovery */
+ const char *allowed_scripts[] = {"startrecovery", "shutdown" };
+ int i;
+ for (i=0;i<ARRAY_SIZE(allowed_scripts);i++) {
+ if (strcmp(options, allowed_scripts[i]) == 0) break;
+ }
+ if (i == ARRAY_SIZE(allowed_scripts)) {
+ DEBUG(0,("Refusing to run event scripts with option '%s' while in recovery\n",
+ options));
+ }
+ return -1;
+ }
+
if (setpgid(0,0) != 0) {
DEBUG(DEBUG_ERR,("Failed to create process group for event scripts - %s\n",
strerror(errno)));
them
*/
while ((script=trbt_findfirstarray32(tree, 1)) != NULL) {
- va_copy(ap2, ap);
- options = talloc_vasprintf(tmp_ctx, fmt, ap2);
- va_end(ap2);
- CTDB_NO_MEMORY(ctdb, options);
-
cmdstr = talloc_asprintf(tmp_ctx, "%s/%s %s",
ctdb->event_script_dir,
script, options);