Ticket #12737: conftest.c

File conftest.c, 3.7 KB (added by korli, 9 years ago)
Line 
1/* confdefs.h */
2#define PACKAGE_NAME "Dovecot"
3#define PACKAGE_TARNAME "dovecot"
4#define PACKAGE_VERSION "2.2.24"
5#define PACKAGE_STRING "Dovecot 2.2.24"
6#define PACKAGE_BUGREPORT "dovecot@dovecot.org"
7#define PACKAGE_URL ""
8#define DOVECOT_ABI_VERSION "2.2.ABIv24(2.2.24)"
9#define PACKAGE "dovecot"
10#define VERSION "2.2.24"
11#define STDC_HEADERS 1
12#define HAVE_SYS_TYPES_H 1
13#define HAVE_SYS_STAT_H 1
14#define HAVE_STDLIB_H 1
15#define HAVE_STRING_H 1
16#define HAVE_MEMORY_H 1
17#define HAVE_STRINGS_H 1
18#define HAVE_INTTYPES_H 1
19#define HAVE_STDINT_H 1
20#define HAVE_UNISTD_H 1
21#define HAVE_DLFCN_H 1
22#define LT_OBJDIR ".libs/"
23#define HAVE_ICONV 1
24#define ICONV_CONST
25#define DOVECOT_NAME "Dovecot"
26#define DOVECOT_STRING "Dovecot 2.2.24"
27#define DOVECOT_VERSION "2.2.24"
28#define DOVECOT_VERSION_MAJOR 2
29#define DOVECOT_VERSION_MINOR 2
30#define HAVE_STRINGS_H 1
31#define HAVE_STDINT_H 1
32#define HAVE_UNISTD_H 1
33#define HAVE_DIRENT_H 1
34#define HAVE_MALLOC_H 1
35#define HAVE_INTTYPES_H 1
36#define HAVE_SYS_UIO_H 1
37#define HAVE_SYS_RESOURCE_H 1
38#define HAVE_SYS_SELECT_H 1
39#define HAVE_LIBGEN_H 1
40#define HAVE_SYS_TIME_H 1
41#define HAVE_EXECINFO_H 1
42#define HAVE_SYS_UTSNAME_H 1
43#define HAVE_SYS_UTSNAME_H 1
44#define HAVE_GLOB_H 1
45#define PACKAGE_WEBPAGE "http://www.dovecot.org/"
46#define HAVE_FCNTL 1
47#define HAVE_FLOCK 1
48#define HAVE_LOCKF 1
49#define HAVE_INET_ATON 1
50#define HAVE_SIGACTION 1
51#define HAVE_GETPAGESIZE 1
52#define HAVE_STRCASECMP 1
53#define HAVE_VSYSLOG 1
54#define HAVE_WRITEV 1
55#define HAVE_PREAD 1
56#define HAVE_UNAME 1
57#define HAVE_UNSETENV 1
58#define HAVE_SETRLIMIT 1
59#define HAVE_SETEUID 1
60#define HAVE_SETREUID 1
61#define HAVE_SETEGID 1
62#define HAVE_DIRFD 1
63#define HAVE_CLEARENV 1
64#define HAVE_MALLOC_USABLE_SIZE 1
65#define HAVE_GLOB 1
66#define HAVE_TIMEGM 1
67#define HAVE_CLOCK_GETTIME /**/
68#define HAVE_TYPEOF /**/
69#define IOLOOP_POLL /**/
70#define IOLOOP_NOTIFY_NONE /**/
71#define SIZEOF_INT 4
72#define SIZEOF_LONG 8
73#define SIZEOF_VOID_P 8
74#define SIZEOF_LONG_LONG 8
75#define HAVE__BOOL 1
76#define UOFF_T_LONG /**/
77#define OFF_T_MAX LONG_MAX
78#define PRIuUOFF_T "lu"
79#define SSIZE_T_MAX LONG_MAX
80#define PRIuSIZE_T "lu"
81#define HAVE_UINTMAX_T /**/
82#define HAVE_UINT_FAST32_T /**/
83#define HAVE_SOCKLEN_T /**/
84#define MEM_ALIGN_SIZE 8
85#define DEV_URANDOM_PATH "/dev/urandom"
86#define HAVE_TM_GMTOFF /**/
87#define TIME_T_MAX_BITS 32
88#define TIME_T_SIGNED /**/
89#define FLEXIBLE_ARRAY_MEMBER
90#define HAVE_STRUCT_IOVEC /**/
91#define HAVE_RLIMIT_AS /**/
92#define HAVE_RLIMIT_CORE /**/
93/* end confdefs.h. */
94
95 #include <sys/types.h>
96 #include <sys/socket.h>
97 #include <sys/wait.h>
98 #include <sys/stat.h>
99 #include <unistd.h>
100 #include <fcntl.h>
101 #include "fdpass.h"
102
103 int nopen(void)
104 {
105 int i, n;
106 struct stat sb;
107 for (i = n = 0; i < 256; i++)
108 if (fstat(i, &sb) == 0) n++;
109 return n;
110 }
111 int main(void)
112 {
113 int fd[2], send_fd, recv_fd, status, n1, n2;
114 struct stat st, st2;
115 char data;
116
117 send_fd = creat("conftest.fdpass", 0600);
118 if (send_fd == -1) return 2;
119 unlink("conftest.fdpass");
120 if (fstat(send_fd, &st) < 0) return 2;
121 if (socketpair(AF_UNIX, SOCK_STREAM, 0, fd) < 0) return 2;
122 n1 = nopen();
123
124 switch (fork()) {
125 case -1:
126 return 2;
127 case 0:
128 alarm(1);
129 if (fd_send(fd[0], send_fd, &data, 1) != 1) return 2;
130 return 0;
131 default:
132 alarm(2);
133 if (wait(&status) == -1)
134 return 2;
135 if (status != 0)
136 return status;
137 if (fd_read(fd[1], &data, 1, &recv_fd) != 1) return 1;
138 if (fstat(recv_fd, &st2) < 0) return 2;
139 /* nopen check is for making sure that only a single fd
140 was received */
141 n2 = nopen();
142 return st.st_ino == st2.st_ino && n2 == n1 + 1 ? 0 : 1;
143 }
144 }
145