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