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