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