aboutsummaryrefslogtreecommitdiff
path: root/src/inetd-bi.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2009-12-23 23:51:39 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2009-12-23 23:57:48 +0200
commita37a83f6143e672a71ee4436fa24aaa2f9c81877 (patch)
treec5791a295aebf12bf7865f1c100dc3ee72bbc79b /src/inetd-bi.c
parentbb72dbbbbac7806a6321a404ec4c852b63e819b7 (diff)
downloadpies-a37a83f6143e672a71ee4436fa24aaa2f9c81877.tar.gz
pies-a37a83f6143e672a71ee4436fa24aaa2f9c81877.tar.bz2
Limit number of connections per socket (IP).
* src/inetd-bi.c (fd_write): Remove. Use fd_report instead. * src/pies.c (component_keywords): New keywords: max-instances-message, max-ip-connections, max-ip-connections-message, access-denied-message. * src/pies.h (struct component): New members: max_ip_connections, access_denied_message, max_instances_message, max_ip_connections_message. (fd_report): New extern. * src/progman.c (conn_class): New struct. (struct prog.p): New member cclass. (conn_tab): New static. (conn_class_lookup, conn_class_report): New functions. (progman_run_comp): Set cclass. (fd_report): New function. (_prog_accept): In case of failure (access denied, etc.) optionally send response strings over the fd. Limit number of connections per socket (IP). (progman_cleanup): Update cclass counter.
Diffstat (limited to 'src/inetd-bi.c')
-rw-r--r--src/inetd-bi.c21
1 files changed, 8 insertions, 13 deletions
diff --git a/src/inetd-bi.c b/src/inetd-bi.c
index d002e4c..b771936 100644
--- a/src/inetd-bi.c
+++ b/src/inetd-bi.c
@@ -296,20 +296,14 @@ fd_getline (int fd, char *buf, int len)
}
static int
-fd_write (int fd, const char *text)
-{
- return write (fd, text, strlen (text));
-}
-
-static int
tcpmux_help (struct component *comp, void *data)
{
int *pfd = data;
if (!(comp->flags & CF_DISABLED) && ISCF_TCPMUX (comp->flags))
{
- fd_write (*pfd, comp->service);
- fd_write (*pfd, "\r\n");
+ fd_report (*pfd, comp->service);
+ fd_report (*pfd, "\r\n");
}
return 0;
}
@@ -327,7 +321,7 @@ tcpmux (int fd, struct component const *comp)
/* Read service name */
if ((len = fd_getline (fd, service, MAX_SERV_LEN)) < 0)
{
- fd_write (fd, "-Error reading service name\r\n");
+ fd_report (fd, "-Error reading service name\r\n");
return;
}
service[len] = 0;
@@ -343,7 +337,7 @@ tcpmux (int fd, struct component const *comp)
srv_comp = progman_lookup_tcpmux (service, comp->tag);
if (!srv_comp)
{
- fd_write (fd, "-Service not available\r\n");
+ fd_report (fd, "-Service not available\r\n");
return;
}
@@ -356,19 +350,20 @@ tcpmux (int fd, struct component const *comp)
{
if (rc)
{
- fd_write (fd, "-Service not available\r\n");
+ fd_report (fd, "-Service not available\r\n");
return;
}
if (check_acl (comp->acl, (struct sockaddr *) &sa, salen))
{
- fd_write (fd, "-Service not available\r\n");
+ fd_report (fd, "-Service not available\r\n");
return;
}
}
+ /* FIXME: What about max-instances, etc.? */
if (srv_comp->flags & CF_TCPMUXPLUS)
- fd_write (fd, "+Go\r\n");
+ fd_report (fd, "+Go\r\n");
progman_run_comp (srv_comp, fd, &sa, salen);
}

Return to:

Send suggestions and report system problems to the System administrator.