annotate src/libident/id_query.c @ 310:f10a56dc7481
reworked online_detect to the simpler online_query
Only pipe is supported now. Use
online_query="/bin/cat /path/to/file"
instead of
online_detect=file
online_file=/path/to/file
and
online_query="/path/to/some/script foo"
instead of
online_detect=pipe
online_pipe="/path/to/some/script foo"
See man page masqmail.conf(5) and admin/config-transition.
author |
meillo@marmaro.de |
date |
Sun, 24 Apr 2011 19:14:38 +0200 |
parents |
08114f7dcc23 |
children |
|
rev |
line source |
meillo@0
|
1 /*
|
meillo@0
|
2 ** id_query.c Transmit a query to an IDENT server
|
meillo@0
|
3 **
|
meillo@0
|
4 ** Author: Peter Eriksson <pen@lysator.liu.se>
|
meillo@0
|
5 */
|
meillo@0
|
6
|
meillo@0
|
7 #ifdef NeXT3
|
meillo@0
|
8 # include <libc.h>
|
meillo@0
|
9 #endif
|
meillo@0
|
10
|
meillo@0
|
11 #include <stdio.h>
|
meillo@0
|
12 #include <errno.h>
|
meillo@0
|
13 #include <signal.h>
|
meillo@0
|
14
|
meillo@0
|
15 #ifdef HAVE_ANSIHEADERS
|
meillo@0
|
16 # include <stdlib.h>
|
meillo@0
|
17 # include <string.h>
|
meillo@0
|
18 # include <unistd.h>
|
meillo@0
|
19 #endif
|
meillo@0
|
20
|
meillo@0
|
21 #include <sys/types.h>
|
meillo@0
|
22 #include <sys/wait.h>
|
meillo@0
|
23 #include <sys/time.h>
|
meillo@0
|
24
|
meillo@0
|
25 #ifdef _AIX
|
meillo@0
|
26 # include <sys/select.h>
|
meillo@0
|
27 #endif
|
meillo@0
|
28
|
meillo@0
|
29 #ifdef _AIX
|
meillo@0
|
30 # include <sys/select.h>
|
meillo@0
|
31 #endif
|
meillo@0
|
32 #ifdef VMS
|
meillo@10
|
33 # include <sys/socket.h> /* for fd_set */
|
meillo@0
|
34 #endif
|
meillo@0
|
35 #define IN_LIBIDENT_SRC
|
meillo@0
|
36 #include "ident.h"
|
meillo@0
|
37
|
meillo@0
|
38
|
meillo@0
|
39 /*
|
meillo@10
|
40 int
|
meillo@10
|
41 id_query __P4(ident_t *, id, int, lport, int, fport, struct timeval *, timeout)
|
meillo@0
|
42 */
|
meillo@0
|
43
|
meillo@10
|
44 int
|
meillo@10
|
45 id_query __P((ident_t * id, int lport, int fport, __STRUCT_TIMEVAL_P timeout))
|
meillo@0
|
46 {
|
meillo@0
|
47 #ifdef SIGRETURNTYPE
|
meillo@10
|
48 SIGRETURNTYPE(*old_sig) ();
|
meillo@0
|
49 #else
|
meillo@10
|
50 void (*old_sig) __P((int));
|
meillo@0
|
51 #endif
|
meillo@10
|
52 int res;
|
meillo@10
|
53 char buf[80];
|
meillo@10
|
54 fd_set ws;
|
meillo@10
|
55
|
meillo@10
|
56 sprintf(buf, "%d , %d\r\n", lport, fport);
|
meillo@10
|
57
|
meillo@10
|
58 if (timeout) {
|
meillo@10
|
59 FD_ZERO(&ws);
|
meillo@10
|
60 FD_SET(id->fd, &ws);
|
meillo@0
|
61
|
meillo@0
|
62 #ifdef __hpux
|
meillo@10
|
63 if ((res = select(FD_SETSIZE, (int *) 0, (int *) &ws, (int *) 0, timeout)) < 0)
|
meillo@0
|
64 #else
|
meillo@10
|
65 if ((res = select(FD_SETSIZE, (fd_set *) 0, &ws, (fd_set *) 0, timeout)) < 0)
|
meillo@0
|
66 #endif
|
meillo@10
|
67 return -1;
|
meillo@10
|
68
|
meillo@10
|
69 if (res == 0) {
|
meillo@10
|
70 errno = ETIMEDOUT;
|
meillo@10
|
71 return -1;
|
meillo@10
|
72 }
|
meillo@0
|
73 }
|
meillo@0
|
74
|
meillo@10
|
75 old_sig = signal(SIGPIPE, SIG_IGN);
|
meillo@10
|
76
|
meillo@10
|
77 res = write(id->fd, buf, strlen(buf));
|
meillo@10
|
78
|
meillo@10
|
79 signal(SIGPIPE, old_sig);
|
meillo@10
|
80
|
meillo@10
|
81 return res;
|
meillo@0
|
82 }
|