Finalize refactor to new log macros, following-up to 37e3be9

This possible also mitigates the issue tracked in #307.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2022-10-09 12:52:40 +02:00
1 parent dc547317c9
commit d22dea74e3
30 files changed
+358 -353

No files matched your search

+4 -4
View File
@@ -36,12 +36,12 @@
static void save(void *arg)
{
if (rescue) {
_d("Skipping %s plugin in rescue mode.", __FILE__);
dbg("Skipping %s plugin in rescue mode.", __FILE__);
return;
}
if (whichp(ALSACTL)) {
_d("Saving sound settings ...");
dbg("Saving sound settings ...");
run_interactive(ALSACTL " -g store", "Saving sound settings");
}
}
@@ -49,12 +49,12 @@ static void save(void *arg)
static void restore(void *arg)
{
if (rescue) {
_d("Skipping %s plugin in rescue mode.", __FILE__);
dbg("Skipping %s plugin in rescue mode.", __FILE__);
return;
}
if (whichp(ALSACTL)) {
_d("Restoring sound settings ...");
dbg("Restoring sound settings ...");
run_interactive(ALSACTL " -g restore", "Restoring sound settings");
}
}
+6 -6
View File
@@ -80,7 +80,7 @@ static int bootclean(const char *fpath, const struct stat *sb, int tflag, struct
if (ftw->level == 0)
return 1;
_d("Removing %s ...", fpath);
dbg("Removing %s ...", fpath);
(void)remove(fpath);
return 0;
@@ -113,7 +113,7 @@ static void clean(void *arg)
static void ln(const char *target, const char *linkpath)
{
if (symlink(target, linkpath) && errno != EEXIST)
_pe("Failed creating %s -> %s symlink", target, linkpath);
err(1, "Failed creating %s -> %s symlink", target, linkpath);
}
/* Kernel defines the following compulsory and recommended links
@@ -164,7 +164,7 @@ static void setup(void *arg)
prev = umask(0);
_d("Setting up FHS structure in /var ...");
dbg("Setting up FHS structure in /var ...");
makedir("/var/cache", 0755);
makedir("/var/db", 0755); /* _PATH_VARDB on some systems */
makedir("/var/games", 0755);
@@ -173,7 +173,7 @@ static void setup(void *arg)
makedir("/var/lib/alarm", 0755);
makedir("/var/lib/urandom",0755);
if (fisdir("/run")) {
_d("System with new /run tmpfs ...");
dbg("System with new /run tmpfs ...");
if (!fisdir("/run/lock"))
makedir("/run/lock", 1777);
ln("/run/lock", "/var/lock");
@@ -203,7 +203,7 @@ static void setup(void *arg)
* If /etc/group or "utmp" group is missing, default to
* "root", or "wheel", group.
*/
_d("Setting up necessary UTMP files ...");
dbg("Setting up necessary UTMP files ...");
gid = getgroup("utmp");
if (gid < 0)
gid = 0;
@@ -223,7 +223,7 @@ static void setup(void *arg)
erase("/etc/network/run/ifstate");
#endif
_d("Setting up misc files ...");
dbg("Setting up misc files ...");
makedir("/var/run/network",0755); /* Needed by Debian/Ubuntu ifupdown */
makedir("/var/run/lldpd", 0755); /* Needed by lldpd */
makedir("/var/run/pluto", 0755); /* Needed by Openswan */
+4 -4
View File
@@ -58,19 +58,19 @@ static void setup(void *arg)
char *cmd;
if (rescue) {
_d("Skipping %s plugin in rescue mode.", __FILE__);
dbg("Skipping %s plugin in rescue mode.", __FILE__);
return;
}
cmd = which(DBUS_DAEMON);
if (!cmd) {
_d("Skipping plugin, %s is not installed.", DBUS_DAEMON);
dbg("Skipping plugin, %s is not installed.", DBUS_DAEMON);
return;
}
prev =umask(0);
_d("Creating D-Bus Required Directories ...");
dbg("Creating D-Bus Required Directories ...");
mksubsys("/var/run/dbus", 0755, DBUS_DAEMONUSER, DBUS_DAEMONGROUP);
mksubsys("/var/run/lock/subsys", 0755, DBUS_DAEMONUSER, DBUS_DAEMONGROUP);
mksubsys("/var/lib/dbus", 0755, DBUS_DAEMONUSER, DBUS_DAEMONGROUP);
@@ -87,7 +87,7 @@ static void setup(void *arg)
snprintf(line, sizeof(line), "[S12345789] cgroup.system pid:!%s @%s:%s %s %s -- %s",
DBUS_DAEMONPIDFILE, DBUS_DAEMONUSER, DBUS_DAEMONGROUP, cmd, DBUS_ARGS, DBUS_DESC);
if (service_register(SVC_TYPE_SERVICE, line, global_rlimit, NULL))
_pe("Failed registering %s", DBUS_DAEMON);
err(1, "Failed registering %s", DBUS_DAEMON);
free(cmd);
umask(prev);
+2 -2
View File
@@ -35,7 +35,7 @@ static void setup(void *arg)
char *path;
if (rescue) {
_d("Skipping %s plugin in rescue mode.", __FILE__);
dbg("Skipping %s plugin in rescue mode.", __FILE__);
return;
}
@@ -64,7 +64,7 @@ static void setup(void *arg)
snprintf(cmd, sizeof(cmd), "[S12345789] cgroup.system pid:udevd name:udevd log %s "
"-- Device event managing daemon", path);
if (service_register(SVC_TYPE_SERVICE, cmd, global_rlimit, NULL)) {
_pe("Failed registering %s", path);
err(1, "Failed registering %s", path);
} else {
snprintf(cmd, sizeof(cmd), "cgroup.init :1 [S] <pid/udevd> log "
"udevadm trigger -c add -t devices "
+3 -3
View File
@@ -61,13 +61,13 @@ static void setup(void *arg)
FILE *fp;
if (rescue) {
_d("Skipping %s plugin in rescue mode.", __FILE__);
dbg("Skipping %s plugin in rescue mode.", __FILE__);
return;
}
cmd = which(MDEVD_DAEMON);
if (!cmd) {
_d("Skipping plugin, %s is not installed.", MDEVD_DAEMON);
dbg("Skipping plugin, %s is not installed.", MDEVD_DAEMON);
return;
}
@@ -91,7 +91,7 @@ static void setup(void *arg)
snprintf(line, sizeof(line), "[S12345789] cgroup.system pid:!%s @%s:%s %s %s -- %s",
MDEVD_DAEMONPIDFILE, MDEVD_DAEMONUSER, MDEVD_DAEMONGROUP, cmd, MDEVD_ARGS, MDEVD_DESC);
if (service_register(SVC_TYPE_SERVICE, line, global_rlimit, NULL))
_pe("Failed registering %s", MDEVD_DAEMON);
err(1, "Failed registering %s", MDEVD_DAEMON);
free(cmd);
umask(prev);
+2 -2
View File
@@ -71,14 +71,14 @@ static int modprobe(char *alias)
pid = fork();
switch (pid) {
case -1:
_pe("Failed forking modprobe child");
err(1, "Failed forking modprobe child");
return 1;
case 0:
execvp(args[0], args);
break;
default:
if (!complete(args[0], pid))
_d("Successful modprobe of %s", alias);
dbg("Successful modprobe of %s", alias);
break;
}
+1 -1
View File
@@ -142,7 +142,7 @@ static void load(void *arg)
int index = 1;
int i, num;
_d("Scanning " MODULES_LOAD_PATH " for config files ...");
dbg("Scanning " MODULES_LOAD_PATH " for config files ...");
num = scandir(MODULES_LOAD_PATH, &dentry, module_filter, alphasort);
if (num > 0) {
for (i = 0; i < num; i++) {
+35 -35
View File
@@ -62,7 +62,7 @@ static void nl_route(struct nlmsghdr *nlmsg, ssize_t len)
int la;
if (nlmsg->nlmsg_len < NLMSG_LENGTH(sizeof(struct rtmsg))) {
_e("Packet too small or truncated!");
errx(1, "Packet too small or truncated!");
return;
}
@@ -70,7 +70,7 @@ static void nl_route(struct nlmsghdr *nlmsg, ssize_t len)
a = RTM_RTA(r);
la = RTM_PAYLOAD(nlmsg);
if (la >= len) {
_e("Packet too large!");
errx(1, "Packet too large!");
return;
}
@@ -80,18 +80,18 @@ static void nl_route(struct nlmsghdr *nlmsg, ssize_t len)
switch (a->rta_type) {
case RTA_GATEWAY:
gw = *((int *)data);
//_d("GW: 0x%04x", gw);
//dbg("GW: 0x%04x", gw);
break;
case RTA_DST:
dst = *((int *)data);
plen = r->rtm_dst_len;
//_d("Prefix LEN: 0x%04x", plen);
//dbg("Prefix LEN: 0x%04x", plen);
break;
case RTA_OIF:
idx = *((int *)data);
//_d("IDX: 0x%04x", idx);
//dbg("IDX: 0x%04x", idx);
break;
}
@@ -102,7 +102,7 @@ static void nl_route(struct nlmsghdr *nlmsg, ssize_t len)
ing.s_addr = gw;
inet_ntop(AF_INET, &ind, daddr, sizeof(daddr));
inet_ntop(AF_INET, &ing, gaddr, sizeof(gaddr));
_d("Got gw %s dst/len %s/%d ifindex %d", gaddr, daddr, plen, idx);
dbg("Got gw %s dst/len %s/%d ifindex %d", gaddr, daddr, plen, idx);
if ((!dst && !plen) && (gw || idx)) {
if (nlmsg->nlmsg_type == RTM_DELROUTE) {
@@ -167,7 +167,7 @@ static void nl_link(struct nlmsghdr *nlmsg, ssize_t len)
int la;
if (nlmsg->nlmsg_len < NLMSG_LENGTH(sizeof(struct ifinfomsg))) {
_e("Packet too small or truncated!");
errx(1, "Packet too small or truncated!");
return;
}
@@ -175,7 +175,7 @@ static void nl_link(struct nlmsghdr *nlmsg, ssize_t len)
a = (struct rtattr *)((char *)i + NLMSG_ALIGN(sizeof(struct ifinfomsg)));
la = NLMSG_PAYLOAD(nlmsg, sizeof(struct ifinfomsg));
if (la >= len) {
_e("Packet too large!");
errx(1, "Packet too large!");
return;
}
@@ -185,7 +185,7 @@ static void nl_link(struct nlmsghdr *nlmsg, ssize_t len)
strlcpy(ifname, RTA_DATA(a), sizeof(ifname));
if (validate_ifname(ifname)) {
_d("Invalid interface name '%s', skipping ...", ifname);
dbg("Invalid interface name '%s', skipping ...", ifname);
continue;
}
@@ -195,7 +195,7 @@ static void nl_link(struct nlmsghdr *nlmsg, ssize_t len)
* New interface has appeared, or interface flags has changed.
* Check ifi_flags here to see if the interface is UP/DOWN
*/
_d("%s: New link, flags 0x%x, change 0x%x", ifname, i->ifi_flags, i->ifi_change);
dbg("%s: New link, flags 0x%x, change 0x%x", ifname, i->ifi_flags, i->ifi_change);
net_cond_set(ifname, "exist", 1);
net_cond_set(ifname, "up", i->ifi_flags & IFF_UP);
net_cond_set(ifname, "running", i->ifi_flags & IFF_RUNNING);
@@ -205,7 +205,7 @@ static void nl_link(struct nlmsghdr *nlmsg, ssize_t len)
case RTM_DELLINK:
/* NOTE: Interface has disappeared, not link down ... */
_d("%s: Delete link", ifname);
dbg("%s: Delete link", ifname);
net_cond_set(ifname, "exist", 0);
net_cond_set(ifname, "up", 0);
net_cond_set(ifname, "running", 0);
@@ -213,15 +213,15 @@ static void nl_link(struct nlmsghdr *nlmsg, ssize_t len)
break;
case RTM_NEWADDR:
_d("%s: New Address", ifname);
dbg("%s: New Address", ifname);
break;
case RTM_DELADDR:
_d("%s: Deconfig Address", ifname);
dbg("%s: Deconfig Address", ifname);
break;
default:
_d("%s: Msg 0x%x", ifname, nlmsg->nlmsg_type);
dbg("%s: Msg 0x%x", ifname, nlmsg->nlmsg_type);
break;
}
}
@@ -246,46 +246,46 @@ static int nl_parse(int sd)
break;
default:
_pe("recv()");
err(1, "recv()");
break;
}
return -1;
}
// _d("recv %zd bytes", len);
// dbg("recv %zd bytes", len);
l = (size_t)len;
for (nh = (struct nlmsghdr *)nl_buf; NLMSG_OK(nh, l); nh = NLMSG_NEXT(nh, l)) {
struct nlmsgerr *nle;
switch (nh->nlmsg_type) {
case NLMSG_DONE:
// _d("Done with netlink messages.");
// dbg("Done with netlink messages.");
return 0;
case NLMSG_ERROR:
// _d("Kernel netlink comm. error.");
// dbg("Kernel netlink comm. error.");
nle = NLMSG_DATA(nh);
if (nle) {
errno = -nle->error;
_pe("Kernel netlink error %d", errno);
err(1, "Kernel netlink error %d", errno);
}
return -1;
case RTM_NEWROUTE:
case RTM_DELROUTE:
// _d("Netlink route ...");
// dbg("Netlink route ...");
nl_route(nh, len);
break;
case RTM_NEWLINK:
case RTM_DELLINK:
// _d("Netlink link ...");
// dbg("Netlink link ...");
nl_link(nh, len);
break;
default:
_w("unhandled netlink message, type %d", nh->nlmsg_type);
warnx("unhandled netlink message, type %d", nh->nlmsg_type);
break;
}
}
@@ -304,21 +304,21 @@ static int nl_request(int sd, unsigned int seq, int type)
switch (type) {
case RTM_GETROUTE:
// _d("RTM_GETROUTE");
// dbg("RTM_GETROUTE");
nlr->rtm.rtm_family = AF_INET;
nlr->rtm.rtm_table = RT_TABLE_MAIN;
nlr->nh.nlmsg_len = NLMSG_LENGTH(sizeof(struct rtmsg));
break;
case RTM_GETLINK:
// _d("RTM_GETLINK");
// dbg("RTM_GETLINK");
nlr->ifi.ifi_family = AF_UNSPEC;
nlr->ifi.ifi_change = 0xFFFFFFFF;
nlr->nh.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifinfomsg));
break;
default:
_w("Cannot resync, unhandled message type %d", type);
warnx("Cannot resync, unhandled message type %d", type);
return -1;
}
@@ -331,13 +331,13 @@ static int nl_request(int sd, unsigned int seq, int type)
static void nl_resync_routes(int sd, unsigned int seq)
{
if (nl_request(sd, seq, RTM_GETROUTE))
_pe("Failed netlink route request");
err(1, "Failed netlink route request");
}
static void nl_resync_ifaces(int sd, unsigned int seq)
{
if (nl_request(sd, seq, RTM_GETLINK))
_pe("Failed netlink link request");
err(1, "Failed netlink link request");
}
/*
@@ -350,12 +350,12 @@ static void nl_resync(int all)
sd = socket(AF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE);
if (sd < 0) {
_pe("netlink socket");
err(1, "netlink socket");
return;
}
if (all) {
_d("============================ RESYNC =================================");
dbg("============================ RESYNC =================================");
/* this doesn't update conditions, and thus does not stop services */
cond_deassert("net/");
@@ -364,7 +364,7 @@ static void nl_resync(int all)
/* delayed update after we've corrected things */
service_step_all(SVC_TYPE_ANY);
_d("=========================== RESYNCED ================================");
dbg("=========================== RESYNCED ================================");
} else
nl_resync_routes(sd, seq++);
@@ -375,7 +375,7 @@ static void nl_callback(void *arg, int sd, int events)
{
if (nl_parse(sd) < 0) {
if (errno == ENOBUFS) { /* netlink(7) */
_w("busy system, resynchronizing with kernel.");
warnx("busy system, resynchronizing with kernel.");
nl_resync(1);
return;
}
@@ -386,7 +386,7 @@ static void nl_callback(void *arg, int sd, int events)
* we need to check ourselves, e.g. for loss of default route.
*/
if (nl_ifdown) {
_d("interface down, checking default route.");
dbg("interface down, checking default route.");
if (nl_defidx > 0) {
nl_defidx = 0;
nl_resync(0);
@@ -421,7 +421,7 @@ PLUGIN_INIT(plugin_init)
sd = socket(AF_NETLINK, SOCK_RAW | SOCK_NONBLOCK | SOCK_CLOEXEC, NETLINK_ROUTE);
if (sd < 0) {
_pe("socket()");
err(1, "socket()");
return;
}
@@ -431,14 +431,14 @@ PLUGIN_INIT(plugin_init)
sa.nl_pid = getpid();
if (bind(sd, (struct sockaddr *)&sa, sizeof(sa)) < 0) {
_pe("bind()");
err(1, "bind()");
close(sd);
return;
}
nl_buf = malloc(NL_BUFSZ);
if (!nl_buf) {
_pe("malloc()");
err(1, "malloc()");
close(sd);
return;
}
+12 -12
View File
@@ -52,7 +52,7 @@ static int pidfile_add_path(struct iwatch *iw, char *path)
ptr = slash++;
slash = strchr(ptr, '/');
if (slash) {
_d("Path too deep, skipping.");
dbg("Path too deep, skipping.");
return -1;
}
}
@@ -71,21 +71,21 @@ static void pidfile_update_conds(char *dir, char *name, uint32_t mask)
if (fnmatch("*\\.pid", fn, 0) && fnmatch("*/pid", fn, 0))
return;
_d("path: %s, mask: %08x", fn, mask);
dbg("path: %s, mask: %08x", fn, mask);
svc = svc_find_by_pidfile(fn);
if (!svc) {
_d("No matching svc for %s", fn);
dbg("No matching svc for %s", fn);
return;
}
_d("Found svc %s for %s with pid %d", svc->name, fn, svc->pid);
dbg("Found svc %s for %s with pid %d", svc->name, fn, svc->pid);
mkcond(svc, cond, sizeof(cond));
if (mask & (IN_CLOSE_WRITE | IN_ATTRIB | IN_MODIFY | IN_MOVED_TO)) {
svc_started(svc);
if (!svc_has_pidfile(svc)) {
_d("Setting %s PID file to %s", svc->name, fn);
dbg("Setting %s PID file to %s", svc->name, fn);
pid_file_set(svc, fn, 1);
}
@@ -102,7 +102,7 @@ static void pidfile_update_conds(char *dir, char *name, uint32_t mask)
service_forked(svc);
if (pid != svc->pid) {
_d("Forking service %s (cmd %s) changed PID from %d to %d",
dbg("Forking service %s (cmd %s) changed PID from %d to %d",
svc_ident(svc, NULL, 0), svc->cmd, svc->pid, pid);
svc->pid = pid;
@@ -135,7 +135,7 @@ static void pidfile_scandir(struct iwatch *iw, char *dir, int len)
return;
for (i = 0; i < gl.gl_pathc; i++) {
_d("scan found %s", gl.gl_pathv[i]);
dbg("scan found %s", gl.gl_pathv[i]);
pidfile_update_conds(dir, gl.gl_pathv[i], IN_CREATE);
}
globfree(&gl);
@@ -150,7 +150,7 @@ static void pidfile_handle_dir(struct iwatch *iw, char *dir, char *name, int mas
struct iwatch_path *iwp;
paste(path, sizeof(path), dir, name);
_d("path: %s", path);
dbg("path: %s", path);
iwp = iwatch_find_by_path(iw, path);
@@ -174,7 +174,7 @@ static void pidfile_callback(void *arg, int fd, int events)
sz = read(fd, ev_buf, sizeof(ev_buf) - 1);
if (sz <= 0) {
_pe("invalid inotify event");
err(1, "invalid inotify event");
return;
}
ev_buf[sz] = 0;
@@ -248,7 +248,7 @@ static void pidfile_init(void *arg)
char *path;
if (mkpath(pid_runpath(_PATH_CONDPID, piddir, sizeof(piddir)), 0755) && errno != EEXIST) {
_pe("Failed creating %s condition directory, %s", COND_PID, _PATH_CONDPID);
err(1, "Failed creating %s condition directory, %s", COND_PID, _PATH_CONDPID);
return;
}
@@ -259,10 +259,10 @@ static void pidfile_init(void *arg)
*/
path = realpath(_PATH_VARRUN, NULL);
if (!path) {
_d("Failed querying realpath(%s): %s", _PATH_VARRUN, strerror(errno));
dbg("Failed querying realpath(%s): %s", _PATH_VARRUN, strerror(errno));
path = realpath("/run", NULL);
if (!path) {
_e("System does not have %s or /run, aborting.", _PATH_VARRUN);
errx(1, "System does not have %s or /run, aborting.", _PATH_VARRUN);
return;
}
}
+1 -1
View File
@@ -37,7 +37,7 @@ static void setup(void *arg)
glob_t gl;
if (rescue) {
_d("Skipping %s plugin in rescue mode.", __FILE__);
dbg("Skipping %s plugin in rescue mode.", __FILE__);
return;
}
+1 -1
View File
@@ -37,7 +37,7 @@
*/
static void setup(void *arg)
{
_d("Setting up the resolver ...");
dbg("Setting up the resolver ...");
mkpath("/etc/resolvconf", 0755);
mkpath("/etc/resolvconf/run", 0755);
mkpath("/var/run/resolvconf", 0755);
+2 -2
View File
@@ -89,7 +89,7 @@ static void rtc_save(void *arg)
char tz[128];
if (rescue) {
_d("Skipping %s plugin in rescue mode.", __FILE__);
dbg("Skipping %s plugin in rescue mode.", __FILE__);
return;
}
@@ -131,7 +131,7 @@ static void rtc_restore(void *arg)
char tz[128];
if (rescue) {
_d("Skipping %s plugin in rescue mode.", __FILE__);
dbg("Skipping %s plugin in rescue mode.", __FILE__);
return;
}
+7 -7
View File
@@ -63,7 +63,7 @@ static void sys_update_conds(char *dir, char *name, uint32_t mask)
return;
cond += strlen(COND_BASE) + 1;
_d("cond: %s set: %d", cond, mask & IN_CREATE ? 1 : 0);
dbg("cond: %s set: %d", cond, mask & IN_CREATE ? 1 : 0);
if (!cond_update(cond))
unlink(path);
}
@@ -82,7 +82,7 @@ static void sys_scandir(struct iwatch *iw, char *dir, int len)
return;
for (i = 0; i < gl.gl_pathc; i++) {
_d("scan found %s", gl.gl_pathv[i]);
dbg("scan found %s", gl.gl_pathv[i]);
sys_update_conds(dir, gl.gl_pathv[i], IN_CREATE);
}
globfree(&gl);
@@ -97,7 +97,7 @@ static void sys_handle_dir(struct iwatch *iw, char *dir, char *name, int mask)
struct iwatch_path *iwp;
paste(path, sizeof(path), dir, name);
_d("path: %s", path);
dbg("path: %s", path);
iwp = iwatch_find_by_path(iw, path);
@@ -121,7 +121,7 @@ static void sys_callback(void *arg, int fd, int events)
sz = read(fd, ev_buf, sizeof(ev_buf) - 1);
if (sz <= 0) {
_pe("invalid inotify event");
err(1, "invalid inotify event");
return;
}
ev_buf[sz] = 0;
@@ -136,7 +136,7 @@ static void sys_callback(void *arg, int fd, int events)
if (off + sizeof(*ev) + ev->len > (size_t)sz)
break;
_d("name %s, event: 0x%08x", ev->name, ev->mask);
dbg("name %s, event: 0x%08x", ev->name, ev->mask);
if (!ev->mask)
continue;
@@ -161,13 +161,13 @@ static void sys_init(void *arg)
char *path;
if (mkpath(pid_runpath(_PATH_CONDSYS, sysdir, sizeof(sysdir)), 0755) && errno != EEXIST) {
_pe("Failed creating %s condition directory, %s", COND_SYS, _PATH_CONDSYS);
err(1, "Failed creating %s condition directory, %s", COND_SYS, _PATH_CONDSYS);
return;
}
path = realpath(_PATH_CONDSYS, NULL);
if (!path) {
_pe("Cannot figure out real path to %s, aborting", _PATH_CONDSYS);
err(1, "Cannot figure out real path to %s, aborting", _PATH_CONDSYS);
return;
}
+5 -5
View File
@@ -55,7 +55,7 @@ static void setup(void)
plugin.io.fd = inotify_init1(IN_NONBLOCK | IN_CLOEXEC);
if (-1 == plugin.io.fd || inotify_add_watch(plugin.io.fd, "/dev", IN_CREATE | IN_DELETE) < 0)
_pe("Failed starting TTY watcher");
err(1, "Failed starting TTY watcher");
}
static void do_tty(char *tty, size_t len, int creat)
@@ -67,10 +67,10 @@ static void do_tty(char *tty, size_t len, int creat)
svc = svc_find_by_tty(name);
if (svc) {
if (svc_is_blocked(svc) && creat) {
_d("%s: blocked, re-enabling", svc_ident(svc, NULL, 0));
dbg("%s: blocked, re-enabling", svc_ident(svc, NULL, 0));
svc_start(svc);
} else if (svc->pid) {
_d("%s: missing ...", svc_ident(svc, NULL, 0));
dbg("%s: missing ...", svc_ident(svc, NULL, 0));
svc_missing(svc);
}
@@ -87,7 +87,7 @@ static void tty_watcher(void *arg, int fd, int events)
sz = read(fd, ev_buf, sizeof(ev_buf) - 1);
if (sz <= 0) {
_pe("invalid inotify event");
err(1, "invalid inotify event");
return;
}
ev_buf[sz] = 0;
@@ -103,7 +103,7 @@ static void tty_watcher(void *arg, int fd, int events)
if (!ev->mask)
continue;
_d("tty %s, event: 0x%08x", ev->name, ev->mask);
dbg("tty %s, event: 0x%08x", ev->name, ev->mask);
do_tty(ev->name, ev->len, ev->mask & IN_CREATE);
}
}
+2 -2
View File
@@ -51,7 +51,7 @@ static void setup(void *arg)
int fd, err;
if (rescue) {
_d("Skipping %s plugin in rescue mode.", __FILE__);
dbg("Skipping %s plugin in rescue mode.", __FILE__);
return;
}
@@ -144,7 +144,7 @@ static void save(void *arg)
mode_t prev;
if (rescue) {
_d("Skipping %s plugin in rescue mode.", __FILE__);
dbg("Skipping %s plugin in rescue mode.", __FILE__);
return;
}
+4 -4
View File
@@ -52,7 +52,7 @@ static void usr_callback(void *arg, int fd, int events)
sz = read(fd, ev_buf, sizeof(ev_buf) - 1);
if (sz <= 0) {
_pe("invalid inotify event");
err(1, "invalid inotify event");
return;
}
ev_buf[sz] = 0;
@@ -65,7 +65,7 @@ static void usr_callback(void *arg, int fd, int events)
if (off + sizeof(*ev) + ev->len > (size_t)sz)
break;
_d("name %s, event: 0x%08x", ev->name, ev->mask);
dbg("name %s, event: 0x%08x", ev->name, ev->mask);
if (!ev->mask)
continue;
@@ -85,13 +85,13 @@ static void usr_init(void *arg)
char *path;
if (mkpath(pid_runpath(_PATH_CONDUSR, usrdir, sizeof(usrdir)), 0755) && errno != EEXIST) {
_pe("Failed creating %s condition directory, %s", COND_USR, _PATH_CONDUSR);
err(1, "Failed creating %s condition directory, %s", COND_USR, _PATH_CONDUSR);
return;
}
path = realpath(_PATH_CONDUSR, NULL);
if (!path) {
_pe("Cannot figure out real path to %s, aborting", _PATH_CONDUSR);
err(1, "Cannot figure out real path to %s, aborting", _PATH_CONDUSR);
return;
}
+1 -1
View File
@@ -44,7 +44,7 @@ static void setup(void *arg)
#endif
if (rescue) {
_d("Skipping %s plugin in rescue mode.", __FILE__);
dbg("Skipping %s plugin in rescue mode.", __FILE__);
return;
}
+33 -33
View File
@@ -210,7 +210,7 @@ static svc_t *do_find_byc(char *buf, size_t len)
input = sanitize(buf, len);
if (!input) {
_d("Invalid input");
dbg("Invalid input");
return NULL;
}
@@ -257,25 +257,25 @@ static int do_reboot(int cmd, int timeout, char *buf, size_t len)
switch (cmd) {
case INIT_CMD_REBOOT:
_d("reboot");
dbg("reboot");
halt = SHUT_REBOOT;
service_runlevel(6);
break;
case INIT_CMD_HALT:
_d("halt");
dbg("halt");
halt = SHUT_HALT;
service_runlevel(0);
break;
case INIT_CMD_POWEROFF:
_d("poweroff");
dbg("poweroff");
halt = SHUT_OFF;
service_runlevel(0);
break;
case INIT_CMD_SUSPEND:
_d("suspend");
dbg("suspend");
sync();
rc = suspend();
if (rc) {
@@ -316,7 +316,7 @@ static void send_svc(int sd, svc_t *svc)
len = write(sd, svc, sizeof(*svc));
if (len != sizeof(*svc))
_d("Failed sending svc_t to client");
dbg("Failed sending svc_t to client");
}
static void api_cb(uev_t *w, void *arg, int events)
@@ -328,7 +328,7 @@ static void api_cb(uev_t *w, void *arg, int events)
sd = accept(w->fd, NULL, NULL);
if (sd < 0) {
_pe("Failed serving API request");
err(1, "Failed serving API request");
goto error;
}
@@ -349,14 +349,14 @@ static void api_cb(uev_t *w, void *arg, int events)
if (ECONNRESET == errno)
break;
_e("Failed reading initctl request, error %d: %s", errno, strerror(errno));
errx(1, "Failed reading initctl request, error %d: %s", errno, strerror(errno));
}
break;
}
if (rq.magic != INIT_MAGIC || len != sizeof(rq)) {
_e("Invalid initctl request");
errx(1, "Invalid initctl request");
break;
}
@@ -369,7 +369,7 @@ static void api_cb(uev_t *w, void *arg, int events)
/* fallthrough */
case '0'...'9':
_d("Setting new runlevel %c", rq.runlevel);
dbg("Setting new runlevel %c", rq.runlevel);
lvl = rq.runlevel - '0';
if (lvl == 0)
halt = SHUT_OFF;
@@ -379,41 +379,41 @@ static void api_cb(uev_t *w, void *arg, int events)
break;
default:
_d("Unsupported runlevel: %d", rq.runlevel);
dbg("Unsupported runlevel: %d", rq.runlevel);
break;
}
break;
case INIT_CMD_DEBUG:
_d("debug");
dbg("debug");
log_debug();
break;
case INIT_CMD_RELOAD: /* 'init q' and 'initctl reload' */
_d("reload");
dbg("reload");
service_reload_dynamic();
break;
case INIT_CMD_START_SVC:
_d("start %s", rq.data);
dbg("start %s", rq.data);
strterm(rq.data, sizeof(rq.data));
result = do_start(rq.data, sizeof(rq.data));
break;
case INIT_CMD_RESTART_SVC:
_d("restart %s", rq.data);
dbg("restart %s", rq.data);
strterm(rq.data, sizeof(rq.data));
result = do_restart(rq.data, sizeof(rq.data));
break;
case INIT_CMD_STOP_SVC:
_d("stop %s", rq.data);
dbg("stop %s", rq.data);
strterm(rq.data, sizeof(rq.data));
result = do_stop(rq.data, sizeof(rq.data));
break;
case INIT_CMD_RELOAD_SVC:
_d("reload %s", rq.data);
dbg("reload %s", rq.data);
strterm(rq.data, sizeof(rq.data));
result = do_reload(rq.data, sizeof(rq.data));
break;
@@ -427,7 +427,7 @@ static void api_cb(uev_t *w, void *arg, int events)
break;
case INIT_CMD_GET_RUNLEVEL:
_d("get runlevel");
dbg("get runlevel");
rq.runlevel = runlevel;
rq.sleeptime = prevlevel;
break;
@@ -440,17 +440,17 @@ static void api_cb(uev_t *w, void *arg, int events)
break;
case INIT_CMD_ACK:
_d("Client failed reading ACK");
dbg("Client failed reading ACK");
goto leave;
case INIT_CMD_WDOG_HELLO:
_d("wdog hello");
dbg("wdog hello");
if (rq.runlevel <= 0) {
result = 1;
break;
}
_d("Request to hand-over wdog ... to PID %d", rq.runlevel);
dbg("Request to hand-over wdog ... to PID %d", rq.runlevel);
svc = svc_find_by_pid(rq.runlevel);
if (!svc) {
logit(LOG_ERR, "Cannot find PID %d, not registered.", rq.runlevel);
@@ -474,7 +474,7 @@ static void api_cb(uev_t *w, void *arg, int events)
break;
case INIT_CMD_SVC_ITER:
// _d("svc iter, first: %d", rq.runlevel);
// dbg("svc iter, first: %d", rq.runlevel);
/*
* XXX: This severely limits the number of
* simultaneous client connections, but will
@@ -485,32 +485,32 @@ static void api_cb(uev_t *w, void *arg, int events)
goto leave;
case INIT_CMD_SVC_QUERY:
_d("svc query: %s", rq.data);
dbg("svc query: %s", rq.data);
strterm(rq.data, sizeof(rq.data));
result = do_query(rq.data, sizeof(rq.data));
break;
case INIT_CMD_SVC_FIND:
_d("svc find: %s", rq.data);
dbg("svc find: %s", rq.data);
strterm(rq.data, sizeof(rq.data));
send_svc(sd, do_find(rq.data, sizeof(rq.data)));
goto leave;
case INIT_CMD_SVC_FIND_BYC:
_d("svc find by cond: %s", rq.data);
dbg("svc find by cond: %s", rq.data);
strterm(rq.data, sizeof(rq.data));
send_svc(sd, do_find_byc(rq.data, sizeof(rq.data)));
goto leave;
case INIT_CMD_SIGNAL:
/* runlevel is reused for signal */
_d("svc signal %d: %s", rq.runlevel, rq.data);
dbg("svc signal %d: %s", rq.runlevel, rq.data);
strterm(rq.data, sizeof(rq.data));
result = do_signal(rq.data, sizeof(rq.data), rq.runlevel);
break;
default:
_d("Unsupported cmd: %d", rq.cmd);
dbg("Unsupported cmd: %d", rq.cmd);
break;
}
@@ -520,7 +520,7 @@ static void api_cb(uev_t *w, void *arg, int events)
rq.cmd = INIT_CMD_ACK;
len = write(sd, &rq, sizeof(rq));
if (len != sizeof(rq))
_d("Failed sending ACK/NACK back to client");
dbg("Failed sending ACK/NACK back to client");
}
leave:
@@ -531,7 +531,7 @@ leave:
error:
api_exit();
if (api_init(w->ctx))
_e("Unrecoverable error on API socket");
errx(1, "Unrecoverable error on API socket");
}
int api_init(uev_ctx_t *ctx)
@@ -544,10 +544,10 @@ int api_init(uev_ctx_t *ctx)
int uid, gid;
int sd;
_d("Setting up external API socket ...");
dbg("Setting up external API socket ...");
sd = socket(AF_UNIX, SOCK_SEQPACKET | SOCK_CLOEXEC, 0);
if (-1 == sd) {
_pe("Failed starting external API socket");
err(1, "Failed starting external API socket");
return 1;
}
@@ -563,14 +563,14 @@ int api_init(uev_ctx_t *ctx)
goto error;
if (chown(INIT_SOCKET, uid, gid))
_pe("Failed setting group %s on %s", DEFGROUP, INIT_SOCKET);
err(1, "Failed setting group %s on %s", DEFGROUP, INIT_SOCKET);
umask(oldmask);
if (!uev_io_init(ctx, &api_watcher, api_cb, NULL, sd, UEV_READ))
return 0;
error:
_pe("Failed initializing API socket");
err(1, "Failed initializing API socket");
umask(oldmask);
close(sd);
return 1;
+27 -27
View File
@@ -63,16 +63,16 @@ static void cgset(const char *path, char *ctrl, char *prop)
{
char *val;
_d("path %s, ctrl %s, prop %s", path ?: "NIL", ctrl ?: "NIL", prop ?: "NIL");
dbg("path %s, ctrl %s, prop %s", path ?: "NIL", ctrl ?: "NIL", prop ?: "NIL");
if (!path || !ctrl) {
_e("Missing path or controller, skipping!");
errx(1, "Missing path or controller, skipping!");
return;
}
if (!prop) {
prop = strchr(ctrl, '.');
if (!prop) {
_e("Invalid cgroup ctrl syntax: %s", ctrl);
errx(1, "Invalid cgroup ctrl syntax: %s", ctrl);
return;
}
@@ -81,20 +81,20 @@ static void cgset(const char *path, char *ctrl, char *prop)
val = strchr(prop, ':');
if (!val) {
_e("Missing cgroup ctrl value, prop %s", prop);
errx(1, "Missing cgroup ctrl value, prop %s", prop);
return;
}
*val++ = 0;
/* disallow sneaky relative paths */
if (strstr(ctrl, "..") || strstr(prop, "..")) {
_e("Possible security violation; '..' not allowed in cgroup config!");
errx(1, "Possible security violation; '..' not allowed in cgroup config!");
return;
}
_d("%s/%s.%s <= %s", path, ctrl, prop, val);
dbg("%s/%s.%s <= %s", path, ctrl, prop, val);
if (fnwrite(val, "%s/%s.%s", path, ctrl, prop))
_pe("Failed setting %s/%s.%s = %s", path, ctrl, prop, val);
err(1, "Failed setting %s/%s.%s = %s", path, ctrl, prop, val);
}
/*
@@ -106,16 +106,16 @@ static void group_init(char *path, int leaf, const char *cfg)
{
char *ptr, *s;
_d("path %s, leaf %d, cfg %s", path, leaf, cfg ?: "NIL");
dbg("path %s, leaf %d, cfg %s", path, leaf, cfg ?: "NIL");
if (!fisdir(path)) {
if (mkdir(path, 0755)) {
_pe("Failed creating cgroup %s", path);
err(1, "Failed creating cgroup %s", path);
return;
}
/* enable detected controllers on domain groups */
if (!leaf && fnwrite(controllers, "%s/cgroup.subtree_control", path))
_pe("Failed enabling %s for %s", controllers, path);
err(1, "Failed enabling %s for %s", controllers, path);
}
if (!cfg || !cfg[0])
@@ -123,14 +123,14 @@ static void group_init(char *path, int leaf, const char *cfg)
s = strdupa(cfg);
if (!s) {
_pe("Failed activating cgroup cfg for %s", path);
err(1, "Failed activating cgroup cfg for %s", path);
return;
}
_d("%s <=> %s", path, s);
dbg("%s <=> %s", path, s);
ptr = strtok(s, ",");
while (ptr) {
_d("ptr: %s", ptr);
dbg("ptr: %s", ptr);
if (!strncmp("mem.", ptr, 4))
cgset(path, "memory", &ptr[4]);
else
@@ -144,7 +144,7 @@ static int cgroup_leaf_init(char *group, char *name, int pid, const char *cfg)
{
char path[256];
_d("group %s, name %s, pid %d, cfg %s", group, name, pid, cfg ?: "NIL");
dbg("group %s, name %s, pid %d, cfg %s", group, name, pid, cfg ?: "NIL");
if (pid < 0 || pid == 1) {
errno = EINVAL;
return 1;
@@ -156,7 +156,7 @@ static int cgroup_leaf_init(char *group, char *name, int pid, const char *cfg)
/* move process to new group */
if (fnwrite(str("%d", pid), "%s/cgroup.procs", path))
_pe("Failed moving pid %d to group %s", pid, path);
err(1, "Failed moving pid %d to group %s", pid, path);
strlcat(path, "/cgroup.events", sizeof(path));
@@ -211,13 +211,13 @@ static void cgroup_handle_event(char *event, uint32_t mask)
char *ptr;
FILE *fp;
_d("event: '%s', mask: %08x", event, mask);
dbg("event: '%s', mask: %08x", event, mask);
if (!(mask & IN_MODIFY))
return;
fp = fopen(event, "r");
if (!fp) {
_d("Failed opening %s, skipping ...", event);
dbg("Failed opening %s, skipping ...", event);
return;
}
@@ -261,7 +261,7 @@ static void cgroup_events_cb(uev_t *w, void *arg, int events)
sz = read(w->fd, ev_buf, sizeof(ev_buf) - 1);
if (sz <= 0) {
_pe("invalid inotify event");
err(1, "invalid inotify event");
return;
}
ev_buf[sz] = 0;
@@ -364,12 +364,12 @@ int cgroup_add(char *name, char *cfg, int is_protected)
if (!cg) {
cg = malloc(sizeof(struct cg));
if (!cg) {
_pe("Failed allocating 'struct cg' for %s", name);
err(1, "Failed allocating 'struct cg' for %s", name);
return -1;
}
cg->name = strdup(name);
if (!cg->name) {
_pe("Failed setting cgroup name %s", name);
err(1, "Failed setting cgroup name %s", name);
free(cg);
return -1;
}
@@ -379,7 +379,7 @@ int cgroup_add(char *name, char *cfg, int is_protected)
cg->cfg = strdup(cfg);
if (!cg->cfg) {
_pe("Failed add/update of cgroup %s", name);
err(1, "Failed add/update of cgroup %s", name);
TAILQ_REMOVE(&cgroups, cg, link);
free(cg->name);
free(cg);
@@ -414,7 +414,7 @@ int cgroup_del(char *dir)
}
if (rmdir(dir) && errno != ENOENT) {
_d("Failed removing %s: %s", dir, strerror(errno));
dbg("Failed removing %s: %s", dir, strerror(errno));
return -1;
}
@@ -469,7 +469,7 @@ void cgroup_init(uev_ctx_t *ctx)
else if (errno == EPERM) /* Probably inside an unpriviliged container */
logit(LOG_INFO, "Not allowed to mount cgroups v2, disabling.");
else
_pe("Failed mounting cgroup v2");
err(1, "Failed mounting cgroup v2");
avail = 0;
return;
}
@@ -478,7 +478,7 @@ void cgroup_init(uev_ctx_t *ctx)
/* Find available controllers */
fp = fopen(FINIT_CGPATH "/cgroup.controllers", "r");
if (!fp) {
_pe("Failed opening %s", FINIT_CGPATH "/cgroup.controllers");
err(1, "Failed opening %s", FINIT_CGPATH "/cgroup.controllers");
abort:
umount(FINIT_CGPATH);
avail = 0;
@@ -505,7 +505,7 @@ void cgroup_init(uev_ctx_t *ctx)
/* Enable all controllers */
if (fnwrite(controllers, FINIT_CGPATH "/cgroup.subtree_control")) {
_pe("Failed enabling %s for %s", controllers, FINIT_CGPATH "/cgroup.subtree_control");
err(1, "Failed enabling %s for %s", controllers, FINIT_CGPATH "/cgroup.subtree_control");
goto abort;
}
@@ -515,7 +515,7 @@ void cgroup_init(uev_ctx_t *ctx)
goto abort;
if (uev_io_init(ctx, &cgw, cgroup_events_cb, NULL, fd, UEV_READ)) {
_pe("Failed setting up cgroup.events watcher");
err(1, "Failed setting up cgroup.events watcher");
iwatch_exit(&iw_cgroup);
close(fd);
goto abort;
@@ -529,7 +529,7 @@ void cgroup_init(uev_ctx_t *ctx)
/* Move ourselves to init (best effort, otherwise run in 'root' group */
if (fnwrite("1", FINIT_CGPATH "/init/cgroup.procs")) {
_pe("Failed moving PID 1 to cgroup %s", FINIT_CGPATH "/init");
err(1, "Failed moving PID 1 to cgroup %s", FINIT_CGPATH "/init");
uev_io_stop(&cgw);
iwatch_exit(&iw_cgroup);
close(fd);
+25 -25
View File
@@ -60,7 +60,7 @@ void cond_boot_parse(char *arg)
node = malloc(sizeof(*node));
if (!node) {
_pe("Out of memory cannot track boot conditions");
err(1, "Out of memory cannot track boot conditions");
return;
}
@@ -172,7 +172,7 @@ static void cond_bump_reconf(void)
rgen++;
if (cond_set_gen(_PATH_RECONF, rgen))
_pe("Failed setting %s to gen %d", _PATH_RECONF, rgen);
err(1, "Failed setting %s to gen %d", _PATH_RECONF, rgen);
}
static int cond_checkpath(const char *path)
@@ -182,12 +182,12 @@ static int cond_checkpath(const char *path)
strlcpy(buf, path, sizeof(buf));
dir = dirname(buf);
if (!dir) {
_e("Invalid path '%s' for condition", path);
errx(1, "Invalid path '%s' for condition", path);
return 1;
}
if (mkpath(dir, 0755) && errno != EEXIST) {
_pe("Failed creating dir '%s' for condition '%s'", dir, path);
err(1, "Failed creating dir '%s' for condition '%s'", dir, path);
return 1;
}
@@ -211,12 +211,12 @@ static void cond_delpath(const char *path)
paste(fn, sizeof(fn), path, d->d_name);
if (remove(fn))
_pe("Failed removing condition path, file %s", fn);
err(1, "Failed removing condition path, file %s", fn);
}
closedir(dir);
if (unlink(path) && errno != EISDIR)
_pe("Failed removing condition path %s", fn);
err(1, "Failed removing condition path %s", fn);
}
int cond_set_path(const char *path, enum cond_state next)
@@ -224,11 +224,11 @@ int cond_set_path(const char *path, enum cond_state next)
enum cond_state prev;
unsigned int rgen;
_d("%s <= %d", path, next);
dbg("%s <= %d", path, next);
rgen = cond_get_gen(_PATH_RECONF);
if (!rgen) {
_e("Unable to read configuration generation (%s)", path);
errx(1, "Unable to read configuration generation (%s)", path);
return -1;
}
@@ -250,14 +250,14 @@ int cond_set_path(const char *path, enum cond_state next)
cond_delpath(path);
break;
default:
_pe("Failed removing condition '%s'", path);
err(1, "Failed removing condition '%s'", path);
break;
}
}
break;
default:
_e("Invalid condition state");
errx(1, "Invalid condition state");
return 0;
}
@@ -270,13 +270,13 @@ int cond_update(const char *name)
svc_t *svc, *iter = NULL;
int affects = 0;
_d("%s", name);
dbg("%s", name);
for (svc = svc_iterator(&iter, 1); svc; svc = svc_iterator(&iter, 0)) {
if (!svc_has_cond(svc) || !cond_affects(name, svc->cond))
continue;
affects++;
_d("%s: match <%s> %s(%s)", name ?: "nil", svc->cond, svc->desc, svc->cmd);
dbg("%s: match <%s> %s(%s)", name ?: "nil", svc->cond, svc->desc, svc->cmd);
service_step(svc);
}
@@ -285,7 +285,7 @@ int cond_update(const char *name)
int cond_set_noupdate(const char *name)
{
_d("%s", name);
dbg("%s", name);
if (string_compare(name, "nop"))
return 1;
@@ -299,7 +299,7 @@ void cond_set(const char *name)
{
svc_t *svc;
_d("%s", name);
dbg("%s", name);
if (cond_set_noupdate(name))
return;
@@ -319,13 +319,13 @@ int cond_set_oneshot_noupdate(const char *name)
return 1;
path = cond_path(name);
_d("%s => %s", name, path);
dbg("%s => %s", name, path);
if (cond_checkpath(path))
return 1;
if (symlink(_PATH_RECONF, path) && errno != EEXIST) {
_pe("Failed creating onshot cond %s", name);
err(1, "Failed creating onshot cond %s", name);
return 1;
}
@@ -334,7 +334,7 @@ int cond_set_oneshot_noupdate(const char *name)
void cond_set_oneshot(const char *name)
{
_d("%s", name);
dbg("%s", name);
if (cond_set_oneshot_noupdate(name))
return;
@@ -343,7 +343,7 @@ void cond_set_oneshot(const char *name)
int cond_clear_noupdate(const char *name)
{
_d("%s", name);
dbg("%s", name);
if (string_compare(name, "nop"))
return 1;
@@ -355,7 +355,7 @@ int cond_clear_noupdate(const char *name)
void cond_clear(const char *name)
{
_d("%s", name);
dbg("%s", name);
if (cond_clear_noupdate(name))
return;
@@ -364,7 +364,7 @@ void cond_clear(const char *name)
void cond_reload(void)
{
_d("");
dbg("");
cond_bump_reconf();
}
@@ -381,12 +381,12 @@ static int do_assert(const char *fpath, const struct stat *sb, int tflg, struct
nm = strstr((char *)fpath, COND_BASE);
if (!nm) {
_e("Incorrect condition path %s, cannot %sassert", fpath, set ? "re" : "de");
errx(1, "Incorrect condition path %s, cannot %sassert", fpath, set ? "re" : "de");
return 1;
}
nm += strlen(COND_BASE);
_d("%sasserting %s => %s", set ? "Re" : "De", fpath, nm);
dbg("%sasserting %s => %s", set ? "Re" : "De", fpath, nm);
if (set)
cond_set(nm);
else
@@ -411,7 +411,7 @@ static int deassert(const char *fpath, const struct stat *sb, int tflg, struct F
*/
void cond_reassert(const char *pat)
{
_d("%s", pat);
dbg("%s", pat);
nftw(cond_path(pat), reassert, 20, FTW_DEPTH);
}
@@ -420,7 +420,7 @@ void cond_reassert(const char *pat)
*/
void cond_deassert(const char *pat)
{
_d("%s", pat);
dbg("%s", pat);
nftw(cond_path(pat), deassert, 20, FTW_DEPTH);
}
@@ -429,7 +429,7 @@ void cond_init(void)
char path[MAX_ARG_LEN];
if (mkpath(pid_runpath(_PATH_COND, path, sizeof(path)), 0755) && errno != EEXIST) {
_pe("Failed creating condition base directory '%s'", _PATH_COND);
err(1, "Failed creating condition base directory '%s'", _PATH_COND);
return;
}
+20 -20
View File
@@ -120,7 +120,7 @@ static void parse_finit_opts(char *opt)
if (string_compare(opt, "status_style")) {
if (!arg) {
_e("status_style option requires an argument, skipping.");
errx(1, "status_style option requires an argument, skipping.");
return;
}
@@ -157,7 +157,7 @@ static int parse_runlevel(char *arg)
num = strtonum(arg, 1, 9, &err);
if (err || num == 6) {
_d("Not a valid runlevel (%s), valid levels are [1-9], excluding 6, skipping.", arg);
dbg("Not a valid runlevel (%s), valid levels are [1-9], excluding 6, skipping.", arg);
return 0;
}
@@ -210,7 +210,7 @@ static void parse_kernel_cmdline(void)
}
cmdline = chomp(line);
_d("%s", cmdline);
dbg("%s", cmdline);
while ((tok = strtok(cmdline, " \t"))) {
cmdline = NULL;
@@ -239,7 +239,7 @@ static void parse_kernel_loglevel(void)
fclose(fp);
ptr = chomp(line);
_d("%s", ptr);
dbg("%s", ptr);
val = atoi(ptr);
if (val >= 7)
kerndebug = 1;
@@ -342,7 +342,7 @@ static void parse_env(char *line)
node = malloc(sizeof(*node));
if (!node) {
_pe("Out of memory cannot track env vars");
err(1, "Out of memory cannot track env vars");
return;
}
node->name = strdup(key);
@@ -434,7 +434,7 @@ void conf_parse_cond(svc_t *svc, char *cond)
char *ptr;
if (!svc) {
_e("Invalid service pointer");
errx(1, "Invalid service pointer");
return;
}
@@ -665,7 +665,7 @@ static int parse_static(char *line, int is_rcsd)
strlcpy(cmd, file, sizeof(cmd));
if (!fexist(cmd)) {
_e("Cannot find include file %s, absolute path required!", x);
errx(1, "Cannot find include file %s, absolute path required!", x);
return 1;
}
@@ -811,7 +811,7 @@ static int parse_conf(char *file, int is_rcsd)
cgroup_current[0] = 0;
}
_d("*** Parsing %s", file);
dbg("*** Parsing %s", file);
while (!feof(fp)) {
char *x;
@@ -820,7 +820,7 @@ static int parse_conf(char *file, int is_rcsd)
chomp(line);
tabstospaces(line);
//DEV _d("%s", line);
//DEV dbg("%s", line);
/* Skip comments, i.e. lines beginning with # */
if (MATCH_CMD(line, "#", x))
@@ -850,7 +850,7 @@ int conf_reload(void)
/* Set time according to current time zone */
tzset();
_d("Set time daylight: %d timezone: %ld tzname: %s %s",
dbg("Set time daylight: %d timezone: %ld tzname: %s %s",
daylight, timezone, tzname[0], tzname[1]);
/* Mark and sweep */
@@ -898,13 +898,13 @@ int conf_reload(void)
/* Check that it's an actual file ... beyond any symlinks */
if (lstat(path, &st)) {
_d("Skipping %s, cannot access: %s", path, strerror(errno));
dbg("Skipping %s, cannot access: %s", path, strerror(errno));
continue;
}
/* Skip directories */
if (S_ISDIR(st.st_mode)) {
_d("Skipping directory %s", path);
dbg("Skipping directory %s", path);
continue;
}
@@ -920,7 +920,7 @@ int conf_reload(void)
/* Check that file ends with '.conf' */
len = strlen(path);
if (len < 6 || strcmp(&path[len - 5], ".conf"))
_d("Skipping %s, not a Finit .conf file ... ", path);
dbg("Skipping %s, not a Finit .conf file ... ", path);
else
parse_conf(path, 1);
@@ -992,7 +992,7 @@ static int do_change(char *dir, char *name, uint32_t mask)
struct conf_change *node;
paste(fn, sizeof(fn), dir, name);
_d("path: %s mask: %08x", fn, mask);
dbg("path: %s mask: %08x", fn, mask);
node = conf_find(fn);
if (mask & (IN_DELETE | IN_MOVED_FROM)) {
@@ -1001,7 +1001,7 @@ static int do_change(char *dir, char *name, uint32_t mask)
}
if (node) {
_d("Event already registered for %s ...", name);
dbg("Event already registered for %s ...", name);
return 0;
}
@@ -1015,7 +1015,7 @@ static int do_change(char *dir, char *name, uint32_t mask)
return 1;
}
_d("Event registered for %s, mask 0x%x", fn, mask);
dbg("Event registered for %s, mask 0x%x", fn, mask);
TAILQ_INSERT_HEAD(&conf_change_list, node, link);
return 0;
@@ -1057,7 +1057,7 @@ static void conf_cb(uev_t *w, void *arg, int events)
sz = read(w->fd, ev_buf, sizeof(ev_buf) - 1);
if (sz <= 0) {
_pe("invalid inotify event");
err(1, "invalid inotify event");
return;
}
ev_buf[sz] = 0;
@@ -1075,7 +1075,7 @@ static void conf_cb(uev_t *w, void *arg, int events)
if (!ev->mask)
continue;
_d("name %s, event: 0x%08x", ev->name, ev->mask);
dbg("name %s, event: 0x%08x", ev->name, ev->mask);
/* Find base path for this event */
iwp = iwatch_find_by_wd(&iw_conf, ev->wd);
@@ -1083,7 +1083,7 @@ static void conf_cb(uev_t *w, void *arg, int events)
continue;
if (do_change(iwp->path, ev->name, ev->mask)) {
_pe(" Out of memory");
err(1, " Out of memory");
break;
}
}
@@ -1159,7 +1159,7 @@ int conf_init(uev_ctx_t *ctx)
return 1;
if (uev_io_init(ctx, &etcw, conf_cb, NULL, fd, UEV_READ)) {
_pe("Failed setting up I/O callback for /etc watcher");
err(1, "Failed setting up I/O callback for /etc watcher");
close(fd);
return 1;
}
+14 -14
View File
@@ -59,11 +59,11 @@ int complete(char *cmd, int pid)
if (waitpid(pid, &status, 0) == -1) {
if (errno == EINTR)
_e("Caught unblocked signal waiting for %s, aborting", cmd);
errx(1, "Caught unblocked signal waiting for %s, aborting", cmd);
else if (errno == ECHILD)
_e("Caught SIGCHLD waiting for %s, aborting", cmd);
errx(1, "Caught SIGCHLD waiting for %s, aborting", cmd);
else
_e("Failed starting %s, error %d: %s", cmd, errno, strerror (errno));
errx(1, "Failed starting %s, error %d: %s", cmd, errno, strerror (errno));
return -1;
}
@@ -131,7 +131,7 @@ int run(char *cmd, char *log)
args[i] = NULL;
if (i == NUM_ARGS && arg) {
_e("Command too long: %s", cmd);
errx(1, "Command too long: %s", cmd);
free(backup);
errno = EOVERFLOW;
return 1;
@@ -166,7 +166,7 @@ int run(char *cmd, char *log)
_exit(rc);
} else if (-1 == pid) {
_pe("%s", !log ? args[0] : cmd);
err(1, "%s", !log ? args[0] : cmd);
if (backup)
free(backup);
@@ -182,9 +182,9 @@ int run(char *cmd, char *log)
result = WEXITSTATUS(status);
if (WIFEXITED(status)) {
_d("Started '%s' and exit without signal, status: %d", cmd, result);
dbg("Started '%s' and exit without signal, status: %d", cmd, result);
} else if (WIFSIGNALED(status)) {
_d("Process '%s' terminated by signal %d", cmd, WTERMSIG(status));
dbg("Process '%s' terminated by signal %d", cmd, WTERMSIG(status));
if (!result)
result = 1; /* Must alert callee that the command did complete successfully.
* This is necessary since not all programs trap signals and
@@ -277,7 +277,7 @@ int exec_runtask(char *cmd, char *args[])
strlcat(buf, args[i], sizeof(buf));
}
logit(LOG_DEBUG, "Calling %s %s", _PATH_BSHELL, buf);
_d("Calling %s %s", _PATH_BSHELL, buf);
dbg("Calling %s %s", _PATH_BSHELL, buf);
return execvp(_PATH_BSHELL, argv);
}
@@ -448,7 +448,7 @@ int run_parts(char *dir, char *cmd)
num = scandir(dir, &e, NULL, alphasort);
if (num < 0) {
_d("No files found in %s, skipping ...", dir);
dbg("No files found in %s, skipping ...", dir);
return -1;
}
@@ -468,19 +468,19 @@ int run_parts(char *dir, char *cmd)
paste(path, sizeof(path), dir, name);
if (stat(path, &st)) {
_d("Failed stat(%s): %s", path, strerror(errno));
dbg("Failed stat(%s): %s", path, strerror(errno));
continue;
}
if (!S_ISEXEC(st.st_mode) || S_ISDIR(st.st_mode)) {
_d("Skipping %s ...", path);
dbg("Skipping %s ...", path);
continue;
}
/* If the callee didn't supply a run_parts() argument */
if (!cmd) {
/* Check if S<NUM>service or K<NUM>service notation is used */
_d("Checking if %s is a sysvinit startstop script ...", name);
dbg("Checking if %s is a sysvinit startstop script ...", name);
if (name[0] == 'S' && isdigit(name[1]))
strlcat(path, " start", sizeof(path));
else if (name[0] == 'K' && isdigit(name[1]))
@@ -499,9 +499,9 @@ int run_parts(char *dir, char *cmd)
status = complete(path, pid);
exit_status = WEXITSTATUS(status);
if (WIFEXITED(status) && exit_status)
_w("%s exited with status %d", path, exit_status);
warnx("%s exited with status %d", path, exit_status);
else if (WIFSIGNALED(status))
_w("%s terminated by signad %d", path, WTERMSIG(status));
warnx("%s terminated by signad %d", path, WTERMSIG(status));
print_result(status);
}
+27 -27
View File
@@ -204,17 +204,17 @@ static int fsck(int pass)
fp = setmntent(fstab, "r");
if (!fp) {
_pe("Failed opening fstab: %s", fstab);
err(1, "Failed opening fstab: %s", fstab);
sulogin(1);
}
_d("Opened %s, pass %d", fstab, pass);
dbg("Opened %s, pass %d", fstab, pass);
while ((mnt = getmntent_r(fp, &mount, buf, sizeof(buf)))) {
int fsck_rc = 0;
struct stat st;
char cmd[256];
char *dev;
_d("got: fsname '%s' dir '%s' type '%s' opts '%s' freq '%d' passno '%d'",
dbg("got: fsname '%s' dir '%s' type '%s' opts '%s' freq '%d' passno '%d'",
mnt->mnt_fsname, mnt->mnt_dir, mnt->mnt_type, mnt->mnt_opts,
mnt->mnt_freq, mnt->mnt_passno);
@@ -244,13 +244,13 @@ static int fsck(int pass)
}
if (skip) {
_d("Cannot fsck %s, not a block device: %s", dev, strerror(errno));
dbg("Cannot fsck %s, not a block device: %s", dev, strerror(errno));
continue;
}
}
if (ismnt("/proc/mounts", mnt->mnt_dir, "rw")) {
_d("Skipping fsck of %s, already mounted rw on %s.", dev, mnt->mnt_dir);
dbg("Skipping fsck of %s, already mounted rw on %s.", dev, mnt->mnt_dir);
continue;
}
@@ -259,7 +259,7 @@ static int fsck(int pass)
#else
snprintf(cmd, sizeof(cmd), "fsck -a %s", dev);
#endif
_d("Running pass %d fsck command %s", pass, cmd);
dbg("Running pass %d fsck command %s", pass, cmd);
fsck_rc = run_interactive(cmd, "Checking filesystem %s", dev);
/*
* "failure" is defined as exiting with a return code of
@@ -302,7 +302,7 @@ static void fs_mount(const char *src, const char *tgt, const char *fstype,
rc = mount(src, tgt, fstype, flags, data);
if (rc && errno != EBUSY)
_pe("Failed %s %s on %s", msg, src, tgt);
err(1, "Failed %s %s on %s", msg, src, tgt);
}
#ifndef SYSROOT
@@ -456,7 +456,7 @@ static void fs_mount_all(void)
if (!rescue)
fs_remount_root(fsck_all());
_d("Root FS up, calling hooks ...");
dbg("Root FS up, calling hooks ...");
plugin_run_hooks(HOOK_ROOTFS_UP);
if (fstab && strcmp(fstab, "/etc/fstab"))
@@ -465,13 +465,13 @@ static void fs_mount_all(void)
if (run_interactive(cmd, "Mounting filesystems from %s", fstab))
plugin_run_hooks(HOOK_MOUNT_ERROR);
_d("Calling extra mount hook, after mount -a ...");
dbg("Calling extra mount hook, after mount -a ...");
plugin_run_hooks(HOOK_MOUNT_POST);
_d("Enable any swap ...");
dbg("Enable any swap ...");
fs_swapon(cmd, sizeof(cmd));
_d("Finalize, ensure common file systems are available ...");
dbg("Finalize, ensure common file systems are available ...");
fs_finalize();
}
@@ -527,11 +527,11 @@ static void fs_init(void)
static void finalize(void *unused)
{
/* Clean up bootstrap-only tasks/services that never started */
_d("Clean up all bootstrap-only tasks/services ...");
dbg("Clean up all bootstrap-only tasks/services ...");
svc_prune_bootstrap();
/* All services/tasks/etc. in configure runlevel have started */
_d("Running svc up hooks ...");
dbg("Running svc up hooks ...");
plugin_run_hooks(HOOK_SVC_UP);
service_step_all(SVC_TYPE_ANY);
@@ -540,7 +540,7 @@ static void finalize(void *unused)
run_interactive(FINIT_RC_LOCAL, "Calling %s", FINIT_RC_LOCAL);
/* Hooks that should run at the very end */
_d("Calling all system up hooks ...");
dbg("Calling all system up hooks ...");
plugin_run_hooks(HOOK_SYSTEM_UP);
service_step_all(SVC_TYPE_ANY);
@@ -591,21 +591,21 @@ static void bootstrap_worker(void *work)
*/
service_init();
_d("Step all services ...");
dbg("Step all services ...");
service_step_all(SVC_TYPE_ANY);
if (cnt-- > 0 && !service_completed()) {
_d("Not all bootstrap run/tasks have completed yet ... %d", cnt);
dbg("Not all bootstrap run/tasks have completed yet ... %d", cnt);
schedule_work(work);
return;
}
if (cnt > 0)
_d("All run/task have completed, resuming bootstrap.");
dbg("All run/task have completed, resuming bootstrap.");
else
_d("Timeout, resuming bootstrap.");
dbg("Timeout, resuming bootstrap.");
_d("Starting runlevel change finalize ...");
dbg("Starting runlevel change finalize ...");
schedule_work(&final);
/*
@@ -620,10 +620,10 @@ static void bootstrap_worker(void *work)
* into the runlevel selected from the command line.
*/
if (cmdlevel) {
_d("Runlevel %d requested from command line, starting all services ...", cmdlevel);
dbg("Runlevel %d requested from command line, starting all services ...", cmdlevel);
level = cmdlevel;
} else
_d("Change to default runlevel(%d), starting all services ...", cfglevel);
dbg("Change to default runlevel(%d), starting all services ...", cfglevel);
service_runlevel(level);
}
@@ -756,7 +756,7 @@ int main(int argc, char *argv[])
conf_reset_env();
if (chdir("/"))
_pe("Failed cd /");
err(1, "Failed cd /");
/*
* In case of emergency.
@@ -829,22 +829,22 @@ int main(int argc, char *argv[])
/* Base FS up, enable standard SysV init signals */
sig_setup(&loop);
_d("Base FS up, calling hooks ...");
dbg("Base FS up, calling hooks ...");
plugin_run_hooks(HOOK_BASEFS_UP);
_d("Starting initctl API responder ...");
dbg("Starting initctl API responder ...");
api_init(&loop);
_d("Starting the big state machine ...");
dbg("Starting the big state machine ...");
schedule_work(&crank_work);
_d("Starting bootstrap finalize timer ...");
dbg("Starting bootstrap finalize timer ...");
schedule_work(&bootstrap_work);
/*
* Enter main loop to monitor /dev/initctl and services
*/
_d("Entering main loop ...");
dbg("Entering main loop ...");
return uev_run(&loop, 0);
}
+6 -5
View File
@@ -42,6 +42,7 @@
#include "finit.h"
#include "helpers.h"
#include "log.h"
#include "private.h"
#include "sig.h"
#include "util.h"
@@ -444,7 +445,7 @@ int mksubsys(const char *dir, mode_t mode, char *user, char *group)
rc = makedir(dir, mode);
if (chown(dir, uid, gid))
_pe("Failed chown(%s, %d, %d)", dir, uid, gid);
err(1, "Failed chown(%s, %d, %d)", dir, uid, gid);
}
umask(omask);
@@ -482,7 +483,7 @@ void set_hostname(char **hostname)
done:
if (*hostname) {
if (sethostname(*hostname, strlen(*hostname)))
_pe("Failed sethostnaem(%s)", *hostname);
err(1, "Failed sethostname(%s)", *hostname);
}
}
@@ -496,9 +497,9 @@ void networking(int updown)
return;
if (updown)
_d("Setting up networking ...");
dbg("Setting up networking ...");
else
_d("Taking down networking ...");
dbg("Taking down networking ...");
/* Run user network start script if enabled */
if (updown && network) {
@@ -557,7 +558,7 @@ done:
/* Hooks that rely on loopback, or basic networking being up. */
if (updown) {
_d("Calling all network up hooks ...");
dbg("Calling all network up hooks ...");
plugin_run_hooks(HOOK_NETWORK_UP);
}
}
+20 -16
View File
@@ -95,7 +95,7 @@ int plugin_register(plugin_t *plugin)
/* Already registered? */
if (plugin_find(plugin->name)) {
_d("... %s already loaded", plugin->name);
dbg("... %s already loaded", plugin->name);
free(plugin->name);
return 0;
@@ -120,10 +120,10 @@ int plugin_unregister(plugin_t *plugin)
#ifndef ENABLE_STATIC
TAILQ_REMOVE(&plugins, plugin, link);
_d("%s exiting ...", plugin->name);
dbg("%s exiting ...", plugin->name);
free(plugin->name);
#else
_d("Finit built statically, cannot unload %s ...", plugin->name);
dbg("Finit built statically, cannot unload %s ...", plugin->name);
#endif
return 0;
@@ -202,7 +202,7 @@ void plugin_run_hook(hook_point_t no, void *arg)
PLUGIN_ITERATOR(p, tmp) {
if (p->hook[no].cb) {
_d("Calling %s hook n:o %d (arg: %p) ...", basename(p->name), no, arg ?: "NIL");
dbg("Calling %s hook n:o %d (arg: %p) ...", basename(p->name), no, arg ?: "NIL");
p->hook[no].cb(arg ? arg : p->hook[no].arg);
}
}
@@ -235,7 +235,7 @@ static void generic_io_cb(uev_t *w, void *arg, int events)
/* Stop watcher, callback may close descriptor on us ... */
uev_io_stop(w);
_d("Calling I/O %s from runloop...", basename(p->name));
dbg("Calling I/O %s from runloop...", basename(p->name));
p->io.cb(p->io.arg, w->fd, events);
/* Update fd, may be changed by plugin callback, e.g., if FIFO */
@@ -248,9 +248,9 @@ int plugin_io_init(plugin_t *p)
if (!is_io_plugin(p))
return 0;
_d("Initializing plugin %s for I/O", basename(p->name));
dbg("Initializing plugin %s for I/O", basename(p->name));
if (uev_io_init(ctx, &p->watcher, generic_io_cb, p, p->io.fd, p->io.flags)) {
_e("Failed setting up I/O plugin %s", basename(p->name));
warn("Failed setting up I/O plugin %s", basename(p->name));
return 1;
}
@@ -302,16 +302,18 @@ static int load_one(char *path, char *name)
noext = strcmp(name + strlen(name) - 3, ".so");
snprintf(sofile, sizeof(sofile), "%s/%s%s", path, name, noext ? ".so" : "");
_d("Loading plugin %s ...", sofile);
dbg("Loading plugin %s ...", sofile);
handle = dlopen(sofile, RTLD_LAZY | RTLD_LOCAL);
if (!handle) {
_e("Failed loading plugin %s: %s", sofile, dlerror());
char *error = dlerror();
warn("Failed loading plugin %s: %s", sofile, error ? error : "unknown error");
return 1;
}
plugin = TAILQ_LAST(&plugins, plugin_head);
if (!plugin) {
_e("Plugin %s failed to register, unloading from memory", sofile);
warn("Plugin %s failed to register, unloading from memory", sofile);
dlclose(handle);
return 1;
}
@@ -338,9 +340,9 @@ static void check_plugin_depends(plugin_t *plugin)
int i;
for (i = 0; i < PLUGIN_DEP_MAX && plugin->depends[i]; i++) {
// _d("Plugin %s depends on %s ...", plugin->name, plugin->depends[i]);
// dbg("Plugin %s depends on %s ...", plugin->name, plugin->depends[i]);
if (plugin_find(plugin->depends[i])) {
// _d("OK plugin %s was already loaded.", plugin->depends[i]);
// dbg("OK plugin %s was already loaded.", plugin->depends[i]);
continue;
}
@@ -358,7 +360,7 @@ static int load_plugins(char *path)
if (!dp) {
if (errno == ENOENT)
return 0;
_e("Failed, cannot open plugin directory %s: %s", path, strerror(errno));
warn("Failed, cannot open plugin directory %s: %s", path, strerror(errno));
return 1;
}
plugpath = path;
@@ -434,7 +436,7 @@ int plugin_init(uev_ctx_t *ctx)
char *path;
if (paths) {
_d("Loading external plugins from %s ...", paths);
dbg("Loading external plugins from %s ...", paths);
path = strtok(paths, ":");
while (path) {
load_plugins(path);
@@ -453,8 +455,10 @@ void plugin_exit(void)
plugin_t *p, *tmp;
PLUGIN_ITERATOR(p, tmp) {
if (dlclose(p->handle))
_e("Failed: unloading plugin %s: %s", p->name, dlerror());
if (dlclose(p->handle)) {
char *error = dlerror();
warn("Failed unloading plugin %s: %s", p->name, error ? error : "unknown error");
}
}
#endif
}
+46 -46
View File
@@ -149,7 +149,7 @@ static int service_script_add(svc_t *svc, pid_t pid)
struct assoc *ptr = malloc(sizeof(*ptr));
if (!ptr) {
_pe("Failed starting service script timer");
err(1, "Failed starting service script timer");
return 1;
}
@@ -487,12 +487,12 @@ static pid_t service_fork(svc_t *svc)
/* Set desired user+group */
if (gid >= 0) {
if (setgid(gid))
_pe("%s: failed setgid(%d)", svc_ident(svc, NULL, 0), gid);
err(1, "%s: failed setgid(%d)", svc_ident(svc, NULL, 0), gid);
}
if (uid >= 0) {
if (setuid(uid))
_pe("%s: failed setuid(%d)", svc_ident(svc, NULL, 0), uid);
err(1, "%s: failed setuid(%d)", svc_ident(svc, NULL, 0), uid);
/* Set default path for regular users */
if (uid > 0)
@@ -501,7 +501,7 @@ static pid_t service_fork(svc_t *svc)
setenv("HOME", home, 1);
if (chdir(home)) {
if (chdir("/"))
_pe("%s: failed chdir(%s) and chdir(/)", svc_ident(svc, NULL, 0), home);
err(1, "%s: failed chdir(%s) and chdir(/)", svc_ident(svc, NULL, 0), home);
}
}
}
@@ -554,7 +554,7 @@ static int service_start(svc_t *svc)
char *dev = tty_canonicalize(svc->dev);
if (!dev || !tty_exists(dev)) {
_d("TTY %s missing or invalid, halting service.", svc->dev);
dbg("TTY %s missing or invalid, halting service.", svc->dev);
svc_missing(svc);
return 1;
}
@@ -598,7 +598,7 @@ static int service_start(svc_t *svc)
int rc;
if ((rc = wordexp(svc->cmd, &we, 0))) {
_e("%s: failed wordexp(%s): %d", svc_ident(svc, NULL, 0), svc->cmd, rc);
errx(1, "%s: failed wordexp(%s): %d", svc_ident(svc, NULL, 0), svc->cmd, rc);
nomem:
wordfree(&we);
_exit(1);
@@ -626,7 +626,7 @@ static int service_start(svc_t *svc)
strlcat(str, arg, sizeof(str));
if ((rc = wordexp(str, &we, WRDE_APPEND))) {
_e("%s: failed wordexp(%s): %d", svc_ident(svc, NULL, 0), str, rc);
errx(1, "%s: failed wordexp(%s): %d", svc_ident(svc, NULL, 0), str, rc);
goto nomem;
}
}
@@ -691,7 +691,7 @@ static int service_start(svc_t *svc)
_exit(status);
} else if (debug) {
_d("Starting %s", cmdline);
dbg("Starting %s", cmdline);
}
if (svc_is_tty(svc))
@@ -747,11 +747,11 @@ static void service_kill(svc_t *svc)
if (svc->pid <= 1) {
/* Avoid killing ourselves or all processes ... */
_d("%s: Aborting SIGKILL, already terminated.", svc_ident(svc, NULL, 0));
dbg("%s: Aborting SIGKILL, already terminated.", svc_ident(svc, NULL, 0));
return;
}
_d("%s: Sending SIGKILL to pid:%d", pid_get_name(svc->pid, NULL, 0), svc->pid);
dbg("%s: Sending SIGKILL to pid:%d", pid_get_name(svc->pid, NULL, 0), svc->pid);
logit(LOG_CONSOLE | LOG_NOTICE, "Stopping %s[%d], sending SIGKILL ...",
svc_ident(svc, NULL, 0), svc->pid);
if (runlevel != 1)
@@ -817,7 +817,7 @@ int service_stop(svc_t *svc)
if (svc->pid <= 1)
return 1;
_d("Sending %s to pid:%d name:%s", sig_name(svc->sighalt),
dbg("Sending %s to pid:%d name:%s", sig_name(svc->sighalt),
svc->pid, pid_get_name(svc->pid, NULL, 0));
logit(LOG_CONSOLE | LOG_NOTICE, "Stopping %s[%d], sending %s ...",
svc_ident(svc, NULL, 0), svc->pid, sig_name(svc->sighalt));
@@ -850,7 +850,7 @@ int service_stop(svc_t *svc)
if (svc->pid > 1) {
/* Kill all children in the same proess group, e.g. logit */
rc = kill(-svc->pid, svc->sighalt);
_d("kill(-%d, %d) => rc %d, errno %d", svc->pid, svc->sighalt, rc, errno);
dbg("kill(-%d, %d) => rc %d, errno %d", svc->pid, svc->sighalt, rc, errno);
/* PID lost or forking process never really started */
if (rc == -1 && (errno == ESRCH || errno == ENOENT)) {
service_cleanup(svc);
@@ -885,7 +885,7 @@ int service_stop(svc_t *svc)
_exit(0);
break;
case -1:
_pe("Failed fork() to call sysv script '%s stop'", cmdline);
err(1, "Failed fork() to call sysv script '%s stop'", cmdline);
rc = 1;
break;
default:
@@ -924,7 +924,7 @@ static int service_restart(svc_t *svc)
return 1;
if (svc->pid <= 1) {
_d("%s: bad PID %d for %s, SIGHUP", svc_ident(svc, NULL, 0), svc->pid, svc->cmd);
dbg("%s: bad PID %d for %s, SIGHUP", svc_ident(svc, NULL, 0), svc->pid, svc->cmd);
svc->start_time = svc->pid = 0;
return 1;
}
@@ -936,7 +936,7 @@ static int service_restart(svc_t *svc)
if (do_progress)
print_desc("Restarting ", svc->desc);
_d("Sending SIGHUP to PID %d", svc->pid);
dbg("Sending SIGHUP to PID %d", svc->pid);
logit(LOG_CONSOLE | LOG_NOTICE, "Restarting %s[%d], sending SIGHUP ...",
svc_ident(svc, NULL, 0), svc->pid);
rc = kill(svc->pid, SIGHUP);
@@ -1027,7 +1027,7 @@ static void parse_env(svc_t *svc, char *env)
return;
if (strlen(env) >= sizeof(svc->env)) {
_e("%s: env file is too long (>%zu chars)", svc_ident(svc, NULL, 0), sizeof(svc->env));
errx(1, "%s: env file is too long (>%zu chars)", svc_ident(svc, NULL, 0), sizeof(svc->env));
return;
}
@@ -1051,7 +1051,7 @@ static void parse_cgroup(svc_t *svc, char *cgroup)
}
if (strlen(ptr) >= sizeof(svc->cgroup)) {
_e("%s: cgroup settings too long (>%zu chars)", svc_ident(svc, NULL, 0), sizeof(svc->cgroup));
errx(1, "%s: cgroup settings too long (>%zu chars)", svc_ident(svc, NULL, 0), sizeof(svc->cgroup));
return;
}
@@ -1076,7 +1076,7 @@ static void parse_killdelay(svc_t *svc, char *delay)
sec = strtonum(delay, 1, 60, &errstr);
if (errstr) {
_e("%s: killdelay %s is %s (1-60)", svc_ident(svc, NULL, 0), delay, errstr);
errx(1, "%s: killdelay %s is %s (1-60)", svc_ident(svc, NULL, 0), delay, errstr);
return;
}
@@ -1200,7 +1200,7 @@ static void parse_cmdline_args(svc_t *svc, char *cmd)
diff += conf_changed(svc_getenv(svc));
if (diff)
_d("Modified args for %s detected", cmd);
dbg("Modified args for %s detected", cmd);
svc->args_dirty = (diff > 0);
}
@@ -1279,7 +1279,7 @@ int service_register(int type, char *cfg, struct rlimit rlimit[], char *file)
svc_t *svc;
if (!cfg) {
_e("Invalid input argument");
errx(1, "Invalid input argument");
return errno = EINVAL;
}
@@ -1308,7 +1308,7 @@ int service_register(int type, char *cfg, struct rlimit rlimit[], char *file)
cmd = strtok(line, " \t");
if (!cmd) {
incomplete:
_e("Incomplete service '%s', cannot register", cfg);
errx(1, "Incomplete service '%s', cannot register", cfg);
return errno = ENOENT;
}
@@ -1381,7 +1381,7 @@ int service_register(int type, char *cfg, struct rlimit rlimit[], char *file)
levels = conf_parse_runlevels(runlevels);
if (runlevel > 0 && !ISOTHER(levels, 0)) {
_d("Skipping %s, bootstrap is completed.", cmd);
dbg("Skipping %s, bootstrap is completed.", cmd);
return 0;
}
@@ -1430,17 +1430,17 @@ int service_register(int type, char *cfg, struct rlimit rlimit[], char *file)
svc = svc_find(name, id);
if (!svc) {
_d("Creating new svc for %s name %s id %s type %d", cmd, name, id, type);
dbg("Creating new svc for %s name %s id %s type %d", cmd, name, id, type);
svc = svc_new(cmd, name, id, type);
if (!svc) {
_e("Out of memory, cannot register service %s", cmd);
errx(1, "Out of memory, cannot register service %s", cmd);
return errno = ENOMEM;
}
if (manual)
svc_stop(svc);
} else {
_d("Found existing svc for %s name %s id %s type %d", cmd, name, id, type);
dbg("Found existing svc for %s name %s id %s type %d", cmd, name, id, type);
/* update type, may have changed from service -> task */
svc->type = type;
@@ -1467,7 +1467,7 @@ int service_register(int type, char *cfg, struct rlimit rlimit[], char *file)
}
svc->runlevels = levels;
_d("Service %s runlevel 0x%02x", svc_ident(svc, NULL, 0), svc->runlevels);
dbg("Service %s runlevel 0x%02x", svc_ident(svc, NULL, 0), svc->runlevels);
conf_parse_cond(svc, cond);
@@ -1613,21 +1613,21 @@ void service_monitor(pid_t lost, int status)
svc = svc_find_by_pid(lost);
if (!svc) {
if (service_script_del(lost))
_d("collected unknown PID %d", lost);
dbg("collected unknown PID %d", lost);
return;
}
switch (svc->state) {
case SVC_CLEANUP_STATE:
case SVC_SETUP_STATE:
_d("collected script %s(%d), normal exit: %d, signaled: %d, exit code: %d",
dbg("collected script %s(%d), normal exit: %d, signaled: %d, exit code: %d",
svc->state == SVC_CLEANUP_STATE ? svc->post_script : svc->pre_script,
lost, WIFEXITED(status), WIFSIGNALED(status), WEXITSTATUS(status));
kill(-svc->pid, SIGKILL);
goto done;
default:
_d("collected %s(%d), normal exit: %d, signaled: %d, exit code: %d",
dbg("collected %s(%d), normal exit: %d, signaled: %d, exit code: %d",
svc_ident(svc, NULL, 0), lost, WIFEXITED(status), WIFSIGNALED(status), WEXITSTATUS(status));
svc->status = status;
break;
@@ -1666,7 +1666,7 @@ cont:
if (!service_step(svc)) {
/* Clean out any bootstrap tasks, they've had their time in the sun. */
if (svc_clean_bootstrap(svc))
_d("collected bootstrap task %s(%d), removing.", svc_ident(svc, NULL, 0), lost);
dbg("collected bootstrap task %s(%d), removing.", svc_ident(svc, NULL, 0), lost);
}
sm_step(&sm);
@@ -1734,7 +1734,7 @@ static void service_pre_script(svc_t *svc)
{
svc->pid = service_fork(svc);
if (svc->pid < 0) {
_pe("Failed forking off %s pre-script %s", svc_ident(svc, NULL, 0), svc->pre_script);
err(1, "Failed forking off %s pre-script %s", svc_ident(svc, NULL, 0), svc->pre_script);
return;
}
@@ -1767,7 +1767,7 @@ static void service_post_script(svc_t *svc)
{
svc->pid = service_fork(svc);
if (svc->pid < 0) {
_pe("Failed forking off %s post-script %s", svc_ident(svc, NULL, 0), svc->post_script);
err(1, "Failed forking off %s post-script %s", svc_ident(svc, NULL, 0), svc->post_script);
return;
}
@@ -1820,7 +1820,7 @@ void service_ready_script(svc_t *svc)
pid = service_fork(svc);
if (pid < 0) {
_pe("Failed forking off %s ready-script %s", svc_ident(svc, NULL, 0), svc->ready_script);
err(1, "Failed forking off %s ready-script %s", svc_ident(svc, NULL, 0), svc->ready_script);
return;
}
@@ -1855,7 +1855,7 @@ static void service_retry(svc_t *svc)
service_timeout_cancel(svc);
if (svc->respawn) {
_d("%s crashed/exited, respawning ...", svc_ident(svc, NULL, 0));
dbg("%s crashed/exited, respawning ...", svc_ident(svc, NULL, 0));
svc_unblock(svc);
service_step(svc);
return;
@@ -1886,7 +1886,7 @@ static void service_retry(svc_t *svc)
(*restart_cnt)++;
_d("%s crashed, trying to start it again, attempt %d", svc_ident(svc, NULL, 0), *restart_cnt);
dbg("%s crashed, trying to start it again, attempt %d", svc_ident(svc, NULL, 0), *restart_cnt);
logit(LOG_CONSOLE | LOG_WARNING, "Service %s[%d] died, restarting (%d/%d)",
svc_ident(svc, NULL, 0), svc->oldpid, *restart_cnt, svc->restart_max);
svc_unblock(svc);
@@ -1907,7 +1907,7 @@ static void svc_set_state(svc_t *svc, svc_state_t new)
/* if PID isn't collected within SVC_TERM_TIMEOUT msec, kill it! */
if (*state == SVC_STOPPING_STATE) {
_d("%s is stopping, wait %d sec before sending SIGKILL ...",
dbg("%s is stopping, wait %d sec before sending SIGKILL ...",
svc_ident(svc, NULL, 0), svc->killdelay / 1000);
service_timeout_cancel(svc);
service_timeout_after(svc, svc->killdelay, service_kill);
@@ -1986,7 +1986,7 @@ restart:
old_state = svc->state;
enabled = svc_enabled(svc);
_d("%20s(%4d): %8s %3sabled/%-7s cond:%-4s", svc_ident(svc, NULL, 0), svc->pid,
dbg("%20s(%4d): %8s %3sabled/%-7s cond:%-4s", svc_ident(svc, NULL, 0), svc->pid,
svc_status(svc), enabled ? "en" : "dis", svc_dirtystr(svc),
condstr(cond_get_agg(svc->cond)));
@@ -2007,7 +2007,7 @@ restart:
if (!svc->pid) {
char condstr[MAX_COND_LEN];
_d("%s: stopped, cleaning up timers and conditions ...", svc_ident(svc, NULL, 0));
dbg("%s: stopped, cleaning up timers and conditions ...", svc_ident(svc, NULL, 0));
service_timeout_cancel(svc);
cond_clear(mkcond(svc, condstr, sizeof(condstr)));
@@ -2030,7 +2030,7 @@ restart:
break;
default:
_e("unknown service type %d", svc->type);
errx(1, "unknown service type %d", svc->type);
break;
}
}
@@ -2101,7 +2101,7 @@ restart:
* file. In both cases, after that, retry after 2 sec
*/
if (!svc->respawn)
_d("delayed restart of %s", svc_ident(svc, NULL, 0));
dbg("delayed restart of %s", svc_ident(svc, NULL, 0));
if (svc_is_forking(svc))
service_timeout_after(svc, 2000, service_retry);
else
@@ -2171,13 +2171,13 @@ restart:
char name[MAX_COND_LEN];
mkcond(svc, name, sizeof(name));
_d("Reassert condition %s", name);
dbg("Reassert condition %s", name);
cond_set_path(cond_path(name), COND_ON);
}
break;
case COND_OFF:
_d("Condition for %s is off, sending SIGCONT + SIGTERM", svc->name);
dbg("Condition for %s is off, sending SIGCONT + SIGTERM", svc->name);
kill(svc->pid, SIGCONT);
service_stop(svc);
break;
@@ -2189,7 +2189,7 @@ restart:
}
if (svc->state != old_state) {
_d("%20s(%4d): -> %8s", svc_ident(svc, NULL, 0), svc->pid, svc_status(svc));
dbg("%20s(%4d): -> %8s", svc_ident(svc, NULL, 0), svc->pid, svc_status(svc));
changed++;
goto restart;
}
@@ -2260,15 +2260,15 @@ int service_completed(void)
if (strstr(svc->cond, plugin_hook_str(HOOK_SVC_UP)) ||
strstr(svc->cond, plugin_hook_str(HOOK_SYSTEM_UP))) {
_d("Skipping %s(%s), post-strap hook", svc->desc, svc_ident(svc, NULL, 0));
dbg("Skipping %s(%s), post-strap hook", svc->desc, svc_ident(svc, NULL, 0));
continue;
}
if (!svc->once) {
_d("%s has not yet completed ...", svc_ident(svc, NULL, 0));
dbg("%s has not yet completed ...", svc_ident(svc, NULL, 0));
return 0;
}
_d("%s has completed ...", svc_ident(svc, NULL, 0));
dbg("%s has completed ...", svc_ident(svc, NULL, 0));
}
return 1;
+21 -21
View File
@@ -231,12 +231,12 @@ void do_iterate_proc(int (*cb)(int, void *), void *data)
if (fgets(file, sizeof(file), fp)) {
if (strstr(file, "gdbserver"))
_d("Skipping %s ...", file);
dbg("Skipping %s ...", file);
else if (file[0] == '@')
_d("Skipping %s ...", &file[1]);
dbg("Skipping %s ...", &file[1]);
else
if (cb(pid, data)) {
_d("PID %d is still alive (%s)", pid, file);
dbg("PID %d is still alive (%s)", pid, file);
fclose(fp);
break;
}
@@ -382,15 +382,15 @@ void do_shutdown(shutop_t op)
do_sleep(1);
}
_d("Rebooting ...");
dbg("Rebooting ...");
reboot(RB_AUTOBOOT);
} else if (op == SHUT_OFF) {
_d("Powering down ...");
dbg("Powering down ...");
reboot(RB_POWER_OFF);
}
/* Also fallback if any of the other two fails */
_d("Halting ...");
dbg("Halting ...");
reboot(RB_HALT_SYSTEM);
}
@@ -399,9 +399,9 @@ void do_shutdown(shutop_t op)
*/
static void sighup_cb(uev_t *w, void *arg, int events)
{
_d("...");
dbg("...");
if (UEV_ERROR == events) {
_e("Unrecoverable error in signal watcher");
errx(1, "Unrecoverable error in signal watcher");
return;
}
@@ -420,9 +420,9 @@ static void sighup_cb(uev_t *w, void *arg, int events)
*/
static void sigint_cb(uev_t *w, void *arg, int events)
{
_d("...");
dbg("...");
if (UEV_ERROR == events) {
_e("Unrecoverable error in signal watcher");
errx(1, "Unrecoverable error in signal watcher");
return;
}
@@ -436,9 +436,9 @@ static void sigint_cb(uev_t *w, void *arg, int events)
*/
static void sigpwr_cb(uev_t *w, void *arg, int events)
{
_d("...");
dbg("...");
if (UEV_ERROR == events) {
_e("Unrecoverable error in signal watcher");
errx(1, "Unrecoverable error in signal watcher");
return;
}
@@ -450,9 +450,9 @@ static void sigpwr_cb(uev_t *w, void *arg, int events)
*/
static void sigusr1_cb(uev_t *w, void *arg, int events)
{
_d("...");
dbg("...");
if (UEV_ERROR == events) {
_e("Unrecoverable error in signal watcher");
errx(1, "Unrecoverable error in signal watcher");
return;
}
@@ -466,9 +466,9 @@ static void sigusr1_cb(uev_t *w, void *arg, int events)
*/
static void sigusr2_cb(uev_t *w, void *arg, int events)
{
_d("...");
dbg("...");
if (UEV_ERROR == events) {
_e("Unrecoverable error in signal watcher");
errx(1, "Unrecoverable error in signal watcher");
return;
}
@@ -481,9 +481,9 @@ static void sigusr2_cb(uev_t *w, void *arg, int events)
*/
static void sigterm_cb(uev_t *w, void *arg, int events)
{
_d("...");
dbg("...");
if (UEV_ERROR == events) {
_e("Unrecoverable error in signal watcher");
errx(1, "Unrecoverable error in signal watcher");
return;
}
@@ -500,7 +500,7 @@ static void sigchld_cb(uev_t *w, void *arg, int events)
pid_t pid;
if (UEV_ERROR == events) {
_e("Unrecoverable error in signal watcher");
errx(1, "Unrecoverable error in signal watcher");
return;
}
@@ -513,7 +513,7 @@ static void sigchld_cb(uev_t *w, void *arg, int events)
break;
}
_d("Collected child %d", pid);
dbg("Collected child %d", pid);
service_monitor(pid, status);
}
}
@@ -603,7 +603,7 @@ void sig_setup(uev_ctx_t *ctx)
{
struct sigaction sa;
_d("Setup signals");
dbg("Setup signals");
/*
* Standard SysV init calls ctrl-alt-delete handler
+12 -12
View File
@@ -116,12 +116,12 @@ void sm_step(sm_t *sm)
restart:
old_state = sm->state;
_d("state: %s, runlevel: %d, newlevel: %d, teardown: %d, reload: %d",
dbg("state: %s, runlevel: %d, newlevel: %d, teardown: %d, reload: %d",
sm_status(sm->state), runlevel, sm->newlevel, sm->in_teardown, sm->reload);
switch (sm->state) {
case SM_BOOTSTRAP_STATE:
_d("Bootstrapping all services in runlevel S from %s", FINIT_CONF);
dbg("Bootstrapping all services in runlevel S from %s", FINIT_CONF);
service_step_all(SVC_TYPE_RUNTASK | SVC_TYPE_SERVICE);
sm->state = SM_RUNNING_STATE;
break;
@@ -154,7 +154,7 @@ restart:
plugin_run_hooks(HOOK_SHUTDOWN);
}
_d("Setting new runlevel --> %d <-- previous %d", runlevel, prevlevel);
dbg("Setting new runlevel --> %d <-- previous %d", runlevel, prevlevel);
if (osheading)
logit(LOG_CONSOLE | LOG_NOTICE, "%s, entering runlevel %d", osheading, runlevel);
else
@@ -173,7 +173,7 @@ restart:
/* Reset once flag of runtasks */
service_runtask_clean();
_d("Stopping services not allowed in new runlevel ...");
dbg("Stopping services not allowed in new runlevel ...");
sm->in_teardown = 1;
service_step_all(SVC_TYPE_ANY);
@@ -187,15 +187,15 @@ restart:
*/
svc = svc_stop_completed();
if (svc) {
_d("Waiting to collect %s, cmd %s(%d) ...", svc_ident(svc, NULL, 0), svc->cmd, svc->pid);
dbg("Waiting to collect %s, cmd %s(%d) ...", svc_ident(svc, NULL, 0), svc->cmd, svc->pid);
break;
}
/* Prev runlevel services stopped, call hooks before starting new runlevel ... */
_d("All services have been stopped, calling runlevel change hooks ...");
dbg("All services have been stopped, calling runlevel change hooks ...");
plugin_run_hooks(HOOK_RUNLEVEL_CHANGE); /* Reconfigure HW/VLANs/etc here */
_d("Starting services new to this runlevel ...");
dbg("Starting services new to this runlevel ...");
sm->in_teardown = 0;
service_step_all(SVC_TYPE_ANY);
@@ -225,7 +225,7 @@ restart:
* Then, mark all affected service conditions as in-flux and
* let all affected services move to WAITING/HALTED
*/
_d("Stopping services not allowed after reconf ...");
dbg("Stopping services not allowed after reconf ...");
sm->in_teardown = 1;
cond_reload();
service_step_all(SVC_TYPE_ANY);
@@ -240,23 +240,23 @@ restart:
*/
svc = svc_stop_completed();
if (svc) {
_d("Waiting to collect %s, cmd %s(%d) ...", svc_ident(svc, NULL, 0), svc->cmd, svc->pid);
dbg("Waiting to collect %s, cmd %s(%d) ...", svc_ident(svc, NULL, 0), svc->cmd, svc->pid);
break;
}
sm->in_teardown = 0;
_d("Starting services after reconf ...");
dbg("Starting services after reconf ...");
service_step_all(SVC_TYPE_ANY);
/* Cleanup stale services */
svc_clean_dynamic(service_unregister);
_d("Calling reconf hooks ...");
dbg("Calling reconf hooks ...");
plugin_run_hooks(HOOK_SVC_RECONF);
service_step_all(SVC_TYPE_ANY);
_d("Reconfiguration done");
dbg("Reconfiguration done");
sm->state = SM_RUNNING_STATE;
break;
+5 -5
View File
@@ -70,12 +70,12 @@ static void maybe_clear_cond(svc_t *svc)
if (!string_compare(cond, c))
continue;
_d("Not clearing cond %s from gc svc %s, provided by new active service %s",
dbg("Not clearing cond %s from gc svc %s, provided by new active service %s",
cond, ident, svc_ident(s, NULL, 0));
return;
}
_d("Cleaning out %s, clearing any conditions ...", svc->name);
dbg("Cleaning out %s, clearing any conditions ...", svc->name);
cond_clear(mkcond(svc, cond, sizeof(cond)));
}
@@ -657,17 +657,17 @@ int svc_parse_jobstr(char *str, size_t len, void *user_data, int (*found)(svc_t
char *input, *token;
int result = 0;
_d("Got str:'%s'", str);
dbg("Got str:'%s'", str);
input = tokstr(str, len);
while (input) {
char *id = NULL;
svc_t *svc, *iter = NULL;
char *ptr;
_d("Got token:'%s'", input);
dbg("Got token:'%s'", input);
token = sanitize(input, strlen(input) + 1);
if (!token) {
_d("Sanitation of token:'%s' failed", input);
dbg("Sanitation of token:'%s' failed", input);
goto next;
}
ptr = strchr(token, ':');
+10 -10
View File
@@ -60,7 +60,7 @@ char *tty_canonicalize(char *dev)
if (stat(path, &st)) {
if (!strncmp(path, _PATH_DEV, strlen(_PATH_DEV))) {
unavailable:
_d("TTY %s not available at the moment, registering anyway.", path);
dbg("TTY %s not available at the moment, registering anyway.", path);
return path;
}
@@ -99,14 +99,14 @@ char *tty_atcon(void)
fp = fopen("/sys/class/tty/console/active", "r");
if (!fp) {
_e("Cannot find system console, is sysfs not mounted?");
errx(1, "Cannot find system console, is sysfs not mounted?");
errno = ENOENT;
return NULL;
}
buf = malloc(512);
if (!buf) {
_pe("Failed allocating memory for @console");
err(1, "Failed allocating memory for @console");
fclose(fp);
return NULL;
}
@@ -118,7 +118,7 @@ char *tty_atcon(void)
fclose(fp);
ptr = chomp(buf);
_d("consoles: %s", ptr);
dbg("consoles: %s", ptr);
}
dev = strtok_r(ptr, " \t", &save);
@@ -223,11 +223,11 @@ int tty_parse_args(char *cmd, struct tty *tty)
tty->dev = tty_canonicalize(dev);
if (!tty->dev) {
_e("Incomplete or non-existing TTY device given, cannot register.");
errx(1, "Incomplete or non-existing TTY device given, cannot register.");
return errno = EINVAL;
}
_d("Registering %s getty on TTY %s at %s baud with term %s", tty->cmd ? "external" : "built-in",
dbg("Registering %s getty on TTY %s at %s baud with term %s", tty->cmd ? "external" : "built-in",
tty->dev, tty->baud ?: "0", tty->term ?: "N/A");
/* Built-in getty now comes as standalone program */
@@ -291,21 +291,21 @@ int tty_exec(svc_t *svc)
dev = tty_canonicalize(svc->dev);
if (!dev) {
_d("%s: Cannot find TTY device: %s", svc->dev, strerror(errno));
dbg("%s: Cannot find TTY device: %s", svc->dev, strerror(errno));
return EX_CONFIG;
}
if (!tty_exists(dev)) {
_d("%s: Not a valid TTY: %s", dev, strerror(errno));
dbg("%s: Not a valid TTY: %s", dev, strerror(errno));
return EX_OSFILE;
}
if (svc->nologin) {
_d("%s: Starting /bin/sh ...", dev);
dbg("%s: Starting /bin/sh ...", dev);
return run_sh(dev, svc->noclear, svc->nowait, svc->rlimit);
}
_d("%s: Starting %s ...", dev, svc->cmd);
dbg("%s: Starting %s ...", dev, svc->cmd);
for (i = 1, j = 0; i < MAX_NUM_SVC_ARGS; i++) {
if (!svc->args[i][0])
break;