1 | dnl this file is part of libptytty, do not make local modifications |
1 | dnl this file is part of libptytty, do not make local modifications |
2 | dnl http://software.schmorp.de/pkg/libptytty |
2 | dnl http://software.schmorp.de/pkg/libptytty |
|
|
3 | |
|
|
4 | AC_DEFUN([PT_FIND_FILE], |
|
|
5 | [AC_CACHE_CHECK(where $1 is located, pt_cv_path_$1, |
|
|
6 | [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h> |
|
|
7 | #include <stdlib.h> |
|
|
8 | #include <sys/stat.h> |
|
|
9 | $5 |
|
|
10 | int main() |
|
|
11 | { |
|
|
12 | char **path, *list[] = { $4, NULL }; |
|
|
13 | FILE *f = fopen("conftestval", "w"); |
|
|
14 | if (!f) return 1; |
|
|
15 | #ifdef $2 |
|
|
16 | fprintf(f, "%s\n", $2); |
|
|
17 | #elif defined($3) |
|
|
18 | fprintf(f, "%s\n", $3); |
|
|
19 | #else |
|
|
20 | for (path = list; *path; path++) { |
|
|
21 | struct stat st; |
|
|
22 | if (stat(*path, &st) == 0) { |
|
|
23 | fprintf(f, "%s\n", *path); |
|
|
24 | break; |
|
|
25 | } |
|
|
26 | } |
|
|
27 | #endif |
|
|
28 | return fclose(f) != 0; |
|
|
29 | }]])],[pt_cv_path_$1=`cat conftestval`],[pt_cv_path_$1=], |
|
|
30 | [AC_MSG_WARN(Define $2 in config.h manually)])]) |
|
|
31 | if test x$pt_cv_path_$1 != x; then |
|
|
32 | AC_DEFINE_UNQUOTED($2, "$pt_cv_path_$1", Define location of $1) |
|
|
33 | fi]) |
3 | |
34 | |
4 | AC_DEFUN([PTY_CHECK], |
35 | AC_DEFUN([PTY_CHECK], |
5 | [ |
36 | [ |
6 | AC_CHECK_HEADERS( \ |
37 | AC_CHECK_HEADERS( \ |
7 | pty.h \ |
38 | pty.h \ |
… | |
… | |
62 | AC_MSG_RESULT(yes)], |
93 | AC_MSG_RESULT(yes)], |
63 | [AC_MSG_RESULT(no)]) |
94 | [AC_MSG_RESULT(no)]) |
64 | fi |
95 | fi |
65 | |
96 | |
66 | if test -z "$unix98_pty"; then |
97 | if test -z "$unix98_pty"; then |
67 | AC_CHECK_FUNCS(openpty, [], [AC_CHECK_LIB(util, openpty, [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lutil"])]) |
98 | AC_SEARCH_LIBS(openpty, util, AC_DEFINE(HAVE_OPENPTY, 1, "")) |
68 | fi |
99 | fi |
69 | ]) |
100 | ]) |
70 | |
101 | |
71 | AC_DEFUN([UTMP_CHECK], |
102 | AC_DEFUN([UTMP_CHECK], |
72 | [ |
103 | [ |
… | |
… | |
194 | dnl# -------------------------------------------------------------------------- |
225 | dnl# -------------------------------------------------------------------------- |
195 | dnl# FIND FILES |
226 | dnl# FIND FILES |
196 | dnl# -------------------------------------------------------------------------- |
227 | dnl# -------------------------------------------------------------------------- |
197 | |
228 | |
198 | dnl# find utmp |
229 | dnl# find utmp |
199 | AC_CACHE_CHECK(where utmp is located, pt_cv_path_utmp, |
230 | PT_FIND_FILE([utmp], [UTMP_FILE], [_PATH_UTMP], |
200 | [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h> |
231 | ["/var/run/utmp", "/var/adm/utmp", "/etc/utmp", "/usr/etc/utmp", "/usr/adm/utmp"],[ |
201 | #include <stdlib.h> |
|
|
202 | #include <sys/types.h> |
232 | #include <sys/types.h> |
203 | #include <utmp.h> |
233 | #include <utmp.h> |
204 | #include <errno.h> |
234 | ]) |
205 | main() |
|
|
206 | { |
|
|
207 | char **u, *utmplist[] = { |
|
|
208 | "/var/run/utmp", "/var/adm/utmp", "/etc/utmp", "/usr/etc/utmp", "/usr/adm/utmp", NULL }; |
|
|
209 | FILE *a, *f=fopen("conftestval", "w"); |
|
|
210 | if (!f) exit(1); |
|
|
211 | #ifdef UTMP_FILE |
|
|
212 | fprintf(f, "%s\n", UTMP_FILE); |
|
|
213 | exit(0); |
|
|
214 | #endif |
|
|
215 | #ifdef _PATH_UTMP |
|
|
216 | fprintf(f, "%s\n", _PATH_UTMP); |
|
|
217 | exit(0); |
|
|
218 | #endif |
|
|
219 | for (u = utmplist; *u; u++) { |
|
|
220 | if ((a = fopen(*u, "r")) != NULL || errno == EACCES) { |
|
|
221 | fprintf(f, "%s\n", *u); |
|
|
222 | exit(0); |
|
|
223 | } |
|
|
224 | } |
|
|
225 | exit(0); |
|
|
226 | }]])],[pt_cv_path_utmp=`cat conftestval`],[pt_cv_path_utmp=],[dnl |
|
|
227 | AC_MSG_WARN(Define UTMP_FILE in config.h manually)])]) |
|
|
228 | if test x$pt_cv_path_utmp != x; then |
|
|
229 | AC_DEFINE_UNQUOTED(UTMP_FILE, "$pt_cv_path_utmp", Define location of utmp) |
|
|
230 | fi |
|
|
231 | |
|
|
232 | dnl# -------------------------------------------------------------------------- |
|
|
233 | |
|
|
234 | dnl# find utmpx - if a utmp file exists at the same location and is more than |
|
|
235 | dnl# a day newer, then dump the utmpx. People leave lots of junk around. |
|
|
236 | AC_CACHE_CHECK(where utmpx is located, pt_cv_path_utmpx, |
|
|
237 | [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h> |
|
|
238 | #include <stdlib.h> |
|
|
239 | #include <sys/types.h> |
|
|
240 | #include <utmpx.h> |
|
|
241 | #include <errno.h> |
|
|
242 | #include <sys/stat.h> |
|
|
243 | #ifdef HAVE_STRING_H |
|
|
244 | #include <string.h> |
|
|
245 | #endif |
|
|
246 | main() |
|
|
247 | { |
|
|
248 | char **u, *p, *utmplist[] = { |
|
|
249 | #ifdef UTMPX_FILE |
|
|
250 | UTMPX_FILE, |
|
|
251 | #endif |
|
|
252 | #ifdef _PATH_UTMPX |
|
|
253 | _PATH_UTMPX, |
|
|
254 | #endif |
|
|
255 | "/var/adm/utmpx", "/etc/utmpx", NULL }; |
|
|
256 | FILE *a, *f=fopen("conftestval", "w"); |
|
|
257 | struct stat statu, statux; |
|
|
258 | if (!f) exit(1); |
|
|
259 | for (u = utmplist; *u; u++) { |
|
|
260 | if ((a = fopen(*u, "r")) != NULL || errno == EACCES) { |
|
|
261 | if (stat(*u, &statux) < 0) |
|
|
262 | continue; |
|
|
263 | p = strdup(*u); |
|
|
264 | p[strlen(p) - 1] = '\0'; |
|
|
265 | if (stat(p, &statu) >= 0 |
|
|
266 | && (statu.st_mtime - statux.st_mtime > 86400)) |
|
|
267 | continue; |
|
|
268 | fprintf(f, "%s\n", *u); |
|
|
269 | exit(0); |
|
|
270 | } |
|
|
271 | } |
|
|
272 | exit(0); |
|
|
273 | }]])],[pt_cv_path_utmpx=`cat conftestval`],[pt_cv_path_utmpx=],[dnl |
|
|
274 | AC_MSG_WARN(Define UTMPX_FILE in config.h manually)])]) |
|
|
275 | if test x$pt_cv_path_utmpx != x; then |
|
|
276 | AC_DEFINE_UNQUOTED(UTMPX_FILE, "$pt_cv_path_utmpx", Define location of utmpx) |
|
|
277 | fi |
|
|
278 | |
235 | |
279 | dnl# -------------------------------------------------------------------------- |
236 | dnl# -------------------------------------------------------------------------- |
280 | |
237 | |
281 | dnl# find wtmp |
238 | dnl# find wtmp |
282 | AC_CACHE_CHECK(where wtmp is located, pt_cv_path_wtmp, |
239 | PT_FIND_FILE([wtmp], [WTMP_FILE], [_PATH_WTMP], |
283 | [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h> |
240 | ["/var/log/wtmp", "/var/adm/wtmp", "/etc/wtmp", "/usr/etc/wtmp", "/usr/adm/wtmp"],[ |
284 | #include <stdlib.h> |
|
|
285 | #include <sys/types.h> |
241 | #include <sys/types.h> |
286 | #ifdef HAVE_UTMP_H |
242 | #ifdef HAVE_UTMP_H |
287 | #include <utmp.h> |
243 | #include <utmp.h> |
288 | #endif |
244 | #endif |
289 | #include <errno.h> |
245 | ]) |
290 | main() |
|
|
291 | { |
|
|
292 | char **w, *wtmplist[] = { |
|
|
293 | "/var/log/wtmp", "/var/adm/wtmp", "/etc/wtmp", "/usr/etc/wtmp", "/usr/adm/wtmp", NULL }; |
|
|
294 | FILE *a, *f=fopen("conftestval", "w"); |
|
|
295 | if (!f) exit(1); |
|
|
296 | #ifdef WTMP_FILE |
|
|
297 | fprintf(f, "%s\n", WTMP_FILE); |
|
|
298 | exit(0); |
|
|
299 | #endif |
|
|
300 | #ifdef _PATH_WTMP |
|
|
301 | fprintf(f, "%s\n", _PATH_WTMP); |
|
|
302 | exit(0); |
|
|
303 | #endif |
|
|
304 | for (w = wtmplist; *w; w++) { |
|
|
305 | if ((a = fopen(*w, "r")) != NULL || errno == EACCES) { |
|
|
306 | fprintf(f, "%s\n", *w); |
|
|
307 | exit(0); |
|
|
308 | } |
|
|
309 | } |
|
|
310 | exit(0); |
|
|
311 | }]])],[pt_cv_path_wtmp=`cat conftestval`],[pt_cv_path_wtmp=],[dnl |
|
|
312 | AC_MSG_WARN(Define WTMP_FILE in config.h manually)])]) |
|
|
313 | if test x$pt_cv_path_wtmp != x; then |
|
|
314 | AC_DEFINE_UNQUOTED(WTMP_FILE, "$pt_cv_path_wtmp", Define location of wtmp) |
|
|
315 | fi |
|
|
316 | dnl# -------------------------------------------------------------------------- |
246 | dnl# -------------------------------------------------------------------------- |
317 | |
247 | |
318 | dnl# find wtmpx |
248 | dnl# find wtmpx |
319 | AC_CACHE_CHECK(where wtmpx is located, pt_cv_path_wtmpx, |
249 | PT_FIND_FILE([wtmpx], [WTMPX_FILE], [_PATH_WTMPX], |
320 | [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h> |
250 | ["/var/log/wtmpx", "/var/adm/wtmpx"],[ |
321 | #include <stdlib.h> |
|
|
322 | #ifdef HAVE_UTMPX_H |
251 | #ifdef HAVE_UTMPX_H |
323 | #include <utmpx.h> |
252 | #include <utmpx.h> |
324 | #endif |
253 | #endif |
325 | #include <errno.h> |
254 | ]) |
326 | main() |
|
|
327 | { |
|
|
328 | char **w, *wtmplist[] = { |
|
|
329 | "/var/log/wtmpx", "/var/adm/wtmpx", NULL }; |
|
|
330 | FILE *a, *f=fopen("conftestval", "w"); |
|
|
331 | if (!f) exit(1); |
|
|
332 | #ifdef WTMPX_FILE |
|
|
333 | fprintf(f, "%s\n", WTMPX_FILE); |
|
|
334 | exit(0); |
|
|
335 | #endif |
|
|
336 | #ifdef _PATH_WTMPX |
|
|
337 | fprintf(f, "%s\n", _PATH_WTMPX); |
|
|
338 | exit(0); |
|
|
339 | #endif |
|
|
340 | for (w = wtmplist; *w; w++) { |
|
|
341 | if ((a = fopen(*w, "r")) != NULL || errno == EACCES) { |
|
|
342 | fprintf(f, "%s\n", *w); |
|
|
343 | exit(0); |
|
|
344 | } |
|
|
345 | } |
|
|
346 | exit(0); |
|
|
347 | }]])],[pt_cv_path_wtmpx=`cat conftestval`],[pt_cv_path_wtmpx=],[dnl |
|
|
348 | AC_MSG_WARN(Define WTMPX_FILE in config.h manually)])]) |
|
|
349 | if test x$pt_cv_path_wtmpx != x; then |
|
|
350 | AC_DEFINE_UNQUOTED(WTMPX_FILE, "$pt_cv_path_wtmpx", Define location of wtmpx) |
|
|
351 | fi |
|
|
352 | dnl# -------------------------------------------------------------------------- |
255 | dnl# -------------------------------------------------------------------------- |
353 | |
256 | |
354 | dnl# find lastlog |
257 | dnl# find lastlog |
355 | AC_CACHE_CHECK(where lastlog is located, pt_cv_path_lastlog, |
258 | PT_FIND_FILE([lastlog], [LASTLOG_FILE], [_PATH_LASTLOG], |
356 | [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h> |
259 | ["/var/log/lastlog"],[ |
|
|
260 | #include <sys/types.h> |
|
|
261 | #ifdef HAVE_UTMP_H |
|
|
262 | #include <utmp.h> |
|
|
263 | #endif |
|
|
264 | #ifdef HAVE_LASTLOG_H |
357 | #include <stdlib.h> |
265 | #include <lastlog.h> |
358 | #include <sys/types.h> |
266 | #endif |
|
|
267 | ]) |
|
|
268 | dnl# -------------------------------------------------------------------------- |
|
|
269 | |
|
|
270 | dnl# find lastlogx |
|
|
271 | PT_FIND_FILE([lastlogx], [LASTLOGX_FILE], [_PATH_LASTLOGX], |
|
|
272 | ["/var/log/lastlogx", "/var/adm/lastlogx"],[ |
359 | #ifdef HAVE_UTMPX_H |
273 | #ifdef HAVE_UTMPX_H |
360 | #include <utmpx.h> |
274 | #include <utmpx.h> |
361 | #elif defined(HAVE_UTMP_H) |
|
|
362 | #include <utmp.h> |
|
|
363 | #endif |
275 | #endif |
364 | #ifdef HAVE_LASTLOG_H |
276 | ]) |
365 | #include <lastlog.h> |
|
|
366 | #endif |
|
|
367 | #include <errno.h> |
|
|
368 | main() |
|
|
369 | { |
|
|
370 | char **w, *lastloglist[] = { "/var/log/lastlog", NULL }; |
|
|
371 | FILE *a, *f=fopen("conftestval", "w"); |
|
|
372 | if (!f) exit(1); |
|
|
373 | #ifdef LASTLOG_FILE |
|
|
374 | fprintf(f, "%s\n", LASTLOG_FILE); |
|
|
375 | exit(0); |
|
|
376 | #endif |
|
|
377 | #ifdef _PATH_LASTLOG |
|
|
378 | fprintf(f, "%s\n", _PATH_LASTLOG); |
|
|
379 | exit(0); |
|
|
380 | #endif |
|
|
381 | for (w = lastloglist; *w; w++) { |
|
|
382 | if ((a = fopen(*w, "r")) != NULL || errno == EACCES) { |
|
|
383 | fprintf(f, "%s\n", *w); |
|
|
384 | exit(0); |
|
|
385 | } |
|
|
386 | } |
|
|
387 | exit(0); |
|
|
388 | }]])],[pt_cv_path_lastlog=`cat conftestval`],[pt_cv_path_lastlog=],[dnl |
|
|
389 | AC_MSG_WARN(Define LASTLOG_FILE in config.h manually)])]) |
|
|
390 | if test x$pt_cv_path_lastlog != x; then |
|
|
391 | AC_DEFINE_UNQUOTED(LASTLOG_FILE, "$pt_cv_path_lastlog", Define location of lastlog) |
|
|
392 | fi |
|
|
393 | dnl# -------------------------------------------------------------------------- |
|
|
394 | |
|
|
395 | dnl# find lastlogx |
|
|
396 | AC_CACHE_CHECK(where lastlogx is located, pt_cv_path_lastlogx, |
|
|
397 | [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h> |
|
|
398 | #include <stdlib.h> |
|
|
399 | #ifdef HAVE_UTMPX_H |
|
|
400 | #include <utmpx.h> |
|
|
401 | #endif |
|
|
402 | #include <errno.h> |
|
|
403 | main() |
|
|
404 | { |
|
|
405 | char **w, *wtmplist[] = { "/var/log/lastlogx", "/var/adm/lastlogx", NULL }; |
|
|
406 | FILE *a, *f=fopen("conftestval", "w"); |
|
|
407 | if (!f) exit(1); |
|
|
408 | #ifdef LASTLOGX_FILE |
|
|
409 | fprintf(f, "%s\n", LASTLOGX_FILE); |
|
|
410 | exit(0); |
|
|
411 | #endif |
|
|
412 | #ifdef _PATH_LASTLOGX |
|
|
413 | fprintf(f, "%s\n", _PATH_LASTLOGX); |
|
|
414 | exit(0); |
|
|
415 | #endif |
|
|
416 | for (w = wtmplist; *w; w++) { |
|
|
417 | if ((a = fopen(*w, "r")) != NULL || errno == EACCES) { |
|
|
418 | fprintf(f, "%s\n", *w); |
|
|
419 | exit(0); |
|
|
420 | } |
|
|
421 | } |
|
|
422 | exit(0); |
|
|
423 | }]])],[pt_cv_path_lastlogx=`cat conftestval`],[pt_cv_path_lastlogx=],[dnl |
|
|
424 | AC_MSG_WARN(Define LASTLOGX_FILE in config.h manually)])]) |
|
|
425 | if test x$pt_cv_path_lastlogx != x; then |
|
|
426 | AC_DEFINE_UNQUOTED(LASTLOGX_FILE, "$pt_cv_path_lastlogx", Define location of lastlogx) |
|
|
427 | fi |
|
|
428 | ]) |
277 | ]) |
429 | |
278 | |
430 | AC_DEFUN([SCM_RIGHTS_CHECK], |
279 | AC_DEFUN([SCM_RIGHTS_CHECK], |
431 | [ |
280 | [ |
432 | AC_CACHE_CHECK(for unix-compliant filehandle passing ability, pt_cv_can_pass_fds, |
281 | AC_CACHE_CHECK(for unix-compliant filehandle passing ability, pt_cv_can_pass_fds, |
… | |
… | |
474 | #include <sys/types.h> |
323 | #include <sys/types.h> |
475 | #include <sys/stat.h> |
324 | #include <sys/stat.h> |
476 | #include <unistd.h> |
325 | #include <unistd.h> |
477 | #include <grp.h> |
326 | #include <grp.h> |
478 | |
327 | |
479 | main() |
328 | int main() |
480 | { |
329 | { |
481 | struct stat st; |
330 | struct stat st; |
482 | struct group *gr; |
331 | struct group *gr; |
483 | char *tty; |
332 | char *tty; |
484 | gr = getgrnam("tty"); |
333 | gr = getgrnam("tty"); |