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

# User Rev Content
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 sf-exg 1.29 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 ayin 1.1
68     if test -z "$unix98_pty"; then
69 sf-exg 1.21 AC_SEARCH_LIBS(openpty, util, AC_DEFINE(HAVE_OPENPTY, 1, ""))
70 ayin 1.1 fi
71     ])
72    
73     AC_DEFUN([UTMP_CHECK],
74     [
75 ayin 1.5 support_utmp=yes
76     support_wtmp=yes
77     support_lastlog=yes
78    
79 ayin 1.4 AC_ARG_ENABLE(utmp,
80 ayin 1.11 [AS_HELP_STRING([--enable-utmp],[enable utmp (utmpx) support])],
81 ayin 1.4 [if test x$enableval = xyes -o x$enableval = xno; then
82     support_utmp=$enableval
83     fi])
84    
85     AC_ARG_ENABLE(wtmp,
86 ayin 1.11 [AS_HELP_STRING([--enable-wtmp],[enable wtmp (wtmpx) support (requires --enable-utmp)])],
87 ayin 1.4 [if test x$enableval = xyes -o x$enableval = xno; then
88     support_wtmp=$enableval
89     fi])
90    
91     AC_ARG_ENABLE(lastlog,
92 ayin 1.11 [AS_HELP_STRING([--enable-lastlog],[enable lastlog support (requires --enable-utmp)])],
93 ayin 1.4 [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 ayin 1.1 AC_CHECK_FUNCS( \
108     updwtmp \
109     updwtmpx \
110 ayin 1.12 updlastlogx \
111 ayin 1.1 )
112    
113 ayin 1.15 AC_CHECK_HEADERS(lastlog.h)
114 ayin 1.1
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 ayin 1.15 AC_CHECK_HEADERS(utmp.h,
122 sf-exg 1.26 AC_CHECK_TYPES([struct utmp], [], [], [
123     #include <sys/types.h>
124     #include <utmp.h>
125     ])
126 ayin 1.1
127 sf-exg 1.26 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 ayin 1.1
133 sf-exg 1.26 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 ayin 1.15 ) dnl# AC_CHECK_HEADERS(utmp.h
139 ayin 1.1
140     dnl# --------------------------------------------
141    
142 ayin 1.15 AC_CHECK_HEADERS(utmpx.h,
143 sf-exg 1.26 AC_CHECK_TYPES([struct utmpx], [], [], [
144     #include <sys/types.h>
145     #include <utmpx.h>
146     ])
147 ayin 1.1
148 sf-exg 1.26 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 ayin 1.1
154 sf-exg 1.26 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 ayin 1.15 ) dnl# AC_CHECK_HEADERS(utmpx.h
160 ayin 1.1
161     dnl# --------------------------------------------------------------------------
162     dnl# check for struct lastlog
163 sf-exg 1.26 AC_CHECK_TYPES([struct lastlog], [], [], [
164     #include <sys/types.h>
165 ayin 1.1 #include <utmp.h>
166     #ifdef HAVE_LASTLOG_H
167     #include <lastlog.h>
168     #endif
169 sf-exg 1.26 ])
170 ayin 1.1
171     dnl# check for struct lastlogx
172 sf-exg 1.26 AC_CHECK_TYPES([struct lastlogx], [], [], [
173     #include <sys/types.h>
174 ayin 1.1 #include <utmpx.h>
175     #ifdef HAVE_LASTLOG_H
176     #include <lastlog.h>
177     #endif
178 sf-exg 1.26 ])
179 ayin 1.1
180     dnl# --------------------------------------------------------------------------
181     dnl# FIND FILES
182     dnl# --------------------------------------------------------------------------
183    
184     dnl# find utmp
185 sf-exg 1.24 PT_FIND_FILE([utmp], [UTMP_FILE], [_PATH_UTMP],
186     ["/var/run/utmp", "/var/adm/utmp", "/etc/utmp", "/usr/etc/utmp", "/usr/adm/utmp"],[
187 ayin 1.1 #include <sys/types.h>
188     #include <utmp.h>
189 sf-exg 1.24 ])
190 ayin 1.1
191     dnl# --------------------------------------------------------------------------
192    
193     dnl# find wtmp
194 sf-exg 1.24 PT_FIND_FILE([wtmp], [WTMP_FILE], [_PATH_WTMP],
195     ["/var/log/wtmp", "/var/adm/wtmp", "/etc/wtmp", "/usr/etc/wtmp", "/usr/adm/wtmp"],[
196 ayin 1.1 #include <sys/types.h>
197     #ifdef HAVE_UTMP_H
198     #include <utmp.h>
199     #endif
200 sf-exg 1.24 ])
201 ayin 1.1 dnl# --------------------------------------------------------------------------
202    
203     dnl# find wtmpx
204 sf-exg 1.24 PT_FIND_FILE([wtmpx], [WTMPX_FILE], [_PATH_WTMPX],
205     ["/var/log/wtmpx", "/var/adm/wtmpx"],[
206 ayin 1.1 #ifdef HAVE_UTMPX_H
207     #include <utmpx.h>
208     #endif
209 sf-exg 1.24 ])
210 ayin 1.1 dnl# --------------------------------------------------------------------------
211    
212     dnl# find lastlog
213 sf-exg 1.24 PT_FIND_FILE([lastlog], [LASTLOG_FILE], [_PATH_LASTLOG],
214     ["/var/log/lastlog"],[
215 ayin 1.1 #include <sys/types.h>
216 sf-exg 1.23 #ifdef HAVE_UTMP_H
217 ayin 1.1 #include <utmp.h>
218     #endif
219     #ifdef HAVE_LASTLOG_H
220     #include <lastlog.h>
221     #endif
222 sf-exg 1.24 ])
223 ayin 1.1 dnl# --------------------------------------------------------------------------
224    
225     dnl# find lastlogx
226 sf-exg 1.24 PT_FIND_FILE([lastlogx], [LASTLOGX_FILE], [_PATH_LASTLOGX],
227     ["/var/log/lastlogx", "/var/adm/lastlogx"],[
228 ayin 1.1 #ifdef HAVE_UTMPX_H
229     #include <utmpx.h>
230     #endif
231 sf-exg 1.24 ])
232 ayin 1.1 ])
233    
234     AC_DEFUN([SCM_RIGHTS_CHECK],
235     [
236 sf-exg 1.18 AC_CACHE_CHECK(for unix-compliant filehandle passing ability, pt_cv_can_pass_fds,
237 ayin 1.16 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
238 root 1.6 #include <cstddef> // broken bsds (is that redundant?) need this
239 ayin 1.1 #include <sys/types.h>
240     #include <sys/socket.h>
241     #include <sys/uio.h>
242 ayin 1.16 ]], [[
243 ayin 1.1 {
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 sf-exg 1.18 ]])],[pt_cv_can_pass_fds=yes],[pt_cv_can_pass_fds=no])])
267     if test x$pt_cv_can_pass_fds = xyes; then
268 ayin 1.1 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 ayin 1.3
274     AC_DEFUN([TTY_GROUP_CHECK],
275     [
276 sf-exg 1.18 AC_CACHE_CHECK([for tty group], pt_cv_tty_group,
277 ayin 1.16 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
278 ayin 1.3 #include <sys/types.h>
279     #include <sys/stat.h>
280     #include <unistd.h>
281     #include <grp.h>
282    
283 sf-exg 1.22 int main()
284 ayin 1.3 {
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 sf-exg 1.18 }]])],[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 ayin 1.3 AC_DEFINE(TTY_GID_SUPPORT, 1, "")
300     fi])
301