ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libptytty/ptytty.m4
Revision: 1.29
Committed: Sun Nov 20 14:38:44 2011 UTC (12 years, 6 months ago) by sf-exg
Branch: MAIN
Changes since 1.28: +9 -7 lines
Log Message:
Fix style.

File Contents

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