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