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 |
case $host in |
101 |
*-*-solaris*) |
102 |
AC_DEFINE(__EXTENSIONS__, 1, Enable declarations in utmp.h on Solaris when the XPG4v2 namespace is active) |
103 |
;; |
104 |
esac |
105 |
|
106 |
dnl# -------------------------------------------------------------------------- |
107 |
dnl# DO ALL UTMP AND WTMP CHECKING |
108 |
dnl# -------------------------------------------------------------------------- |
109 |
dnl# check for host field in utmp structure |
110 |
|
111 |
dnl# -------------------------------------------- |
112 |
AC_CHECK_HEADERS(utmp.h, |
113 |
AC_CHECK_TYPES([struct utmp], [], [], [ |
114 |
#include <sys/types.h> |
115 |
#include <utmp.h> |
116 |
]) |
117 |
|
118 |
AC_CHECK_MEMBER([struct utmp.ut_host], |
119 |
[AC_DEFINE(HAVE_UTMP_HOST, 1, Define if struct utmp contains ut_host)], [], [ |
120 |
#include <sys/types.h> |
121 |
#include <utmp.h> |
122 |
]) |
123 |
|
124 |
AC_CHECK_MEMBER([struct utmp.ut_pid], |
125 |
[AC_DEFINE(HAVE_UTMP_PID, 1, Define if struct utmp contains ut_pid)], [], [ |
126 |
#include <sys/types.h> |
127 |
#include <utmp.h> |
128 |
]) |
129 |
) dnl# AC_CHECK_HEADERS(utmp.h |
130 |
|
131 |
dnl# -------------------------------------------- |
132 |
|
133 |
AC_CHECK_HEADERS(utmpx.h, |
134 |
AC_CHECK_TYPES([struct utmpx], [], [], [ |
135 |
#include <sys/types.h> |
136 |
#include <utmpx.h> |
137 |
]) |
138 |
|
139 |
AC_CHECK_MEMBER([struct utmpx.ut_host], |
140 |
[AC_DEFINE(HAVE_UTMPX_HOST, 1, Define if struct utmpx contains ut_host)], [], [ |
141 |
#include <sys/types.h> |
142 |
#include <utmpx.h> |
143 |
]) |
144 |
) dnl# AC_CHECK_HEADERS(utmpx.h |
145 |
|
146 |
dnl# -------------------------------------------------------------------------- |
147 |
dnl# check for struct lastlog |
148 |
AC_CHECK_TYPES([struct lastlog], [], [], [ |
149 |
#include <sys/types.h> |
150 |
#include <utmp.h> |
151 |
#ifdef HAVE_LASTLOG_H |
152 |
#include <lastlog.h> |
153 |
#endif |
154 |
]) |
155 |
|
156 |
dnl# check for struct lastlogx |
157 |
AC_CHECK_TYPES([struct lastlogx], [], [], [ |
158 |
#include <sys/types.h> |
159 |
#include <utmpx.h> |
160 |
#ifdef HAVE_LASTLOG_H |
161 |
#include <lastlog.h> |
162 |
#endif |
163 |
]) |
164 |
|
165 |
dnl# -------------------------------------------------------------------------- |
166 |
dnl# FIND FILES |
167 |
dnl# -------------------------------------------------------------------------- |
168 |
|
169 |
dnl# find utmp |
170 |
PT_FIND_FILE([utmp], [PT_UTMP_FILE], |
171 |
["/var/run/utmp" "/var/adm/utmp" "/etc/utmp" "/usr/etc/utmp" "/usr/adm/utmp"]) |
172 |
|
173 |
dnl# -------------------------------------------------------------------------- |
174 |
|
175 |
dnl# find wtmp |
176 |
PT_FIND_FILE([wtmp], [PT_WTMP_FILE], |
177 |
["/var/log/wtmp" "/var/adm/wtmp" "/etc/wtmp" "/usr/etc/wtmp" "/usr/adm/wtmp"]) |
178 |
dnl# -------------------------------------------------------------------------- |
179 |
|
180 |
dnl# find wtmpx |
181 |
PT_FIND_FILE([wtmpx], [PT_WTMPX_FILE], |
182 |
["/var/log/wtmpx" "/var/adm/wtmpx"]) |
183 |
dnl# -------------------------------------------------------------------------- |
184 |
|
185 |
dnl# find lastlog |
186 |
PT_FIND_FILE([lastlog], [PT_LASTLOG_FILE], |
187 |
["/var/log/lastlog" "/var/adm/lastlog"]) |
188 |
dnl# -------------------------------------------------------------------------- |
189 |
|
190 |
dnl# find lastlogx |
191 |
PT_FIND_FILE([lastlogx], [PT_LASTLOGX_FILE], |
192 |
["/var/log/lastlogx" "/var/adm/lastlogx"]) |
193 |
]) |
194 |
|
195 |
AC_DEFUN([SCM_RIGHTS_CHECK], |
196 |
[ |
197 |
case $host in |
198 |
*-*-solaris*) |
199 |
AC_DEFINE(_XOPEN_SOURCE, 500, Enable declarations of msg_control and msg_controllen on Solaris) |
200 |
AC_SEARCH_LIBS(sendmsg, socket) |
201 |
;; |
202 |
esac |
203 |
|
204 |
AC_CACHE_CHECK(for unix-compliant filehandle passing ability, pt_cv_can_pass_fds, |
205 |
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[ |
206 |
#include <cstddef> // broken bsds (is that redundant?) need this |
207 |
#include <sys/types.h> |
208 |
#include <sys/socket.h> |
209 |
#include <sys/uio.h> |
210 |
]], [[ |
211 |
{ |
212 |
msghdr msg; |
213 |
iovec iov; |
214 |
char buf [100]; |
215 |
char data = 0; |
216 |
|
217 |
iov.iov_base = &data; |
218 |
iov.iov_len = 1; |
219 |
|
220 |
msg.msg_iov = &iov; |
221 |
msg.msg_iovlen = 1; |
222 |
msg.msg_control = buf; |
223 |
msg.msg_controllen = sizeof buf; |
224 |
|
225 |
cmsghdr *cmsg = CMSG_FIRSTHDR (&msg); |
226 |
cmsg->cmsg_level = SOL_SOCKET; |
227 |
cmsg->cmsg_type = SCM_RIGHTS; |
228 |
cmsg->cmsg_len = 100; |
229 |
|
230 |
*(int *)CMSG_DATA (cmsg) = 5; |
231 |
|
232 |
return sendmsg (3, &msg, 0); |
233 |
} |
234 |
]])],[pt_cv_can_pass_fds=yes],[pt_cv_can_pass_fds=no])]) |
235 |
if test x$pt_cv_can_pass_fds = xyes; then |
236 |
AC_DEFINE(HAVE_UNIX_FDPASS, 1, Define if sys/socket.h defines the necessary macros/functions for file handle passing) |
237 |
else |
238 |
AC_MSG_ERROR([libptytty requires unix-compliant filehandle passing ability]) |
239 |
fi |
240 |
]) |
241 |
|
242 |
AC_DEFUN([TTY_GROUP_CHECK], |
243 |
[ |
244 |
AC_CACHE_CHECK([for tty group], pt_cv_tty_group, |
245 |
[AC_RUN_IFELSE([AC_LANG_SOURCE([[ |
246 |
#include <sys/types.h> |
247 |
#include <sys/stat.h> |
248 |
#include <unistd.h> |
249 |
#include <grp.h> |
250 |
|
251 |
int main() |
252 |
{ |
253 |
struct stat st; |
254 |
struct group *gr; |
255 |
char *tty; |
256 |
gr = getgrnam("tty"); |
257 |
tty = ttyname(0); |
258 |
if (gr != 0 |
259 |
&& tty != 0 |
260 |
&& (stat(tty, &st)) == 0 |
261 |
&& st.st_gid == gr->gr_gid) |
262 |
return 0; |
263 |
else |
264 |
return 1; |
265 |
}]])],[pt_cv_tty_group=yes],[pt_cv_tty_group=no],[pt_cv_tty_group=no])]) |
266 |
if test x$pt_cv_tty_group = xyes; then |
267 |
AC_DEFINE(TTY_GID_SUPPORT, 1, "") |
268 |
fi]) |
269 |
|