... | ... |
@@ -227,15 +227,6 @@ CHECK_VIA check_via |
227 | 227 |
SYN_BRANCH syn_branch |
228 | 228 |
MEMLOG "memlog"|"mem_log" |
229 | 229 |
SIP_WARNING sip_warning |
230 |
-FIFO fifo |
|
231 |
-FIFO_DIR fifo_dir |
|
232 |
-SOCK_MODE "fifo_mode"|"sock_mode"|"file_mode" |
|
233 |
-SOCK_USER "fifo_user"|"sock_user" |
|
234 |
-SOCK_GROUP "fifo_group"|"sock_group" |
|
235 |
-FIFO_DB_URL fifo_db_url |
|
236 |
-UNIX_SOCK unix_sock |
|
237 |
-UNIX_SOCK_CHILDREN unix_sock_children |
|
238 |
-UNIX_TX_TIMEOUT unix_tx_timeout |
|
239 | 230 |
SERVER_SIGNATURE server_signature |
240 | 231 |
REPLY_TO_VIA reply_to_via |
241 | 232 |
USER "user"|"uid" |
... | ... |
@@ -460,15 +451,6 @@ EAT_ABLE [\ \t\b\r] |
460 | 451 |
return TLS_HANDSHAKE_TIMEOUT; } |
461 | 452 |
<INITIAL>{TLS_SEND_TIMEOUT} { count(); yylval.strval=yytext; |
462 | 453 |
return TLS_SEND_TIMEOUT; } |
463 |
-<INITIAL>{FIFO} { count(); yylval.strval=yytext; return FIFO; } |
|
464 |
-<INITIAL>{FIFO_DIR} { count(); yylval.strval=yytext; return FIFO_DIR; } |
|
465 |
-<INITIAL>{FIFO_DB_URL} { count(); yylval.strval=yytext; return FIFO_DB_URL; } |
|
466 |
-<INITIAL>{SOCK_MODE} { count(); yylval.strval=yytext; return SOCK_MODE; } |
|
467 |
-<INITIAL>{SOCK_USER} { count(); yylval.strval=yytext; return SOCK_USER; } |
|
468 |
-<INITIAL>{SOCK_GROUP} { count(); yylval.strval=yytext; return SOCK_GROUP; } |
|
469 |
-<INITIAL>{UNIX_SOCK} { count(); yylval.strval=yytext; return UNIX_SOCK; } |
|
470 |
-<INITIAL>{UNIX_SOCK_CHILDREN} { count(); yylval.strval=yytext; return UNIX_SOCK_CHILDREN; } |
|
471 |
-<INITIAL>{UNIX_TX_TIMEOUT} { count(); yylval.strval=yytext; return UNIX_TX_TIMEOUT; } |
|
472 | 454 |
<INITIAL>{SERVER_SIGNATURE} { count(); yylval.strval=yytext; return SERVER_SIGNATURE; } |
473 | 455 |
<INITIAL>{REPLY_TO_VIA} { count(); yylval.strval=yytext; return REPLY_TO_VIA; } |
474 | 456 |
<INITIAL>{ADVERTISED_ADDRESS} { count(); yylval.strval=yytext; |
... | ... |
@@ -234,15 +234,6 @@ static struct socket_id* mk_listen_id(char*, int, int); |
234 | 234 |
%token SYN_BRANCH |
235 | 235 |
%token MEMLOG |
236 | 236 |
%token SIP_WARNING |
237 |
-%token FIFO |
|
238 |
-%token FIFO_DIR |
|
239 |
-%token SOCK_MODE |
|
240 |
-%token SOCK_USER |
|
241 |
-%token SOCK_GROUP |
|
242 |
-%token FIFO_DB_URL |
|
243 |
-%token UNIX_SOCK |
|
244 |
-%token UNIX_SOCK_CHILDREN |
|
245 |
-%token UNIX_TX_TIMEOUT |
|
246 | 237 |
%token SERVER_SIGNATURE |
247 | 238 |
%token REPLY_TO_VIA |
248 | 239 |
%token LOADMODULE |
... | ... |
@@ -476,26 +467,6 @@ assign_stm: DEBUG_V EQUAL NUMBER { debug=$3; } |
476 | 467 |
| MEMLOG EQUAL error { yyerror("int value expected"); } |
477 | 468 |
| SIP_WARNING EQUAL NUMBER { sip_warning=$3; } |
478 | 469 |
| SIP_WARNING EQUAL error { yyerror("boolean value expected"); } |
479 |
- | FIFO EQUAL STRING { fifo=$3; } |
|
480 |
- | FIFO EQUAL error { yyerror("string value expected"); } |
|
481 |
- | FIFO_DIR EQUAL STRING { fifo_dir=$3; } |
|
482 |
- | FIFO_DIR EQUAL error { yyerror("string value expected"); } |
|
483 |
- | SOCK_MODE EQUAL NUMBER { sock_mode=$3; } |
|
484 |
- | SOCK_MODE EQUAL error { yyerror("int value expected"); } |
|
485 |
- | SOCK_USER EQUAL STRING { sock_user=$3; } |
|
486 |
- | SOCK_USER EQUAL ID { sock_user=$3; } |
|
487 |
- | SOCK_USER EQUAL error { yyerror("string value expected"); } |
|
488 |
- | SOCK_GROUP EQUAL STRING { sock_group=$3; } |
|
489 |
- | SOCK_GROUP EQUAL ID { sock_group=$3; } |
|
490 |
- | SOCK_GROUP EQUAL error { yyerror("string value expected"); } |
|
491 |
- | FIFO_DB_URL EQUAL STRING { fifo_db_url=$3; } |
|
492 |
- | FIFO_DB_URL EQUAL error { yyerror("string value expected"); } |
|
493 |
- | UNIX_SOCK EQUAL STRING { unixsock_name=$3; } |
|
494 |
- | UNIX_SOCK EQUAL error { yyerror("string value expected"); } |
|
495 |
- | UNIX_SOCK_CHILDREN EQUAL NUMBER { unixsock_children=$3; } |
|
496 |
- | UNIX_SOCK_CHILDREN EQUAL error { yyerror("int value expected\n"); } |
|
497 |
- | UNIX_TX_TIMEOUT EQUAL NUMBER { unixsock_tx_timeout=$3; } |
|
498 |
- | UNIX_TX_TIMEOUT EQUAL error { yyerror("int value expected\n"); } |
|
499 | 470 |
| USER EQUAL STRING { user=$3; } |
500 | 471 |
| USER EQUAL ID { user=$3; } |
501 | 472 |
| USER EQUAL error { yyerror("string value expected"); } |
... | ... |
@@ -1354,7 +1325,6 @@ select_params : select_params DOT select_param |
1354 | 1325 |
; |
1355 | 1326 |
|
1356 | 1327 |
select_id : SELECT_MARK { sel.n = 0; sel.f = 0; } select_params { |
1357 |
-// if (resolve_select(&sel) < 0) yyerror("Unable to resolve select"); |
|
1358 | 1328 |
sel_ptr = (select_t*)pkg_malloc(sizeof(select_t)); |
1359 | 1329 |
if (!sel_ptr) { |
1360 | 1330 |
yyerror("No memory left to allocate select structure\n"); |
... | ... |
@@ -1364,6 +1334,7 @@ select_id : SELECT_MARK { sel.n = 0; sel.f = 0; } select_params { |
1364 | 1334 |
} |
1365 | 1335 |
; |
1366 | 1336 |
|
1337 |
+ |
|
1367 | 1338 |
attr_id : ATTR_MARK ID { s_attr = (struct avp_spec*)pkg_malloc(sizeof(struct avp_spec)); |
1368 | 1339 |
if (!s_attr) { yyerror("No memory left"); } |
1369 | 1340 |
s_attr->type = AVP_NAME_STR; |
... | ... |
@@ -150,13 +150,6 @@ |
150 | 150 |
/* maximum number of branches per transaction */ |
151 | 151 |
#define MAX_BRANCHES 12 |
152 | 152 |
|
153 |
-/* maximum length of a FIFO server command */ |
|
154 |
-#define MAX_FIFO_COMMAND 512 |
|
155 |
- |
|
156 |
-/* buffer dimensions for FIFO server */ |
|
157 |
-#define MAX_CONSUME_BUFFER 1024 |
|
158 |
-/* where reply pipes may be opened */ |
|
159 |
-#define DEFAULT_FIFO_DIR "/tmp/" |
|
160 | 153 |
/* max length of the text of fifo 'print' command */ |
161 | 154 |
#define MAX_PRINT_TEXT 256 |
162 | 155 |
|
... | ... |
@@ -169,12 +162,6 @@ |
169 | 162 |
*/ |
170 | 163 |
#define CLEANUP_EOL " \n" |
171 | 164 |
|
172 |
-/* how patient is ser with FIFO clients not awaiting a reply? |
|
173 |
- 4 x 80ms = 0.32 sec |
|
174 |
-*/ |
|
175 |
-#define FIFO_REPLY_RETRIES 4 |
|
176 |
-#define FIFO_REPLY_WAIT 80000 |
|
177 |
- |
|
178 | 165 |
/* magic cookie for transaction matching as defined in RFC3261 */ |
179 | 166 |
#define MCOOKIE "z9hG4bK" |
180 | 167 |
#define MCOOKIE_LEN (sizeof(MCOOKIE)-1) |
181 | 168 |
deleted file mode 100644 |
... | ... |
@@ -1,950 +0,0 @@ |
1 |
-/* |
|
2 |
- * $Id$ |
|
3 |
- * |
|
4 |
- * |
|
5 |
- * Copyright (C) 2001-2003 FhG Fokus |
|
6 |
- * |
|
7 |
- * This file is part of ser, a free SIP server. |
|
8 |
- * |
|
9 |
- * ser is free software; you can redistribute it and/or modify |
|
10 |
- * it under the terms of the GNU General Public License as published by |
|
11 |
- * the Free Software Foundation; either version 2 of the License, or |
|
12 |
- * (at your option) any later version |
|
13 |
- * |
|
14 |
- * For a license to use the ser software under conditions |
|
15 |
- * other than those described here, or to purchase support for this |
|
16 |
- * software, please contact iptel.org by e-mail at the following addresses: |
|
17 |
- * info@iptel.org |
|
18 |
- * |
|
19 |
- * ser is distributed in the hope that it will be useful, |
|
20 |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
21 |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
22 |
- * GNU General Public License for more details. |
|
23 |
- * |
|
24 |
- * You should have received a copy of the GNU General Public License |
|
25 |
- * along with this program; if not, write to the Free Software |
|
26 |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
27 |
- * |
|
28 |
- * Fifo server is a very powerful tool used to access easily |
|
29 |
- * ser's internals via textual interface, similarly to |
|
30 |
- * how internals of many operating systems are accessible |
|
31 |
- * via the proc file system. This might be used for |
|
32 |
- * making ser do things for you (such as initiating new |
|
33 |
- * transaction from webpages) or inspect server's health. |
|
34 |
- * |
|
35 |
- * FIFO server allows new functionality to be registered |
|
36 |
- * with it -- thats what register_fifo_cmd is good for. |
|
37 |
- * Remember, the initialization must take place before |
|
38 |
- * forking; best in init_module functions. When a function |
|
39 |
- * is registered, it can be always evoked by sending its |
|
40 |
- * name prefixed by colon to the FIFO. |
|
41 |
- * |
|
42 |
- * There are few commands already implemented in core. |
|
43 |
- * These are 'uptime' for looking at how long the server |
|
44 |
- * is alive and 'print' for debugging purposes. |
|
45 |
- * |
|
46 |
- * Every command sent to FIFO must be sent atomically to |
|
47 |
- * avoid intermixing with other commands and MUST be |
|
48 |
- * terminated by empty line so that the server is to able |
|
49 |
- * to find its end if it does not understand the command. |
|
50 |
- * |
|
51 |
- * File test/transaction.fifo illustrates example of use |
|
52 |
- * of t_uac command (part of TM module). |
|
53 |
- * |
|
54 |
- * History: |
|
55 |
- * -------- |
|
56 |
- * 2003-03-29 destroy pkg mem introduced (jiri) |
|
57 |
- * 2003-03-19 replaced all mallocs/frees w/ pkg_malloc/pkg_free (andrei) |
|
58 |
- * 2003-01-29 new built-in fifo commands: arg and pwd (jiri) |
|
59 |
- * 2003-10-07 fifo security fixes: permissions, always delete old fifo, |
|
60 |
- * reply fifo checks -- added fifo_check (andrei) |
|
61 |
- * 2003-10-13 added fifo_dir for reply fifos (andrei) |
|
62 |
- * 2003-10-30 DB interface exported via FIFO (bogdan) |
|
63 |
- * 2004-03-09 open_fifo_server split into init_ and start_ (andrei) |
|
64 |
- * 2004-04-29 added chown(sock_user, sock_group) (andrei) |
|
65 |
- * 2004-06-06 updated to the new DB interface & init_db_fifo (andrei) |
|
66 |
- * 2004-09-19 fifo is deleted on exit (destroy_fifo) (andrei) |
|
67 |
- * 2005-03-02 meminfo fifo cmd added (andrei) |
|
68 |
- */ |
|
69 |
- |
|
70 |
- |
|
71 |
-#include <limits.h> |
|
72 |
-#include <stdlib.h> |
|
73 |
-#include <sys/types.h> |
|
74 |
-#include <unistd.h> |
|
75 |
-#include <stdio.h> |
|
76 |
-#include <errno.h> |
|
77 |
-#include <sys/stat.h> |
|
78 |
-#include <fcntl.h> |
|
79 |
-#include <signal.h> |
|
80 |
-#include <string.h> |
|
81 |
-#include <time.h> |
|
82 |
-#include <stdarg.h> |
|
83 |
-#ifdef USE_TCP |
|
84 |
-#include <sys/socket.h> |
|
85 |
-#endif |
|
86 |
- |
|
87 |
-#include "dprint.h" |
|
88 |
-#include "ut.h" |
|
89 |
-#include "error.h" |
|
90 |
-#include "config.h" |
|
91 |
-#include "globals.h" |
|
92 |
-#include "fifo_server.h" |
|
93 |
-#include "mem/mem.h" |
|
94 |
-#include "mem/shm_mem.h" /* shm_info() */ |
|
95 |
-#include "sr_module.h" |
|
96 |
-#include "pt.h" |
|
97 |
-#include "db/db_fifo.h" |
|
98 |
- |
|
99 |
-/* FIFO server vars */ |
|
100 |
-char *fifo=0; /* FIFO name */ |
|
101 |
-char* fifo_dir=DEFAULT_FIFO_DIR; /* dir where reply fifos are allowed */ |
|
102 |
-char *fifo_db_url = 0; |
|
103 |
-pid_t fifo_pid; |
|
104 |
- |
|
105 |
- |
|
106 |
-/* file descriptors */ |
|
107 |
-static int fifo_read=0; |
|
108 |
-static int fifo_write=0; |
|
109 |
-static FILE *fifo_stream=0; |
|
110 |
- |
|
111 |
-/* list of fifo command */ |
|
112 |
-static struct fifo_command *cmd_list=0; |
|
113 |
- |
|
114 |
-/* up time */ |
|
115 |
-static time_t up_since; |
|
116 |
-static char up_since_ctime[MAX_CTIME_LEN]; |
|
117 |
- |
|
118 |
-static struct fifo_command *lookup_fifo_cmd( char *name ) |
|
119 |
-{ |
|
120 |
- struct fifo_command *c; |
|
121 |
- for(c=cmd_list; c; c=c->next) { |
|
122 |
- if (strcasecmp(c->name, name)==0) return c; |
|
123 |
- } |
|
124 |
- return 0; |
|
125 |
-} |
|
126 |
- |
|
127 |
-int register_fifo_cmd(fifo_cmd f, char *cmd_name, void *param) |
|
128 |
-{ |
|
129 |
- struct fifo_command *new_cmd; |
|
130 |
- |
|
131 |
- if (lookup_fifo_cmd(cmd_name)) { |
|
132 |
- LOG(L_ERR, "ERROR: register_fifo_cmd: attempt to register synonyms\n"); |
|
133 |
- return E_BUG; |
|
134 |
- } |
|
135 |
- new_cmd=pkg_malloc(sizeof(struct fifo_command)); |
|
136 |
- if (new_cmd==0) { |
|
137 |
- LOG(L_ERR, "ERROR: register_fifo_cmd: out of mem\n"); |
|
138 |
- return E_OUT_OF_MEM; |
|
139 |
- } |
|
140 |
- new_cmd->f=f; |
|
141 |
- new_cmd->name=cmd_name; |
|
142 |
- new_cmd->param=param; |
|
143 |
- |
|
144 |
- new_cmd->next=cmd_list; |
|
145 |
- cmd_list=new_cmd; |
|
146 |
- |
|
147 |
- DBG("DEBUG: register_fifo_cmd: new command (%s) registered\n", cmd_name ); |
|
148 |
- |
|
149 |
- return 1; |
|
150 |
-} |
|
151 |
- |
|
152 |
-void destroy_fifo() |
|
153 |
-{ |
|
154 |
- struct fifo_command *c, *foo; |
|
155 |
- |
|
156 |
- c=cmd_list; |
|
157 |
- |
|
158 |
- while(c) { |
|
159 |
- foo=c->next; |
|
160 |
- pkg_free(c); |
|
161 |
- c=foo; |
|
162 |
- } |
|
163 |
- if (fifo_stream){ |
|
164 |
- fclose(fifo_stream); |
|
165 |
- fifo_stream=0; |
|
166 |
- /* if FIFO was created, delete it */ |
|
167 |
- if (fifo && strlen(fifo)){ |
|
168 |
- if (unlink(fifo)<0){ |
|
169 |
- LOG(L_ERR, "WARNING: destroy_fifo: cannot delete fifo (%s):" |
|
170 |
- " %s\n", fifo, strerror(errno)); |
|
171 |
- } |
|
172 |
- } |
|
173 |
- } |
|
174 |
-} |
|
175 |
- |
|
176 |
- |
|
177 |
-int read_line( char *b, int max, FILE *stream, int *read ) |
|
178 |
-{ |
|
179 |
- int len; |
|
180 |
- int retry_cnt; |
|
181 |
- |
|
182 |
- retry_cnt=0; |
|
183 |
- |
|
184 |
-retry: |
|
185 |
- if (fgets(b, max, stream)==NULL) { |
|
186 |
- LOG(L_ERR, "ERROR: fifo_server fgets failed: %s\n", |
|
187 |
- strerror(errno)); |
|
188 |
- /* on Linux, fgets sometimes returns ESPIPE -- give |
|
189 |
- it few more chances |
|
190 |
- */ |
|
191 |
- if (errno==ESPIPE) { |
|
192 |
- retry_cnt++; |
|
193 |
- if (retry_cnt<4) goto retry; |
|
194 |
- } |
|
195 |
- /* interrupted by signal or ... */ |
|
196 |
- if ((errno==EINTR)||(errno==EAGAIN)) goto retry; |
|
197 |
- kill(0, SIGTERM); |
|
198 |
- } |
|
199 |
- /* if we did not read whole line, our buffer is too small |
|
200 |
- and we cannot process the request; consume the remainder of |
|
201 |
- request |
|
202 |
- */ |
|
203 |
- len=strlen(b); |
|
204 |
- if (len && !(b[len-1]=='\n' || b[len-1]=='\r')) { |
|
205 |
- LOG(L_ERR, "ERROR: read_line: request line too long\n"); |
|
206 |
- return 0; |
|
207 |
- } |
|
208 |
- /* trim from right */ |
|
209 |
- while(len) { |
|
210 |
- if(b[len-1]=='\n' || b[len-1]=='\r' |
|
211 |
- || b[len-1]==' ' || b[len-1]=='\t' ) { |
|
212 |
- len--; |
|
213 |
- b[len]=0; |
|
214 |
- } else break; |
|
215 |
- } |
|
216 |
- *read=len; |
|
217 |
- return 1; |
|
218 |
-} |
|
219 |
- |
|
220 |
-static void consume_request( FILE *stream ) |
|
221 |
-{ |
|
222 |
- int len; |
|
223 |
- char buffer[MAX_CONSUME_BUFFER]; |
|
224 |
- |
|
225 |
- while(!read_line(buffer, MAX_CONSUME_BUFFER, stream, &len)); |
|
226 |
- |
|
227 |
-} |
|
228 |
- |
|
229 |
-int read_eol( FILE *stream ) |
|
230 |
-{ |
|
231 |
- int len; |
|
232 |
- char buffer[MAX_CONSUME_BUFFER]; |
|
233 |
- if (!read_line(buffer, MAX_CONSUME_BUFFER, stream, &len) || len!=0) { |
|
234 |
- LOG(L_ERR, "ERROR: read_eol: EOL expected: %.10s...\n", |
|
235 |
- buffer ); |
|
236 |
- return 0; |
|
237 |
- } |
|
238 |
- return 1; |
|
239 |
-} |
|
240 |
- |
|
241 |
-/* read from input until empty line is encountered */ |
|
242 |
-int read_line_set(char *buf, int max_len, FILE *fifo, int *len) |
|
243 |
-{ |
|
244 |
- int set_len; |
|
245 |
- char *c; |
|
246 |
- int line_len; |
|
247 |
- |
|
248 |
- c=buf;set_len=0; |
|
249 |
- while(1) { |
|
250 |
- if (!read_line(c,max_len,fifo,&line_len)) { |
|
251 |
- LOG(L_ERR, "ERROR: fifo_server: line expected\n"); |
|
252 |
- return 0; |
|
253 |
- } |
|
254 |
- /* end encountered ... return */ |
|
255 |
- if (line_len==0 || (line_len==1 && c[0]=='.' )) { |
|
256 |
- *len=set_len; |
|
257 |
- return 1; |
|
258 |
- } |
|
259 |
- max_len-=line_len; c+=line_len; set_len+=line_len; |
|
260 |
- if (max_len<CRLF_LEN) { |
|
261 |
- LOG(L_ERR, "ERROR: fifo_server: no place for CRLF\n"); |
|
262 |
- return 0; |
|
263 |
- } |
|
264 |
- memcpy(c, CRLF, CRLF_LEN); |
|
265 |
- max_len-=CRLF_LEN; c+=CRLF_LEN; set_len+=CRLF_LEN; |
|
266 |
- } |
|
267 |
-} |
|
268 |
- |
|
269 |
- |
|
270 |
-/* read from input until line with only dot in it is encountered */ |
|
271 |
-int read_body(char *buf, int max_len, FILE *fifo, int *len) |
|
272 |
-{ |
|
273 |
- int set_len; |
|
274 |
- char *c; |
|
275 |
- int line_len; |
|
276 |
- |
|
277 |
- c=buf;set_len=0; |
|
278 |
- while(1) { |
|
279 |
- if (!read_line(c,max_len,fifo,&line_len)) { |
|
280 |
- LOG(L_ERR, "ERROR: fifo_server: line expected\n"); |
|
281 |
- return 0; |
|
282 |
- } |
|
283 |
- /* end encountered ... return */ |
|
284 |
- if (line_len==1 && *c=='.') { |
|
285 |
- *len=set_len; |
|
286 |
- return 1; |
|
287 |
- } |
|
288 |
- max_len-=line_len; c+=line_len; set_len+=line_len; |
|
289 |
- if (max_len<CRLF_LEN) { |
|
290 |
- LOG(L_ERR, "ERROR: fifo_server: no place for CRLF\n"); |
|
291 |
- return 0; |
|
292 |
- } |
|
293 |
- memcpy(c, CRLF, CRLF_LEN); |
|
294 |
- max_len-=CRLF_LEN; c+=CRLF_LEN; set_len+=CRLF_LEN; |
|
295 |
- } |
|
296 |
-} |
|
297 |
- |
|
298 |
-static char *trim_filename( char * file ) |
|
299 |
-{ |
|
300 |
- int prefix_len, fn_len; |
|
301 |
- char *new_fn; |
|
302 |
- |
|
303 |
- /* we only allow files in "/tmp" -- any directory |
|
304 |
- changes are not welcome |
|
305 |
- */ |
|
306 |
- if (strchr(file,'.') || strchr(file,'/') |
|
307 |
- || strchr(file, '\\')) { |
|
308 |
- LOG(L_ERR, "ERROR: trim_filename: forbidden filename: %s\n" |
|
309 |
- , file); |
|
310 |
- return 0; |
|
311 |
- } |
|
312 |
- prefix_len=strlen(fifo_dir); fn_len=strlen(file); |
|
313 |
- new_fn=pkg_malloc(prefix_len+fn_len+1); |
|
314 |
- if (new_fn==0) { |
|
315 |
- LOG(L_ERR, "ERROR: trim_filename: no mem\n"); |
|
316 |
- return 0; |
|
317 |
- } |
|
318 |
- |
|
319 |
- memcpy(new_fn, fifo_dir, prefix_len); |
|
320 |
- memcpy(new_fn+prefix_len, file, fn_len ); |
|
321 |
- new_fn[prefix_len+fn_len]=0; |
|
322 |
- |
|
323 |
- return new_fn; |
|
324 |
-} |
|
325 |
- |
|
326 |
- |
|
327 |
- |
|
328 |
-/* reply fifo security checks: |
|
329 |
- * checks if fd is a fifo, is not hardlinked and it's not a softlink |
|
330 |
- * opened file descriptor + file name (for soft link check) |
|
331 |
- * returns 0 if ok, <0 if not */ |
|
332 |
-static int fifo_check(int fd, char* fname) |
|
333 |
-{ |
|
334 |
- struct stat fst; |
|
335 |
- struct stat lst; |
|
336 |
- |
|
337 |
- if (fstat(fd, &fst)<0){ |
|
338 |
- LOG(L_ERR, "ERROR: fifo_check: fstat failed: %s\n", |
|
339 |
- strerror(errno)); |
|
340 |
- return -1; |
|
341 |
- } |
|
342 |
- /* check if fifo */ |
|
343 |
- if (!S_ISFIFO(fst.st_mode)){ |
|
344 |
- LOG(L_ERR, "ERROR: fifo_check: %s is not a fifo\n", fname); |
|
345 |
- return -1; |
|
346 |
- } |
|
347 |
- /* check if hard-linked */ |
|
348 |
- if (fst.st_nlink>1){ |
|
349 |
- LOG(L_ERR, "ERROR: security: fifo_check: %s is hard-linked %d times\n", |
|
350 |
- fname, (unsigned)fst.st_nlink); |
|
351 |
- return -1; |
|
352 |
- } |
|
353 |
- |
|
354 |
- /* lstat to check for soft links */ |
|
355 |
- if (lstat(fname, &lst)<0){ |
|
356 |
- LOG(L_ERR, "ERROR: fifo_check: lstat failed: %s\n", |
|
357 |
- strerror(errno)); |
|
358 |
- return -1; |
|
359 |
- } |
|
360 |
- if (S_ISLNK(lst.st_mode)){ |
|
361 |
- LOG(L_ERR, "ERROR: security: fifo_check: %s is a soft link\n", |
|
362 |
- fname); |
|
363 |
- return -1; |
|
364 |
- } |
|
365 |
- /* if this is not a symbolic link, check to see if the inode didn't |
|
366 |
- * change to avoid possible sym.link, rm sym.link & replace w/ fifo race |
|
367 |
- */ |
|
368 |
- if ((lst.st_dev!=fst.st_dev)||(lst.st_ino!=fst.st_ino)){ |
|
369 |
- LOG(L_ERR, "ERROR: security: fifo_check: inode/dev number differ" |
|
370 |
- ": %d %d (%s)\n", |
|
371 |
- (int)fst.st_ino, (int)lst.st_ino, fname); |
|
372 |
- return -1; |
|
373 |
- } |
|
374 |
- /* success */ |
|
375 |
- return 0; |
|
376 |
-} |
|
377 |
- |
|
378 |
- |
|
379 |
- |
|
380 |
-/* tell FIFO client what happened via reply pipe */ |
|
381 |
-void fifo_reply( char *reply_fifo, char *reply_fmt, ... ) |
|
382 |
-{ |
|
383 |
- FILE *file_handle; |
|
384 |
- int r; |
|
385 |
- va_list ap; |
|
386 |
- |
|
387 |
- file_handle=open_reply_pipe(reply_fifo); |
|
388 |
- if (file_handle==0) { |
|
389 |
- LOG(L_ERR, "ERROR: fifo_reply: no reply pipe %s\n", |
|
390 |
- reply_fifo); |
|
391 |
- return; |
|
392 |
- } |
|
393 |
-retry: |
|
394 |
- va_start(ap, reply_fmt); |
|
395 |
- r=vfprintf(file_handle, reply_fmt, ap); |
|
396 |
- va_end(ap); |
|
397 |
- if (r<=0) { |
|
398 |
- LOG(L_ERR, "ERROR: fifo_error: write error (%s): %s\n", |
|
399 |
- fifo, strerror(errno)); |
|
400 |
- if ((errno==EINTR)||(errno==EAGAIN)||(errno==EWOULDBLOCK)) { |
|
401 |
- goto retry; |
|
402 |
- } |
|
403 |
- } |
|
404 |
- fclose(file_handle); |
|
405 |
-} |
|
406 |
- |
|
407 |
-FILE *open_reply_pipe( char *pipe_name ) |
|
408 |
-{ |
|
409 |
- |
|
410 |
- int fifofd; |
|
411 |
- FILE *file_handle; |
|
412 |
- int flags; |
|
413 |
- |
|
414 |
- int retries=FIFO_REPLY_RETRIES; |
|
415 |
- |
|
416 |
- if (!pipe_name || *pipe_name==0) { |
|
417 |
- DBG("DEBUG: open_reply_pipe: no file to write to about missing cmd\n"); |
|
418 |
- return 0; |
|
419 |
- } |
|
420 |
- |
|
421 |
-tryagain: |
|
422 |
- /* open non-blocking to make sure that a broken client will not |
|
423 |
- * block the FIFO server forever */ |
|
424 |
- fifofd=open( pipe_name, O_WRONLY | O_NONBLOCK ); |
|
425 |
- if (fifofd==-1) { |
|
426 |
- /* retry several times if client is not yet ready for getting |
|
427 |
- feedback via a reply pipe |
|
428 |
- */ |
|
429 |
- if (errno==ENXIO) { |
|
430 |
- /* give up on the client - we can't afford server blocking */ |
|
431 |
- if (retries==0) { |
|
432 |
- LOG(L_ERR, "ERROR: open_reply_pipe: no client at %s\n", |
|
433 |
- pipe_name ); |
|
434 |
- return 0; |
|
435 |
- } |
|
436 |
- /* don't be noisy on the very first try */ |
|
437 |
- if (retries!=FIFO_REPLY_RETRIES) |
|
438 |
- DBG("DEBUG: open_reply_pipe: retry countdown: %d\n", retries ); |
|
439 |
- sleep_us( FIFO_REPLY_WAIT ); |
|
440 |
- retries--; |
|
441 |
- goto tryagain; |
|
442 |
- } |
|
443 |
- /* some other opening error */ |
|
444 |
- LOG(L_ERR, "ERROR: open_reply_pipe: open error (%s): %s\n", |
|
445 |
- pipe_name, strerror(errno)); |
|
446 |
- return 0; |
|
447 |
- } |
|
448 |
- /* security checks: is this really a fifo?, is |
|
449 |
- * it hardlinked? is it a soft link? */ |
|
450 |
- if (fifo_check(fifofd, pipe_name)<0) goto error; |
|
451 |
- |
|
452 |
- /* we want server blocking for big writes */ |
|
453 |
- if ( (flags=fcntl(fifofd, F_GETFL, 0))<0) { |
|
454 |
- LOG(L_ERR, "ERROR: open_reply_pipe (%s): getfl failed: %s\n", |
|
455 |
- pipe_name, strerror(errno)); |
|
456 |
- goto error; |
|
457 |
- } |
|
458 |
- flags&=~O_NONBLOCK; |
|
459 |
- if (fcntl(fifofd, F_SETFL, flags)<0) { |
|
460 |
- LOG(L_ERR, "ERROR: open_reply_pipe (%s): setfl cntl failed: %s\n", |
|
461 |
- pipe_name, strerror(errno)); |
|
462 |
- goto error; |
|
463 |
- } |
|
464 |
- |
|
465 |
- /* create an I/O stream */ |
|
466 |
- file_handle=fdopen( fifofd, "w"); |
|
467 |
- if (file_handle==NULL) { |
|
468 |
- LOG(L_ERR, "ERROR: open_reply_pipe: open error (%s): %s\n", |
|
469 |
- pipe_name, strerror(errno)); |
|
470 |
- goto error; |
|
471 |
- } |
|
472 |
- return file_handle; |
|
473 |
-error: |
|
474 |
- close(fifofd); |
|
475 |
- return 0; |
|
476 |
-} |
|
477 |
- |
|
478 |
-static void fifo_server(FILE *fifo_stream) |
|
479 |
-{ |
|
480 |
- char buf[MAX_FIFO_COMMAND]; |
|
481 |
- int line_len; |
|
482 |
- char *file_sep, *command, *file; |
|
483 |
- struct fifo_command *f; |
|
484 |
- |
|
485 |
- file_sep=command=file=0; |
|
486 |
- |
|
487 |
- /* register a diagnostic FIFO command */ |
|
488 |
- register_core_fifo(); |
|
489 |
- |
|
490 |
- while(1) { |
|
491 |
- |
|
492 |
- /* commands must look this way ':<command>:[filename]' */ |
|
493 |
- if (!read_line(buf, MAX_FIFO_COMMAND, fifo_stream, &line_len)) { |
|
494 |
- /* line breaking must have failed -- consume the rest |
|
495 |
- and proceed to a new request |
|
496 |
- */ |
|
497 |
- LOG(L_ERR, "ERROR: fifo_server: command expected\n"); |
|
498 |
- goto consume; |
|
499 |
- } |
|
500 |
- if (line_len==0) { |
|
501 |
- LOG(L_DBG, "INFO: fifo_server: command empty\n"); |
|
502 |
- continue; |
|
503 |
- } |
|
504 |
- if (line_len<3) { |
|
505 |
- LOG(L_ERR, "ERROR: fifo_server: command must have at least 3 chars\n"); |
|
506 |
- goto consume; |
|
507 |
- } |
|
508 |
- if (*buf!=CMD_SEPARATOR) { |
|
509 |
- LOG(L_ERR, "ERROR: fifo_server: command must begin with %c: %.*s\n", |
|
510 |
- CMD_SEPARATOR, line_len, buf ); |
|
511 |
- goto consume; |
|
512 |
- } |
|
513 |
- command=buf+1; |
|
514 |
- file_sep=strchr(command, CMD_SEPARATOR ); |
|
515 |
- if (file_sep==NULL) { |
|
516 |
- LOG(L_ERR, "ERROR: fifo_server: file separator missing\n"); |
|
517 |
- goto consume; |
|
518 |
- } |
|
519 |
- if (file_sep==command) { |
|
520 |
- LOG(L_ERR, "ERROR: fifo_server: empty command\n"); |
|
521 |
- goto consume; |
|
522 |
- } |
|
523 |
- if (*(file_sep+1)==0) file=NULL; |
|
524 |
- else { |
|
525 |
- file=file_sep+1; |
|
526 |
- file=trim_filename(file); |
|
527 |
- if (file==0) { |
|
528 |
- LOG(L_ERR, "ERROR: fifo_server: trimming filename\n"); |
|
529 |
- goto consume; |
|
530 |
- } |
|
531 |
- } |
|
532 |
- /* make command zero-terminated */ |
|
533 |
- *file_sep=0; |
|
534 |
- |
|
535 |
- f=lookup_fifo_cmd( command ); |
|
536 |
- if (f==0) { |
|
537 |
- LOG(L_ERR, "ERROR: fifo_server: command %s is not available\n", |
|
538 |
- command); |
|
539 |
- fifo_reply(file, "500 command '%s' not available\n", command); |
|
540 |
- goto consume; |
|
541 |
- } |
|
542 |
- if (f->f(fifo_stream, file)<0) { |
|
543 |
- LOG(L_ERR, "ERROR: fifo_server: command (%s) " |
|
544 |
- "processing failed\n", command ); |
|
545 |
- goto consume; |
|
546 |
- } |
|
547 |
- |
|
548 |
-consume: |
|
549 |
- if (file) { pkg_free(file); file=0;} |
|
550 |
- consume_request(fifo_stream); |
|
551 |
- DBG("**** done consume\n"); |
|
552 |
- } |
|
553 |
-} |
|
554 |
- |
|
555 |
-int init_fifo_server() |
|
556 |
-{ |
|
557 |
- char *t; |
|
558 |
- struct stat filestat; |
|
559 |
- int n; |
|
560 |
- long opt; |
|
561 |
- |
|
562 |
- if (fifo==NULL) { |
|
563 |
- DBG("DBG: open_fifo_server: no fifo will be opened\n"); |
|
564 |
- /* everything is ok, we just do not want to start */ |
|
565 |
- return 1; |
|
566 |
- } |
|
567 |
- if (strlen(fifo)==0) { |
|
568 |
- DBG("DBG: open_fifo_server: fifo disabled\n"); |
|
569 |
- return 1; |
|
570 |
- } |
|
571 |
- DBG("DBG: open_uac_fifo: opening fifo...\n"); |
|
572 |
- n=stat(fifo, &filestat); |
|
573 |
- if (n==0){ |
|
574 |
- /* FIFO exist, delete it (safer) */ |
|
575 |
- if (unlink(fifo)<0){ |
|
576 |
- LOG(L_ERR, "ERROR: open_fifo_server: cannot delete old fifo (%s):" |
|
577 |
- " %s\n", fifo, strerror(errno)); |
|
578 |
- return -1; |
|
579 |
- } |
|
580 |
- }else if (n<0 && errno!=ENOENT){ |
|
581 |
- LOG(L_DBG, "DEBUG: open_fifo_server: FIFO stat failed: %s\n", |
|
582 |
- strerror(errno)); |
|
583 |
- } |
|
584 |
- /* create FIFO ... */ |
|
585 |
- if ((mkfifo(fifo, sock_mode)<0)) { |
|
586 |
- LOG(L_ERR, "ERROR: open_fifo_server; can't create FIFO: " |
|
587 |
- "%s (mode=%d)\n", |
|
588 |
- strerror(errno), sock_mode); |
|
589 |
- return -1; |
|
590 |
- } |
|
591 |
- DBG("DEBUG: FIFO created @ %s\n", fifo ); |
|
592 |
- if ((chmod(fifo, sock_mode)<0)) { |
|
593 |
- LOG(L_ERR, "ERROR: open_fifo_server; can't chmod FIFO: " |
|
594 |
- "%s (mode=%d)\n", |
|
595 |
- strerror(errno), sock_mode); |
|
596 |
- return -1; |
|
597 |
- } |
|
598 |
- if ((sock_uid!=-1) || (sock_gid!=-1)){ |
|
599 |
- if (chown(fifo, sock_uid, sock_gid)<0){ |
|
600 |
- LOG(L_ERR, "ERROR: open_fifo_server: failed to change the" |
|
601 |
- " owner/group for %s to %d.%d; %s[%d]\n", |
|
602 |
- fifo, sock_uid, sock_gid, strerror(errno), errno); |
|
603 |
- return -1; |
|
604 |
- } |
|
605 |
- } |
|
606 |
- |
|
607 |
- |
|
608 |
- DBG("DEBUG: fifo %s opened, mode=%d\n", fifo, sock_mode ); |
|
609 |
- time(&up_since); |
|
610 |
- t=ctime(&up_since); |
|
611 |
- if (strlen(t)+1>=MAX_CTIME_LEN) { |
|
612 |
- LOG(L_ERR, "ERROR: open_fifo_server: " |
|
613 |
- "too long date %d\n", (int)strlen(t)); |
|
614 |
- return -1; |
|
615 |
- } |
|
616 |
- memcpy(up_since_ctime,t,strlen(t)+1); |
|
617 |
- /* open it non-blocking or else wait here until someone |
|
618 |
- * opens it for writing */ |
|
619 |
- fifo_read=open(fifo, O_RDONLY|O_NONBLOCK, 0); |
|
620 |
- if (fifo_read<0) { |
|
621 |
- LOG(L_ERR, "ERROR: init_fifo_server: fifo_read did not open: %s\n", |
|
622 |
- strerror(errno)); |
|
623 |
- return -1; |
|
624 |
- } |
|
625 |
- fifo_stream=fdopen(fifo_read, "r"); |
|
626 |
- if (fifo_stream==NULL) { |
|
627 |
- LOG(L_ERR, "ERROR: init_fifo_server: fdopen failed: %s\n", |
|
628 |
- strerror(errno)); |
|
629 |
- return -1; |
|
630 |
- } |
|
631 |
- /* make sure the read fifo will not close */ |
|
632 |
- fifo_write=open(fifo, O_WRONLY|O_NONBLOCK, 0); |
|
633 |
- if (fifo_write<0) { |
|
634 |
- LOG(L_ERR, "ERROR: init_fifo_server: fifo_write did not open: %s\n", |
|
635 |
- strerror(errno)); |
|
636 |
- return -1; |
|
637 |
- } |
|
638 |
- /* set read fifo blocking mode */ |
|
639 |
- if ((opt=fcntl(fifo_read, F_GETFL))==-1){ |
|
640 |
- LOG(L_ERR, "ERROR: init_fifo_server: fcntl(F_GETFL) failed: %s [%d]\n", |
|
641 |
- strerror(errno), errno); |
|
642 |
- return -1; |
|
643 |
- } |
|
644 |
- if (fcntl(fifo_read, F_SETFL, opt & (~O_NONBLOCK))==-1){ |
|
645 |
- LOG(L_ERR, "ERROR: init_fifo_server: fcntl(F_SETFL) failed: %s [%d]\n", |
|
646 |
- strerror(errno), errno); |
|
647 |
- return -1; |
|
648 |
- } |
|
649 |
- return 0; |
|
650 |
-} |
|
651 |
- |
|
652 |
- |
|
653 |
- |
|
654 |
-int start_fifo_server() |
|
655 |
-{ |
|
656 |
-#ifdef USE_TCP |
|
657 |
- int sockfd[2]; |
|
658 |
-#endif |
|
659 |
- if (fifo_stream==0) return 1; /* no error, we just don't start it */ |
|
660 |
-#ifdef USE_TCP |
|
661 |
- if (socketpair(AF_UNIX, SOCK_STREAM, 0, sockfd)<0){ |
|
662 |
- LOG(L_ERR, "ERROR: open_fifo_server: socketpair failed: %s\n", |
|
663 |
- strerror(errno)); |
|
664 |
- return -1; |
|
665 |
- } |
|
666 |
-#endif |
|
667 |
- process_no++; |
|
668 |
- fifo_pid=fork(); |
|
669 |
- if (fifo_pid<0) { |
|
670 |
- LOG(L_ERR, "ERROR: open_fifo_server: failure to fork: %s\n", |
|
671 |
- strerror(errno)); |
|
672 |
- return -1; |
|
673 |
- } |
|
674 |
- if (fifo_pid==0) { /* child == FIFO server */ |
|
675 |
- /* record pid twice to avoid the child using it, before |
|
676 |
- * parent gets a chance to set it*/ |
|
677 |
- pt[process_no].pid=getpid(); |
|
678 |
- LOG(L_INFO, "INFO: fifo process starting: %d\n", getpid()); |
|
679 |
- /* call per-child module initialization too -- some |
|
680 |
- FIFO commands may need it |
|
681 |
- */ |
|
682 |
-#ifdef USE_TCP |
|
683 |
- close(sockfd[0]); |
|
684 |
- unix_tcp_sock=sockfd[1]; |
|
685 |
-#endif |
|
686 |
- if (init_child(PROC_FIFO) < 0 ) { |
|
687 |
- LOG(L_ERR, "ERROR: open_uac_fifo: init_child failed\n"); |
|
688 |
- return -1; |
|
689 |
- } |
|
690 |
- /* a real server doesn't die if writing to reply fifo fails */ |
|
691 |
- signal(SIGPIPE, SIG_IGN); |
|
692 |
- LOG(L_INFO, "SER: open_uac_fifo: fifo server up at %s...\n", |
|
693 |
- fifo); |
|
694 |
- fifo_server( fifo_stream ); /* never returns */ |
|
695 |
- } |
|
696 |
- /* dad process */ |
|
697 |
- pt[process_no].pid=fifo_pid; |
|
698 |
- strncpy(pt[process_no].desc, "fifo server", MAX_PT_DESC ); |
|
699 |
-#ifdef USE_TCP |
|
700 |
- close(sockfd[1]); |
|
701 |
- pt[process_no].unix_sock=sockfd[0]; |
|
702 |
- pt[process_no].idx=-1; /* this is not "tcp" process*/ |
|
703 |
-#endif |
|
704 |
- return 1; |
|
705 |
-} |
|
706 |
- |
|
707 |
-static int print_version_cmd( FILE *stream, char *response_file ) |
|
708 |
-{ |
|
709 |
- if (response_file) { |
|
710 |
- fifo_reply(response_file, "200 ok\n" SERVER_HDR CRLF ); |
|
711 |
- } else { |
|
712 |
- LOG(L_ERR, "ERROR: no file for %s\n", "print_version_cmd" ); |
|
713 |
- } |
|
714 |
- return 1; |
|
715 |
-} |
|
716 |
- |
|
717 |
-static int pwd_cmd( FILE *stream, char *response_file ) |
|
718 |
-{ |
|
719 |
- char *cwd_buf; |
|
720 |
- int max_len; |
|
721 |
- |
|
722 |
- if (!response_file) { |
|
723 |
- LOG(L_ERR, "ERROR: no file for %s\n", "pwd_cmd" ); |
|
724 |
- return 1; |
|
725 |
- } |
|
726 |
- |
|
727 |
- max_len=pathmax(); |
|
728 |
- cwd_buf=pkg_malloc(max_len); |
|
729 |
- if (!cwd_buf) { |
|
730 |
- LOG(L_ERR, "ERROR: pwd_cmd: no cwd pkg mem\n"); |
|
731 |
- fifo_reply(response_file, "500 no memory\n"); |
|
732 |
- return 1; |
|
733 |
- } |
|
734 |
- |
|
735 |
- if (getcwd(cwd_buf, max_len)) { |
|
736 |
- fifo_reply(response_file, "200 ok\n%s\n", cwd_buf ); |
|
737 |
- } else { |
|
738 |
- fifo_reply(response_file, "500 getcwd failed\n" ); |
|
739 |
- } |
|
740 |
- |
|
741 |
- pkg_free(cwd_buf); |
|
742 |
- return 1; |
|
743 |
-} |
|
744 |
- |
|
745 |
-static int arg_cmd( FILE *stream, char *response_file ) |
|
746 |
-{ |
|
747 |
- FILE *reply_pipe; |
|
748 |
- int p; |
|
749 |
- |
|
750 |
- if (response_file==0 || *response_file==0 ) { |
|
751 |
- LOG(L_ERR, "ERROR: ps_fifo_cmd: null file\n"); |
|
752 |
- return -1; |
|
753 |
- } |
|
754 |
- reply_pipe=open_reply_pipe(response_file); |
|
755 |
- if (reply_pipe==NULL) { |
|
756 |
- LOG(L_ERR, "ERROR: ps_fifo_cmd: opening reply pipe (%s) failed\n", |
|
757 |
- response_file ); |
|
758 |
- return -1; |
|
759 |
- } |
|
760 |
- |
|
761 |
- fputs( "200 ok\n", reply_pipe); |
|
762 |
- for (p=0; p<my_argc;p++) |
|
763 |
- fprintf( reply_pipe, "%s\n", my_argv[p] ); |
|
764 |
- |
|
765 |
- fclose(reply_pipe); |
|
766 |
- return 1; |
|
767 |
-} |
|
768 |
- |
|
769 |
- |
|
770 |
- |
|
771 |
-/* diagnostic and hello-world FIFO command */ |
|
772 |
-static int print_fifo_cmd( FILE *stream, char *response_file ) |
|
773 |
-{ |
|
774 |
- char text[MAX_PRINT_TEXT]; |
|
775 |
- int text_len; |
|
776 |
- |
|
777 |
- /* expect one line which will be printed out */ |
|
778 |
- if (response_file==0 || *response_file==0 ) { |
|
779 |
- LOG(L_ERR, "ERROR: print_fifo_cmd: null file\n"); |
|
780 |
- return -1; |
|
781 |
- } |
|
782 |
- if (!read_line(text, MAX_PRINT_TEXT, stream, &text_len)) { |
|
783 |
- fifo_reply(response_file, |
|
784 |
- "500 print_fifo_cmd: too big text"); |
|
785 |
- return -1; |
|
786 |
- } |
|
787 |
- /* now the work begins */ |
|
788 |
- if (response_file) { |
|
789 |
- fifo_reply(response_file, "200 ok\n%s\n", text ); |
|
790 |
- } else { |
|
791 |
- LOG(L_INFO, "INFO: print_fifo_cmd: %.*s\n", |
|
792 |
- text_len, text ); |
|
793 |
- } |
|
794 |
- return 1; |
|
795 |
-} |
|
796 |
- |
|
797 |
-static int uptime_fifo_cmd( FILE *stream, char *response_file ) |
|
798 |
-{ |
|
799 |
- time_t now; |
|
800 |
- |
|
801 |
- if (response_file==0 || *response_file==0 ) { |
|
802 |
- LOG(L_ERR, "ERROR: uptime_fifo_cmd: null file\n"); |
|
803 |
- return -1; |
|
804 |
- } |
|
805 |
- |
|
806 |
- time(&now); |
|
807 |
- fifo_reply( response_file, "200 ok\n" |
|
808 |
- "Now: %sUp Since: %sUp time: %.0f [sec]\n", |
|
809 |
- ctime(&now), up_since_ctime, difftime(now, up_since) ); |
|
810 |
- |
|
811 |
- return 1; |
|
812 |
-} |
|
813 |
- |
|
814 |
-static int kill_fifo_cmd( FILE *stream, char *response_file ) |
|
815 |
-{ |
|
816 |
- if (response_file==0 || *response_file==0 ) { |
|
817 |
- LOG(L_ERR, "ERROR: uptime_fifo_cmd: null file\n"); |
|
818 |
- return -1; |
|
819 |
- } |
|
820 |
- fifo_reply(response_file, "200 killing now..." ); |
|
821 |
- kill(0, SIGTERM); |
|
822 |
- return 1; |
|
823 |
-} |
|
824 |
- |
|
825 |
-static int which_fifo_cmd(FILE *stream, char *response_file ) |
|
826 |
-{ |
|
827 |
- FILE *reply_pipe; |
|
828 |
- struct fifo_command *c; |
|
829 |
- |
|
830 |
- if (response_file==0 || *response_file==0 ) { |
|
831 |
- LOG(L_ERR, "ERROR: which_fifo_cmd: null file\n"); |
|
832 |
- return -1; |
|
833 |
- } |
|
834 |
- |
|
835 |
- reply_pipe=open_reply_pipe(response_file); |
|
836 |
- if (reply_pipe==NULL) { |
|
837 |
- LOG(L_ERR, "ERROR: which_fifo_cmd: opening reply pipe (%s) failed\n", |
|
838 |
- response_file ); |
|
839 |
- return -1; |
|
840 |
- } |
|
841 |
- fputs( "200 ok\n", reply_pipe); |
|
842 |
- for(c=cmd_list; c; c=c->next) { |
|
843 |
- fprintf( reply_pipe, "%s\n", c->name ); |
|
844 |
- } |
|
845 |
- |
|
846 |
- fclose(reply_pipe); |
|
847 |
- return 1; |
|
848 |
-} |
|
849 |
- |
|
850 |
-static int ps_fifo_cmd(FILE *stream, char *response_file ) |
|
851 |
-{ |
|
852 |
- FILE *reply_pipe; |
|
853 |
- int p; |
|
854 |
- |
|
855 |
- if (response_file==0 || *response_file==0 ) { |
|
856 |
- LOG(L_ERR, "ERROR: ps_fifo_cmd: null file\n"); |
|
857 |
- return -1; |
|
858 |
- } |
|
859 |
- reply_pipe=open_reply_pipe(response_file); |
|
860 |
- if (reply_pipe==NULL) { |
|
861 |
- LOG(L_ERR, "ERROR: ps_fifo_cmd: opening reply pipe (%s) failed\n", |
|
862 |
- response_file ); |
|
863 |
- return -1; |
|
864 |
- } |
|
865 |
- |
|
866 |
- fputs( "200 ok\n", reply_pipe); |
|
867 |
- for (p=0; p<process_count;p++) |
|
868 |
- fprintf( reply_pipe, "%d\t%d\t%s\n", |
|
869 |
- p, pt[p].pid, pt[p].desc ); |
|
870 |
- |
|
871 |
- fclose(reply_pipe); |
|
872 |
- return 1; |
|
873 |
-} |
|
874 |
- |
|
875 |
- |
|
876 |
- |
|
877 |
-static int meminfo_fifo_cmd( FILE *stream, char *response_file ) |
|
878 |
-{ |
|
879 |
- struct mem_info mi; |
|
880 |
- |
|
881 |
- if (response_file==0 || *response_file==0 ) { |
|
882 |
- LOG(L_ERR, "ERROR: meminfo_fifo_cmd: null file\n"); |
|
883 |
- return -1; |
|
884 |
- } |
|
885 |
- |
|
886 |
-#ifdef SHM_MEM |
|
887 |
- shm_info(&mi); |
|
888 |
- fifo_reply( response_file, "200 ok\n" |
|
889 |
- "total:%ld\n" |
|
890 |
- "free:%ld\n" |
|
891 |
- "used:%ld\n" |
|
892 |
- "max used:%ld\n" |
|
893 |
- "fragments:%ld\n", |
|
894 |
- mi.total_size, mi.free, mi.real_used, |
|
895 |
- mi.max_used, mi.total_frags); |
|
896 |
-#else |
|
897 |
- fifo_reply( response_file, "400 No shared memory support\n"); |
|
898 |
-#endif |
|
899 |
- |
|
900 |
- return 1; |
|
901 |
-} |
|
902 |
- |
|
903 |
- |
|
904 |
- |
|
905 |
-int register_core_fifo() |
|
906 |
-{ |
|
907 |
- if (register_fifo_cmd(print_fifo_cmd, FIFO_PRINT, 0)<0) { |
|
908 |
- LOG(L_ERR, "ERROR: unable to register '%s' FIFO cmd\n", FIFO_PRINT); |
|
909 |
- return -1; |
|
910 |
- } |
|
911 |
- if (register_fifo_cmd(uptime_fifo_cmd, FIFO_UPTIME, 0)<0) { |
|
912 |
- LOG(L_ERR, "ERROR: unable to register '%s' FIFO cmd\n", FIFO_UPTIME); |
|
913 |
- return -1; |
|
914 |
- } |
|
915 |
- if (register_fifo_cmd(print_version_cmd, FIFO_VERSION, 0)<0) { |
|
916 |
- LOG(L_ERR, "ERROR: unable to register '%s' FIFO cmd\n",FIFO_VERSION); |
|
917 |
- return -1; |
|
918 |
- } |
|
919 |
- if (register_fifo_cmd(pwd_cmd, FIFO_PWD, 0)<0) { |
|
920 |
- LOG(L_ERR, "ERROR: unable to register '%s' FIFO cmd\n", FIFO_PWD); |
|
921 |
- return -1; |
|
922 |
- } |
|
923 |
- if (register_fifo_cmd(arg_cmd, FIFO_ARG, 0)<0) { |
|
924 |
- LOG(L_ERR, "ERROR: unable to register '%s' FIFO cmd\n", FIFO_ARG); |
|
925 |
- return -1; |
|
926 |
- } |
|
927 |
- if (register_fifo_cmd(which_fifo_cmd, FIFO_WHICH, 0)<0) { |
|
928 |
- LOG(L_ERR, "ERROR: unable to register '%s' FIFO cmd\n", FIFO_WHICH); |
|
929 |
- return -1; |
|
930 |
- } |
|
931 |
- if (register_fifo_cmd(ps_fifo_cmd, FIFO_PS, 0)<0) { |
|
932 |
- LOG(L_ERR, "ERROR: unable to register '%s' FIFO cmd\n", FIFO_PS); |
|
933 |
- return -1; |
|
934 |
- } |
|
935 |
- if (register_fifo_cmd(kill_fifo_cmd, FIFO_KILL, 0)<0) { |
|
936 |
- LOG(L_CRIT, "ERROR: unable to register '%s' FIFO cmd\n", FIFO_KILL); |
|
937 |
- return -1; |
|
938 |
- } |
|
939 |
- if (register_fifo_cmd(meminfo_fifo_cmd, FIFO_MEMINFO, 0)<0) { |
|
940 |
- LOG(L_CRIT, "ERROR: unable to register '%s' FIFO cmd\n", FIFO_MEMINFO); |
|
941 |
- return -1; |
|
942 |
- } |
|
943 |
- if (fifo_db_url==0) { |
|
944 |
- LOG(L_WARN,"WARNING: no fifo_db_url given - " |
|
945 |
- "fifo DB commands disabled!\n"); |
|
946 |
- } else if (init_db_fifo(fifo_db_url)<0){ |
|
947 |
- return -1; |
|
948 |
- } |
|
949 |
- return 1; |
|
950 |
-} |
951 | 0 |
deleted file mode 100644 |
... | ... |
@@ -1,92 +0,0 @@ |
1 |
-/* |
|
2 |
- * $Id$ |
|
3 |
- * |
|
4 |
- * |
|
5 |
- * Copyright (C) 2001-2003 FhG Fokus |
|
6 |
- * |
|
7 |
- * This file is part of ser, a free SIP server. |
|
8 |
- * |
|
9 |
- * ser is free software; you can redistribute it and/or modify |
|
10 |
- * it under the terms of the GNU General Public License as published by |
|
11 |
- * the Free Software Foundation; either version 2 of the License, or |
|
12 |
- * (at your option) any later version |
|
13 |
- * |
|
14 |
- * For a license to use the ser software under conditions |
|
15 |
- * other than those described here, or to purchase support for this |
|
16 |
- * software, please contact iptel.org by e-mail at the following addresses: |
|
17 |
- * info@iptel.org |
|
18 |
- * |
|
19 |
- * ser is distributed in the hope that it will be useful, |
|
20 |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
21 |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
22 |
- * GNU General Public License for more details. |
|
23 |
- * |
|
24 |
- * You should have received a copy of the GNU General Public License |
|
25 |
- * along with this program; if not, write to the Free Software |
|
26 |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
27 |
- */ |
|
28 |
- |
|
29 |
- |
|
30 |
-#ifndef _FIFO_SERVER_H |
|
31 |
-#define _FIFO_SERVER_H |
|
32 |
- |
|
33 |
-#include <stdio.h> |
|
34 |
- |
|
35 |
-#define CMD_SEPARATOR ':' |
|
36 |
- |
|
37 |
-/* core FIFO command set */ |
|
38 |
-/* echo input */ |
|
39 |
-#define FIFO_PRINT "print" |
|
40 |
-/* print server's uptime */ |
|
41 |
-#define FIFO_UPTIME "uptime" |
|
42 |
-/* print server's version */ |
|
43 |
-#define FIFO_VERSION "version" |
|
44 |
-/* print available FIFO commands */ |
|
45 |
-#define FIFO_WHICH "which" |
|
46 |
-/* print server's process table */ |
|
47 |
-#define FIFO_PS "ps" |
|
48 |
-/* print server's command line arguments */ |
|
49 |
-#define FIFO_ARG "arg" |
|
50 |
-/* print server's working directory */ |
|
51 |
-#define FIFO_PWD "pwd" |
|
52 |
-/* kill the server */ |
|
53 |
-#define FIFO_KILL "kill" |
|
54 |
-#define FIFO_MEMINFO "meminfo" |
|
55 |
- |
|
56 |
-#define MAX_CTIME_LEN 128 |
|
57 |
- |
|
58 |
-typedef int (fifo_cmd)( FILE *fifo_stream, char *response_file ); |
|
59 |
- |
|
60 |
-struct fifo_command{ |
|
61 |
- fifo_cmd *f; |
|
62 |
- struct fifo_command *next; |
|
63 |
- void *param; |
|
64 |
- char *name; |
|
65 |
-}; |
|
66 |
- |
|
67 |
-int register_fifo_cmd(fifo_cmd f, char *cmd_name, void *param); |
|
68 |
- |
|
69 |
-/* read a single EoL-terminated line from fifo */ |
|
70 |
-int read_line( char *b, int max, FILE *stream, int *read ); |
|
71 |
-/* consume EoL from fifo */ |
|
72 |
-int read_eol( FILE *stream ); |
|
73 |
-/* consume a set of EoL-terminated lines terminated by an additional EoL */ |
|
74 |
-int read_line_set(char *buf, int max_len, FILE *fifo, int *len); |
|
75 |
-/* consume a set of EoL-terminated lines terminated by a single dot line */ |
|
76 |
-int read_body(char *buf, int max_len, FILE *fifo, int *len); |
|
77 |
- |
|
78 |
-int init_fifo_server(); |
|
79 |
-int start_fifo_server(); |
|
80 |
- |
|
81 |
-/* register core FIFO command set */ |
|
82 |
-int register_core_fifo(); |
|
83 |
- |
|
84 |
-FILE *open_reply_pipe( char *pipe_name ); |
|
85 |
- |
|
86 |
-/* tell FIFO client an error occurred via reply pipe */ |
|
87 |
-void fifo_reply( char *reply_fifo, char *reply_fmt, ... ); |
|
88 |
- |
|
89 |
-/* memory deallocation */ |
|
90 |
-void destroy_fifo(); |
|
91 |
- |
|
92 |
-#endif |
... | ... |
@@ -124,17 +124,6 @@ extern unsigned int msg_no; |
124 | 124 |
|
125 | 125 |
extern unsigned long shm_mem_size; |
126 | 126 |
|
127 |
-/* FIFO server config */ |
|
128 |
-extern char *fifo; /* FIFO name */ |
|
129 |
-extern int fifo_mode; |
|
130 |
-extern char *fifo_dir; /* dir. where reply fifos are allowed */ |
|
131 |
-extern char *fifo_db_url; /* db url used by db_fifo interface */ |
|
132 |
- |
|
133 |
-/* UNIX domain socket configuration */ |
|
134 |
-extern char *unixsock_name; /* The name of the socket */ |
|
135 |
-extern int unixsock_children; /* The number of listening children */ |
|
136 |
-extern int unixsock_tx_timeout; /* Timeout (in ms) used when sending data */ |
|
137 |
- |
|
138 | 127 |
/* AVP configuration */ |
139 | 128 |
extern char *avp_db_url; /* db url used by user preferences (AVPs) */ |
140 | 129 |
|
... | ... |
@@ -112,8 +112,6 @@ |
112 | 112 |
#include "resolve.h" |
113 | 113 |
#include "parser/parse_hname2.h" |
114 | 114 |
#include "parser/digest/digest_parser.h" |
115 |
-#include "fifo_server.h" |
|
116 |
-#include "unixsock_server.h" |
|
117 | 115 |
#include "name_alias.h" |
118 | 116 |
#include "hash_func.h" |
119 | 117 |
#include "pt.h" |
... | ... |
@@ -128,7 +126,7 @@ |
128 | 126 |
#endif |
129 | 127 |
#endif |
130 | 128 |
#include "usr_avp.h" |
131 |
- |
|
129 |
+#include "core_cmd.h" |
|
132 | 130 |
|
133 | 131 |
#include "stats.h" |
134 | 132 |
|
... | ... |
@@ -179,9 +177,7 @@ Options:\n\ |
179 | 177 |
-u uid Change uid \n\ |
180 | 178 |
-g gid Change gid \n\ |
181 | 179 |
-P file Create a pid file\n\ |
182 |
- -G file Create a pgid file\n\ |
|
183 |
- -i fifo_path Create a fifo (useful for monitoring " NAME ") \n\ |
|
184 |
- -x socket Create a unix domain socket \n" |
|
180 |
+ -G file Create a pgid file\n" |
|
185 | 181 |
#ifdef STATS |
186 | 182 |
" -s file File to which statistics is dumped (disabled otherwise)\n" |
187 | 183 |
#endif |
... | ... |
@@ -388,8 +384,6 @@ void cleanup(show_status) |
388 | 384 |
destroy_tls(); |
389 | 385 |
#endif |
390 | 386 |
destroy_timer(); |
391 |
- close_unixsock_server(); |
|
392 |
- destroy_fifo(); |
|
393 | 387 |
destroy_script_cb(); |
394 | 388 |
#ifdef PKG_MALLOC |
395 | 389 |
if (show_status){ |
... | ... |
@@ -804,18 +798,6 @@ int main_loop() |
804 | 798 |
LOG(L_WARN, "WARNING: using only the first listen address" |
805 | 799 |
" (no fork)\n"); |
806 | 800 |
} |
807 |
- /* initialize fifo server -- we need to open the fifo before |
|
808 |
- * do_suid() and start the fifo server after all the socket |
|
809 |
- * are initialized, to inherit them*/ |
|
810 |
- if (init_fifo_server()<0) { |
|
811 |
- LOG(L_ERR, "initializing fifo server failed\n"); |
|
812 |
- goto error; |
|
813 |
- } |
|
814 |
- /* Initialize Unix domain socket server */ |
|
815 |
- if (init_unixsock_socket()<0) { |
|
816 |
- LOG(L_ERR, "Error while creating unix domain sockets\n"); |
|
817 |
- goto error; |
|
818 |
- } |
|
819 | 801 |
if (do_suid()==-1) goto error; /* try to drop privileges */ |
820 | 802 |
/* process_no now initialized to zero -- increase from now on |
821 | 803 |
as new processes are forked (while skipping 0 reserved for main |
... | ... |
@@ -872,19 +854,6 @@ int main_loop() |
872 | 854 |
strncpy(pt[process_no].desc, "timer", MAX_PT_DESC ); |
873 | 855 |
} |
874 | 856 |
|
875 |
- /* if configured, start a server for accepting FIFO commands, |
|
876 |
- * we need to do it after all the sockets are initialized, to |
|
877 |
- * inherit them*/ |
|
878 |
- if (start_fifo_server()<0) { |
|
879 |
- LOG(L_ERR, "starting fifo server failed\n"); |
|
880 |
- goto error; |
|
881 |
- } |
|
882 |
- |
|
883 |
- if (init_unixsock_children()<0) { |
|
884 |
- LOG(L_ERR, "Error while initializing Unix domain socket server\n"); |
|
885 |
- goto error; |
|
886 |
- } |
|
887 |
- |
|
888 | 857 |
/* main process, receive loop */ |
889 | 858 |
process_no=0; /*main process number*/ |
890 | 859 |
pt[process_no].pid=getpid(); |
... | ... |
@@ -958,39 +927,10 @@ int main_loop() |
958 | 927 |
#endif /* USE_TLS */ |
959 | 928 |
#endif /* USE_TCP */ |
960 | 929 |
|
961 |
- /* initialize fifo server -- we need to open the fifo before |
|
962 |
- * do_suid() and start the fifo server after all the socket |
|
963 |
- * are initialized, to inherit them*/ |
|
964 |
- if (init_fifo_server()<0) { |
|
965 |
- LOG(L_ERR, "initializing fifo server failed\n"); |
|
966 |
- goto error; |
|
967 |
- } |
|
968 |
- /* Initialize Unix domain socket server */ |
|
969 |
- /* Create the unix domain sockets */ |
|
970 |
- if (init_unixsock_socket()<0) { |
|
971 |
- LOG(L_ERR, "ERROR: Could not create unix domain sockets\n"); |
|
972 |
- goto error; |
|
973 |
- } |
|
974 |
- |
|
975 | 930 |
/* all processes should have access to all the sockets (for sending) |
976 | 931 |
* so we open all first*/ |
977 | 932 |
if (do_suid()==-1) goto error; /* try to drop privileges */ |
978 | 933 |
|
979 |
- /* if configured, start a server for accepting FIFO commands, |
|
980 |
- * we need to do it after all the sockets are initialized, to |
|
981 |
- * inherit them*/ |
|
982 |
- if (start_fifo_server()<0) { |
|
983 |
- LOG(L_ERR, "starting fifo server failed\n"); |
|
984 |
- goto error; |
|
985 |
- } |
|
986 |
- /* Spawn children listening on unix domain socket if and only if |
|
987 |
- * the unix domain socket server has not been disabled (i == 0) |
|
988 |
- */ |
|
989 |
- if (init_unixsock_children()<0) { |
|
990 |
- LOG(L_ERR, "ERROR: Could not initialize unix domain socket server\n"); |
|
991 |
- goto error; |
|
992 |
- } |
|
993 |
- |
|
994 | 934 |
/* udp processes */ |
995 | 935 |
for(si=udp_listen; si; si=si->next){ |
996 | 936 |
for(i=0;i<children_no;i++){ |
... | ... |
@@ -1219,7 +1159,6 @@ int main_loop() |
1219 | 1159 |
|
1220 | 1160 |
} |
1221 | 1161 |
|
1222 |
- |
|
1223 | 1162 |
/* |
1224 | 1163 |
* Calculate number of processes, this does not |
1225 | 1164 |
* include processes created by modules |
... | ... |
@@ -1239,17 +1178,12 @@ static int calc_proc_no(void) |
1239 | 1178 |
#ifdef USE_SLOW_TIMER |
1240 | 1179 |
+ 1 /* slow timer process */ |
1241 | 1180 |
#endif |
1242 |
- /* fifo server */ |
|
1243 |
- +((fifo==NULL || strlen(fifo)==0) ? 0 : 1 ) |
|
1244 |
- /* unixsock server*/ |
|
1245 |
- +(unixsock_name?unixsock_children:0) |
|
1246 | 1181 |
#ifdef USE_TCP |
1247 | 1182 |
+((!tcp_disable)?( 1/* tcp main */ + tcp_children_no ):0) |
1248 | 1183 |
#endif |
1249 | 1184 |
; |
1250 | 1185 |
} |
1251 | 1186 |
|
1252 |
- |
|
1253 | 1187 |
int main(int argc, char** argv) |
1254 | 1188 |
{ |
1255 | 1189 |
|
... | ... |
@@ -1285,7 +1219,7 @@ int main(int argc, char** argv) |
1285 | 1219 |
#ifdef STATS |
1286 | 1220 |
"s:" |
1287 | 1221 |
#endif |
1288 |
- "f:cm:b:l:n:N:rRvdDETVhw:t:u:g:P:G:i:x:W:"; |
|
1222 |
+ "f:cm:b:l:n:N:rRvdDETVhw:t:u:g:P:G:W:"; |
|
1289 | 1223 |
|
1290 | 1224 |
while((c=getopt(argc,argv,options))!=-1){ |
1291 | 1225 |
switch(c){ |
... | ... |
@@ -1423,12 +1357,6 @@ int main(int argc, char** argv) |
1423 | 1357 |
case 'G': |
1424 | 1358 |
pgid_file=optarg; |
1425 | 1359 |
break; |
1426 |
- case 'i': |
|
1427 |
- fifo=optarg; |
|
1428 |
- break; |
|
1429 |
- case 'x': |
|
1430 |
- unixsock_name=optarg; |
|
1431 |
- break; |
|
1432 | 1360 |
case '?': |
1433 | 1361 |
if (isprint(optopt)) |
1434 | 1362 |
fprintf(stderr, "Unknown option `-%c�.\n", optopt); |
... | ... |
@@ -1478,14 +1406,6 @@ try_again: |
1478 | 1406 |
srand(seed); |
1479 | 1407 |
DBG("test random number %u\n", rand()); |
1480 | 1408 |
|
1481 |
- |
|
1482 |
- |
|
1483 |
- /* register a diagnostic FIFO command - moved to fifo server - bogdan |
|
1484 |
- if (register_core_fifo()<0) { |
|
1485 |
- LOG(L_CRIT, "unable to register core FIFO commands\n"); |
|
1486 |
- goto error; |
|
1487 |
- }*/ |
|
1488 |
- |
|
1489 | 1409 |
/*register builtin modules*/ |
1490 | 1410 |
register_builtin_modules(); |
1491 | 1411 |
|
... | ... |
@@ -1494,9 +1414,7 @@ try_again: |
1494 | 1414 |
fprintf(stderr, "ERROR: bad config file (%d errors)\n", cfg_errors); |
1495 | 1415 |
goto error; |
1496 | 1416 |
} |
1497 |
- |
|
1498 |
- |
|
1499 |
- |
|
1417 |
+ |
|
1500 | 1418 |
print_rl(); |
1501 | 1419 |
|
1502 | 1420 |
/* init the resolver, before fixing the config */ |
... | ... |
@@ -1530,19 +1448,6 @@ try_again: |
1530 | 1448 |
goto error; |
1531 | 1449 |
} |
1532 | 1450 |
} |
1533 |
- /* fix sock/fifo uid/gid */ |
|
1534 |
- if (sock_user){ |
|
1535 |
- if (user2uid(&sock_uid, 0, sock_user)<0){ |
|
1536 |
- fprintf(stderr, "bad socket user name/uid number %s\n", user); |
|
1537 |
- goto error; |
|
1538 |
- } |
|
1539 |
- } |
|
1540 |
- if (sock_group){ |
|
1541 |
- if (group2gid(&sock_gid, sock_group)<0){ |
|
1542 |
- fprintf(stderr, "bad group name/gid number: -u %s\n", group); |
|
1543 |
- goto error; |
|
1544 |
- } |
|
1545 |
- } |
|
1546 | 1451 |
if (fix_all_socket_lists()!=0){ |
1547 | 1452 |
fprintf(stderr, "failed to initialize list addresses\n"); |
1548 | 1453 |
goto error; |
... | ... |
@@ -1586,6 +1491,7 @@ try_again: |
1586 | 1491 |
} |
1587 | 1492 |
|
1588 | 1493 |
if (init_avps()<0) goto error; |
1494 |
+ if (rpc_init_time() < 0) goto error; |
|
1589 | 1495 |
|
1590 | 1496 |
#ifdef USE_TCP |
1591 | 1497 |
if (!tcp_disable){ |
... | ... |
@@ -1622,8 +1528,6 @@ try_again: |
1622 | 1528 |
goto error; |
1623 | 1529 |
} |
1624 | 1530 |
} |
1625 |
- |
|
1626 |
- |
|
1627 | 1531 |
/* Calculate initial process count, mod_init functions called |
1628 | 1532 |
* below can add to it |
1629 | 1533 |
*/ |
... | ... |
@@ -1632,6 +1536,7 @@ try_again: |
1632 | 1536 |
fprintf(stderr, "ERROR: error while initializing modules\n"); |
1633 | 1537 |
goto error; |
1634 | 1538 |
} |
1539 |
+ |
|
1635 | 1540 |
/* The total number of processes is know now, note that no |
1636 | 1541 |
* function being called before this point may rely on the |
1637 | 1542 |
* number of processes ! |
... | ... |
@@ -1676,4 +1581,3 @@ error: |
1676 | 1581 |
return -1; |
1677 | 1582 |
|
1678 | 1583 |
} |
1679 |