annotate dpid/main.c @ 2104:3e7e5395f0bc

non-ASCII keybindings Alexander Voigt has kindly done some testing, and it seems that this makes bindings to most keys on a German keyboard possible -- except those that need AltGr don't work yet.
author corvid <corvid@lavabit.com>
date Thu, 23 Jun 2011 19:24:11 +0000
parents 3a159d7e5098
children
rev   line source
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
2 Copyright (C) 2003 Ferdi Franceschini <ferdif@optusnet.com.au>
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
3
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
4 This program is free software; you can redistribute it and/or modify
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
5 it under the terms of the GNU General Public License as published by
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
6 the Free Software Foundation; either version 3 of the License, or
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
7 (at your option) any later version.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
8
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
9 This program is distributed in the hope that it will be useful,
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
12 GNU General Public License for more details.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
13
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
14 You should have received a copy of the GNU General Public License
972
d7dbd3dcfa38 Updated the GPL copyright note in the source files
Detlef Riekenberg <wine.dev@web.de>
parents: 368
diff changeset
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
16 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
17
1382
7faa2c7a544f Switch the DPI framework from Unix sockets to Internet sockets
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
18 #include <errno.h> /* for ckd_write */
7faa2c7a544f Switch the DPI framework from Unix sockets to Internet sockets
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
19 #include <unistd.h> /* for ckd_write */
7faa2c7a544f Switch the DPI framework from Unix sockets to Internet sockets
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
20 #include <stdlib.h> /* for exit */
7faa2c7a544f Switch the DPI framework from Unix sockets to Internet sockets
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
21 #include <assert.h> /* for assert */
7faa2c7a544f Switch the DPI framework from Unix sockets to Internet sockets
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
22 #include <sys/stat.h> /* for umask */
1223
a09dbf132be6 Remove system includes for dpid
Jorge Arellano Cid <jcid@dillo.org>
parents: 972
diff changeset
23
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
24 #include "dpid_common.h"
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
25 #include "dpid.h"
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
26 #include "dpi.h"
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
27 #include "dpi_socket_dir.h"
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
28 #include "misc_new.h"
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
29 #include "../dpip/dpip.h"
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
30
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
31 sigset_t mask_sigchld;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
32
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
33
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
34 /* Start a dpi filter plugin after accepting the pending connection
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
35 * \Return
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
36 * \li Child process ID on success
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
37 * \li 0 on failure
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
38 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
39 static int start_filter_plugin(struct dp dpi_attr)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
40 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
41 int newsock, old_stdout=-1, old_stdin=-1;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
42 socklen_t csz;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
43 struct sockaddr_un clnt_addr;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
44 pid_t pid;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
45
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
46 csz = (socklen_t) sizeof(clnt_addr);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
47
1382
7faa2c7a544f Switch the DPI framework from Unix sockets to Internet sockets
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
48 newsock = accept(dpi_attr.sock_fd, (struct sockaddr *) &clnt_addr, &csz);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
49 if (newsock == -1)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
50 ERRMSG("start_plugin", "accept", errno);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
51
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
52 dup2(STDIN_FILENO, old_stdin);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
53 if (dup2(newsock, STDIN_FILENO) == -1) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
54 ERRMSG("start_plugin", "dup2", errno);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
55 MSG_ERR("ERROR in child proc for %s\n", dpi_attr.path);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
56 exit(1);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
57 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
58
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
59 dup2(STDOUT_FILENO, old_stdout);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
60 if (dup2(newsock, STDOUT_FILENO) == -1) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
61 ERRMSG("start_plugin", "dup2", errno);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
62 MSG_ERR("ERROR in child proc for %s\n", dpi_attr.path);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
63 exit(1);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
64 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
65 if ((pid = fork()) == -1) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
66 ERRMSG("main", "fork", errno);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
67 return 0;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
68 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
69 if (pid == 0) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
70 /* Child, start plugin */
1230
60fb2b1b6220 Cast NULL sentinel to (char*) for execl (fix for LP64 arch).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1223
diff changeset
71 if (execl(dpi_attr.path, dpi_attr.path, (char*)NULL) == -1) {
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
72 ERRMSG("start_plugin", "execl", errno);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
73 MSG_ERR("ERROR in child proc for %s\n", dpi_attr.path);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
74 exit(1);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
75 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
76 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
77
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
78 /* Parent, Close sockets fix stdio and return pid */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
79 if (a_Misc_close_fd(newsock) == -1) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
80 ERRMSG("start_plugin", "close", errno);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
81 MSG_ERR("ERROR in child proc for %s\n", dpi_attr.path);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
82 exit(1);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
83 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
84 a_Misc_close_fd(STDIN_FILENO);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
85 a_Misc_close_fd(STDOUT_FILENO);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
86 dup2(old_stdin, STDIN_FILENO);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
87 dup2(old_stdout, STDOUT_FILENO);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
88 return pid;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
89 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
90
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
91 static void start_server_plugin(struct dp dpi_attr)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
92 {
1382
7faa2c7a544f Switch the DPI framework from Unix sockets to Internet sockets
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
93 if (dup2(dpi_attr.sock_fd, STDIN_FILENO) == -1) {
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
94 ERRMSG("start_plugin", "dup2", errno);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
95 MSG_ERR("ERROR in child proc for %s\n", dpi_attr.path);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
96 exit(1);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
97 }
1382
7faa2c7a544f Switch the DPI framework from Unix sockets to Internet sockets
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
98 if (a_Misc_close_fd(dpi_attr.sock_fd) == -1) {
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
99 ERRMSG("start_plugin", "close", errno);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
100 MSG_ERR("ERROR in child proc for %s\n", dpi_attr.path);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
101 exit(1);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
102 }
1230
60fb2b1b6220 Cast NULL sentinel to (char*) for execl (fix for LP64 arch).
Jorge Arellano Cid <jcid@dillo.org>
parents: 1223
diff changeset
103 if (execl(dpi_attr.path, dpi_attr.path, (char*)NULL) == -1) {
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
104 ERRMSG("start_plugin", "execl", errno);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
105 MSG_ERR("ERROR in child proc for %s\n", dpi_attr.path);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
106 exit(1);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
107 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
108 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
109
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
110 /*!
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
111 * Read service request from sock
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
112 * \Return
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
113 * pointer to dynamically allocated request tag
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
114 */
1387
16cf380cd04c Convert dpid, file dpi and cookies dpi to dsh API
Jorge Arellano Cid <jcid@dillo.org>
parents: 1382
diff changeset
115 static char *get_request(Dsh *sh)
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
116 {
1387
16cf380cd04c Convert dpid, file dpi and cookies dpi to dsh API
Jorge Arellano Cid <jcid@dillo.org>
parents: 1382
diff changeset
117 char *dpip_tag;
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
118
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
119 (void) sigprocmask(SIG_BLOCK, &mask_sigchld, NULL);
1388
eb35203124e4 Implemented the file dpi based on select() (removed its pthreads dependency)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1387
diff changeset
120 dpip_tag = a_Dpip_dsh_read_token(sh, 1);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
121 (void) sigprocmask(SIG_UNBLOCK, &mask_sigchld, NULL);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
122
1387
16cf380cd04c Convert dpid, file dpi and cookies dpi to dsh API
Jorge Arellano Cid <jcid@dillo.org>
parents: 1382
diff changeset
123 return dpip_tag;
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
124 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
125
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
126 /*!
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
127 * Get value of cmd field in dpi_tag
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
128 * \Return
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
129 * command code on success, -1 on failure
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
130 */
1387
16cf380cd04c Convert dpid, file dpi and cookies dpi to dsh API
Jorge Arellano Cid <jcid@dillo.org>
parents: 1382
diff changeset
131 static int get_command(Dsh *sh, char *dpi_tag)
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
132 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
133 char *cmd, *d_cmd;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
134 int COMMAND;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
135
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
136 if (dpi_tag == NULL) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
137 _ERRMSG("get_command", "dpid tag is NULL", 0);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
138 return (-1);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
139 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
140
1236
b912173aecd1 Added a_Dpip_get_attr_l() to DPIP's API
Jorge Arellano Cid <jcid@dillo.org>
parents: 1230
diff changeset
141 cmd = a_Dpip_get_attr(dpi_tag, "cmd");
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
142
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
143 if (cmd == NULL) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
144 ERRMSG("get_command", "a_Dpip_get_attr", 0);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
145 MSG_ERR(": dpid failed to parse cmd in %s\n", dpi_tag);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
146 d_cmd = a_Dpip_build_cmd("cmd=%s msg=%s",
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
147 "DpiError", "Failed to parse request");
1387
16cf380cd04c Convert dpid, file dpi and cookies dpi to dsh API
Jorge Arellano Cid <jcid@dillo.org>
parents: 1382
diff changeset
148 a_Dpip_dsh_write_str(sh, 1, d_cmd);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
149 dFree(d_cmd);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
150 COMMAND = -1;
1387
16cf380cd04c Convert dpid, file dpi and cookies dpi to dsh API
Jorge Arellano Cid <jcid@dillo.org>
parents: 1382
diff changeset
151 } else if (strcmp("auth", cmd) == 0) {
16cf380cd04c Convert dpid, file dpi and cookies dpi to dsh API
Jorge Arellano Cid <jcid@dillo.org>
parents: 1382
diff changeset
152 COMMAND = AUTH_CMD;
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
153 } else if (strcmp("DpiBye", cmd) == 0) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
154 COMMAND = BYE_CMD;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
155 } else if (strcmp("check_server", cmd) == 0) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
156 COMMAND = CHECK_SERVER_CMD;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
157 } else if (strcmp("register_all", cmd) == 0) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
158 COMMAND = REGISTER_ALL_CMD;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
159 } else if (strcmp("register_service", cmd) == 0) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
160 COMMAND = REGISTER_SERVICE_CMD;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
161 } else { /* Error unknown command */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
162 COMMAND = UNKNOWN_CMD;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
163 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
164
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
165 dFree(cmd);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
166 return (COMMAND);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
167 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
168
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
169 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
170 * Check whether a dpi server is running
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
171 */
84
03f9a7877a2e Implemented the SELECT element in FORMS!
jcid
parents: 67
diff changeset
172 static int server_is_running(char *server_id)
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
173 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
174 int i;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
175
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
176 /* Search in the set of running servers */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
177 for (i = 0; i < numdpis; i++) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
178 if (!dpi_attr_list[i].filter && dpi_attr_list[i].pid > 1 &&
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
179 strcmp(dpi_attr_list[i].id, server_id) == 0)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
180 return 1;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
181 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
182 return 0;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
183 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
184
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
185
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
186 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
187 * Get MAX open FD limit (yes, it's tricky --Jcid).
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
188 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
189 static int get_open_max(void)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
190 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
191 #ifdef OPEN_MAX
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
192 return OPEN_MAX;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
193 #else
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
194 int ret = sysconf(_SC_OPEN_MAX);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
195 if (ret < 0)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
196 ret = 256;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
197 return ret;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
198 #endif
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
199 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
200
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
201 /*! \todo
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
202 * \li Add a dpid_idle_timeout variable to dpidrc
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
203 * \bug Infinite loop if plugin crashes before it accepts a connection
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
204 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
205 int main(void)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
206 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
207 int i, n = 0, open_max;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
208 int dpid_idle_timeout = 60 * 60; /* default, in seconds */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
209 struct timeval select_timeout;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
210 sigset_t mask_none;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
211 fd_set selected_set;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
212
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
213 dpi_attr_list = NULL;
67
ec671a7ea6e2 - * Improved the dpi framework. Now dpi-programs can be specified in dpidrc,
jcid
parents: 0
diff changeset
214 services_list = NULL;
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
215 //daemon(0,0); /* Use 0,1 for feedback */
368
2242da885677 - s/todo:/TODO:/g
jcid
parents: 335
diff changeset
216 /* TODO: call setsid() ?? */
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
217
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
218 /* Allow read and write access, but only for the user.
368
2242da885677 - s/todo:/TODO:/g
jcid
parents: 335
diff changeset
219 * TODO: can this cause trouble with umount? */
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
220 umask(0077);
368
2242da885677 - s/todo:/TODO:/g
jcid
parents: 335
diff changeset
221 /* TODO: make dpid work on any directory. */
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
222 // chdir("/");
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
223
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
224 /* close inherited file descriptors */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
225 open_max = get_open_max();
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
226 for (i = 3; i < open_max; i++)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
227 a_Misc_close_fd(i);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
228
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
229 /* this sleep used to unmask a race condition */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
230 // sleep(2);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
231
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
232 dpi_errno = no_errors;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
233
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
234 /* Get list of available dpis */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
235 numdpis = register_all(&dpi_attr_list);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
236
1382
7faa2c7a544f Switch the DPI framework from Unix sockets to Internet sockets
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
237 #if 0
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
238 /* Get name of socket directory */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
239 dirname = a_Dpi_sockdir_file();
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
240 if ((sockdir = init_sockdir(dirname)) == NULL) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
241 ERRMSG("main", "init_sockdir", 0);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
242 MSG_ERR("Failed to create socket directory\n");
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
243 exit(1);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
244 }
1382
7faa2c7a544f Switch the DPI framework from Unix sockets to Internet sockets
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
245 #endif
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
246
67
ec671a7ea6e2 - * Improved the dpi framework. Now dpi-programs can be specified in dpidrc,
jcid
parents: 0
diff changeset
247 /* Init and get services list */
ec671a7ea6e2 - * Improved the dpi framework. Now dpi-programs can be specified in dpidrc,
jcid
parents: 0
diff changeset
248 fill_services_list(dpi_attr_list, numdpis, &services_list);
ec671a7ea6e2 - * Improved the dpi framework. Now dpi-programs can be specified in dpidrc,
jcid
parents: 0
diff changeset
249
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
250 /* Remove any sockets that may have been leftover from a crash */
1382
7faa2c7a544f Switch the DPI framework from Unix sockets to Internet sockets
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
251 //cleanup();
7faa2c7a544f Switch the DPI framework from Unix sockets to Internet sockets
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
252
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
253 /* Initialise sockets */
1382
7faa2c7a544f Switch the DPI framework from Unix sockets to Internet sockets
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
254 if ((numsocks = init_ids_srs_socket()) == -1) {
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
255 switch (dpi_errno) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
256 case dpid_srs_addrinuse:
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
257 MSG_ERR("dpid refuses to start, possibly because:\n");
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
258 MSG_ERR("\t1) An instance of dpid is already running.\n");
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
259 MSG_ERR("\t2) A previous dpid didn't clean up on exit.\n");
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
260 exit(1);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
261 default:
1382
7faa2c7a544f Switch the DPI framework from Unix sockets to Internet sockets
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
262 //ERRMSG("main", "init_srs_socket failed", 0);
7faa2c7a544f Switch the DPI framework from Unix sockets to Internet sockets
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
263 ERRMSG("main", "init_ids_srs_socket failed", 0);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
264 exit(1);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
265 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
266 }
1382
7faa2c7a544f Switch the DPI framework from Unix sockets to Internet sockets
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
267 numsocks = init_all_dpi_sockets(dpi_attr_list);
1550
3a159d7e5098 remove ~/.dillo/dpid_comm_keys on exit of dpid
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1388
diff changeset
268 est_dpi_terminator();
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
269 est_dpi_sigchld();
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
270
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
271 (void) sigemptyset(&mask_sigchld);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
272 (void) sigaddset(&mask_sigchld, SIGCHLD);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
273 (void) sigemptyset(&mask_none);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
274 (void) sigprocmask(SIG_SETMASK, &mask_none, NULL);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
275
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
276 printf("dpid started\n");
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
277 /* Start main loop */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
278 while (1) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
279 do {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
280 (void) sigprocmask(SIG_BLOCK, &mask_sigchld, NULL);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
281 if (caught_sigchld) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
282 handle_sigchld();
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
283 caught_sigchld = 0;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
284 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
285 (void) sigprocmask(SIG_UNBLOCK, &mask_sigchld, NULL);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
286 select_timeout.tv_sec = dpid_idle_timeout;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
287 select_timeout.tv_usec = 0;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
288 selected_set = sock_set;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
289 n = select(FD_SETSIZE, &selected_set, NULL, NULL, &select_timeout);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
290 if (n == 0) { /* select timed out, try to exit */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
291 /* BUG: This is a workaround for dpid not to exit when the
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
292 * downloads server is active. The proper way to handle it is with
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
293 * a dpip command that asks the server whether it's busy.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
294 * Note: the cookies server may lose session info too. */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
295 if (server_is_running("downloads"))
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
296 continue;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
297
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
298 stop_active_dpis(dpi_attr_list, numdpis);
1382
7faa2c7a544f Switch the DPI framework from Unix sockets to Internet sockets
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
299 //cleanup();
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
300 exit(0);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
301 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
302 } while (n == -1 && errno == EINTR);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
303
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
304 if (n == -1) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
305 ERRMSG("main", "select", errno);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
306 exit(1);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
307 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
308 /* If the service req socket is selected then service the req. */
1382
7faa2c7a544f Switch the DPI framework from Unix sockets to Internet sockets
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
309 if (FD_ISSET(srs_fd, &selected_set)) {
7faa2c7a544f Switch the DPI framework from Unix sockets to Internet sockets
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
310 int sock_fd;
7faa2c7a544f Switch the DPI framework from Unix sockets to Internet sockets
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
311 socklen_t sin_sz;
7faa2c7a544f Switch the DPI framework from Unix sockets to Internet sockets
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
312 struct sockaddr_in sin;
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
313 char *req = NULL;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
314
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
315 --n;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
316 assert(n >= 0);
1382
7faa2c7a544f Switch the DPI framework from Unix sockets to Internet sockets
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
317 sin_sz = (socklen_t) sizeof(sin);
7faa2c7a544f Switch the DPI framework from Unix sockets to Internet sockets
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
318 sock_fd = accept(srs_fd, (struct sockaddr *)&sin, &sin_sz);
7faa2c7a544f Switch the DPI framework from Unix sockets to Internet sockets
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
319 if (sock_fd == -1) {
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
320 ERRMSG("main", "accept", errno);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
321 MSG_ERR("accept on srs socket failed\n");
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
322 MSG_ERR("service pending connections, and continue\n");
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
323 } else {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
324 int command;
1387
16cf380cd04c Convert dpid, file dpi and cookies dpi to dsh API
Jorge Arellano Cid <jcid@dillo.org>
parents: 1382
diff changeset
325 Dsh *sh;
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
326
1387
16cf380cd04c Convert dpid, file dpi and cookies dpi to dsh API
Jorge Arellano Cid <jcid@dillo.org>
parents: 1382
diff changeset
327 sh = a_Dpip_dsh_new(sock_fd, sock_fd, 1024);
16cf380cd04c Convert dpid, file dpi and cookies dpi to dsh API
Jorge Arellano Cid <jcid@dillo.org>
parents: 1382
diff changeset
328 read_next:
16cf380cd04c Convert dpid, file dpi and cookies dpi to dsh API
Jorge Arellano Cid <jcid@dillo.org>
parents: 1382
diff changeset
329 req = get_request(sh);
16cf380cd04c Convert dpid, file dpi and cookies dpi to dsh API
Jorge Arellano Cid <jcid@dillo.org>
parents: 1382
diff changeset
330 command = get_command(sh, req);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
331 switch (command) {
1387
16cf380cd04c Convert dpid, file dpi and cookies dpi to dsh API
Jorge Arellano Cid <jcid@dillo.org>
parents: 1382
diff changeset
332 case AUTH_CMD:
16cf380cd04c Convert dpid, file dpi and cookies dpi to dsh API
Jorge Arellano Cid <jcid@dillo.org>
parents: 1382
diff changeset
333 if (a_Dpip_check_auth(req) != -1) {
16cf380cd04c Convert dpid, file dpi and cookies dpi to dsh API
Jorge Arellano Cid <jcid@dillo.org>
parents: 1382
diff changeset
334 dFree(req);
16cf380cd04c Convert dpid, file dpi and cookies dpi to dsh API
Jorge Arellano Cid <jcid@dillo.org>
parents: 1382
diff changeset
335 goto read_next;
16cf380cd04c Convert dpid, file dpi and cookies dpi to dsh API
Jorge Arellano Cid <jcid@dillo.org>
parents: 1382
diff changeset
336 }
16cf380cd04c Convert dpid, file dpi and cookies dpi to dsh API
Jorge Arellano Cid <jcid@dillo.org>
parents: 1382
diff changeset
337 break;
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
338 case BYE_CMD:
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
339 stop_active_dpis(dpi_attr_list, numdpis);
1382
7faa2c7a544f Switch the DPI framework from Unix sockets to Internet sockets
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
340 //cleanup();
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
341 exit(0);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
342 break;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
343 case CHECK_SERVER_CMD:
1382
7faa2c7a544f Switch the DPI framework from Unix sockets to Internet sockets
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
344 send_sockport(sock_fd, req, dpi_attr_list);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
345 break;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
346 case REGISTER_ALL_CMD:
1382
7faa2c7a544f Switch the DPI framework from Unix sockets to Internet sockets
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
347 register_all_cmd();
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
348 break;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
349 case UNKNOWN_CMD:
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
350 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
351 char *d_cmd = a_Dpip_build_cmd("cmd=%s msg=%s",
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
352 "DpiError", "Unknown command");
1382
7faa2c7a544f Switch the DPI framework from Unix sockets to Internet sockets
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
353 (void) CKD_WRITE(sock_fd, d_cmd);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
354 dFree(d_cmd);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
355 ERRMSG("main", "Unknown command", 0);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
356 MSG_ERR(" for request: %s\n", req);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
357 break;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
358 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
359 case -1:
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
360 _ERRMSG("main", "get_command failed", 0);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
361 break;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
362 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
363 if (req)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
364 free(req);
1387
16cf380cd04c Convert dpid, file dpi and cookies dpi to dsh API
Jorge Arellano Cid <jcid@dillo.org>
parents: 1382
diff changeset
365 a_Dpip_dsh_close(sh);
16cf380cd04c Convert dpid, file dpi and cookies dpi to dsh API
Jorge Arellano Cid <jcid@dillo.org>
parents: 1382
diff changeset
366 a_Dpip_dsh_free(sh);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
367 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
368 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
369
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
370 /* While there's a request on one of the plugin sockets
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
371 * find the matching plugin and start it. */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
372 for (i = 0; n > 0 && i < numdpis; i++) {
1382
7faa2c7a544f Switch the DPI framework from Unix sockets to Internet sockets
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
373 if (FD_ISSET(dpi_attr_list[i].sock_fd, &selected_set)) {
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
374 --n;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
375 assert(n >= 0);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
376
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
377 if (dpi_attr_list[i].filter) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
378 /* start a dpi filter plugin and continue watching its socket
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
379 * for new connections */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
380 (void) sigprocmask(SIG_SETMASK, &mask_none, NULL);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
381 start_filter_plugin(dpi_attr_list[i]);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
382 } else {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
383 /* start a dpi server plugin but don't wait for new connections
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
384 * on its socket */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
385 numsocks--;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
386 assert(numsocks >= 0);
1382
7faa2c7a544f Switch the DPI framework from Unix sockets to Internet sockets
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
387 FD_CLR(dpi_attr_list[i].sock_fd, &sock_set);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
388 if ((dpi_attr_list[i].pid = fork()) == -1) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
389 ERRMSG("main", "fork", errno);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
390 /* exit(1); */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
391 } else if (dpi_attr_list[i].pid == 0) {
1382
7faa2c7a544f Switch the DPI framework from Unix sockets to Internet sockets
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
392 /* child */
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
393 (void) sigprocmask(SIG_SETMASK, &mask_none, NULL);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
394 start_server_plugin(dpi_attr_list[i]);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
395 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
396 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
397 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
398 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
399 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
400 }