DEBUG(DEBUG_INFO,("SET BAN STATE\n"));
if (bantime->pnn != ctdb->pnn) {
- if (bantime->pnn < 0 || bantime->pnn >= ctdb->num_nodes) {
+ if (bantime->pnn >= ctdb->num_nodes) {
DEBUG(DEBUG_ERR,(__location__ " ERROR: Invalid ban request. PNN:%d is invalid. Max nodes %d\n", bantime->pnn, ctdb->num_nodes));
return -1;
}
}
talloc_report_full(NULL, f);
fsize = ftell(f);
+ if (fsize == -1) {
+ DEBUG(DEBUG_ERR, (__location__ " Unable to get file size - %s\n",
+ strerror(errno)));
+ fclose(f);
+ return -1;
+ }
rewind(f);
outdata->dptr = talloc_size(outdata, fsize);
if (outdata->dptr == NULL) {
memset(&addr, 0, sizeof(addr));
addr.sun_family = AF_UNIX;
- strncpy(addr.sun_path, ctdb->daemon.name, sizeof(addr.sun_path));
+ strncpy(addr.sun_path, ctdb->daemon.name, sizeof(addr.sun_path)-1);
/* First check if an old ctdbd might be running */
if (connect(ctdb->daemon.sd,
{
uint32_t priority;
- for (priority=NUM_DB_PRIORITIES; priority>=0; priority--) {
+ for (priority=NUM_DB_PRIORITIES; priority>0; priority--) {
if (ctdb_db_iterator(ctdb, priority, db_lock_unmark_handler, NULL) != 0) {
return -1;
}
}
/* Read the status from the child process */
- read(lock_ctx->fd[0], &c, 1);
- locked = (c == 0 ? true : false);
+ if (read(lock_ctx->fd[0], &c, 1) != 1) {
+ locked = false;
+ } else {
+ locked = (c == 0 ? true : false);
+ }
/* Update statistics */
CTDB_DECREMENT_STAT(lock_ctx->ctdb, locks.num_pending);
void (*callback)(void *, bool),
void *private_data)
{
- if (priority < 0 || priority > NUM_DB_PRIORITIES) {
+ if (priority < 1 || priority > NUM_DB_PRIORITIES) {
DEBUG(DEBUG_ERR, ("Invalid db priority: %u\n", priority));
return NULL;
}
static int syslogd_is_started = 0;
-
/* called when child is finished
* this is for the syslog daemon, we can not use DEBUG here
*/
return;
}
msg = (struct syslog_message *)str;
+ if (msg->len >= (sizeof(str) - offsetof(struct syslog_message, message))) {
+ msg->len = (sizeof(str)-1) - offsetof(struct syslog_message, message);
+ }
+ msg->message[msg->len] = '\0';
syslog(msg->level, "%s", msg->message);
}
do_debug("%*.*s\n", len, len, buf);
}
/* log it in the eventsystem as well */
- if (log->logfn)
+ if (log && log->logfn) {
log->logfn(log->buf, len, log->logfn_private);
+ }
}
}
data2 = tdb_fetch(ctdb_db->ltdb->tdb, key);
if (data2.dptr == NULL || data2.dsize < sizeof(struct ctdb_ltdb_header)) {
- tdb_store(ctdb_db->ltdb->tdb, key, data, 0);
+ if (tdb_store(ctdb_db->ltdb->tdb, key, data, 0) == -1) {
+ DEBUG(DEBUG_ERR, (__location__ "Failed to store record\n"));
+ ret = -1;
+ goto done;
+ }
DEBUG(DEBUG_INFO, (__location__ " Stored record\n"));
ret = 0;
goto done;
continue;
}
/* ok so we need to create this database */
- ctdb_ctrl_getdbname(ctdb, CONTROL_TIMEOUT(), pnn, dbmap->dbs[db].dbid,
- mem_ctx, &name);
+ ret = ctdb_ctrl_getdbname(ctdb, CONTROL_TIMEOUT(), pnn,
+ dbmap->dbs[db].dbid, mem_ctx,
+ &name);
if (ret != 0) {
DEBUG(DEBUG_ERR, (__location__ " Unable to get dbname from node %u\n", pnn));
return -1;
}
- ctdb_ctrl_createdb(ctdb, CONTROL_TIMEOUT(), nodemap->nodes[j].pnn,
- mem_ctx, name,
- dbmap->dbs[db].flags & CTDB_DB_FLAGS_PERSISTENT);
+ ret = ctdb_ctrl_createdb(ctdb, CONTROL_TIMEOUT(),
+ nodemap->nodes[j].pnn,
+ mem_ctx, name,
+ dbmap->dbs[db].flags & CTDB_DB_FLAGS_PERSISTENT);
if (ret != 0) {
DEBUG(DEBUG_ERR, (__location__ " Unable to create remote db:%s\n", name));
return -1;
/* send a message to all clients telling them that the cluster
has been reconfigured */
- ctdb_client_send_message(ctdb, CTDB_BROADCAST_CONNECTED, CTDB_SRVID_RECONFIGURE, tdb_null);
+ ret = ctdb_client_send_message(ctdb, CTDB_BROADCAST_CONNECTED,
+ CTDB_SRVID_RECONFIGURE, tdb_null);
+ if (ret != 0) {
+ DEBUG(DEBUG_ERR, (__location__ " Failed to send reconfigure message\n"));
+ return -1;
+ }
DEBUG(DEBUG_NOTICE, (__location__ " Recovery complete\n"));
/* send an election message to all active nodes */
DEBUG(DEBUG_INFO,(__location__ " Send election request to all active nodes\n"));
- ctdb_client_send_message(ctdb, CTDB_BROADCAST_ALL, srvid, election_data);
-
- return 0;
+ return ctdb_client_send_message(ctdb, CTDB_BROADCAST_ALL, srvid, election_data);
}
/*
for (i=0;i<nodemap->num;i++) {
if ( (!(nodemap->nodes[i].flags & NODE_FLAGS_DISCONNECTED))
&& (nodemap->nodes[i].flags & NODE_FLAGS_BANNED) ) {
- ctdb_ctrl_modflags(ctdb, CONTROL_TIMEOUT(), nodemap->nodes[i].pnn, 0, NODE_FLAGS_BANNED);
+ ret = ctdb_ctrl_modflags(ctdb, CONTROL_TIMEOUT(),
+ nodemap->nodes[i].pnn, 0,
+ NODE_FLAGS_BANNED);
+ if (ret != 0) {
+ DEBUG(DEBUG_ERR, (__location__ " failed to reset ban state\n"));
+ }
}
}
DEBUG(DEBUG_ERR,(__location__ " Wrong size for data :%lu "
"expecting %lu\n", (long unsigned)data.dsize,
(long unsigned)sizeof(struct srvid_request)));
- ret = -EINVAL;
- goto done;
+ return;
}
if (data.dptr == NULL) {
DEBUG(DEBUG_ERR,(__location__ " No data received\n"));
- ret = -EINVAL;
- goto done;
+ return;
}
r = (struct srvid_request *)data.dptr;
if (vnn->iface == cur) {
info->active_idx = i;
}
- strcpy(info->ifaces[i].name, cur->name);
+ strncpy(info->ifaces[i].name, cur->name, sizeof(info->ifaces[i].name)-1);
info->ifaces[i].link_state = cur->link_up;
info->ifaces[i].references = cur->references;
}