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