ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libptytty/ptytty.m4
Revision: 1.16
Committed: Mon Dec 24 01:04:37 2007 UTC (16 years, 4 months ago) by ayin
Branch: MAIN
Changes since 1.15: +9 -12 lines
Log Message:
autoupdate.

File Contents

# Content
1 dnl this file is part of libptytty, do not make local modifications
2 dnl http://software.schmorp.de/pkg/libptytty
3
4 AC_DEFUN([PTY_CHECK],
5 [
6 AC_CHECK_HEADERS( \
7 pty.h \
8 util.h \
9 libutil.h \
10 sys/ioctl.h \
11 sys/stropts.h \
12 )
13
14 AC_CHECK_FUNCS( \
15 revoke \
16 _getpty \
17 getpt \
18 posix_openpt \
19 isastream \
20 setuid \
21 seteuid \
22 setreuid \
23 setresuid \
24 )
25
26 have_clone=no
27
28 AC_MSG_CHECKING(for /dev/ptym/clone)
29 if test -e /dev/ptym/clone; then
30 AC_MSG_RESULT(yes)
31 AC_DEFINE(HAVE_DEV_CLONE, 1, [Define to 1 if you have /dev/ptym/clone])
32 AC_DEFINE(CLONE_DEVICE, "/dev/ptym/clone", [clone device filename])
33 have_clone=yes
34 else
35 AC_MSG_RESULT(no)
36 fi
37
38 AC_MSG_CHECKING(for /dev/ptc)
39 if test -e /dev/ptc; then
40 AC_MSG_RESULT(yes)
41 AC_DEFINE(HAVE_DEV_PTC, 1, [Define to 1 if you have /dev/ptc])
42 AC_DEFINE(CLONE_DEVICE, "/dev/ptc", [clone device filename])
43 have_clone=yes
44 else
45 AC_MSG_RESULT(no)
46 fi
47
48 case $host in
49 *-*-cygwin*)
50 have_clone=yes
51 AC_DEFINE(CLONE_DEVICE, "/dev/ptmx", [clone device filename])
52 ;;
53 *)
54 AC_MSG_CHECKING(for /dev/ptmx)
55 if test -e /dev/ptmx; then
56 AC_MSG_RESULT(yes)
57 AC_DEFINE(HAVE_DEV_PTMX, 1, [Define to 1 if you have /dev/ptmx])
58 AC_DEFINE(CLONE_DEVICE, "/dev/ptmx", [clone device filename])
59 have_clone=yes
60 else
61 AC_MSG_RESULT(no)
62 fi
63 ;;
64 esac
65
66 if test x$ac_cv_func_getpt = xyes -o x$ac_cv_func_posix_openpt = xyes -o x$have_clone = xyes; then
67 AC_MSG_CHECKING(for UNIX98 ptys)
68 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>]],
69 [[grantpt(0);unlockpt(0);ptsname(0);]])],
70 [unix98_pty=yes
71 AC_DEFINE(UNIX98_PTY, 1, "")
72 AC_MSG_RESULT(yes)],
73 [AC_MSG_RESULT(no)])
74 fi
75
76 if test -z "$unix98_pty"; then
77 AC_CHECK_FUNCS(openpty, [], [AC_CHECK_LIB(util, openpty, [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lutil"])])
78 fi
79 ])
80
81 AC_DEFUN([UTMP_CHECK],
82 [
83 support_utmp=yes
84 support_wtmp=yes
85 support_lastlog=yes
86
87 AC_ARG_ENABLE(utmp,
88 [AS_HELP_STRING([--enable-utmp],[enable utmp (utmpx) support])],
89 [if test x$enableval = xyes -o x$enableval = xno; then
90 support_utmp=$enableval
91 fi])
92
93 AC_ARG_ENABLE(wtmp,
94 [AS_HELP_STRING([--enable-wtmp],[enable wtmp (wtmpx) support (requires --enable-utmp)])],
95 [if test x$enableval = xyes -o x$enableval = xno; then
96 support_wtmp=$enableval
97 fi])
98
99 AC_ARG_ENABLE(lastlog,
100 [AS_HELP_STRING([--enable-lastlog],[enable lastlog support (requires --enable-utmp)])],
101 [if test x$enableval = xyes -o x$enableval = xno; then
102 support_lastlog=$enableval
103 fi])
104
105 if test x$support_utmp = xyes; then
106 AC_DEFINE(UTMP_SUPPORT, 1, Define if you want to have utmp/utmpx support)
107 fi
108 if test x$support_wtmp = xyes; then
109 AC_DEFINE(WTMP_SUPPORT, 1, Define if you want to have wtmp support when utmp/utmpx is enabled)
110 fi
111 if test x$support_lastlog = xyes; then
112 AC_DEFINE(LASTLOG_SUPPORT, 1, Define if you want to have lastlog support when utmp/utmpx is enabled)
113 fi
114
115 AC_CHECK_FUNCS( \
116 updwtmp \
117 updwtmpx \
118 updlastlogx \
119 )
120
121 AC_CHECK_HEADERS(lastlog.h)
122
123 dnl# --------------------------------------------------------------------------
124 dnl# DO ALL UTMP AND WTMP CHECKING
125 dnl# --------------------------------------------------------------------------
126 dnl# check for host field in utmp structure
127
128 dnl# --------------------------------------------
129 AC_CHECK_HEADERS(utmp.h,
130 [AC_CACHE_CHECK([for struct utmp], struct_utmp,
131 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
132 #include <utmp.h>]], [[struct utmp ut;]])],[struct_utmp=yes],[struct_utmp=no])])
133 if test x$struct_utmp = xyes; then
134 AC_DEFINE(HAVE_STRUCT_UTMP, 1, Define if utmp.h has struct utmp)
135 fi
136 ]
137
138 AC_CACHE_CHECK(for ut_host in utmp struct, struct_utmp_host,
139 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
140 #include <utmp.h>]], [[struct utmp ut; ut.ut_host;]])],[struct_utmp_host=yes],[struct_utmp_host=no])])
141 if test x$struct_utmp_host = xyes; then
142 AC_DEFINE(HAVE_UTMP_HOST, 1, Define if struct utmp contains ut_host)
143 fi
144
145 AC_CACHE_CHECK(for ut_pid in utmp struct, struct_utmp_pid,
146 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
147 #include <utmp.h>]], [[struct utmp ut; ut.ut_pid;]])],[struct_utmp_pid=yes],[struct_utmp_pid=no])])
148 if test x$struct_utmp_pid = xyes; then
149 AC_DEFINE(HAVE_UTMP_PID, 1, Define if struct utmp contains ut_pid)
150 fi
151 ) dnl# AC_CHECK_HEADERS(utmp.h
152
153 dnl# --------------------------------------------
154
155 AC_CHECK_HEADERS(utmpx.h,
156 [AC_CACHE_CHECK([for struct utmpx], struct_utmpx,
157 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
158 #include <utmpx.h>]], [[struct utmpx ut;]])],[struct_utmpx=yes],[struct_utmpx=no])])
159 if test x$struct_utmpx = xyes; then
160 AC_DEFINE(HAVE_STRUCT_UTMPX, 1, Define if utmpx.h has struct utmpx)
161 fi
162 ]
163
164 AC_CACHE_CHECK(for host in utmpx struct, struct_utmpx_host,
165 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
166 #include <utmpx.h>]], [[struct utmpx utx; utx.ut_host;]])],[struct_utmpx_host=yes],[struct_utmpx_host=no])])
167 if test x$struct_utmpx_host = xyes; then
168 AC_DEFINE(HAVE_UTMPX_HOST, 1, Define if struct utmpx contains ut_host)
169 fi
170
171 AC_CACHE_CHECK(for session in utmpx struct, struct_utmpx_session,
172 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
173 #include <utmpx.h>]], [[struct utmpx utx; utx.ut_session;]])],[struct_utmpx_session=yes],[struct_utmpx_session=no])])
174 if test x$struct_utmpx_session = xyes; then
175 AC_DEFINE(HAVE_UTMPX_SESSION, 1, Define if struct utmpx contains ut_session)
176 fi
177 ) dnl# AC_CHECK_HEADERS(utmpx.h
178
179 dnl# --------------------------------------------------------------------------
180 dnl# check for struct lastlog
181 AC_CACHE_CHECK(for struct lastlog, struct_lastlog,
182 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
183 #include <utmp.h>
184 #ifdef HAVE_LASTLOG_H
185 #include <lastlog.h>
186 #endif
187 ]], [[struct lastlog ll;]])],[struct_lastlog=yes],[struct_lastlog=no])])
188 if test x$struct_lastlog = xyes; then
189 AC_DEFINE(HAVE_STRUCT_LASTLOG, 1, Define if utmp.h or lastlog.h has struct lastlog)
190 fi
191
192 dnl# check for struct lastlogx
193 AC_CACHE_CHECK(for struct lastlogx, struct_lastlogx,
194 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
195 #include <utmpx.h>
196 #ifdef HAVE_LASTLOG_H
197 #include <lastlog.h>
198 #endif
199 ]], [[struct lastlogx ll;]])],[struct_lastlogx=yes],[struct_lastlogx=no])])
200 if test x$struct_lastlogx = xyes; then
201 AC_DEFINE(HAVE_STRUCT_LASTLOGX, 1, Define if utmpx.h or lastlog.h has struct lastlogx)
202 fi
203
204 dnl# --------------------------------------------------------------------------
205 dnl# FIND FILES
206 dnl# --------------------------------------------------------------------------
207
208 dnl# find utmp
209 AC_CACHE_CHECK(where utmp is located, path_utmp,
210 [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
211 #include <stdlib.h>
212 #include <sys/types.h>
213 #include <utmp.h>
214 #include <errno.h>
215 main()
216 {
217 char **u, *utmplist[] = {
218 "/var/run/utmp", "/var/adm/utmp", "/etc/utmp", "/usr/etc/utmp", "/usr/adm/utmp", NULL };
219 FILE *a, *f=fopen("conftestval", "w");
220 if (!f) exit(1);
221 #ifdef UTMP_FILE
222 fprintf(f, "%s\n", UTMP_FILE);
223 exit(0);
224 #endif
225 #ifdef _PATH_UTMP
226 fprintf(f, "%s\n", _PATH_UTMP);
227 exit(0);
228 #endif
229 for (u = utmplist; *u; u++) {
230 if ((a = fopen(*u, "r")) != NULL || errno == EACCES) {
231 fprintf(f, "%s\n", *u);
232 exit(0);
233 }
234 }
235 exit(0);
236 }]])],[path_utmp=`cat conftestval`],[path_utmp=],[dnl
237 AC_MSG_WARN(Define UTMP_FILE in config.h manually)])])
238 if test x$path_utmp != x; then
239 AC_DEFINE_UNQUOTED(UTMP_FILE, "$path_utmp", Define location of utmp)
240 fi
241
242 dnl# --------------------------------------------------------------------------
243
244 dnl# find utmpx - if a utmp file exists at the same location and is more than
245 dnl# a day newer, then dump the utmpx. People leave lots of junk around.
246 AC_CACHE_CHECK(where utmpx is located, path_utmpx,
247 [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
248 #include <stdlib.h>
249 #include <sys/types.h>
250 #include <utmpx.h>
251 #include <errno.h>
252 #include <sys/stat.h>
253 #ifdef HAVE_STRING_H
254 #include <string.h>
255 #endif
256 main()
257 {
258 char **u, *p, *utmplist[] = {
259 #ifdef UTMPX_FILE
260 UTMPX_FILE,
261 #endif
262 #ifdef _PATH_UTMPX
263 _PATH_UTMPX,
264 #endif
265 "/var/adm/utmpx", "/etc/utmpx", NULL };
266 FILE *a, *f=fopen("conftestval", "w");
267 struct stat statu, statux;
268 if (!f) exit(1);
269 for (u = utmplist; *u; u++) {
270 if ((a = fopen(*u, "r")) != NULL || errno == EACCES) {
271 if (stat(*u, &statux) < 0)
272 continue;
273 p = strdup(*u);
274 p[strlen(p) - 1] = '\0';
275 if (stat(p, &statu) >= 0
276 && (statu.st_mtime - statux.st_mtime > 86400))
277 continue;
278 fprintf(f, "%s\n", *u);
279 exit(0);
280 }
281 }
282 exit(0);
283 }]])],[path_utmpx=`cat conftestval`],[path_utmpx=],[dnl
284 AC_MSG_WARN(Define UTMPX_FILE in config.h manually)])])
285 if test x$path_utmpx != x; then
286 AC_DEFINE_UNQUOTED(UTMPX_FILE, "$path_utmpx", Define location of utmpx)
287 fi
288
289 dnl# --------------------------------------------------------------------------
290
291 dnl# find wtmp
292 AC_CACHE_CHECK(where wtmp is located, path_wtmp,
293 [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
294 #include <stdlib.h>
295 #include <sys/types.h>
296 #ifdef HAVE_UTMP_H
297 #include <utmp.h>
298 #endif
299 #include <errno.h>
300 main()
301 {
302 char **w, *wtmplist[] = {
303 "/var/log/wtmp", "/var/adm/wtmp", "/etc/wtmp", "/usr/etc/wtmp", "/usr/adm/wtmp", NULL };
304 FILE *a, *f=fopen("conftestval", "w");
305 if (!f) exit(1);
306 #ifdef WTMP_FILE
307 fprintf(f, "%s\n", WTMP_FILE);
308 exit(0);
309 #endif
310 #ifdef _PATH_WTMP
311 fprintf(f, "%s\n", _PATH_WTMP);
312 exit(0);
313 #endif
314 for (w = wtmplist; *w; w++) {
315 if ((a = fopen(*w, "r")) != NULL || errno == EACCES) {
316 fprintf(f, "%s\n", *w);
317 exit(0);
318 }
319 }
320 exit(0);
321 }]])],[path_wtmp=`cat conftestval`],[path_wtmp=],[dnl
322 AC_MSG_WARN(Define WTMP_FILE in config.h manually)])])
323 if test x$path_wtmp != x; then
324 AC_DEFINE_UNQUOTED(WTMP_FILE, "$path_wtmp", Define location of wtmp)
325 fi
326 dnl# --------------------------------------------------------------------------
327
328 dnl# find wtmpx
329 AC_CACHE_CHECK(where wtmpx is located, path_wtmpx,
330 [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
331 #include <stdlib.h>
332 #ifdef HAVE_UTMPX_H
333 #include <utmpx.h>
334 #endif
335 #include <errno.h>
336 main()
337 {
338 char **w, *wtmplist[] = {
339 "/var/log/wtmpx", "/var/adm/wtmpx", NULL };
340 FILE *a, *f=fopen("conftestval", "w");
341 if (!f) exit(1);
342 #ifdef WTMPX_FILE
343 fprintf(f, "%s\n", WTMPX_FILE);
344 exit(0);
345 #endif
346 #ifdef _PATH_WTMPX
347 fprintf(f, "%s\n", _PATH_WTMPX);
348 exit(0);
349 #endif
350 for (w = wtmplist; *w; w++) {
351 if ((a = fopen(*w, "r")) != NULL || errno == EACCES) {
352 fprintf(f, "%s\n", *w);
353 exit(0);
354 }
355 }
356 exit(0);
357 }]])],[path_wtmpx=`cat conftestval`],[path_wtmpx=],[dnl
358 AC_MSG_WARN(Define WTMPX_FILE in config.h manually)])])
359 if test x$path_wtmpx != x; then
360 AC_DEFINE_UNQUOTED(WTMPX_FILE, "$path_wtmpx", Define location of wtmpx)
361 fi
362 dnl# --------------------------------------------------------------------------
363
364 dnl# find lastlog
365 AC_CACHE_CHECK(where lastlog is located, path_lastlog,
366 [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
367 #include <stdlib.h>
368 #include <sys/types.h>
369 #ifdef HAVE_UTMPX_H
370 #include <utmpx.h>
371 #elif defined(HAVE_UTMP_H)
372 #include <utmp.h>
373 #endif
374 #ifdef HAVE_LASTLOG_H
375 #include <lastlog.h>
376 #endif
377 #include <errno.h>
378 main()
379 {
380 char **w, *lastloglist[] = { "/var/log/lastlog", NULL };
381 FILE *a, *f=fopen("conftestval", "w");
382 if (!f) exit(1);
383 #ifdef LASTLOG_FILE
384 fprintf(f, "%s\n", LASTLOG_FILE);
385 exit(0);
386 #endif
387 #ifdef _PATH_LASTLOG
388 fprintf(f, "%s\n", _PATH_LASTLOG);
389 exit(0);
390 #endif
391 for (w = lastloglist; *w; w++) {
392 if ((a = fopen(*w, "r")) != NULL || errno == EACCES) {
393 fprintf(f, "%s\n", *w);
394 exit(0);
395 }
396 }
397 exit(0);
398 }]])],[path_lastlog=`cat conftestval`],[path_lastlog=],[dnl
399 AC_MSG_WARN(Define LASTLOG_FILE in config.h manually)])])
400 if test x$path_lastlog != x; then
401 AC_DEFINE_UNQUOTED(LASTLOG_FILE, "$path_lastlog", Define location of lastlog)
402 fi
403 dnl# --------------------------------------------------------------------------
404
405 dnl# find lastlogx
406 AC_CACHE_CHECK(where lastlogx is located, path_lastlogx,
407 [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
408 #include <stdlib.h>
409 #ifdef HAVE_UTMPX_H
410 #include <utmpx.h>
411 #endif
412 #include <errno.h>
413 main()
414 {
415 char **w, *wtmplist[] = { "/var/log/lastlogx", "/var/adm/lastlogx", NULL };
416 FILE *a, *f=fopen("conftestval", "w");
417 if (!f) exit(1);
418 #ifdef LASTLOGX_FILE
419 fprintf(f, "%s\n", LASTLOGX_FILE);
420 exit(0);
421 #endif
422 #ifdef _PATH_LASTLOGX
423 fprintf(f, "%s\n", _PATH_LASTLOGX);
424 exit(0);
425 #endif
426 for (w = wtmplist; *w; w++) {
427 if ((a = fopen(*w, "r")) != NULL || errno == EACCES) {
428 fprintf(f, "%s\n", *w);
429 exit(0);
430 }
431 }
432 exit(0);
433 }]])],[path_lastlogx=`cat conftestval`],[path_lastlogx=],[dnl
434 AC_MSG_WARN(Define LASTLOGX_FILE in config.h manually)])])
435 if test x$path_lastlogx != x; then
436 AC_DEFINE_UNQUOTED(LASTLOGX_FILE, "$path_lastlogx", Define location of lastlogx)
437 fi
438 ])
439
440 AC_DEFUN([SCM_RIGHTS_CHECK],
441 [
442 AC_CACHE_CHECK(for unix-compliant filehandle passing ability, can_pass_fds,
443 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
444 #include <cstddef> // broken bsds (is that redundant?) need this
445 #include <sys/types.h>
446 #include <sys/socket.h>
447 #include <sys/uio.h>
448 ]], [[
449 {
450 msghdr msg;
451 iovec iov;
452 char buf [100];
453 char data = 0;
454
455 iov.iov_base = &data;
456 iov.iov_len = 1;
457
458 msg.msg_iov = &iov;
459 msg.msg_iovlen = 1;
460 msg.msg_control = buf;
461 msg.msg_controllen = sizeof buf;
462
463 cmsghdr *cmsg = CMSG_FIRSTHDR (&msg);
464 cmsg->cmsg_level = SOL_SOCKET;
465 cmsg->cmsg_type = SCM_RIGHTS;
466 cmsg->cmsg_len = 100;
467
468 *(int *)CMSG_DATA (cmsg) = 5;
469
470 return sendmsg (3, &msg, 0);
471 }
472 ]])],[can_pass_fds=yes],[can_pass_fds=no])])
473 if test x$can_pass_fds = xyes; then
474 AC_DEFINE(HAVE_UNIX_FDPASS, 1, Define if sys/socket.h defines the necessary macros/functions for file handle passing)
475 else
476 AC_MSG_ERROR([libptytty requires unix-compliant filehandle passing ability])
477 fi
478 ])
479
480 AC_DEFUN([TTY_GROUP_CHECK],
481 [
482 AC_CACHE_CHECK([for tty group], tty_group,
483 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
484 #include <sys/types.h>
485 #include <sys/stat.h>
486 #include <unistd.h>
487 #include <grp.h>
488
489 main()
490 {
491 struct stat st;
492 struct group *gr;
493 char *tty;
494 gr = getgrnam("tty");
495 tty = ttyname(0);
496 if (gr != 0
497 && tty != 0
498 && (stat(tty, &st)) == 0
499 && st.st_gid == gr->gr_gid)
500 return 0;
501 else
502 return 1;
503 }]])],[tty_group=yes],[tty_group=no],[tty_group=no])])
504 if test x$tty_group = xyes; then
505 AC_DEFINE(TTY_GID_SUPPORT, 1, "")
506 fi])
507