diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2009-11-26 21:49:15 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2009-11-26 21:49:15 +0200 |
commit | 9de9182e3517c677e2309b0dd58ab4e3af1b3176 (patch) | |
tree | a8d2f33ee720591be9212b9cc6a33a5b018f60bd /src/inetd.c | |
parent | c0802ebe4ebd7e7bb173c6efa2c6e59dd5440cc3 (diff) | |
download | pies-9de9182e3517c677e2309b0dd58ab4e3af1b3176.tar.gz pies-9de9182e3517c677e2309b0dd58ab4e3af1b3176.tar.bz2 |
Implement internal inetd services in the pies config.
* src/pies.h (CF_INTERNAL): New flag.
(ISCF_TCPMUX): New macro.
(struct component): Reorder fields.
New field: tcpmux.
(progman_lookup_service): Remove proto.
(progman_lookup_tcpmux): New proto.
(struct inetd_builtin.foo): Change signature. All uses updated.
* src/progman.c (progman_lookup_service): Remove.
(progman_lookup_tcpmux): New function.
(progman_create_sockets): Skip tcpmux subservices.
(progman_start): Skip disabled inetd components.
* src/inetd-bi.c (tcpmux): Use progman_lookup_tcpmux.
* src/inetd.c (tcpmux_service, mktag): New functions.
(inetd_conf_file): Minor changes.
* src/pies.c (_cb_bitmask, _cb_precious)
(_cb_disabled, _cb_wait): Remove.
(str_to_cf, _cb_flags): New functions.
(component_keywords): Remove keywords:
disable, precious, wait.
Add keywords: flags, service, tcpmux-master.
(component_verify): Improve.
* src/url.c (pies_url_destroy): Fix coredump on NULL argument.
Diffstat (limited to 'src/inetd.c')
-rw-r--r-- | src/inetd.c | 66 |
1 files changed, 44 insertions, 22 deletions
diff --git a/src/inetd.c b/src/inetd.c index f356512..a43bdf2 100644 --- a/src/inetd.c +++ b/src/inetd.c @@ -39,6 +39,43 @@ listel_dispose(const void *el) #define TCPMUX_PREFIX_LEN (sizeof(TCPMUX_PREFIX_STR)-1) static int +tcpmux_service (const char *service, char **psrv, int *pflag) +{ + if (strncmp (service, TCPMUX_PREFIX_STR, TCPMUX_PREFIX_LEN) == 0) + { + service += TCPMUX_PREFIX_LEN; + if (*service == '+') + { + *pflag |= CF_TCPMUXPLUS; + service++; + } + else + *pflag |= CF_TCPMUX; + *psrv = (char *) service; + return 1; + } + return 0; +} + +static char * +mktag (const char *address, const char *service) +{ + char *str; + + if (address) + { + str = xmalloc (strlen (address) + 1 + strlen (service) + 1); + strcpy (str, address); + strcat (str, ":"); + strcat (str, service); + } + else + str = xstrdup (service); + return str; +} + + +static int inetd_conf_file (const char *file) { FILE *fp; @@ -141,17 +178,8 @@ inetd_conf_file (const char *file) tag = service; /* Handle eventual "tcpmux/" */ - if (strncmp (service, TCPMUX_PREFIX_STR, TCPMUX_PREFIX_LEN) == 0) + if (tcpmux_service (service, &service, &flags)) { - 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", @@ -224,7 +252,7 @@ inetd_conf_file (const char *file) if (!builtin) { logmsg (LOG_ERR, "%s:%lu: %s", - file, line_no, _("unknown built-in")); + file, line_no, _("unknown internal service")); continue; } } @@ -232,17 +260,9 @@ inetd_conf_file (const char *file) builtin = NULL; /* Create the component */ - if (address) - { - str = xmalloc (strlen (address) + 1 + strlen (tag) + 1); - strcpy (str, address); - strcat (str, ":"); - strcat (str, tag); - comp = component_create (str); - free (str); - } - else - comp = component_create (tag); + str = mktag (address, tag); + comp = component_create (str); + free (str); comp->mode = pies_comp_inetd; comp->socket_type = socket_type; @@ -255,6 +275,8 @@ inetd_conf_file (const char *file) } else comp->flags = flags; + if (ISCF_TCPMUX (comp->flags)) + comp->tcpmux = mktag (address, "tcpmux"); comp->service = xstrdup (service); comp->privs.user = xstrdup (user); /* FIXME: memory leak */ if (group) |