aboutsummaryrefslogtreecommitdiff
path: root/src/inetd.c
diff options
context:
space:
mode:
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.