1 |
root |
1.2 |
dnl this file is part of libptytty, do not make local modifications |
2 |
|
|
dnl http://software.schmorp.de/pkg/libptytty |
3 |
|
|
|
4 |
sf-exg |
1.24 |
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 |
|
|
$5 |
9 |
|
|
#include <errno.h> |
10 |
|
|
int main() |
11 |
|
|
{ |
12 |
|
|
char **path, *list[] = { $4, NULL }; |
13 |
|
|
FILE *a, *f=fopen("conftestval", "w"); |
14 |
|
|
if (!f) exit(1); |
15 |
|
|
#ifdef $2 |
16 |
|
|
fprintf(f, "%s\n", $2); |
17 |
|
|
exit(0); |
18 |
|
|
#endif |
19 |
|
|
#ifdef $3 |
20 |
|
|
fprintf(f, "%s\n", $3); |
21 |
|
|
exit(0); |
22 |
|
|
#endif |
23 |
|
|
for (path = list; *path; path++) { |
24 |
|
|
if ((a = fopen(*path, "r")) != NULL || errno == EACCES) { |
25 |
|
|
fprintf(f, "%s\n", *path); |
26 |
|
|
exit(0); |
27 |
|
|
} |
28 |
|
|
} |
29 |
|
|
exit(0); |
30 |
|
|
}]])],[pt_cv_path_$1=`cat conftestval`],[pt_cv_path_$1=], |
31 |
|
|
[AC_MSG_WARN(Define $2 in config.h manually)])]) |
32 |
|
|
if test x$pt_cv_path_$1 != x; then |
33 |
|
|
AC_DEFINE_UNQUOTED($2, "$pt_cv_path_$1", Define location of $1) |
34 |
|
|
fi]) |
35 |
|
|
|
36 |
ayin |
1.1 |
AC_DEFUN([PTY_CHECK], |
37 |
|
|
[ |
38 |
|
|
AC_CHECK_HEADERS( \ |
39 |
|
|
pty.h \ |
40 |
|
|
util.h \ |
41 |
|
|
libutil.h \ |
42 |
|
|
sys/ioctl.h \ |
43 |
|
|
sys/stropts.h \ |
44 |
root |
1.17 |
stropts.h \ |
45 |
ayin |
1.1 |
) |
46 |
|
|
|
47 |
|
|
AC_CHECK_FUNCS( \ |
48 |
|
|
revoke \ |
49 |
|
|
_getpty \ |
50 |
|
|
getpt \ |
51 |
|
|
posix_openpt \ |
52 |
|
|
isastream \ |
53 |
root |
1.7 |
setuid \ |
54 |
|
|
seteuid \ |
55 |
|
|
setreuid \ |
56 |
|
|
setresuid \ |
57 |
ayin |
1.1 |
) |
58 |
|
|
|
59 |
|
|
have_clone=no |
60 |
|
|
|
61 |
|
|
AC_MSG_CHECKING(for /dev/ptc) |
62 |
|
|
if test -e /dev/ptc; then |
63 |
|
|
AC_MSG_RESULT(yes) |
64 |
|
|
AC_DEFINE(CLONE_DEVICE, "/dev/ptc", [clone device filename]) |
65 |
|
|
have_clone=yes |
66 |
|
|
else |
67 |
|
|
AC_MSG_RESULT(no) |
68 |
|
|
fi |
69 |
|
|
|
70 |
|
|
case $host in |
71 |
|
|
*-*-cygwin*) |
72 |
|
|
have_clone=yes |
73 |
|
|
AC_DEFINE(CLONE_DEVICE, "/dev/ptmx", [clone device filename]) |
74 |
|
|
;; |
75 |
|
|
*) |
76 |
|
|
AC_MSG_CHECKING(for /dev/ptmx) |
77 |
|
|
if test -e /dev/ptmx; then |
78 |
|
|
AC_MSG_RESULT(yes) |
79 |
|
|
AC_DEFINE(HAVE_DEV_PTMX, 1, [Define to 1 if you have /dev/ptmx]) |
80 |
|
|
AC_DEFINE(CLONE_DEVICE, "/dev/ptmx", [clone device filename]) |
81 |
|
|
have_clone=yes |
82 |
|
|
else |
83 |
|
|
AC_MSG_RESULT(no) |
84 |
|
|
fi |
85 |
|
|
;; |
86 |
|
|
esac |
87 |
|
|
|
88 |
|
|
if test x$ac_cv_func_getpt = xyes -o x$ac_cv_func_posix_openpt = xyes -o x$have_clone = xyes; then |
89 |
|
|
AC_MSG_CHECKING(for UNIX98 ptys) |
90 |
ayin |
1.16 |
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>]], |
91 |
|
|
[[grantpt(0);unlockpt(0);ptsname(0);]])], |
92 |
ayin |
1.1 |
[unix98_pty=yes |
93 |
|
|
AC_DEFINE(UNIX98_PTY, 1, "") |
94 |
|
|
AC_MSG_RESULT(yes)], |
95 |
|
|
[AC_MSG_RESULT(no)]) |
96 |
|
|
fi |
97 |
|
|
|
98 |
|
|
if test -z "$unix98_pty"; then |
99 |
sf-exg |
1.21 |
AC_SEARCH_LIBS(openpty, util, AC_DEFINE(HAVE_OPENPTY, 1, "")) |
100 |
ayin |
1.1 |
fi |
101 |
|
|
]) |
102 |
|
|
|
103 |
|
|
AC_DEFUN([UTMP_CHECK], |
104 |
|
|
[ |
105 |
ayin |
1.5 |
support_utmp=yes |
106 |
|
|
support_wtmp=yes |
107 |
|
|
support_lastlog=yes |
108 |
|
|
|
109 |
ayin |
1.4 |
AC_ARG_ENABLE(utmp, |
110 |
ayin |
1.11 |
[AS_HELP_STRING([--enable-utmp],[enable utmp (utmpx) support])], |
111 |
ayin |
1.4 |
[if test x$enableval = xyes -o x$enableval = xno; then |
112 |
|
|
support_utmp=$enableval |
113 |
|
|
fi]) |
114 |
|
|
|
115 |
|
|
AC_ARG_ENABLE(wtmp, |
116 |
ayin |
1.11 |
[AS_HELP_STRING([--enable-wtmp],[enable wtmp (wtmpx) support (requires --enable-utmp)])], |
117 |
ayin |
1.4 |
[if test x$enableval = xyes -o x$enableval = xno; then |
118 |
|
|
support_wtmp=$enableval |
119 |
|
|
fi]) |
120 |
|
|
|
121 |
|
|
AC_ARG_ENABLE(lastlog, |
122 |
ayin |
1.11 |
[AS_HELP_STRING([--enable-lastlog],[enable lastlog support (requires --enable-utmp)])], |
123 |
ayin |
1.4 |
[if test x$enableval = xyes -o x$enableval = xno; then |
124 |
|
|
support_lastlog=$enableval |
125 |
|
|
fi]) |
126 |
|
|
|
127 |
|
|
if test x$support_utmp = xyes; then |
128 |
|
|
AC_DEFINE(UTMP_SUPPORT, 1, Define if you want to have utmp/utmpx support) |
129 |
|
|
fi |
130 |
|
|
if test x$support_wtmp = xyes; then |
131 |
|
|
AC_DEFINE(WTMP_SUPPORT, 1, Define if you want to have wtmp support when utmp/utmpx is enabled) |
132 |
|
|
fi |
133 |
|
|
if test x$support_lastlog = xyes; then |
134 |
|
|
AC_DEFINE(LASTLOG_SUPPORT, 1, Define if you want to have lastlog support when utmp/utmpx is enabled) |
135 |
|
|
fi |
136 |
|
|
|
137 |
ayin |
1.1 |
AC_CHECK_FUNCS( \ |
138 |
|
|
updwtmp \ |
139 |
|
|
updwtmpx \ |
140 |
ayin |
1.12 |
updlastlogx \ |
141 |
ayin |
1.1 |
) |
142 |
|
|
|
143 |
ayin |
1.15 |
AC_CHECK_HEADERS(lastlog.h) |
144 |
ayin |
1.1 |
|
145 |
|
|
dnl# -------------------------------------------------------------------------- |
146 |
|
|
dnl# DO ALL UTMP AND WTMP CHECKING |
147 |
|
|
dnl# -------------------------------------------------------------------------- |
148 |
|
|
dnl# check for host field in utmp structure |
149 |
|
|
|
150 |
|
|
dnl# -------------------------------------------- |
151 |
ayin |
1.15 |
AC_CHECK_HEADERS(utmp.h, |
152 |
sf-exg |
1.18 |
[AC_CACHE_CHECK([for struct utmp], pt_cv_struct_utmp, |
153 |
ayin |
1.1 |
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> |
154 |
sf-exg |
1.18 |
#include <utmp.h>]], [[struct utmp ut;]])],[pt_cv_struct_utmp=yes],[pt_cv_struct_utmp=no])]) |
155 |
|
|
if test x$pt_cv_struct_utmp = xyes; then |
156 |
ayin |
1.1 |
AC_DEFINE(HAVE_STRUCT_UTMP, 1, Define if utmp.h has struct utmp) |
157 |
|
|
fi |
158 |
|
|
] |
159 |
|
|
|
160 |
sf-exg |
1.18 |
AC_CACHE_CHECK(for ut_host in utmp struct, pt_cv_struct_utmp_host, |
161 |
ayin |
1.1 |
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> |
162 |
sf-exg |
1.18 |
#include <utmp.h>]], [[struct utmp ut; ut.ut_host;]])],[pt_cv_struct_utmp_host=yes],[pt_cv_struct_utmp_host=no])]) |
163 |
|
|
if test x$pt_cv_struct_utmp_host = xyes; then |
164 |
ayin |
1.1 |
AC_DEFINE(HAVE_UTMP_HOST, 1, Define if struct utmp contains ut_host) |
165 |
|
|
fi |
166 |
|
|
|
167 |
sf-exg |
1.18 |
AC_CACHE_CHECK(for ut_pid in utmp struct, pt_cv_struct_utmp_pid, |
168 |
ayin |
1.1 |
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> |
169 |
sf-exg |
1.18 |
#include <utmp.h>]], [[struct utmp ut; ut.ut_pid;]])],[pt_cv_struct_utmp_pid=yes],[pt_cv_struct_utmp_pid=no])]) |
170 |
|
|
if test x$pt_cv_struct_utmp_pid = xyes; then |
171 |
ayin |
1.1 |
AC_DEFINE(HAVE_UTMP_PID, 1, Define if struct utmp contains ut_pid) |
172 |
|
|
fi |
173 |
ayin |
1.15 |
) dnl# AC_CHECK_HEADERS(utmp.h |
174 |
ayin |
1.1 |
|
175 |
|
|
dnl# -------------------------------------------- |
176 |
|
|
|
177 |
ayin |
1.15 |
AC_CHECK_HEADERS(utmpx.h, |
178 |
sf-exg |
1.18 |
[AC_CACHE_CHECK([for struct utmpx], pt_cv_struct_utmpx, |
179 |
ayin |
1.1 |
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> |
180 |
sf-exg |
1.18 |
#include <utmpx.h>]], [[struct utmpx ut;]])],[pt_cv_struct_utmpx=yes],[pt_cv_struct_utmpx=no])]) |
181 |
|
|
if test x$pt_cv_struct_utmpx = xyes; then |
182 |
ayin |
1.1 |
AC_DEFINE(HAVE_STRUCT_UTMPX, 1, Define if utmpx.h has struct utmpx) |
183 |
|
|
fi |
184 |
|
|
] |
185 |
|
|
|
186 |
sf-exg |
1.18 |
AC_CACHE_CHECK(for host in utmpx struct, pt_cv_struct_utmpx_host, |
187 |
ayin |
1.1 |
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> |
188 |
sf-exg |
1.18 |
#include <utmpx.h>]], [[struct utmpx utx; utx.ut_host;]])],[pt_cv_struct_utmpx_host=yes],[pt_cv_struct_utmpx_host=no])]) |
189 |
|
|
if test x$pt_cv_struct_utmpx_host = xyes; then |
190 |
ayin |
1.1 |
AC_DEFINE(HAVE_UTMPX_HOST, 1, Define if struct utmpx contains ut_host) |
191 |
|
|
fi |
192 |
|
|
|
193 |
sf-exg |
1.18 |
AC_CACHE_CHECK(for session in utmpx struct, pt_cv_struct_utmpx_session, |
194 |
ayin |
1.16 |
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> |
195 |
sf-exg |
1.18 |
#include <utmpx.h>]], [[struct utmpx utx; utx.ut_session;]])],[pt_cv_struct_utmpx_session=yes],[pt_cv_struct_utmpx_session=no])]) |
196 |
|
|
if test x$pt_cv_struct_utmpx_session = xyes; then |
197 |
ayin |
1.1 |
AC_DEFINE(HAVE_UTMPX_SESSION, 1, Define if struct utmpx contains ut_session) |
198 |
|
|
fi |
199 |
ayin |
1.15 |
) dnl# AC_CHECK_HEADERS(utmpx.h |
200 |
ayin |
1.1 |
|
201 |
|
|
dnl# -------------------------------------------------------------------------- |
202 |
|
|
dnl# check for struct lastlog |
203 |
sf-exg |
1.18 |
AC_CACHE_CHECK(for struct lastlog, pt_cv_struct_lastlog, |
204 |
ayin |
1.1 |
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> |
205 |
|
|
#include <utmp.h> |
206 |
|
|
#ifdef HAVE_LASTLOG_H |
207 |
|
|
#include <lastlog.h> |
208 |
|
|
#endif |
209 |
sf-exg |
1.18 |
]], [[struct lastlog ll;]])],[pt_cv_struct_lastlog=yes],[pt_cv_struct_lastlog=no])]) |
210 |
|
|
if test x$pt_cv_struct_lastlog = xyes; then |
211 |
ayin |
1.1 |
AC_DEFINE(HAVE_STRUCT_LASTLOG, 1, Define if utmp.h or lastlog.h has struct lastlog) |
212 |
|
|
fi |
213 |
|
|
|
214 |
|
|
dnl# check for struct lastlogx |
215 |
sf-exg |
1.18 |
AC_CACHE_CHECK(for struct lastlogx, pt_cv_struct_lastlogx, |
216 |
ayin |
1.1 |
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> |
217 |
|
|
#include <utmpx.h> |
218 |
|
|
#ifdef HAVE_LASTLOG_H |
219 |
|
|
#include <lastlog.h> |
220 |
|
|
#endif |
221 |
sf-exg |
1.18 |
]], [[struct lastlogx ll;]])],[pt_cv_struct_lastlogx=yes],[pt_cv_struct_lastlogx=no])]) |
222 |
|
|
if test x$pt_cv_struct_lastlogx = xyes; then |
223 |
ayin |
1.1 |
AC_DEFINE(HAVE_STRUCT_LASTLOGX, 1, Define if utmpx.h or lastlog.h has struct lastlogx) |
224 |
|
|
fi |
225 |
|
|
|
226 |
|
|
dnl# -------------------------------------------------------------------------- |
227 |
|
|
dnl# FIND FILES |
228 |
|
|
dnl# -------------------------------------------------------------------------- |
229 |
|
|
|
230 |
|
|
dnl# find utmp |
231 |
sf-exg |
1.24 |
PT_FIND_FILE([utmp], [UTMP_FILE], [_PATH_UTMP], |
232 |
|
|
["/var/run/utmp", "/var/adm/utmp", "/etc/utmp", "/usr/etc/utmp", "/usr/adm/utmp"],[ |
233 |
ayin |
1.1 |
#include <sys/types.h> |
234 |
|
|
#include <utmp.h> |
235 |
sf-exg |
1.24 |
]) |
236 |
ayin |
1.1 |
|
237 |
|
|
dnl# -------------------------------------------------------------------------- |
238 |
|
|
|
239 |
|
|
dnl# find wtmp |
240 |
sf-exg |
1.24 |
PT_FIND_FILE([wtmp], [WTMP_FILE], [_PATH_WTMP], |
241 |
|
|
["/var/log/wtmp", "/var/adm/wtmp", "/etc/wtmp", "/usr/etc/wtmp", "/usr/adm/wtmp"],[ |
242 |
ayin |
1.1 |
#include <sys/types.h> |
243 |
|
|
#ifdef HAVE_UTMP_H |
244 |
|
|
#include <utmp.h> |
245 |
|
|
#endif |
246 |
sf-exg |
1.24 |
]) |
247 |
ayin |
1.1 |
dnl# -------------------------------------------------------------------------- |
248 |
|
|
|
249 |
|
|
dnl# find wtmpx |
250 |
sf-exg |
1.24 |
PT_FIND_FILE([wtmpx], [WTMPX_FILE], [_PATH_WTMPX], |
251 |
|
|
["/var/log/wtmpx", "/var/adm/wtmpx"],[ |
252 |
ayin |
1.1 |
#ifdef HAVE_UTMPX_H |
253 |
|
|
#include <utmpx.h> |
254 |
|
|
#endif |
255 |
sf-exg |
1.24 |
]) |
256 |
ayin |
1.1 |
dnl# -------------------------------------------------------------------------- |
257 |
|
|
|
258 |
|
|
dnl# find lastlog |
259 |
sf-exg |
1.24 |
PT_FIND_FILE([lastlog], [LASTLOG_FILE], [_PATH_LASTLOG], |
260 |
|
|
["/var/log/lastlog"],[ |
261 |
ayin |
1.1 |
#include <sys/types.h> |
262 |
sf-exg |
1.23 |
#ifdef HAVE_UTMP_H |
263 |
ayin |
1.1 |
#include <utmp.h> |
264 |
|
|
#endif |
265 |
|
|
#ifdef HAVE_LASTLOG_H |
266 |
|
|
#include <lastlog.h> |
267 |
|
|
#endif |
268 |
sf-exg |
1.24 |
]) |
269 |
ayin |
1.1 |
dnl# -------------------------------------------------------------------------- |
270 |
|
|
|
271 |
|
|
dnl# find lastlogx |
272 |
sf-exg |
1.24 |
PT_FIND_FILE([lastlogx], [LASTLOGX_FILE], [_PATH_LASTLOGX], |
273 |
|
|
["/var/log/lastlogx", "/var/adm/lastlogx"],[ |
274 |
ayin |
1.1 |
#ifdef HAVE_UTMPX_H |
275 |
|
|
#include <utmpx.h> |
276 |
|
|
#endif |
277 |
sf-exg |
1.24 |
]) |
278 |
ayin |
1.1 |
]) |
279 |
|
|
|
280 |
|
|
AC_DEFUN([SCM_RIGHTS_CHECK], |
281 |
|
|
[ |
282 |
sf-exg |
1.18 |
AC_CACHE_CHECK(for unix-compliant filehandle passing ability, pt_cv_can_pass_fds, |
283 |
ayin |
1.16 |
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[ |
284 |
root |
1.6 |
#include <cstddef> // broken bsds (is that redundant?) need this |
285 |
ayin |
1.1 |
#include <sys/types.h> |
286 |
|
|
#include <sys/socket.h> |
287 |
|
|
#include <sys/uio.h> |
288 |
ayin |
1.16 |
]], [[ |
289 |
ayin |
1.1 |
{ |
290 |
|
|
msghdr msg; |
291 |
|
|
iovec iov; |
292 |
|
|
char buf [100]; |
293 |
|
|
char data = 0; |
294 |
|
|
|
295 |
|
|
iov.iov_base = &data; |
296 |
|
|
iov.iov_len = 1; |
297 |
|
|
|
298 |
|
|
msg.msg_iov = &iov; |
299 |
|
|
msg.msg_iovlen = 1; |
300 |
|
|
msg.msg_control = buf; |
301 |
|
|
msg.msg_controllen = sizeof buf; |
302 |
|
|
|
303 |
|
|
cmsghdr *cmsg = CMSG_FIRSTHDR (&msg); |
304 |
|
|
cmsg->cmsg_level = SOL_SOCKET; |
305 |
|
|
cmsg->cmsg_type = SCM_RIGHTS; |
306 |
|
|
cmsg->cmsg_len = 100; |
307 |
|
|
|
308 |
|
|
*(int *)CMSG_DATA (cmsg) = 5; |
309 |
|
|
|
310 |
|
|
return sendmsg (3, &msg, 0); |
311 |
|
|
} |
312 |
sf-exg |
1.18 |
]])],[pt_cv_can_pass_fds=yes],[pt_cv_can_pass_fds=no])]) |
313 |
|
|
if test x$pt_cv_can_pass_fds = xyes; then |
314 |
ayin |
1.1 |
AC_DEFINE(HAVE_UNIX_FDPASS, 1, Define if sys/socket.h defines the necessary macros/functions for file handle passing) |
315 |
|
|
else |
316 |
|
|
AC_MSG_ERROR([libptytty requires unix-compliant filehandle passing ability]) |
317 |
|
|
fi |
318 |
|
|
]) |
319 |
ayin |
1.3 |
|
320 |
|
|
AC_DEFUN([TTY_GROUP_CHECK], |
321 |
|
|
[ |
322 |
sf-exg |
1.18 |
AC_CACHE_CHECK([for tty group], pt_cv_tty_group, |
323 |
ayin |
1.16 |
[AC_RUN_IFELSE([AC_LANG_SOURCE([[ |
324 |
ayin |
1.3 |
#include <sys/types.h> |
325 |
|
|
#include <sys/stat.h> |
326 |
|
|
#include <unistd.h> |
327 |
|
|
#include <grp.h> |
328 |
|
|
|
329 |
sf-exg |
1.22 |
int main() |
330 |
ayin |
1.3 |
{ |
331 |
|
|
struct stat st; |
332 |
|
|
struct group *gr; |
333 |
|
|
char *tty; |
334 |
|
|
gr = getgrnam("tty"); |
335 |
|
|
tty = ttyname(0); |
336 |
|
|
if (gr != 0 |
337 |
|
|
&& tty != 0 |
338 |
|
|
&& (stat(tty, &st)) == 0 |
339 |
|
|
&& st.st_gid == gr->gr_gid) |
340 |
|
|
return 0; |
341 |
|
|
else |
342 |
|
|
return 1; |
343 |
sf-exg |
1.18 |
}]])],[pt_cv_tty_group=yes],[pt_cv_tty_group=no],[pt_cv_tty_group=no])]) |
344 |
|
|
if test x$pt_cv_tty_group = xyes; then |
345 |
ayin |
1.3 |
AC_DEFINE(TTY_GID_SUPPORT, 1, "") |
346 |
|
|
fi]) |
347 |
|
|
|