mirror of
https://github.com/troglobit/finit.git
synced 2026-11-29 21:08:21 +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
@@ -31,6 +31,7 @@
|
||||
#include <sys/shm.h> /* shmat() */
|
||||
#include <sys/types.h> /* pid_t */
|
||||
|
||||
#include "inetd.h"
|
||||
#include "queue.h" /* BSD sys/queue.h API */
|
||||
#include "libuev/uev.h"
|
||||
|
||||
@@ -64,20 +65,12 @@ typedef struct svc {
|
||||
int reload;
|
||||
int runlevels;
|
||||
|
||||
/* Event loop handler, used for inetd services */
|
||||
uev_t watcher;
|
||||
|
||||
/* For inetd services */
|
||||
int sock_type;
|
||||
int port;
|
||||
int proto;
|
||||
int forking;
|
||||
char service[10];
|
||||
int (*internal_cmd)(int sock_type);
|
||||
|
||||
/* Incremented for each restart by service monitor. */
|
||||
unsigned int restart_counter;
|
||||
|
||||
/* For inetd services */
|
||||
inetd_t inetd;
|
||||
|
||||
/* Identity */
|
||||
char username[MAX_USER_LEN];
|
||||
char group[MAX_USER_LEN];
|
||||
@@ -116,7 +109,8 @@ static inline svc_t *finit_svc_connect(void)
|
||||
}
|
||||
|
||||
svc_t *svc_new (void);
|
||||
svc_t *svc_find (char *name);
|
||||
svc_t *svc_find (char *path);
|
||||
svc_t *svc_find_inetd (char *path, char *service, char *proto, char *port);
|
||||
svc_t *svc_iterator (int restart);
|
||||
void svc_runlevel (int newlevel);
|
||||
|
||||
|
||||
Reference in new issue
Block a user