mirror of
https://github.com/troglobit/finit.git
synced 2026-11-13 17:00:16 +00:00
Refactor inetd support, now with support for custom ports and iface filtering
This patch adds support for custom port and interface filtering to inetd
services, in a very condensed syntax:
inetd ssh@eth0:222/tcp nowait [2345] /usr/sbin/sshd -i
inetd ssh@eth1:22/tcp nowait [2345] /usr/sbin/sshd -i
In this example eth0 and eth1 are allowed inbound interfaces for SSH
connections, on port 222 and 22, respectively. Attempting to connect
from any other interface is denied. Also, if the system is not in
runlevel 2, 3, 4, or 5, ports 222 and 22 will not even be opened.
If eth0 is your upstream interface you may want to avoid using the
default port. To run ssh on port 222, and all others on port 22:
inetd ssh@eth0:222/tcp nowait [2345] /usr/sbin/sshd -i
inetd ssh/tcp nowait [2345] /usr/sbin/sshd -i
This actually adds a deny rule for eth0 on ssh/tcp, implicitly. You can
even list the services in the reverse order with the same result:
inetd ssh/tcp nowait [2345] /usr/sbin/sshd -i
inetd ssh@eth0:222/tcp nowait [2345] /usr/sbin/sshd -i
There is no specific deny syntax available yet, see the TODO file for
more details on how this can be implemented.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
365932510f
commit
ded4b3926e
4 files changed
+430
-91
No files matched your search
@@ -24,14 +24,46 @@
|
||||
#ifndef FINIT_INETD_H_
|
||||
#define FINIT_INETD_H_
|
||||
|
||||
#include <netdb.h>
|
||||
#include <net/if.h>
|
||||
|
||||
#include "queue.h"
|
||||
#include "libuev/uev.h"
|
||||
|
||||
|
||||
typedef struct inetd_filter {
|
||||
LIST_ENTRY(inetd_filter) link;
|
||||
int deny; /* 0:allow, 1:deny */
|
||||
char ifname[IFNAMSIZ]; /* E.g., eth0 */
|
||||
} inetd_filter_t;
|
||||
|
||||
typedef struct {
|
||||
uev_t watcher;
|
||||
|
||||
int type; /* Socket type: SOCK_STREAM/SOCK_DGRAM */
|
||||
int std; /* Standard proto/port from /etc/services */
|
||||
int proto;
|
||||
int port;
|
||||
int forking;
|
||||
char name[10];
|
||||
int (*cmd)(int type); /* internal inetd service, like 'time' */
|
||||
|
||||
LIST_HEAD(, inetd_filter) filters;
|
||||
} inetd_t;
|
||||
|
||||
int inetd_dgram_peek (int sd, char *ifname);
|
||||
int inetd_stream_peek (int sd, char *ifname);
|
||||
|
||||
int inetd_respawn (pid_t pid);
|
||||
void inetd_runlevel(uev_ctx_t *ctx, int runlevel);
|
||||
|
||||
int inetd_match (inetd_t *inetd, char *service, char *proto, char *port);
|
||||
int inetd_add (inetd_t *inetd, char *service, char *proto, char *ifname, char *port, int forking);
|
||||
|
||||
inetd_filter_t *inetd_filter_find (inetd_t *inetd, char *ifname);
|
||||
int inetd_allow_iface (inetd_t *inetd, char *ifname);
|
||||
int inetd_is_iface_allowed (inetd_t *inetd, char *ifname);
|
||||
|
||||
#endif /* FINIT_INETD_H_ */
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user