Add support for a deny filter syntax to inetd services

This patch changes the syntax for custom inetd services and adds support
for deny filters.  The new syntax is:

    inetd service/proto[@iface,!iface,...] </path/to/cmd | internal[.service]>

This means the second column now defines what@from and the third to/what
process.  For internal services on a custom port the internal.service
syntax must be specified, so Finit can properly bind the inetd service
to the correct plugin.  Here follows a few examples:

    inetd time/udp                    wait [2345] internal                -- UNIX rdate service
    inetd time/tcp                  nowait [2345] internal                -- UNIX rdate service
    inetd 3737/tcp                  nowait [2345] internal.time           -- UNIX rdate service
    inetd telnet/tcp@*,!eth1,!eth0, nowait [2345] /sbin/telnetd -i -F     -- Telnet service
    inetd 2323/tcp@eth1,eth2,eth0   nowait [2345] /sbin/telnetd -i -F     -- Telnet service
    inetd 222/tcp@eth0              nowait [2345] /sbin/dropbear -i -R -F -- SSH service
    inetd ssh/tcp@*,!eth0           nowait [2345] /sbin/dropbear -i -R -F -- SSH service

Access to telnet on port `2323` is only possible from interfaces `eth0`,
`eth1` and `eth2`.  The standard telnet port (`23`) is available from
all other interfaces, but also `eth2`.  The `*` notation used in the ssh
stanza means *any* interface, however, here `eth0` is not allowed.

NOTE: This patch breaks syntax compatibility with Finit v1.12!

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson committed 2015-06-15 14:15:39 +02:00
1 parent b0c759e518
commit 03573b41ca
7 files changed
+177 -195

No files matched your search

+7 -5
View File
@@ -59,14 +59,16 @@ static int do_send(int cmd, int runlevel)
return result;
}
/* telinit q | telinit <1-6> */
/* telinit q | telinit <0-9> */
static int usage(int rc)
{
fprintf(stderr, "Usage: %s <q | 1-6>\n\n"
fprintf(stderr, "Usage: %s [OPTIONS] [q | Q | 0-9]\n\n"
"Options:\n"
" -v, --verbose Verbose output\n"
" -h, --help This help text\n\n"
" -V, --version Show Finit version\n\n", __progname);
" -V, --version Show Finit version\n\n"
"Commands:\n"
" q | Q Reload *.conf in /etc/finit.d/, like SIGHUP\n"
" 0 - 9 Change runlevel: 0 halt, 6 reboot\n\n", __progname);
return rc;
}
@@ -95,7 +97,7 @@ int client(int argc, char *argv[])
if (optind < argc) {
int req = (int)argv[optind][0];
/* Compat: 'init <1-9>' */
/* Compat: 'init <0-9>' */
if (isdigit(req))
return do_send(INIT_CMD_RUNLVL, req);