The inability to use a token is quite artificial.
TAILQ_INSERT_TAIL(priv, root, next);
root->el = json_object();
if (root->el == NULL)
- fatalx("cannot create JSON root object");
+ fatalx("lldpctl", "cannot create JSON root object");
result = malloc(sizeof(*result));
if (result == NULL) fatal(NULL, NULL);
TAILQ_INSERT_TAIL(priv, root, next);
root->el = json_object_new_object();
if (root->el == NULL)
- fatalx("cannot create JSON root object");
+ fatalx("lldpctl", "cannot create JSON root object");
result = malloc(sizeof(*result));
if (result == NULL) fatal(NULL, NULL);
priv = malloc(sizeof(*priv));
if (!priv) {
- fatalx("out of memory");
+ fatalx("lldpctl", "out of memory");
return NULL;
}
result = malloc(sizeof(struct writer));
if (!result) {
- fatalx("out of memory");
+ fatalx("llpctl", "out of memory");
free(priv);
return NULL;
}
priv = malloc( sizeof( *priv ) );
if ( ! priv ) {
- fatalx("out of memory");
+ fatalx("lldpctl", "out of memory");
return NULL;
}
priv->xw = xmlNewTextWriterDoc(&(priv->doc), 0);
if ( ! priv->xw ) {
- fatalx("cannot create xml writer");
+ fatalx("lldpctl", "cannot create xml writer");
return NULL;
}
xmlTextWriterSetIndent(priv->xw, 4);
if (xmlTextWriterStartDocument(priv->xw, NULL, MY_ENCODING, NULL) < 0 ) {
- fatalx("cannot start xml document");
+ fatalx("lldpctl", "cannot start xml document");
return NULL;
}
result = malloc( sizeof( struct writer ) );
if ( ! result ) {
- fatalx("out of memory");
+ fatalx("lldpctl", "out of memory");
return NULL;
}
log_debug("event", "initialize libevent");
event_set_log_callback(levent_log_cb);
if (!(cfg->g_base = event_base_new()))
- fatalx("unable to create a new libevent base");
+ fatalx("event", "unable to create a new libevent base");
log_info("event", "libevent %s initialized with %s method",
event_get_version(),
event_base_get_method(cfg->g_base));
levent_snmp_timeout,
cfg);
if (!cfg->g_snmp_timeout)
- fatalx("unable to setup timeout function for SNMP");
+ fatalx("event", "unable to setup timeout function for SNMP");
if ((cfg->g_snmp_fds =
malloc(sizeof(struct ev_l))) == NULL)
- fatalx("unable to allocate memory for SNMP events");
+ fatalx("event", "unable to allocate memory for SNMP events");
TAILQ_INIT(levent_snmp_fds(cfg));
}
#endif
if (!(cfg->g_main_loop = event_new(cfg->g_base, -1, 0,
levent_update_and_send,
cfg)))
- fatalx("unable to setup main timer");
+ fatalx("event", "unable to setup main timer");
event_active(cfg->g_main_loop, EV_TIMEOUT, 1);
/* Setup unix socket */
levent_make_socket_nonblocking(cfg->g_ctl);
if ((ctl_event = event_new(cfg->g_base, cfg->g_ctl,
EV_READ|EV_PERSIST, levent_ctl_accept, cfg)) == NULL)
- fatalx("unable to setup control socket event");
+ fatalx("event", "unable to setup control socket event");
event_add(ctl_event, NULL);
/* Signals */
/* Another instance is running */
close(tfd);
log_warnx("main", "another instance is running, please stop it");
- fatalx("giving up");
+ fatalx("main", "giving up");
} else if (errno == ECONNREFUSED) {
/* Nobody is listening */
log_info("main", "old control socket is present, clean it");
continue;
}
log_warn("main", "cannot determine if another daemon is already running");
- fatalx("giving up");
+ fatalx("main", "giving up");
}
log_warn("main", "unable to create control socket");
- fatalx("giving up");
+ fatalx("main", "giving up");
}
#ifdef ENABLE_PRIVSEP
if (chown(ctlname, uid, gid) == -1)
/* Kill children and exit */
kill(monitored, SIGTERM);
- fatalx("invalid syscall not allowed: stop here");
+ fatalx("seccomp", "invalid syscall not allowed: stop here");
_exit(161);
}
}
}
if (a->function == NULL)
- fatal("privsep", "bogus message received");
+ fatalx("privsep", "bogus message received");
if (once) break;
}
}
}
void
-fatalx(const char *emsg)
+fatalx(const char *token, const char *emsg)
{
errno = 0;
- fatal(NULL, emsg);
+ fatal(token, emsg);
}
void log_info(const char *, const char *, ...) __attribute__ ((format (printf, 2, 3)));
void log_debug(const char *, const char *, ...) __attribute__ ((format (printf, 2, 3)));
void fatal(const char*, const char *) __attribute__((__noreturn__));
-void fatalx(const char *) __attribute__((__noreturn__));
+void fatalx(const char *, const char *) __attribute__((__noreturn__));
void log_register(void (*cb)(int, const char*));
void log_accept(const char *);