1 |
dnl this file is part of libptytty, do not make local modifications |
2 |
dnl http://software.schmorp.de/pkg/libptytty |
3 |
|
4 |
AC_DEFUN([PT_FIND_FILE], |
5 |
[AC_CACHE_CHECK(for a fallback location of $1, pt_cv_path_$1, [ |
6 |
if test "$cross_compiling" != yes; then |
7 |
for file in $3; do |
8 |
if test -f "$file"; then |
9 |
pt_cv_path_$1=$file |
10 |
break |
11 |
fi |
12 |
done |
13 |
fi]) |
14 |
if test x$pt_cv_path_$1 != x; then |
15 |
AC_DEFINE_UNQUOTED($2, "$pt_cv_path_$1", Define to a fallback location of $1) |
16 |
elif test "$cross_compiling" = yes; then |
17 |
AC_MSG_WARN(Define $2 in config.h manually) |
18 |
fi]) |
19 |
|
20 |
AC_DEFUN([PTY_CHECK], |
21 |
[ |
22 |
AC_CHECK_HEADERS( \ |
23 |
pty.h \ |
24 |
util.h \ |
25 |
libutil.h \ |
26 |
sys/ioctl.h \ |
27 |
sys/stropts.h \ |
28 |
stropts.h \ |
29 |
) |
30 |
|
31 |
AC_CHECK_FUNCS( \ |
32 |
revoke \ |
33 |
_getpty \ |
34 |
getpt \ |
35 |
posix_openpt \ |
36 |
isastream \ |
37 |
setuid \ |
38 |
seteuid \ |
39 |
setreuid \ |
40 |
setresuid \ |
41 |
) |
42 |
|
43 |
AC_MSG_CHECKING(for UNIX98 ptys) |
44 |
AC_LINK_IFELSE( |
45 |
[AC_LANG_PROGRAM( |
46 |
[[#include <stdlib.h>]], |
47 |
[[grantpt(0);unlockpt(0);ptsname(0);]])], |
48 |
[unix98_pty=yes |
49 |
AC_DEFINE(UNIX98_PTY, 1, "") |
50 |
AC_MSG_RESULT(yes)], |
51 |
[AC_MSG_RESULT(no)]) |
52 |
|
53 |
if test -z "$unix98_pty"; then |
54 |
AC_SEARCH_LIBS(openpty, util, AC_DEFINE(HAVE_OPENPTY, 1, "")) |
55 |
fi |
56 |
]) |
57 |
|
58 |
AC_DEFUN([UTMP_CHECK], |
59 |
[ |
60 |
support_utmp=yes |
61 |
support_wtmp=yes |
62 |
support_lastlog=yes |
63 |
|
64 |
AC_ARG_ENABLE(utmp, |
65 |
[AS_HELP_STRING([--enable-utmp],[enable utmp (utmpx) support])], |
66 |
[if test x$enableval = xyes -o x$enableval = xno; then |
67 |
support_utmp=$enableval |
68 |
fi]) |
69 |
|
70 |
AC_ARG_ENABLE(wtmp, |
71 |
[AS_HELP_STRING([--enable-wtmp],[enable wtmp (wtmpx) support (requires --enable-utmp)])], |
72 |
[if test x$enableval = xyes -o x$enableval = xno; then |
73 |
support_wtmp=$enableval |
74 |
fi]) |
75 |
|
76 |
AC_ARG_ENABLE(lastlog, |
77 |
[AS_HELP_STRING([--enable-lastlog],[enable lastlog support (requires --enable-utmp)])], |
78 |
[if test x$enableval = xyes -o x$enableval = xno; then |
79 |
support_lastlog=$enableval |
80 |
fi]) |
81 |
|
82 |
if test x$support_utmp = xyes; then |
83 |
AC_DEFINE(UTMP_SUPPORT, 1, Define if you want to have utmp/utmpx support) |
84 |
fi |
85 |
if test x$support_wtmp = xyes; then |
86 |
AC_DEFINE(WTMP_SUPPORT, 1, Define if you want to have wtmp support when utmp/utmpx is enabled) |
87 |
fi |
88 |
if test x$support_lastlog = xyes; then |
89 |
AC_DEFINE(LASTLOG_SUPPORT, 1, Define if you want to have lastlog support when utmp/utmpx is enabled) |
90 |
fi |
91 |
|
92 |
AC_CHECK_FUNCS( \ |
93 |
updwtmp \ |
94 |
updwtmpx \ |
95 |
updlastlogx \ |
96 |
) |
97 |
|
98 |
AC_CHECK_HEADERS(lastlog.h) |
99 |
|
100 |
dnl# -------------------------------------------------------------------------- |
101 |
dnl# DO ALL UTMP AND WTMP CHECKING |
102 |
dnl# -------------------------------------------------------------------------- |
103 |
dnl# check for host field in utmp structure |
104 |
|
105 |
dnl# -------------------------------------------- |
106 |
AC_CHECK_HEADERS(utmp.h, |
107 |
AC_CHECK_TYPES([struct utmp], [], [], [ |
108 |
#include <sys/types.h> |
109 |
#include <utmp.h> |
110 |
]) |
111 |
|
112 |
AC_CHECK_MEMBER([struct utmp.ut_host], |
113 |
[AC_DEFINE(HAVE_UTMP_HOST, 1, Define if struct utmp contains ut_host)], [], [ |
114 |
#include <sys/types.h> |
115 |
#include <utmp.h> |
116 |
]) |
117 |
|
118 |
AC_CHECK_MEMBER([struct utmp.ut_pid], |
119 |
[AC_DEFINE(HAVE_UTMP_PID, 1, Define if struct utmp contains ut_pid)], [], [ |
120 |
#include <sys/types.h> |
121 |
#include <utmp.h> |
122 |
]) |
123 |
) dnl# AC_CHECK_HEADERS(utmp.h |
124 |
|
125 |
dnl# -------------------------------------------- |
126 |
|
127 |
AC_CHECK_HEADERS(utmpx.h, |
128 |
AC_CHECK_TYPES([struct utmpx], [], [], [ |
129 |
#include <sys/types.h> |
130 |
#include <utmpx.h> |
131 |
]) |
132 |
|
133 |
AC_CHECK_MEMBER([struct utmpx.ut_host], |
134 |
[AC_DEFINE(HAVE_UTMPX_HOST, 1, Define if struct utmpx contains ut_host)], [], [ |
135 |
#include <sys/types.h> |
136 |
#include <utmpx.h> |
137 |
]) |
138 |
) dnl# AC_CHECK_HEADERS(utmpx.h |
139 |
|
140 |
dnl# -------------------------------------------------------------------------- |
141 |
dnl# check for struct lastlog |
142 |
AC_CHECK_TYPES([struct lastlog], [], [], [ |
143 |
#include <sys/types.h> |
144 |
#include <utmp.h> |
145 |
#ifdef HAVE_LASTLOG_H |
146 |
#include <lastlog.h> |
147 |
#endif |
148 |
]) |
149 |
|
150 |
dnl# check for struct lastlogx |
151 |
AC_CHECK_TYPES([struct lastlogx], [], [], [ |
152 |
#include <sys/types.h> |
153 |
#include <utmpx.h> |
154 |
#ifdef HAVE_LASTLOG_H |
155 |
#include <lastlog.h> |
156 |
#endif |
157 |
]) |
158 |
|
159 |
dnl# -------------------------------------------------------------------------- |
160 |
dnl# FIND FILES |
161 |
dnl# -------------------------------------------------------------------------- |
162 |
|
163 |
dnl# find utmp |
164 |
PT_FIND_FILE([utmp], [PT_UTMP_FILE], |
165 |
["/var/run/utmp" "/var/adm/utmp" "/etc/utmp" "/usr/etc/utmp" "/usr/adm/utmp"]) |
166 |
|
167 |
dnl# -------------------------------------------------------------------------- |
168 |
|
169 |
dnl# find wtmp |
170 |
PT_FIND_FILE([wtmp], [PT_WTMP_FILE], |
171 |
["/var/log/wtmp" "/var/adm/wtmp" "/etc/wtmp" "/usr/etc/wtmp" "/usr/adm/wtmp"]) |
172 |
dnl# -------------------------------------------------------------------------- |
173 |
|
174 |
dnl# find wtmpx |
175 |
PT_FIND_FILE([wtmpx], [PT_WTMPX_FILE], |
176 |
["/var/log/wtmpx" "/var/adm/wtmpx"]) |
177 |
dnl# -------------------------------------------------------------------------- |
178 |
|
179 |
dnl# find lastlog |
180 |
PT_FIND_FILE([lastlog], [PT_LASTLOG_FILE], |
181 |
["/var/log/lastlog"]) |
182 |
dnl# -------------------------------------------------------------------------- |
183 |
|
184 |
dnl# find lastlogx |
185 |
PT_FIND_FILE([lastlogx], [PT_LASTLOGX_FILE], |
186 |
["/var/log/lastlogx" "/var/adm/lastlogx"]) |
187 |
]) |
188 |
|
189 |
AC_DEFUN([SCM_RIGHTS_CHECK], |
190 |
[ |
191 |
AC_CACHE_CHECK(for unix-compliant filehandle passing ability, pt_cv_can_pass_fds, |
192 |
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[ |
193 |
#include <cstddef> // broken bsds (is that redundant?) need this |
194 |
#include <sys/types.h> |
195 |
#include <sys/socket.h> |
196 |
#include <sys/uio.h> |
197 |
]], [[ |
198 |
{ |
199 |
msghdr msg; |
200 |
iovec iov; |
201 |
char buf [100]; |
202 |
char data = 0; |
203 |
|
204 |
iov.iov_base = &data; |
205 |
iov.iov_len = 1; |
206 |
|
207 |
msg.msg_iov = &iov; |
208 |
msg.msg_iovlen = 1; |
209 |
msg.msg_control = buf; |
210 |
msg.msg_controllen = sizeof buf; |
211 |
|
212 |
cmsghdr *cmsg = CMSG_FIRSTHDR (&msg); |
213 |
cmsg->cmsg_level = SOL_SOCKET; |
214 |
cmsg->cmsg_type = SCM_RIGHTS; |
215 |
cmsg->cmsg_len = 100; |
216 |
|
217 |
*(int *)CMSG_DATA (cmsg) = 5; |
218 |
|
219 |
return sendmsg (3, &msg, 0); |
220 |
} |
221 |
]])],[pt_cv_can_pass_fds=yes],[pt_cv_can_pass_fds=no])]) |
222 |
if test x$pt_cv_can_pass_fds = xyes; then |
223 |
AC_DEFINE(HAVE_UNIX_FDPASS, 1, Define if sys/socket.h defines the necessary macros/functions for file handle passing) |
224 |
else |
225 |
AC_MSG_ERROR([libptytty requires unix-compliant filehandle passing ability]) |
226 |
fi |
227 |
]) |
228 |
|
229 |
AC_DEFUN([TTY_GROUP_CHECK], |
230 |
[ |
231 |
AC_CACHE_CHECK([for tty group], pt_cv_tty_group, |
232 |
[AC_RUN_IFELSE([AC_LANG_SOURCE([[ |
233 |
#include <sys/types.h> |
234 |
#include <sys/stat.h> |
235 |
#include <unistd.h> |
236 |
#include <grp.h> |
237 |
|
238 |
int main() |
239 |
{ |
240 |
struct stat st; |
241 |
struct group *gr; |
242 |
char *tty; |
243 |
gr = getgrnam("tty"); |
244 |
tty = ttyname(0); |
245 |
if (gr != 0 |
246 |
&& tty != 0 |
247 |
&& (stat(tty, &st)) == 0 |
248 |
&& st.st_gid == gr->gr_gid) |
249 |
return 0; |
250 |
else |
251 |
return 1; |
252 |
}]])],[pt_cv_tty_group=yes],[pt_cv_tty_group=no],[pt_cv_tty_group=no])]) |
253 |
if test x$pt_cv_tty_group = xyes; then |
254 |
AC_DEFINE(TTY_GID_SUPPORT, 1, "") |
255 |
fi]) |
256 |
|