aboutsummaryrefslogtreecommitdiff
path: root/src/pies.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2009-11-28 12:09:15 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2009-11-28 13:15:51 +0200
commit36a53f1875a097fa16bceaf674dc627d916651df (patch)
treeee33a5cf08231f11a3b31e0f16652229d5add561 /src/pies.c
parent69bc6e88c7babf356efbacbdc2230de407c27590 (diff)
downloadpies-36a53f1875a097fa16bceaf674dc627d916651df.tar.gz
pies-36a53f1875a097fa16bceaf674dc627d916651df.tar.bz2
Handle per-tcpmux ACL's. Optionally pass socket data via environment variables.
* src/inetd-bi.c (tcpmux): Consult the component's ACL before deciding whether to handle the connection. * src/pies.c (str_to_socket_type): Rewrite using strtotok. (socket_type_to_str): New function (str_to_cf): New flags: sockenv and resolve. Use strtotok. (main): Log_tag defaults to program instance name. * src/pies.h: Include socket-related headers. (CF_SOCKENV, CF_RESOLVE): New flags. (pies_sockaddr_storage): New union. (check_acl): New proto. (progman_run_comp): Change signature. (socket_type_to_str): New proto. * src/progman.c (struct prog): New members sa_storage, sa_len. (prog_sockenv): New function. (progman_run_comp): Call prog_sockenv. Initialize sa_storage and sa_len of the created struct prog. (prog_start): Call prog_sockenv. Do not close 2 if logging to stderr. (check_acl): Remove static. (_prog_accept): Use union pies_sockaddr_storage. Pass socket address in pinst->v.p.sa_storage and pinst->v.p.sa_len. (sockenv_hint, envsize): New variables. (add_env): New function. (env_setup): Remove. (environ_setup): New function. * src/socket.c: Remove unnecessary includes.
Diffstat (limited to 'src/pies.c')
-rw-r--r--src/pies.c63
1 files changed, 35 insertions, 28 deletions
diff --git a/src/pies.c b/src/pies.c
index c583d7b..20ad9e2 100644
--- a/src/pies.c
+++ b/src/pies.c
@@ -772,22 +772,26 @@ _cb_url (enum grecs_callback_command cmd,
return 0;
}
+static struct tokendef socktype_xtab[] = {
+ { "stream", SOCK_STREAM },
+ { "dgram", SOCK_DGRAM },
+ { "seqpacket", SOCK_SEQPACKET },
+ { "raw", SOCK_RAW },
+ { "rdm", SOCK_RDM },
+ { "packet", SOCK_PACKET },
+ { NULL }
+};
+
int
-str_to_socket_type (const char *str, int *pret)
+str_to_socket_type (const char *str, int *pres)
{
- if (strcmp (str, "stream") == 0)
- *pret = SOCK_STREAM;
- else if (strcmp (str, "dgram") == 0)
- *pret = SOCK_DGRAM;
- else if (strcmp (str, "rdm") == 0)
- *pret = SOCK_RDM;
- else if (strcmp (str, "seqpacket") == 0)
- *pret = SOCK_SEQPACKET;
- else if (strcmp (str, "raw") == 0)
- *pret = SOCK_RAW;
- else
- return 1;
- return 0;
+ return strtotok (socktype_xtab, str, pres);
+}
+
+int
+socket_type_to_str (int socket_type, const char **pres)
+{
+ return toktostr (socktype_xtab, socket_type, pres);
}
static int
@@ -854,6 +858,18 @@ str_to_cf (const char *string, int *flags)
size_t len = strlen (string);
int neg = 0;
int mask;
+
+ static struct tokendef cf_tab[] = {
+ { "disable", CF_DISABLED },
+ { "precious", CF_PRECIOUS },
+ { "wait", CF_WAIT },
+ { "tcpmux", CF_TCPMUX },
+ { "tcpmuxplus", CF_TCPMUXPLUS },
+ { "internal", CF_INTERNAL },
+ { "sockenv", CF_SOCKENV },
+ { "resolve", CF_RESOLVE },
+ { NULL }
+ };
if (len > 2 && memcmp (string, "no", 2) == 0)
{
@@ -861,19 +877,7 @@ str_to_cf (const char *string, int *flags)
string += 2;
}
- if (strcmp (string, "disable") == 0)
- mask = CF_DISABLED;
- else if (strcmp (string, "precious") == 0)
- mask = CF_PRECIOUS;
- else if (strcmp (string, "wait") == 0)
- mask = CF_WAIT;
- else if (strcmp (string, "tcpmux") == 0)
- mask = CF_TCPMUX;
- else if (strcmp (string, "tcpmuxplus") == 0)
- mask = CF_TCPMUXPLUS;
- else if (strcmp (string, "internal") == 0)
- mask = CF_INTERNAL;
- else
+ if (strtotok (cf_tab, string, &mask))
return 1;
if (neg)
@@ -2215,6 +2219,9 @@ main (int argc, char **argv)
else
instance++;
}
+ else
+ log_tag = instance;
+
set_file_names (instance);
if (!DEFAULT_PREPROCESSOR)
@@ -2224,7 +2231,7 @@ main (int argc, char **argv)
grecs_preprocessor = obstack_finish (&pp_stk);
free (pp_qopt);
}
-
+
if (preprocess_only)
{
for (file = conf_head; file; file = file->next)

Return to:

Send suggestions and report system problems to the System administrator.