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