mirror of
https://github.com/troglobit/finit.git
synced 2026-10-29 12:40:44 +00:00
Refactor: introduce telinit and a new initctl tool w/ API
- Reduce size of `helpers.c`, for linking against new `initctl` tool, by moving out functions to `pid.c` and `exec.c` - Add `AF_UNIX` API to Finit, to complement old `/dev/initctl` FIFO - Let old FIFO API be used by init/telinit: `init <q | 1-9>` - Move all advanced initctl code from `client.c` to `initctl.c`, yes its a bit confusing to call the *new* tool the same as the old FIFO but this is more in line with what, e.g Upstart does. - Move all advanced server side code from `plugins/initctl.c` to `api.c` - Update TODO with upcoming inetd syntax change and dynamic events. - Temporarily fix display of inetd services from `initctl status -v` Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
66edb42e06
commit
1a1f24721f
15 files changed
+934
-731
No files matched your search
@@ -390,6 +390,60 @@ int inetd_match(inetd_t *inetd, char *service, char *proto, char *port)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Compose presentable string of inetd filters: !eth0,eth1,eth2,!eth3 */
|
||||
int inetd_filter_str(inetd_t *inetd, char *str, size_t len)
|
||||
{
|
||||
int prev = 0;
|
||||
char buf[42];
|
||||
inetd_filter_t *filter;
|
||||
|
||||
if (!inetd || !str || len <= 0) {
|
||||
_e("Dafuq?");
|
||||
return 1;
|
||||
}
|
||||
|
||||
snprintf(str, len, "%s allow ", inetd->name);
|
||||
LIST_FOREACH(filter, &inetd->filters, link) {
|
||||
char ifname[IFNAMSIZ];
|
||||
|
||||
if (filter->deny)
|
||||
continue;
|
||||
|
||||
if (!strlen(filter->ifname))
|
||||
snprintf(ifname, sizeof(ifname), "ANY");
|
||||
else
|
||||
strlcpy(ifname, filter->ifname, sizeof(ifname));
|
||||
|
||||
snprintf(buf, sizeof(buf), "%s%s:%d", prev ? "," : "",
|
||||
ifname, inetd->port);
|
||||
prev = 1;
|
||||
strlcat(str, buf, len);
|
||||
}
|
||||
|
||||
prev = 0;
|
||||
LIST_FOREACH(filter, &inetd->filters, link) {
|
||||
char ifname[IFNAMSIZ];
|
||||
|
||||
if (!filter->deny)
|
||||
continue;
|
||||
if (!prev) {
|
||||
snprintf(buf, sizeof(buf), " deny ");
|
||||
strlcat(str, buf, len);
|
||||
}
|
||||
|
||||
if (!strlen(filter->ifname))
|
||||
snprintf(ifname, sizeof(ifname), "ANY");
|
||||
else
|
||||
strlcpy(ifname, filter->ifname, sizeof(ifname));
|
||||
|
||||
snprintf(buf, sizeof(buf), "%s%s", prev ? "," : "", ifname);
|
||||
prev = 1;
|
||||
strlcat(str, buf, len);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function is called to add a new, unique, inetd service. When an
|
||||
* ifname is given as argument this means *only* run service on this
|
||||
|
||||
Reference in new issue
Block a user