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