aboutsummaryrefslogtreecommitdiff
path: root/src/inetd.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2009-11-25 10:08:33 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2009-11-25 10:08:33 +0200
commit849e60108f8df449367f4a05eb489017bea35281 (patch)
treecd54057a69e19b9adc1364639a4dac9a37088a6b /src/inetd.c
parent534098c3d35f36ab9d333fb0ee800c7ffaf0dcbd (diff)
downloadpies-849e60108f8df449367f4a05eb489017bea35281.tar.gz
pies-849e60108f8df449367f4a05eb489017bea35281.tar.bz2
Implement TCPMUX internal service.
* src/pies.h (CF_TCPMUX, CF_TCPMUXPLUS): New flags. (struct component): New member: service. (progman_lookup_service, progman_run_comp) (progman_iterate_comp): New protos. * src/progman.c (progman_iterate_comp) (prog_lookup_by_service) (progman_lookup_service): New functions (prog_start_prologue, prog_execute): New functions, extracted from prog_start. (progman_run_comp): New function. (prog_start): Replace extracted parts of code with calls to prog_start_prologue and prog_execute. * src/inetd-bi.c: Implement TCPMUX * src/inetd.c (inetd_conf_file): Handle tcpmux extries.
Diffstat (limited to 'src/inetd.c')
-rw-r--r--src/inetd.c66
1 files changed, 50 insertions, 16 deletions
diff --git a/src/inetd.c b/src/inetd.c
index f6c8276..f356512 100644
--- a/src/inetd.c
+++ b/src/inetd.c
@@ -35,6 +35,9 @@ listel_dispose(const void *el)
free((void*)el);
}
+#define TCPMUX_PREFIX_STR "tcpmux/"
+#define TCPMUX_PREFIX_LEN (sizeof(TCPMUX_PREFIX_STR)-1)
+
static int
inetd_conf_file (const char *file)
{
@@ -69,6 +72,7 @@ inetd_conf_file (const char *file)
char *service;
size_t len;
struct inetd_builtin *builtin;
+ char *tag;
if (line_no)
wordsplit_free (&ws);
@@ -135,21 +139,50 @@ inetd_conf_file (const char *file)
continue;
}
- /* Create URL from protocol and service fields. */
- str = xasprintf ("inet+%s://%s:%s",
- ws.ws_wordv[IFLD_PROTOCOL],
- address ? address : "0.0.0.0",
- service);
- if (pies_url_create (&url, str))
+ tag = service;
+ /* Handle eventual "tcpmux/" */
+ if (strncmp (service, TCPMUX_PREFIX_STR, TCPMUX_PREFIX_LEN) == 0)
{
- /* FIXME: Better error message */
- logmsg (LOG_ERR, "%s:%lu: %s",
- file, line_no, _("invalid socket address"));
- continue;
- }
-
- free (str);
+ service += TCPMUX_PREFIX_LEN;
+ if (*service == '+')
+ {
+ flags |= CF_TCPMUXPLUS;
+ service++;
+ }
+ else
+ flags |= CF_TCPMUX;
+ if (strncmp (ws.ws_wordv[IFLD_PROTOCOL], "tcp", 3))
+ {
+ logmsg (LOG_ERR, "%s:%lu: %s",
+ file, line_no, _("bad protocol for tcpmux service"));
+ continue;
+ }
+ if (socket_type != SOCK_STREAM)
+ {
+ logmsg (LOG_ERR, "%s:%lu: %s",
+ file, line_no, _("bad socket type for tcpmux service"));
+ continue;
+ }
+ url = NULL;
+ }
+ else
+ {
+ /* Create URL from protocol and service fields. */
+ str = xasprintf ("inet+%s://%s:%s",
+ ws.ws_wordv[IFLD_PROTOCOL],
+ address ? address : "0.0.0.0",
+ service);
+ if (pies_url_create (&url, str))
+ {
+ /* FIXME: Better error message */
+ logmsg (LOG_ERR, "%s:%lu: %s",
+ file, line_no, _("invalid socket address"));
+ continue;
+ }
+ free (str);
+ }
+
/* Parse wait/nowait field */
str = strchr (ws.ws_wordv[IFLD_WAIT], '.');
if (str)
@@ -201,15 +234,15 @@ inetd_conf_file (const char *file)
/* Create the component */
if (address)
{
- str = xmalloc (strlen (address) + 1 + strlen (service) + 1);
+ str = xmalloc (strlen (address) + 1 + strlen (tag) + 1);
strcpy (str, address);
strcat (str, ":");
- strcat (str, service);
+ strcat (str, tag);
comp = component_create (str);
free (str);
}
else
- comp = component_create (service);
+ comp = component_create (tag);
comp->mode = pies_comp_inetd;
comp->socket_type = socket_type;
@@ -222,6 +255,7 @@ inetd_conf_file (const char *file)
}
else
comp->flags = flags;
+ comp->service = xstrdup (service);
comp->privs.user = xstrdup (user); /* FIXME: memory leak */
if (group)
{

Return to:

Send suggestions and report system problems to the System administrator.