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], |
1 | AC_DEFUN([PT_FIND_FILE], |
5 | [AC_CACHE_CHECK(where $1 is located, pt_cv_path_$1, |
2 | [AC_CACHE_CHECK(for a fallback location of $1, pt_cv_path_$1, [ |
6 | [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h> |
3 | if test "$cross_compiling" != yes; then |
7 | #include <stdlib.h> |
4 | for file in $3; do |
8 | #include <sys/stat.h> |
5 | if test -f "$file"; then |
9 | #include <sys/types.h> |
6 | pt_cv_path_$1=$file |
10 | #ifdef HAVE_UTMPX_H |
|
|
11 | #include <utmpx.h> |
|
|
12 | #endif |
|
|
13 | #ifdef HAVE_UTMP_H |
|
|
14 | #include <utmp.h> |
|
|
15 | #endif |
|
|
16 | #ifdef HAVE_LASTLOG_H |
|
|
17 | #include <lastlog.h> |
|
|
18 | #endif |
|
|
19 | int main() |
|
|
20 | { |
|
|
21 | const char **path, *list[] = { $4, NULL }; |
|
|
22 | FILE *f = fopen("conftestval", "w"); |
|
|
23 | if (!f) return 1; |
|
|
24 | #ifdef $2 |
|
|
25 | fprintf(f, "%s\n", $2); |
|
|
26 | #elif defined($3) |
|
|
27 | fprintf(f, "%s\n", $3); |
|
|
28 | #else |
|
|
29 | for (path = list; *path; path++) { |
|
|
30 | struct stat st; |
|
|
31 | if (stat(*path, &st) == 0) { |
|
|
32 | fprintf(f, "%s\n", *path); |
|
|
33 | break; |
7 | break |
34 | } |
8 | fi |
35 | } |
9 | done |
36 | #endif |
10 | fi]) |
37 | return fclose(f) != 0; |
|
|
38 | }]])],[pt_cv_path_$1=`cat conftestval`],[pt_cv_path_$1=], |
|
|
39 | [AC_MSG_WARN(Define $2 in config.h manually)])]) |
|
|
40 | if test x$pt_cv_path_$1 != x; then |
11 | if test x$pt_cv_path_$1 != x; then |
41 | AC_DEFINE_UNQUOTED($2, "$pt_cv_path_$1", Define location of $1) |
12 | AC_DEFINE_UNQUOTED($2, "$pt_cv_path_$1", Define to a fallback location of $1) |
|
|
13 | elif test "$cross_compiling" = yes; then |
|
|
14 | AC_MSG_WARN(Define $2 in config.h manually) |
42 | fi]) |
15 | fi]) |
43 | |
16 | |
44 | AC_DEFUN([PTY_CHECK], |
17 | AC_DEFUN([PTY_CHECK], |
45 | [ |
18 | [ |
46 | AC_CHECK_HEADERS( \ |
19 | AC_CHECK_HEADERS( \ |
47 | pty.h \ |
20 | pty.h \ |
48 | util.h \ |
21 | util.h \ |
49 | libutil.h \ |
22 | libutil.h \ |
50 | sys/ioctl.h \ |
23 | sys/ioctl.h \ |
51 | sys/stropts.h \ |
|
|
52 | stropts.h \ |
24 | stropts.h \ |
53 | ) |
25 | ) |
54 | |
26 | |
55 | AC_CHECK_FUNCS( \ |
27 | AC_CHECK_FUNCS( \ |
56 | revoke \ |
28 | revoke \ |
57 | _getpty \ |
29 | _getpty \ |
58 | getpt \ |
30 | getpt \ |
59 | posix_openpt \ |
31 | posix_openpt \ |
60 | isastream \ |
32 | isastream \ |
61 | setuid \ |
33 | setuid \ |
62 | seteuid \ |
|
|
63 | setreuid \ |
34 | setreuid \ |
64 | setresuid \ |
35 | setresuid \ |
65 | ) |
36 | ) |
66 | |
37 | |
67 | AC_MSG_CHECKING(for UNIX98 ptys) |
38 | AC_MSG_CHECKING(for UNIX98 ptys) |
… | |
… | |
111 | fi |
82 | fi |
112 | if test x$support_lastlog = xyes; then |
83 | if test x$support_lastlog = xyes; then |
113 | AC_DEFINE(LASTLOG_SUPPORT, 1, Define if you want to have lastlog support when utmp/utmpx is enabled) |
84 | AC_DEFINE(LASTLOG_SUPPORT, 1, Define if you want to have lastlog support when utmp/utmpx is enabled) |
114 | fi |
85 | fi |
115 | |
86 | |
116 | AC_CHECK_FUNCS( \ |
87 | case $host in |
117 | updwtmp \ |
88 | *-*-solaris*) |
118 | updwtmpx \ |
89 | AC_DEFINE(__EXTENSIONS__, 1, Enable declarations in utmp.h on Solaris when the XPG4v2 namespace is active) |
119 | updlastlogx \ |
90 | ;; |
120 | ) |
91 | esac |
121 | |
92 | |
122 | AC_CHECK_HEADERS(lastlog.h) |
|
|
123 | |
|
|
124 | dnl# -------------------------------------------------------------------------- |
|
|
125 | dnl# DO ALL UTMP AND WTMP CHECKING |
|
|
126 | dnl# -------------------------------------------------------------------------- |
|
|
127 | dnl# check for host field in utmp structure |
|
|
128 | |
|
|
129 | dnl# -------------------------------------------- |
|
|
130 | AC_CHECK_HEADERS(utmp.h, |
93 | AC_CHECK_HEADERS(utmp.h, [ |
131 | AC_CHECK_TYPES([struct utmp], [], [], [ |
94 | AC_CHECK_TYPES([struct utmp], [], [], [ |
132 | #include <sys/types.h> |
95 | #include <sys/types.h> |
133 | #include <utmp.h> |
96 | #include <utmp.h> |
134 | ]) |
97 | ]) |
135 | |
98 | |
… | |
… | |
142 | AC_CHECK_MEMBER([struct utmp.ut_pid], |
105 | AC_CHECK_MEMBER([struct utmp.ut_pid], |
143 | [AC_DEFINE(HAVE_UTMP_PID, 1, Define if struct utmp contains ut_pid)], [], [ |
106 | [AC_DEFINE(HAVE_UTMP_PID, 1, Define if struct utmp contains ut_pid)], [], [ |
144 | #include <sys/types.h> |
107 | #include <sys/types.h> |
145 | #include <utmp.h> |
108 | #include <utmp.h> |
146 | ]) |
109 | ]) |
147 | ) dnl# AC_CHECK_HEADERS(utmp.h |
|
|
148 | |
110 | |
149 | dnl# -------------------------------------------- |
111 | AC_CHECK_FUNCS([updwtmp]) |
150 | |
112 | |
151 | AC_CHECK_HEADERS(utmpx.h, |
113 | AC_CHECK_HEADERS([lastlog.h]) |
152 | AC_CHECK_TYPES([struct utmpx], [], [], [ |
|
|
153 | #include <sys/types.h> |
|
|
154 | #include <utmpx.h> |
|
|
155 | ]) |
|
|
156 | |
114 | |
157 | AC_CHECK_MEMBER([struct utmpx.ut_host], |
|
|
158 | [AC_DEFINE(HAVE_UTMPX_HOST, 1, Define if struct utmpx contains ut_host)], [], [ |
|
|
159 | #include <sys/types.h> |
|
|
160 | #include <utmpx.h> |
|
|
161 | ]) |
|
|
162 | |
|
|
163 | AC_CHECK_MEMBER([struct utmpx.ut_session], |
|
|
164 | [AC_DEFINE(HAVE_UTMPX_SESSION, 1, Define if struct utmpx contains ut_session)], [], [ |
|
|
165 | #include <sys/types.h> |
|
|
166 | #include <utmpx.h> |
|
|
167 | ]) |
|
|
168 | ) dnl# AC_CHECK_HEADERS(utmpx.h |
|
|
169 | |
|
|
170 | dnl# -------------------------------------------------------------------------- |
|
|
171 | dnl# check for struct lastlog |
|
|
172 | AC_CHECK_TYPES([struct lastlog], [], [], [ |
115 | AC_CHECK_TYPES([struct lastlog], [], [], [ |
173 | #include <sys/types.h> |
116 | #include <sys/types.h> |
174 | #include <utmp.h> |
117 | #include <utmp.h> |
175 | #ifdef HAVE_LASTLOG_H |
118 | #ifdef HAVE_LASTLOG_H |
176 | #include <lastlog.h> |
119 | #include <lastlog.h> |
177 | #endif |
120 | #endif |
178 | ]) |
121 | ]) |
179 | |
122 | |
180 | dnl# check for struct lastlogx |
123 | PT_FIND_FILE([utmp], [PT_UTMP_FILE], |
|
|
124 | ["/var/run/utmp" "/var/adm/utmp" "/etc/utmp" "/usr/etc/utmp" "/usr/adm/utmp"]) |
|
|
125 | |
|
|
126 | PT_FIND_FILE([wtmp], [PT_WTMP_FILE], |
|
|
127 | ["/var/log/wtmp" "/var/adm/wtmp" "/etc/wtmp" "/usr/etc/wtmp" "/usr/adm/wtmp"]) |
|
|
128 | |
|
|
129 | PT_FIND_FILE([lastlog], [PT_LASTLOG_FILE], |
|
|
130 | ["/var/log/lastlog" "/var/adm/lastlog"]) |
|
|
131 | |
|
|
132 | ]) |
|
|
133 | |
|
|
134 | AC_CHECK_HEADERS(utmpx.h, [ |
|
|
135 | AC_CHECK_TYPES([struct utmpx], [], [], [ |
|
|
136 | #include <sys/types.h> |
|
|
137 | #include <utmpx.h> |
|
|
138 | ]) |
|
|
139 | |
|
|
140 | AC_CHECK_MEMBER([struct utmpx.ut_host], |
|
|
141 | [AC_DEFINE(HAVE_UTMPX_HOST, 1, Define if struct utmpx contains ut_host)], [], [ |
|
|
142 | #include <sys/types.h> |
|
|
143 | #include <utmpx.h> |
|
|
144 | ]) |
|
|
145 | |
|
|
146 | AC_CHECK_FUNCS([updwtmpx updlastlogx]) |
|
|
147 | |
181 | AC_CHECK_TYPES([struct lastlogx], [], [], [ |
148 | AC_CHECK_TYPES([struct lastlogx], [], [], [ |
182 | #include <sys/types.h> |
149 | #include <sys/types.h> |
183 | #include <utmpx.h> |
150 | #include <utmpx.h> |
184 | #ifdef HAVE_LASTLOG_H |
151 | ]) |
185 | #include <lastlog.h> |
152 | |
|
|
153 | PT_FIND_FILE([wtmpx], [PT_WTMPX_FILE], |
|
|
154 | ["/var/log/wtmpx" "/var/adm/wtmpx"]) |
|
|
155 | |
|
|
156 | PT_FIND_FILE([lastlogx], [PT_LASTLOGX_FILE], |
|
|
157 | ["/var/log/lastlogx" "/var/adm/lastlogx"]) |
|
|
158 | ]) |
|
|
159 | |
|
|
160 | ]) |
|
|
161 | |
|
|
162 | AC_DEFUN([SCM_RIGHTS_CHECK], |
|
|
163 | [ |
|
|
164 | AH_TEMPLATE([_XOPEN_SOURCE], [Enable declarations of msg_control and msg_controllen on Solaris]) |
|
|
165 | case $host in |
|
|
166 | *-*-solaris*) |
|
|
167 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ |
|
|
168 | #if __STDC_VERSION__ >= 199901L |
|
|
169 | error |
186 | #endif |
170 | #endif |
187 | ]) |
171 | ]])],[AC_DEFINE(_XOPEN_SOURCE, 500)],[AC_DEFINE(_XOPEN_SOURCE, 600)]) |
|
|
172 | AC_SEARCH_LIBS(sendmsg, socket) |
|
|
173 | ;; |
|
|
174 | esac |
188 | |
175 | |
189 | dnl# -------------------------------------------------------------------------- |
|
|
190 | dnl# FIND FILES |
|
|
191 | dnl# -------------------------------------------------------------------------- |
|
|
192 | |
|
|
193 | dnl# find utmp |
|
|
194 | PT_FIND_FILE([utmp], [UTMP_FILE], [_PATH_UTMP], |
|
|
195 | ["/var/run/utmp", "/var/adm/utmp", "/etc/utmp", "/usr/etc/utmp", "/usr/adm/utmp"]) |
|
|
196 | |
|
|
197 | dnl# -------------------------------------------------------------------------- |
|
|
198 | |
|
|
199 | dnl# find wtmp |
|
|
200 | PT_FIND_FILE([wtmp], [WTMP_FILE], [_PATH_WTMP], |
|
|
201 | ["/var/log/wtmp", "/var/adm/wtmp", "/etc/wtmp", "/usr/etc/wtmp", "/usr/adm/wtmp"]) |
|
|
202 | dnl# -------------------------------------------------------------------------- |
|
|
203 | |
|
|
204 | dnl# find wtmpx |
|
|
205 | PT_FIND_FILE([wtmpx], [WTMPX_FILE], [_PATH_WTMPX], |
|
|
206 | ["/var/log/wtmpx", "/var/adm/wtmpx"]) |
|
|
207 | dnl# -------------------------------------------------------------------------- |
|
|
208 | |
|
|
209 | dnl# find lastlog |
|
|
210 | PT_FIND_FILE([lastlog], [LASTLOG_FILE], [_PATH_LASTLOG], |
|
|
211 | ["/var/log/lastlog"]) |
|
|
212 | dnl# -------------------------------------------------------------------------- |
|
|
213 | |
|
|
214 | dnl# find lastlogx |
|
|
215 | PT_FIND_FILE([lastlogx], [LASTLOGX_FILE], [_PATH_LASTLOGX], |
|
|
216 | ["/var/log/lastlogx", "/var/adm/lastlogx"]) |
|
|
217 | ]) |
|
|
218 | |
|
|
219 | AC_DEFUN([SCM_RIGHTS_CHECK], |
|
|
220 | [ |
|
|
221 | AC_CACHE_CHECK(for unix-compliant filehandle passing ability, pt_cv_can_pass_fds, |
176 | AC_CACHE_CHECK(for unix-compliant filehandle passing ability, pt_cv_can_pass_fds, |
222 | [AC_LINK_IFELSE([AC_LANG_PROGRAM([[ |
177 | [AC_LINK_IFELSE([AC_LANG_PROGRAM([[ |
223 | #include <cstddef> // broken bsds (is that redundant?) need this |
178 | #include <stddef.h> // broken bsds (is that redundant?) need this |
224 | #include <sys/types.h> |
179 | #include <sys/types.h> |
225 | #include <sys/socket.h> |
180 | #include <sys/socket.h> |
226 | #include <sys/uio.h> |
181 | #include <sys/uio.h> |
227 | ]], [[ |
182 | ]], [[ |
228 | { |
183 | { |
… | |
… | |
247 | *(int *)CMSG_DATA (cmsg) = 5; |
202 | *(int *)CMSG_DATA (cmsg) = 5; |
248 | |
203 | |
249 | return sendmsg (3, &msg, 0); |
204 | return sendmsg (3, &msg, 0); |
250 | } |
205 | } |
251 | ]])],[pt_cv_can_pass_fds=yes],[pt_cv_can_pass_fds=no])]) |
206 | ]])],[pt_cv_can_pass_fds=yes],[pt_cv_can_pass_fds=no])]) |
252 | if test x$pt_cv_can_pass_fds = xyes; then |
207 | if test x$pt_cv_can_pass_fds = xno; then |
253 | AC_DEFINE(HAVE_UNIX_FDPASS, 1, Define if sys/socket.h defines the necessary macros/functions for file handle passing) |
|
|
254 | else |
|
|
255 | AC_MSG_ERROR([libptytty requires unix-compliant filehandle passing ability]) |
208 | AC_MSG_ERROR([libptytty requires unix-compliant filehandle passing ability]) |
256 | fi |
209 | fi |
257 | ]) |
210 | ]) |
258 | |
211 | |
259 | AC_DEFUN([TTY_GROUP_CHECK], |
212 | AC_DEFUN([TTY_GROUP_CHECK], |