ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libptytty/ptytty.m4
Revision: 1.32
Committed: Thu Dec 22 10:16:49 2011 UTC (12 years, 5 months ago) by sf-exg
Branch: MAIN
CVS Tags: rel-1_5
Changes since 1.31: +0 -6 lines
Log Message:
Remove support for utmpx ut_session extension, it serves no purpose.

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.15 ) dnl# AC_CHECK_HEADERS(utmpx.h
139 ayin 1.1
140     dnl# --------------------------------------------------------------------------
141     dnl# check for struct lastlog
142 sf-exg 1.26 AC_CHECK_TYPES([struct lastlog], [], [], [
143     #include <sys/types.h>
144 ayin 1.1 #include <utmp.h>
145     #ifdef HAVE_LASTLOG_H
146     #include <lastlog.h>
147     #endif
148 sf-exg 1.26 ])
149 ayin 1.1
150     dnl# check for struct lastlogx
151 sf-exg 1.26 AC_CHECK_TYPES([struct lastlogx], [], [], [
152     #include <sys/types.h>
153 ayin 1.1 #include <utmpx.h>
154     #ifdef HAVE_LASTLOG_H
155     #include <lastlog.h>
156     #endif
157 sf-exg 1.26 ])
158 ayin 1.1
159     dnl# --------------------------------------------------------------------------
160     dnl# FIND FILES
161     dnl# --------------------------------------------------------------------------
162    
163     dnl# find utmp
164 sf-exg 1.31 PT_FIND_FILE([utmp], [PT_UTMP_FILE],
165     ["/var/run/utmp" "/var/adm/utmp" "/etc/utmp" "/usr/etc/utmp" "/usr/adm/utmp"])
166 ayin 1.1
167     dnl# --------------------------------------------------------------------------
168    
169     dnl# find wtmp
170 sf-exg 1.31 PT_FIND_FILE([wtmp], [PT_WTMP_FILE],
171     ["/var/log/wtmp" "/var/adm/wtmp" "/etc/wtmp" "/usr/etc/wtmp" "/usr/adm/wtmp"])
172 ayin 1.1 dnl# --------------------------------------------------------------------------
173    
174     dnl# find wtmpx
175 sf-exg 1.31 PT_FIND_FILE([wtmpx], [PT_WTMPX_FILE],
176     ["/var/log/wtmpx" "/var/adm/wtmpx"])
177 ayin 1.1 dnl# --------------------------------------------------------------------------
178    
179     dnl# find lastlog
180 sf-exg 1.31 PT_FIND_FILE([lastlog], [PT_LASTLOG_FILE],
181 sf-exg 1.30 ["/var/log/lastlog"])
182 ayin 1.1 dnl# --------------------------------------------------------------------------
183    
184     dnl# find lastlogx
185 sf-exg 1.31 PT_FIND_FILE([lastlogx], [PT_LASTLOGX_FILE],
186     ["/var/log/lastlogx" "/var/adm/lastlogx"])
187 ayin 1.1 ])
188    
189     AC_DEFUN([SCM_RIGHTS_CHECK],
190     [
191 sf-exg 1.18 AC_CACHE_CHECK(for unix-compliant filehandle passing ability, pt_cv_can_pass_fds,
192 ayin 1.16 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
193 root 1.6 #include <cstddef> // broken bsds (is that redundant?) need this
194 ayin 1.1 #include <sys/types.h>
195     #include <sys/socket.h>
196     #include <sys/uio.h>
197 ayin 1.16 ]], [[
198 ayin 1.1 {
199     msghdr msg;
200     iovec iov;
201     char buf [100];
202     char data = 0;
203    
204     iov.iov_base = &data;
205     iov.iov_len = 1;
206    
207     msg.msg_iov = &iov;
208     msg.msg_iovlen = 1;
209     msg.msg_control = buf;
210     msg.msg_controllen = sizeof buf;
211    
212     cmsghdr *cmsg = CMSG_FIRSTHDR (&msg);
213     cmsg->cmsg_level = SOL_SOCKET;
214     cmsg->cmsg_type = SCM_RIGHTS;
215     cmsg->cmsg_len = 100;
216    
217     *(int *)CMSG_DATA (cmsg) = 5;
218    
219     return sendmsg (3, &msg, 0);
220     }
221 sf-exg 1.18 ]])],[pt_cv_can_pass_fds=yes],[pt_cv_can_pass_fds=no])])
222     if test x$pt_cv_can_pass_fds = xyes; then
223 ayin 1.1 AC_DEFINE(HAVE_UNIX_FDPASS, 1, Define if sys/socket.h defines the necessary macros/functions for file handle passing)
224     else
225     AC_MSG_ERROR([libptytty requires unix-compliant filehandle passing ability])
226     fi
227     ])
228 ayin 1.3
229     AC_DEFUN([TTY_GROUP_CHECK],
230     [
231 sf-exg 1.18 AC_CACHE_CHECK([for tty group], pt_cv_tty_group,
232 ayin 1.16 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
233 ayin 1.3 #include <sys/types.h>
234     #include <sys/stat.h>
235     #include <unistd.h>
236     #include <grp.h>
237    
238 sf-exg 1.22 int main()
239 ayin 1.3 {
240     struct stat st;
241     struct group *gr;
242     char *tty;
243     gr = getgrnam("tty");
244     tty = ttyname(0);
245     if (gr != 0
246     && tty != 0
247     && (stat(tty, &st)) == 0
248     && st.st_gid == gr->gr_gid)
249     return 0;
250     else
251     return 1;
252 sf-exg 1.18 }]])],[pt_cv_tty_group=yes],[pt_cv_tty_group=no],[pt_cv_tty_group=no])])
253     if test x$pt_cv_tty_group = xyes; then
254 ayin 1.3 AC_DEFINE(TTY_GID_SUPPORT, 1, "")
255     fi])
256