ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libptytty/ptytty.m4
Revision: 1.31
Committed: Sat Nov 26 13:39:03 2011 UTC (12 years, 6 months ago) by sf-exg
Branch: MAIN
CVS Tags: rel-9_14
Changes since 1.30: +21 -45 lines
Log Message:
Change PT_FIND_FILE to search only for fallback locations of
utmp/wtmp/lastlog files and define the *_FILE macros at compile time.

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