]> andersk Git - openssh.git/blob - configure.ac
- (dtucker) [acconfig.h auth.c configure.ac sshd.8] Bug #422 again: deny
[openssh.git] / configure.ac
1 # $Id$
2
3 AC_INIT
4 AC_CONFIG_SRCDIR([ssh.c])
5
6 AC_CONFIG_HEADER(config.h)
7 AC_PROG_CC
8 AC_CANONICAL_HOST
9 AC_C_BIGENDIAN
10
11 # Checks for programs.
12 AC_PROG_CPP
13 AC_PROG_RANLIB
14 AC_PROG_INSTALL
15 AC_PATH_PROG(AR, ar)
16 AC_PATH_PROGS(PERL, perl5 perl)
17 AC_PATH_PROG(SED, sed)
18 AC_SUBST(PERL)
19 AC_PATH_PROG(ENT, ent)
20 AC_SUBST(ENT)
21 AC_PATH_PROG(TEST_MINUS_S_SH, bash)
22 AC_PATH_PROG(TEST_MINUS_S_SH, ksh)
23 AC_PATH_PROG(TEST_MINUS_S_SH, sh)
24 AC_PATH_PROG(SH, sh)
25
26 # System features
27 AC_SYS_LARGEFILE
28
29 if test -z "$AR" ; then
30         AC_MSG_ERROR([*** 'ar' missing, please install or fix your \$PATH ***])
31 fi
32
33 # Use LOGIN_PROGRAM from environment if possible
34 if test ! -z "$LOGIN_PROGRAM" ; then
35         AC_DEFINE_UNQUOTED(LOGIN_PROGRAM_FALLBACK, "$LOGIN_PROGRAM")
36 else
37         # Search for login
38         AC_PATH_PROG(LOGIN_PROGRAM_FALLBACK, login)
39         if test ! -z "$LOGIN_PROGRAM_FALLBACK" ; then
40                 AC_DEFINE_UNQUOTED(LOGIN_PROGRAM_FALLBACK, "$LOGIN_PROGRAM_FALLBACK")
41         fi
42 fi
43
44 if test -z "$LD" ; then
45         LD=$CC
46 fi
47 AC_SUBST(LD)
48         
49 AC_C_INLINE
50 if test "$GCC" = "yes" || test "$GCC" = "egcs"; then 
51         CFLAGS="$CFLAGS -Wall -Wpointer-arith -Wno-uninitialized"
52 fi
53
54 # Check for some target-specific stuff
55 case "$host" in
56 *-*-aix*)
57         CPPFLAGS="$CPPFLAGS -I/usr/local/include"
58         LDFLAGS="$LDFLAGS -L/usr/local/lib"
59         AC_MSG_CHECKING([how to specify blibpath for linker ($LD)]) 
60         if (test -z "$blibpath"); then
61                 blibpath="/usr/lib:/lib:/usr/local/lib"
62         fi
63         saved_LDFLAGS="$LDFLAGS"
64         for tryflags in -blibpath: -Wl,-blibpath: -Wl,-rpath, ;do
65                 if (test -z "$blibflags"); then
66                         LDFLAGS="$saved_LDFLAGS $tryflags$blibpath"
67                         AC_TRY_LINK([], [], [blibflags=$tryflags])
68                 fi
69         done
70         if (test -z "$blibflags"); then
71                 AC_MSG_RESULT(not found)
72                 AC_MSG_ERROR([*** must be able to specify blibpath on AIX - check config.log])
73         else
74                 AC_MSG_RESULT($blibflags)
75         fi
76         LDFLAGS="$saved_LDFLAGS"
77         dnl Check for authenticate.  Might be in libs.a on older AIXes
78         AC_CHECK_FUNC(authenticate, [AC_DEFINE(WITH_AIXAUTHENTICATE)],
79                 [AC_CHECK_LIB(s,authenticate,
80                         [ AC_DEFINE(WITH_AIXAUTHENTICATE)
81                                 LIBS="$LIBS -ls"
82                         ])
83                 ])
84         dnl Check if loginfailed is declared and takes 4 arguments (AIX >= 5.2)
85         AC_CHECK_DECL(loginfailed,
86                  [AC_MSG_CHECKING(if loginfailed takes 4 arguments)
87                   AC_TRY_COMPILE(
88                         [#include <usersec.h>],
89                         [(void)loginfailed("user","host","tty",0);],
90                         [AC_MSG_RESULT(yes)
91                          AC_DEFINE(AIX_LOGINFAILED_4ARG)],
92                         [AC_MSG_RESULT(no)]
93                 )],
94                 [],
95                 [#include <usersec.h>]
96         )
97         AC_CHECK_FUNCS(setauthdb)
98         AC_DEFINE(BROKEN_GETADDRINFO)
99         AC_DEFINE(BROKEN_REALPATH)
100         dnl AIX handles lastlog as part of its login message
101         AC_DEFINE(DISABLE_LASTLOG)
102         AC_DEFINE(LOGIN_NEEDS_UTMPX)
103         AC_DEFINE(SPT_TYPE,SPT_REUSEARGV)
104         ;;
105 *-*-cygwin*)
106         check_for_libcrypt_later=1
107         LIBS="$LIBS /usr/lib/textmode.o"
108         AC_DEFINE(HAVE_CYGWIN)
109         AC_DEFINE(USE_PIPES)
110         AC_DEFINE(DISABLE_SHADOW)
111         AC_DEFINE(IP_TOS_IS_BROKEN)
112         AC_DEFINE(NO_X11_UNIX_SOCKETS)
113         AC_DEFINE(NO_IPPORT_RESERVED_CONCEPT)
114         AC_DEFINE(DISABLE_FD_PASSING)
115         AC_DEFINE(SETGROUPS_NOOP)
116         ;;
117 *-*-dgux*)
118         AC_DEFINE(IP_TOS_IS_BROKEN)
119         ;;
120 *-*-darwin*)
121         AC_MSG_CHECKING(if we have working getaddrinfo)
122         AC_TRY_RUN([#include <mach-o/dyld.h>
123 main() { if (NSVersionOfRunTimeLibrary("System") >= (60 << 16))
124                 exit(0);
125         else
126                 exit(1);
127 }], [AC_MSG_RESULT(working)],
128         [AC_MSG_RESULT(buggy)
129         AC_DEFINE(BROKEN_GETADDRINFO)],
130         [AC_MSG_RESULT(assume it is working)])
131         ;;
132 *-*-hpux10.26)
133         if test -z "$GCC"; then
134                 CFLAGS="$CFLAGS -Ae"
135         fi
136         CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED=1"
137         IPADDR_IN_DISPLAY=yes
138         AC_DEFINE(HAVE_SECUREWARE)
139         AC_DEFINE(USE_PIPES)
140         AC_DEFINE(LOGIN_NO_ENDOPT)
141         AC_DEFINE(LOGIN_NEEDS_UTMPX)
142         AC_DEFINE(DISABLE_SHADOW)
143         AC_DEFINE(DISABLE_UTMP)
144         AC_DEFINE(LOCKED_PASSWD_STRING, "*")
145         AC_DEFINE(SPT_TYPE,SPT_PSTAT)
146         LIBS="$LIBS -lsec -lsecpw"
147         AC_CHECK_LIB(xnet, t_error, ,AC_MSG_ERROR([*** -lxnet needed on HP-UX - check config.log ***]))
148         disable_ptmx_check=yes
149         ;;
150 *-*-hpux10*)
151         if test -z "$GCC"; then
152                 CFLAGS="$CFLAGS -Ae"
153         fi
154         CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED=1"
155         IPADDR_IN_DISPLAY=yes
156         AC_DEFINE(USE_PIPES)
157         AC_DEFINE(LOGIN_NO_ENDOPT)
158         AC_DEFINE(LOGIN_NEEDS_UTMPX)
159         AC_DEFINE(DISABLE_SHADOW)
160         AC_DEFINE(DISABLE_UTMP)
161         AC_DEFINE(LOCKED_PASSWD_STRING, "*")
162         AC_DEFINE(SPT_TYPE,SPT_PSTAT)
163         LIBS="$LIBS -lsec"
164         AC_CHECK_LIB(xnet, t_error, ,AC_MSG_ERROR([*** -lxnet needed on HP-UX - check config.log ***]))
165         ;;
166 *-*-hpux11*)
167         CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED=1"
168         IPADDR_IN_DISPLAY=yes
169         AC_DEFINE(PAM_SUN_CODEBASE)
170         AC_DEFINE(USE_PIPES)
171         AC_DEFINE(LOGIN_NO_ENDOPT)
172         AC_DEFINE(LOGIN_NEEDS_UTMPX)
173         AC_DEFINE(DISABLE_SHADOW)
174         AC_DEFINE(DISABLE_UTMP)
175         AC_DEFINE(LOCKED_PASSWD_STRING, "*")
176         AC_DEFINE(SPT_TYPE,SPT_PSTAT)
177         LIBS="$LIBS -lsec"
178         AC_CHECK_LIB(xnet, t_error, ,AC_MSG_ERROR([*** -lxnet needed on HP-UX - check config.log ***]))
179         ;;
180 *-*-irix5*)
181         CPPFLAGS="$CPPFLAGS -I/usr/local/include"
182         LDFLAGS="$LDFLAGS"
183         PATH="$PATH:/usr/etc"
184         AC_DEFINE(BROKEN_INET_NTOA)
185         AC_DEFINE(WITH_ABBREV_NO_TTY)
186         AC_DEFINE(LOCKED_PASSWD_STRING, "*LK*")
187         ;;
188 *-*-irix6*)
189         CPPFLAGS="$CPPFLAGS -I/usr/local/include"
190         LDFLAGS="$LDFLAGS"
191         PATH="$PATH:/usr/etc"
192         AC_DEFINE(WITH_IRIX_ARRAY)
193         AC_DEFINE(WITH_IRIX_PROJECT)
194         AC_DEFINE(WITH_IRIX_AUDIT)
195         AC_CHECK_FUNC(jlimit_startjob, [AC_DEFINE(WITH_IRIX_JOBS)])
196         AC_DEFINE(BROKEN_INET_NTOA)
197         AC_DEFINE(WITH_ABBREV_NO_TTY)
198         AC_DEFINE(LOCKED_PASSWD_STRING, "*LK*")
199         ;;
200 *-*-linux*)
201         no_dev_ptmx=1
202         check_for_libcrypt_later=1
203         check_for_openpty_ctty_bug=1
204         AC_DEFINE(DONT_TRY_OTHER_AF)
205         AC_DEFINE(PAM_TTY_KLUDGE)
206         AC_DEFINE(LOCKED_PASSWD_PREFIX, "!!")
207         AC_DEFINE(SPT_TYPE,SPT_REUSEARGV)
208         inet6_default_4in6=yes
209         case `uname -r` in
210         1.*|2.0.*)
211                 AC_DEFINE(BROKEN_CMSG_TYPE)
212                 ;;
213         esac
214         ;;
215 mips-sony-bsd|mips-sony-newsos4)
216         AC_DEFINE(HAVE_NEWS4)
217         SONY=1
218         ;;
219 *-*-netbsd*)
220         check_for_libcrypt_before=1
221         need_dash_r=1
222         ;;
223 *-*-freebsd*)
224         check_for_libcrypt_later=1
225         ;;
226 *-next-*)
227         conf_lastlog_location="/usr/adm/lastlog"
228         conf_utmp_location=/etc/utmp
229         conf_wtmp_location=/usr/adm/wtmp
230         MAIL=/usr/spool/mail
231         AC_DEFINE(HAVE_NEXT)
232         AC_DEFINE(BROKEN_REALPATH)
233         AC_DEFINE(USE_PIPES)
234         AC_DEFINE(BROKEN_SAVED_UIDS)
235         CPPFLAGS="$CPPFLAGS -I/usr/local/include"
236         CFLAGS="$CFLAGS"
237         ;;
238 *-*-solaris*)
239         CPPFLAGS="$CPPFLAGS -I/usr/local/include"
240         LDFLAGS="$LDFLAGS -L/usr/local/lib -R/usr/local/lib" 
241         need_dash_r=1
242         AC_DEFINE(PAM_SUN_CODEBASE)
243         AC_DEFINE(LOGIN_NEEDS_UTMPX)
244         AC_DEFINE(LOGIN_NEEDS_TERM)
245         AC_DEFINE(PAM_TTY_KLUDGE)
246         AC_DEFINE(LOCKED_PASSWD_STRING, "*LK*")
247         # Pushing STREAMS modules will cause sshd to acquire a controlling tty.
248         AC_DEFINE(SSHD_ACQUIRES_CTTY)
249         # hardwire lastlog location (can't detect it on some versions)
250         conf_lastlog_location="/var/adm/lastlog"
251         AC_MSG_CHECKING(for obsolete utmp and wtmp in solaris2.x)
252         sol2ver=`echo "$host"| sed -e 's/.*[[0-9]]\.//'`
253         if test "$sol2ver" -ge 8; then
254                 AC_MSG_RESULT(yes)
255                 AC_DEFINE(DISABLE_UTMP)
256                 AC_DEFINE(DISABLE_WTMP)
257         else
258                 AC_MSG_RESULT(no)
259         fi
260         ;;
261 *-*-sunos4*)
262         CPPFLAGS="$CPPFLAGS -DSUNOS4"
263         AC_CHECK_FUNCS(getpwanam)
264         AC_DEFINE(PAM_SUN_CODEBASE)
265         conf_utmp_location=/etc/utmp
266         conf_wtmp_location=/var/adm/wtmp
267         conf_lastlog_location=/var/adm/lastlog
268         AC_DEFINE(USE_PIPES)
269         ;;
270 *-ncr-sysv*)
271         CPPFLAGS="$CPPFLAGS -I/usr/local/include"
272         LDFLAGS="$LDFLAGS -L/usr/local/lib"
273         LIBS="$LIBS -lc89"
274         AC_DEFINE(USE_PIPES)
275         AC_DEFINE(SSHD_ACQUIRES_CTTY)
276         ;;
277 *-sni-sysv*)
278         CPPFLAGS="$CPPFLAGS -I/usr/local/include"
279         # /usr/ucblib MUST NOT be searched on ReliantUNIX
280         LDFLAGS="$LDFLAGS -L/usr/local/lib"
281         IPADDR_IN_DISPLAY=yes
282         AC_DEFINE(USE_PIPES)
283         AC_DEFINE(IP_TOS_IS_BROKEN)
284         AC_DEFINE(SSHD_ACQUIRES_CTTY)
285         # /usr/ucblib/libucb.a no longer needed on ReliantUNIX
286         # Attention: always take care to bind libsocket and libnsl before libc,
287         # otherwise you will find lots of "SIOCGPGRP errno 22" on syslog
288         ;;
289 *-*-sysv4.2*)
290         CPPFLAGS="$CPPFLAGS -I/usr/local/include"
291         LDFLAGS="$LDFLAGS -L/usr/local/lib"
292         AC_DEFINE(USE_PIPES)
293         ;;
294 *-*-sysv5*)
295         CPPFLAGS="$CPPFLAGS -I/usr/local/include"
296         LDFLAGS="$LDFLAGS -L/usr/local/lib"
297         AC_DEFINE(USE_PIPES)
298         ;;
299 *-*-sysv*)
300         CPPFLAGS="$CPPFLAGS -I/usr/local/include"
301         LDFLAGS="$LDFLAGS -L/usr/local/lib"
302         ;;
303 *-*-sco3.2v4*)
304         CPPFLAGS="$CPPFLAGS -Dftruncate=chsize -I/usr/local/include"
305         LDFLAGS="$LDFLAGS -L/usr/local/lib"
306         LIBS="$LIBS -los -lprot -lx -ltinfo -lm"
307         RANLIB=true
308         no_dev_ptmx=1
309         AC_DEFINE(BROKEN_SYS_TERMIO_H)
310         AC_DEFINE(USE_PIPES)
311         AC_DEFINE(HAVE_SECUREWARE)
312         AC_DEFINE(DISABLE_SHADOW)
313         AC_DEFINE(BROKEN_SAVED_UIDS)
314         AC_CHECK_FUNCS(getluid setluid)
315         MANTYPE=man
316         do_sco3_extra_lib_check=yes
317         ;;
318 *-*-sco3.2v5*)
319         if test -z "$GCC"; then
320                 CFLAGS="$CFLAGS -belf"
321         fi
322         CPPFLAGS="$CPPFLAGS -I/usr/local/include"
323         LDFLAGS="$LDFLAGS -L/usr/local/lib"
324         LIBS="$LIBS -lprot -lx -ltinfo -lm"
325         no_dev_ptmx=1
326         AC_DEFINE(USE_PIPES)
327         AC_DEFINE(HAVE_SECUREWARE)
328         AC_DEFINE(DISABLE_SHADOW)
329         AC_DEFINE(DISABLE_FD_PASSING)
330         AC_CHECK_FUNCS(getluid setluid)
331         MANTYPE=man
332         ;;
333 *-*-unicosmk*)
334         AC_DEFINE(USE_PIPES)
335         AC_DEFINE(DISABLE_FD_PASSING)
336         LDFLAGS="$LDFLAGS"
337         LIBS="$LIBS -lgen -lrsc -lshare -luex -lacm"
338         MANTYPE=cat
339         ;;
340 *-*-unicos*)
341         AC_DEFINE(USE_PIPES)
342         AC_DEFINE(DISABLE_FD_PASSING)
343         AC_DEFINE(NO_SSH_LASTLOG)
344         LDFLAGS="$LDFLAGS -Wl,-Dmsglevel=334:fatal"
345         LIBS="$LIBS -lgen -lrsc -lshare -luex -lacm"
346         MANTYPE=cat
347         ;;
348 *-dec-osf*)
349         AC_MSG_CHECKING(for Digital Unix SIA)
350         no_osfsia=""
351         AC_ARG_WITH(osfsia,
352                 [  --with-osfsia           Enable Digital Unix SIA],
353                 [
354                         if test "x$withval" = "xno" ; then
355                                 AC_MSG_RESULT(disabled)
356                                 no_osfsia=1
357                         fi
358                 ],
359         )
360         if test -z "$no_osfsia" ; then
361                 if test -f /etc/sia/matrix.conf; then
362                         AC_MSG_RESULT(yes)
363                         AC_DEFINE(HAVE_OSF_SIA)
364                         AC_DEFINE(DISABLE_LOGIN)
365                         AC_DEFINE(DISABLE_FD_PASSING)
366                         LIBS="$LIBS -lsecurity -ldb -lm -laud"
367                 else
368                         AC_MSG_RESULT(no)
369                 fi
370         fi
371         AC_DEFINE(DISABLE_FD_PASSING)
372         AC_DEFINE(LOCKED_PASSWD_SUBSTR, "Nologin")
373         ;;
374
375 *-*-nto-qnx)
376         AC_DEFINE(USE_PIPES)
377         AC_DEFINE(NO_X11_UNIX_SOCKETS)
378         AC_DEFINE(MISSING_NFDBITS)
379         AC_DEFINE(MISSING_HOWMANY)
380         AC_DEFINE(MISSING_FD_MASK)
381         ;;
382 esac
383
384 # Allow user to specify flags
385 AC_ARG_WITH(cflags,
386         [  --with-cflags           Specify additional flags to pass to compiler],
387         [
388                 if test "x$withval" != "xno" ; then
389                         CFLAGS="$CFLAGS $withval"
390                 fi
391         ]       
392 )
393 AC_ARG_WITH(cppflags,
394         [  --with-cppflags         Specify additional flags to pass to preprocessor] ,
395         [
396                 if test "x$withval" != "xno"; then
397                         CPPFLAGS="$CPPFLAGS $withval"
398                 fi
399         ]
400 )
401 AC_ARG_WITH(ldflags,
402         [  --with-ldflags          Specify additional flags to pass to linker],
403         [
404                 if test "x$withval" != "xno" ; then
405                         LDFLAGS="$LDFLAGS $withval"
406                 fi
407         ]       
408 )
409 AC_ARG_WITH(libs,
410         [  --with-libs             Specify additional libraries to link with],
411         [
412                 if test "x$withval" != "xno" ; then
413                         LIBS="$LIBS $withval"
414                 fi
415         ]       
416 )
417
418 AC_MSG_CHECKING(compiler and flags for sanity)
419 AC_TRY_RUN([
420 #include <stdio.h>
421 int main(){exit(0);}
422         ],
423         [       AC_MSG_RESULT(yes) ],
424         [
425                 AC_MSG_RESULT(no)
426                 AC_MSG_ERROR([*** compiler cannot create working executables, check config.log ***])
427         ]
428 )
429
430 # Checks for header files.
431 AC_CHECK_HEADERS(bstring.h crypt.h endian.h features.h floatingpoint.h \
432         getopt.h glob.h ia.h lastlog.h libgen.h limits.h login.h \
433         login_cap.h maillock.h netdb.h netgroup.h \
434         netinet/in_systm.h paths.h pty.h readpassphrase.h \
435         rpc/types.h security/pam_appl.h shadow.h stddef.h stdint.h \
436         strings.h sys/strtio.h sys/audit.h sys/bitypes.h sys/bsdtty.h \
437         sys/cdefs.h sys/mman.h sys/pstat.h sys/select.h sys/stat.h \
438         sys/stropts.h sys/sysmacros.h sys/time.h sys/timers.h \
439         sys/un.h time.h tmpdir.h ttyent.h usersec.h \
440         util.h utime.h utmp.h utmpx.h)
441
442 # Checks for libraries.
443 AC_CHECK_FUNC(yp_match, , AC_CHECK_LIB(nsl, yp_match))
444 AC_CHECK_FUNC(setsockopt, , AC_CHECK_LIB(socket, setsockopt))
445
446 dnl SCO OS3 needs this for libwrap
447 if test "x$with_tcp_wrappers" != "xno" ; then
448     if test "x$do_sco3_extra_lib_check" = "xyes" ; then
449         AC_CHECK_LIB(rpc, innetgr, LIBS="-lrpc -lyp -lrpc $LIBS" , , -lyp -lrpc)
450     fi
451 fi
452
453 AC_CHECK_FUNC(getspnam, ,
454         AC_CHECK_LIB(gen, getspnam, LIBS="$LIBS -lgen"))
455
456 AC_ARG_WITH(rpath,
457         [  --without-rpath         Disable auto-added -R linker paths],
458         [
459                 if test "x$withval" = "xno" ; then      
460                         need_dash_r=""
461                 fi
462                 if test "x$withval" = "xyes" ; then
463                         need_dash_r=1
464                 fi
465         ]
466 )
467
468 dnl zlib is required
469 AC_ARG_WITH(zlib,
470         [  --with-zlib=PATH        Use zlib in PATH],
471         [
472                 if test "x$withval" = "xno" ; then
473                         AC_MSG_ERROR([*** zlib is required ***])
474                 fi
475                 if test -d "$withval/lib"; then
476                         if test -n "${need_dash_r}"; then
477                                 LDFLAGS="-L${withval}/lib -R${withval}/lib ${LDFLAGS}"
478                         else
479                                 LDFLAGS="-L${withval}/lib ${LDFLAGS}"
480                         fi
481                 else
482                         if test -n "${need_dash_r}"; then
483                                 LDFLAGS="-L${withval} -R${withval} ${LDFLAGS}"
484                         else
485                                 LDFLAGS="-L${withval} ${LDFLAGS}"
486                         fi
487                 fi
488                 if test -d "$withval/include"; then
489                         CPPFLAGS="-I${withval}/include ${CPPFLAGS}"
490                 else
491                         CPPFLAGS="-I${withval} ${CPPFLAGS}"
492                 fi
493         ]
494 )
495
496 AC_CHECK_LIB(z, deflate, ,AC_MSG_ERROR([*** zlib missing - please install first or check config.log ***]))
497
498 dnl UnixWare 2.x
499 AC_CHECK_FUNC(strcasecmp, 
500         [], [ AC_CHECK_LIB(resolv, strcasecmp, LIBS="$LIBS -lresolv") ]
501 )
502 AC_CHECK_FUNC(utimes, 
503         [], [ AC_CHECK_LIB(c89, utimes, [AC_DEFINE(HAVE_UTIMES)
504                                         LIBS="$LIBS -lc89"]) ]
505 )
506
507 dnl    Checks for libutil functions
508 AC_CHECK_HEADERS(libutil.h)
509 AC_SEARCH_LIBS(login, util bsd, [AC_DEFINE(HAVE_LOGIN)])
510 AC_CHECK_FUNCS(logout updwtmp logwtmp)
511
512 AC_FUNC_STRFTIME
513
514 # Check for ALTDIRFUNC glob() extension
515 AC_MSG_CHECKING(for GLOB_ALTDIRFUNC support)
516 AC_EGREP_CPP(FOUNDIT,
517         [
518                 #include <glob.h>
519                 #ifdef GLOB_ALTDIRFUNC
520                 FOUNDIT
521                 #endif
522         ], 
523         [
524                 AC_DEFINE(GLOB_HAS_ALTDIRFUNC)
525                 AC_MSG_RESULT(yes)
526         ],
527         [
528                 AC_MSG_RESULT(no)
529         ]
530 )
531
532 # Check for g.gl_matchc glob() extension
533 AC_MSG_CHECKING(for gl_matchc field in glob_t)
534 AC_EGREP_CPP(FOUNDIT,
535         [
536                 #include <glob.h>
537                 int main(void){glob_t g; g.gl_matchc = 1;}
538         ],
539         [
540                 AC_DEFINE(GLOB_HAS_GL_MATCHC)
541                 AC_MSG_RESULT(yes)
542         ],
543         [
544                 AC_MSG_RESULT(no)
545         ]
546 )
547
548 AC_MSG_CHECKING([whether struct dirent allocates space for d_name])
549 AC_TRY_RUN(
550         [
551 #include <sys/types.h>
552 #include <dirent.h>
553 int main(void){struct dirent d;exit(sizeof(d.d_name)<=sizeof(char));}
554         ],
555         [AC_MSG_RESULT(yes)], 
556         [
557                 AC_MSG_RESULT(no)
558                 AC_DEFINE(BROKEN_ONE_BYTE_DIRENT_D_NAME)
559         ]
560 )
561
562 # Check whether user wants S/Key support
563 SKEY_MSG="no" 
564 AC_ARG_WITH(skey,
565         [  --with-skey[[=PATH]]      Enable S/Key support
566                             (optionally in PATH)],
567         [
568                 if test "x$withval" != "xno" ; then
569
570                         if test "x$withval" != "xyes" ; then
571                                 CPPFLAGS="$CPPFLAGS -I${withval}/include"
572                                 LDFLAGS="$LDFLAGS -L${withval}/lib"
573                         fi
574
575                         AC_DEFINE(SKEY)
576                         LIBS="-lskey $LIBS"
577                         SKEY_MSG="yes" 
578         
579                         AC_MSG_CHECKING([for s/key support])
580                         AC_TRY_RUN(
581                                 [
582 #include <stdio.h>
583 #include <skey.h>
584 int main() { char *ff = skey_keyinfo(""); ff=""; exit(0); }
585                                 ],
586                                 [AC_MSG_RESULT(yes)],
587                                 [
588                                         AC_MSG_RESULT(no)
589                                         AC_MSG_ERROR([** Incomplete or missing s/key libraries.])
590                                 ])
591                 fi
592         ]
593 )
594
595 # Check whether user wants TCP wrappers support
596 TCPW_MSG="no"
597 AC_ARG_WITH(tcp-wrappers,
598         [  --with-tcp-wrappers[[=PATH]]      Enable tcpwrappers support
599                             (optionally in PATH)],
600         [
601                 if test "x$withval" != "xno" ; then
602                         saved_LIBS="$LIBS"
603                         saved_LDFLAGS="$LDFLAGS"
604                         saved_CPPFLAGS="$CPPFLAGS"
605                         if test -n "${withval}" -a "${withval}" != "yes"; then
606                                 if test -d "${withval}/lib"; then
607                                         if test -n "${need_dash_r}"; then
608                                                 LDFLAGS="-L${withval}/lib -R${withval}/lib ${LDFLAGS}"
609                                         else
610                                                 LDFLAGS="-L${withval}/lib ${LDFLAGS}"
611                                         fi
612                                 else
613                                         if test -n "${need_dash_r}"; then
614                                                 LDFLAGS="-L${withval} -R${withval} ${LDFLAGS}"
615                                         else
616                                                 LDFLAGS="-L${withval} ${LDFLAGS}"
617                                         fi
618                                 fi
619                                 if test -d "${withval}/include"; then
620                                         CPPFLAGS="-I${withval}/include ${CPPFLAGS}"
621                                 else
622                                         CPPFLAGS="-I${withval} ${CPPFLAGS}"
623                                 fi
624                         fi
625                         LIBWRAP="-lwrap"
626                         LIBS="$LIBWRAP $LIBS"
627                         AC_MSG_CHECKING(for libwrap)
628                         AC_TRY_LINK(
629                                 [
630 #include <tcpd.h>
631                                         int deny_severity = 0, allow_severity = 0;
632                                 ],
633                                 [hosts_access(0);],
634                                 [
635                                         AC_MSG_RESULT(yes)
636                                         AC_DEFINE(LIBWRAP)
637                                         AC_SUBST(LIBWRAP)
638                                         TCPW_MSG="yes"
639                                 ],
640                                 [
641                                         AC_MSG_ERROR([*** libwrap missing])
642                                 ]
643                         )
644                         LIBS="$saved_LIBS"
645                 fi
646         ]
647 )
648
649 dnl    Checks for library functions. Please keep in alphabetical order
650 AC_CHECK_FUNCS(\
651         arc4random __b64_ntop b64_ntop __b64_pton b64_pton basename \
652         bcopy bindresvport_sa clock fchmod fchown freeaddrinfo futimes \
653         gai_strerror getaddrinfo getcwd getgrouplist getnameinfo getopt \
654         getpeereid _getpty getrlimit getttyent glob inet_aton \
655         inet_ntoa inet_ntop innetgr login_getcapbool md5_crypt memmove \
656         mkdtemp mmap ngetaddrinfo nsleep ogetaddrinfo openlog_r openpty \
657         pstat readpassphrase realpath recvmsg rresvport_af sendmsg \
658         setdtablesize setegid setenv seteuid setgroups setlogin setpcred \
659         setproctitle setregid setresgid setresuid setreuid setrlimit \
660         setsid setvbuf sigaction sigvec snprintf socketpair strerror \
661         strlcat strlcpy strmode strnvis sysconf tcgetpgrp tcsendbreak \
662         truncate utimes vhangup vsnprintf waitpid \
663 )
664
665 AC_SEARCH_LIBS(nanosleep, rt posix4, AC_DEFINE(HAVE_NANOSLEEP))
666 AC_SEARCH_LIBS(basename, gen, AC_DEFINE(HAVE_BASENAME))
667
668 dnl Make sure prototypes are defined for these before using them.
669 AC_CHECK_DECL(strsep, [AC_CHECK_FUNCS(strsep)])
670 AC_CHECK_DECL(getrusage, [AC_CHECK_FUNCS(getrusage)])
671
672 dnl IRIX and Solaris 2.5.1 have dirname() in libgen
673 AC_CHECK_FUNCS(dirname, [AC_CHECK_HEADERS(libgen.h)] ,[
674         AC_CHECK_LIB(gen, dirname,[
675                 AC_CACHE_CHECK([for broken dirname],
676                         ac_cv_have_broken_dirname, [
677                         save_LIBS="$LIBS"
678                         LIBS="$LIBS -lgen"
679                         AC_TRY_RUN(
680                                 [
681 #include <libgen.h>
682 #include <string.h>
683
684 int main(int argc, char **argv) {
685     char *s, buf[32];
686
687     strncpy(buf,"/etc", 32);
688     s = dirname(buf);
689     if (!s || strncmp(s, "/", 32) != 0) {
690         exit(1);
691     } else {
692         exit(0);
693     }
694 }
695                                 ],
696                                 [ ac_cv_have_broken_dirname="no" ],
697                                 [ ac_cv_have_broken_dirname="yes" ]
698                         )
699                         LIBS="$save_LIBS"
700                 ])
701                 if test "x$ac_cv_have_broken_dirname" = "xno" ; then
702                         LIBS="$LIBS -lgen"
703                         AC_DEFINE(HAVE_DIRNAME)
704                         AC_CHECK_HEADERS(libgen.h)
705                 fi
706         ])
707 ])
708
709 dnl    Checks for time functions
710 AC_CHECK_FUNCS(gettimeofday time)
711 dnl    Checks for utmp functions
712 AC_CHECK_FUNCS(endutent getutent getutid getutline pututline setutent)
713 AC_CHECK_FUNCS(utmpname)
714 dnl    Checks for utmpx functions
715 AC_CHECK_FUNCS(endutxent getutxent getutxid getutxline pututxline )
716 AC_CHECK_FUNCS(setutxent utmpxname)
717
718 AC_CHECK_FUNC(daemon, 
719         [AC_DEFINE(HAVE_DAEMON)],
720         [AC_CHECK_LIB(bsd, daemon, [LIBS="$LIBS -lbsd"; AC_DEFINE(HAVE_DAEMON)])]
721 )
722
723 AC_CHECK_FUNC(getpagesize, 
724         [AC_DEFINE(HAVE_GETPAGESIZE)],
725         [AC_CHECK_LIB(ucb, getpagesize, [LIBS="$LIBS -lucb"; AC_DEFINE(HAVE_GETPAGESIZE)])]
726 )
727
728 # Check for broken snprintf
729 if test "x$ac_cv_func_snprintf" = "xyes" ; then
730         AC_MSG_CHECKING([whether snprintf correctly terminates long strings])
731         AC_TRY_RUN(
732                 [
733 #include <stdio.h>
734 int main(void){char b[5];snprintf(b,5,"123456789");exit(b[4]!='\0');}
735                 ],
736                 [AC_MSG_RESULT(yes)], 
737                 [
738                         AC_MSG_RESULT(no)
739                         AC_DEFINE(BROKEN_SNPRINTF)
740                         AC_MSG_WARN([****** Your snprintf() function is broken, complain to your vendor])
741                 ]
742         )
743 fi
744
745 dnl see whether mkstemp() requires XXXXXX
746 if test "x$ac_cv_func_mkdtemp" = "xyes" ; then
747 AC_MSG_CHECKING([for (overly) strict mkstemp])
748 AC_TRY_RUN(
749         [
750 #include <stdlib.h>
751 main() { char template[]="conftest.mkstemp-test";
752 if (mkstemp(template) == -1)
753         exit(1);
754 unlink(template); exit(0);
755 }
756         ],
757         [
758                 AC_MSG_RESULT(no)
759         ],
760         [ 
761                 AC_MSG_RESULT(yes)
762                 AC_DEFINE(HAVE_STRICT_MKSTEMP)
763         ],
764         [
765                 AC_MSG_RESULT(yes)
766                 AC_DEFINE(HAVE_STRICT_MKSTEMP)
767         ] 
768 )
769 fi
770
771 dnl make sure that openpty does not reacquire controlling terminal
772 if test ! -z "$check_for_openpty_ctty_bug"; then
773         AC_MSG_CHECKING(if openpty correctly handles controlling tty)
774         AC_TRY_RUN(
775                 [
776 #include <stdio.h>
777 #include <sys/fcntl.h>
778 #include <sys/types.h>
779 #include <sys/wait.h>
780
781 int
782 main()
783 {
784         pid_t pid;
785         int fd, ptyfd, ttyfd, status;
786
787         pid = fork();
788         if (pid < 0) {          /* failed */
789                 exit(1);
790         } else if (pid > 0) {   /* parent */
791                 waitpid(pid, &status, 0);
792                 if (WIFEXITED(status)) 
793                         exit(WEXITSTATUS(status));
794                 else
795                         exit(2);
796         } else {                /* child */
797                 close(0); close(1); close(2);
798                 setsid();
799                 openpty(&ptyfd, &ttyfd, NULL, NULL, NULL);
800                 fd = open("/dev/tty", O_RDWR | O_NOCTTY);
801                 if (fd >= 0)
802                         exit(3);        /* Acquired ctty: broken */
803                 else
804                         exit(0);        /* Did not acquire ctty: OK */
805         }
806 }
807                 ],
808                 [
809                         AC_MSG_RESULT(yes)
810                 ],
811                 [
812                         AC_MSG_RESULT(no)
813                         AC_DEFINE(SSHD_ACQUIRES_CTTY)
814                 ]
815         )
816 fi
817
818 AC_FUNC_GETPGRP
819
820 # Check for PAM libs
821 PAM_MSG="no"
822 AC_ARG_WITH(pam,
823         [  --with-pam              Enable PAM support ],
824         [
825                 if test "x$withval" != "xno" ; then
826                         if test "x$ac_cv_header_security_pam_appl_h" != "xyes" ; then
827                                 AC_MSG_ERROR([PAM headers not found])
828                         fi
829
830                         AC_CHECK_LIB(dl, dlopen, , )
831                         AC_CHECK_LIB(pam, pam_set_item, , AC_MSG_ERROR([*** libpam missing]))
832                         AC_CHECK_FUNCS(pam_getenvlist)
833
834                         disable_shadow=yes
835                         PAM_MSG="yes"
836
837                         AC_DEFINE(USE_PAM)
838                         if test $ac_cv_lib_dl_dlopen = yes; then
839                                 LIBPAM="-lpam -ldl"
840                         else
841                                 LIBPAM="-lpam"
842                         fi
843                         AC_SUBST(LIBPAM)
844                 fi
845         ]
846 )
847
848 # Check for older PAM
849 if test "x$PAM_MSG" = "xyes" ; then
850         # Check PAM strerror arguments (old PAM)
851         AC_MSG_CHECKING([whether pam_strerror takes only one argument])
852         AC_TRY_COMPILE(
853                 [
854 #include <stdlib.h>
855 #include <security/pam_appl.h>
856                 ], 
857                 [(void)pam_strerror((pam_handle_t *)NULL, -1);], 
858                 [AC_MSG_RESULT(no)],
859                 [
860                         AC_DEFINE(HAVE_OLD_PAM)
861                         AC_MSG_RESULT(yes)
862                         PAM_MSG="yes (old library)"
863                 ]
864         )
865 fi
866
867 # Some systems want crypt() from libcrypt, *not* the version in OpenSSL,
868 # because the system crypt() is more featureful.
869 if test "x$check_for_libcrypt_before" = "x1"; then
870         AC_CHECK_LIB(crypt, crypt)
871 fi
872
873 # Search for OpenSSL
874 saved_CPPFLAGS="$CPPFLAGS"
875 saved_LDFLAGS="$LDFLAGS"
876 AC_ARG_WITH(ssl-dir,
877         [  --with-ssl-dir=PATH     Specify path to OpenSSL installation ],
878         [
879                 if test "x$withval" != "xno" ; then
880                         if test -d "$withval/lib"; then
881                                 if test -n "${need_dash_r}"; then
882                                         LDFLAGS="-L${withval}/lib -R${withval}/lib ${LDFLAGS}"
883                                 else
884                                         LDFLAGS="-L${withval}/lib ${LDFLAGS}"
885                                 fi
886                         else
887                                 if test -n "${need_dash_r}"; then
888                                         LDFLAGS="-L${withval} -R${withval} ${LDFLAGS}"
889                                 else
890                                         LDFLAGS="-L${withval} ${LDFLAGS}"
891                                 fi
892                         fi
893                         if test -d "$withval/include"; then
894                                 CPPFLAGS="-I${withval}/include ${CPPFLAGS}"
895                         else
896                                 CPPFLAGS="-I${withval} ${CPPFLAGS}"
897                         fi
898                 fi
899         ]
900 )
901 LIBS="$LIBS -lcrypto"
902 AC_TRY_LINK_FUNC(RAND_add, AC_DEFINE(HAVE_OPENSSL),
903         [
904                 dnl Check default openssl install dir
905                 if test -n "${need_dash_r}"; then
906                         LDFLAGS="-L/usr/local/ssl/lib -R/usr/local/ssl/lib ${saved_LDFLAGS}"
907                 else
908                         LDFLAGS="-L/usr/local/ssl/lib ${saved_LDFLAGS}"
909                 fi
910                 CPPFLAGS="-I/usr/local/ssl/include ${saved_CPPFLAGS}"
911                 AC_TRY_LINK_FUNC(RAND_add, AC_DEFINE(HAVE_OPENSSL),
912                         [
913                                 AC_MSG_ERROR([*** Can't find recent OpenSSL libcrypto (see config.log for details) ***])
914                         ]
915                 )
916         ]
917 )
918
919 # Determine OpenSSL header version
920 AC_MSG_CHECKING([OpenSSL header version])
921 AC_TRY_RUN(
922         [
923 #include <stdio.h>
924 #include <string.h>
925 #include <openssl/opensslv.h>
926 #define DATA "conftest.sslincver"
927 int main(void) {
928         FILE *fd;
929         int rc;
930
931         fd = fopen(DATA,"w");
932         if(fd == NULL)
933                 exit(1);
934
935         if ((rc = fprintf(fd ,"%x (%s)\n", OPENSSL_VERSION_NUMBER, OPENSSL_VERSION_TEXT)) <0)
936                 exit(1);
937
938         exit(0);
939 }
940         ],
941         [
942                 ssl_header_ver=`cat conftest.sslincver`
943                 AC_MSG_RESULT($ssl_header_ver)
944         ],
945         [
946                 AC_MSG_RESULT(not found)
947                 AC_MSG_ERROR(OpenSSL version header not found.)
948         ]
949 )
950
951 # Determine OpenSSL library version
952 AC_MSG_CHECKING([OpenSSL library version])
953 AC_TRY_RUN(
954         [
955 #include <stdio.h>
956 #include <string.h>
957 #include <openssl/opensslv.h>
958 #include <openssl/crypto.h>
959 #define DATA "conftest.ssllibver"
960 int main(void) {
961         FILE *fd;
962         int rc;
963
964         fd = fopen(DATA,"w");
965         if(fd == NULL)
966                 exit(1);
967
968         if ((rc = fprintf(fd ,"%x (%s)\n", SSLeay(), SSLeay_version(SSLEAY_VERSION))) <0)
969                 exit(1);
970
971         exit(0);
972 }
973         ],
974         [
975                 ssl_library_ver=`cat conftest.ssllibver`
976                 AC_MSG_RESULT($ssl_library_ver)
977         ],
978         [
979                 AC_MSG_RESULT(not found)
980                 AC_MSG_ERROR(OpenSSL library not found.)
981         ]
982 )
983
984 # Sanity check OpenSSL headers
985 AC_MSG_CHECKING([whether OpenSSL's headers match the library])
986 AC_TRY_RUN(
987         [
988 #include <string.h>
989 #include <openssl/opensslv.h>
990 int main(void) { exit(SSLeay() == OPENSSL_VERSION_NUMBER ? 0 : 1); }
991         ],
992         [
993                 AC_MSG_RESULT(yes)
994         ],
995         [
996                 AC_MSG_RESULT(no)
997                 AC_MSG_ERROR([Your OpenSSL headers do not match your library.
998 Check config.log for details.
999 Also see contrib/findssl.sh for help identifying header/library mismatches.])
1000         ]
1001 )
1002
1003 # Some Linux systems (Slackware) need crypt() from libcrypt, *not* the 
1004 # version in OpenSSL. Skip this for PAM
1005 if test "x$check_for_libcrypt_later" = "x1"; then
1006         AC_CHECK_LIB(crypt, crypt, LIBS="$LIBS -lcrypt")
1007 fi
1008
1009
1010 ### Configure cryptographic random number support
1011
1012 # Check wheter OpenSSL seeds itself
1013 AC_MSG_CHECKING([whether OpenSSL's PRNG is internally seeded])
1014 AC_TRY_RUN(
1015         [
1016 #include <string.h>
1017 #include <openssl/rand.h>
1018 int main(void) { exit(RAND_status() == 1 ? 0 : 1); }
1019         ],
1020         [
1021                 OPENSSL_SEEDS_ITSELF=yes
1022                 AC_MSG_RESULT(yes)
1023         ],
1024         [
1025                 AC_MSG_RESULT(no)
1026                 # Default to use of the rand helper if OpenSSL doesn't
1027                 # seed itself
1028                 USE_RAND_HELPER=yes
1029         ]
1030 )
1031
1032
1033 # Do we want to force the use of the rand helper?
1034 AC_ARG_WITH(rand-helper,
1035         [  --with-rand-helper      Use subprocess to gather strong randomness ],
1036         [
1037                 if test "x$withval" = "xno" ; then
1038                         # Force use of OpenSSL's internal RNG, even if 
1039                         # the previous test showed it to be unseeded.
1040                         if test -z "$OPENSSL_SEEDS_ITSELF" ; then
1041                                 AC_MSG_WARN([*** Forcing use of OpenSSL's non-self-seeding PRNG])
1042                                 OPENSSL_SEEDS_ITSELF=yes
1043                                 USE_RAND_HELPER=""
1044                         fi
1045                 else
1046                         USE_RAND_HELPER=yes
1047                 fi
1048         ],
1049 )       
1050
1051 # Which randomness source do we use?
1052 if test ! -z "$OPENSSL_SEEDS_ITSELF" -a -z "$USE_RAND_HELPER" ; then
1053         # OpenSSL only
1054         AC_DEFINE(OPENSSL_PRNG_ONLY)
1055         RAND_MSG="OpenSSL internal ONLY"
1056         INSTALL_SSH_RAND_HELPER=""
1057 elif test ! -z "$USE_RAND_HELPER" ; then
1058         # install rand helper
1059         RAND_MSG="ssh-rand-helper"
1060         INSTALL_SSH_RAND_HELPER="yes"
1061 fi
1062 AC_SUBST(INSTALL_SSH_RAND_HELPER)
1063
1064 ### Configuration of ssh-rand-helper
1065
1066 # PRNGD TCP socket
1067 AC_ARG_WITH(prngd-port,
1068         [  --with-prngd-port=PORT  read entropy from PRNGD/EGD TCP localhost:PORT],
1069         [
1070                 case "$withval" in
1071                 no)
1072                         withval=""
1073                         ;;
1074                 [[0-9]]*)
1075                         ;;
1076                 *)
1077                         AC_MSG_ERROR(You must specify a numeric port number for --with-prngd-port)
1078                         ;;
1079                 esac
1080                 if test ! -z "$withval" ; then
1081                         PRNGD_PORT="$withval"
1082                         AC_DEFINE_UNQUOTED(PRNGD_PORT, $PRNGD_PORT)
1083                 fi
1084         ]
1085 )
1086
1087 # PRNGD Unix domain socket
1088 AC_ARG_WITH(prngd-socket,
1089         [  --with-prngd-socket=FILE read entropy from PRNGD/EGD socket FILE (default=/var/run/egd-pool)],
1090         [
1091                 case "$withval" in
1092                 yes)
1093                         withval="/var/run/egd-pool"
1094                         ;;
1095                 no)
1096                         withval=""
1097                         ;;
1098                 /*)
1099                         ;;
1100                 *)
1101                         AC_MSG_ERROR(You must specify an absolute path to the entropy socket)
1102                         ;;
1103                 esac
1104
1105                 if test ! -z "$withval" ; then
1106                         if test ! -z "$PRNGD_PORT" ; then
1107                                 AC_MSG_ERROR(You may not specify both a PRNGD/EGD port and socket)
1108                         fi
1109                         if test ! -r "$withval" ; then
1110                                 AC_MSG_WARN(Entropy socket is not readable)
1111                         fi
1112                         PRNGD_SOCKET="$withval"
1113                         AC_DEFINE_UNQUOTED(PRNGD_SOCKET, "$PRNGD_SOCKET")
1114                 fi
1115         ],
1116         [
1117                 # Check for existing socket only if we don't have a random device already
1118                 if test "$USE_RAND_HELPER" = yes ; then
1119                         AC_MSG_CHECKING(for PRNGD/EGD socket)
1120                         # Insert other locations here
1121                         for sock in /var/run/egd-pool /dev/egd-pool /etc/entropy; do
1122                                 if test -r $sock && $TEST_MINUS_S_SH -c "test -S $sock -o -p $sock" ; then
1123                                         PRNGD_SOCKET="$sock"
1124                                         AC_DEFINE_UNQUOTED(PRNGD_SOCKET, "$PRNGD_SOCKET")
1125                                         break;
1126                                 fi
1127                         done
1128                         if test ! -z "$PRNGD_SOCKET" ; then
1129                                 AC_MSG_RESULT($PRNGD_SOCKET)
1130                         else
1131                                 AC_MSG_RESULT(not found)
1132                         fi
1133                 fi
1134         ]
1135 )
1136
1137 # Change default command timeout for hashing entropy source
1138 entropy_timeout=200
1139 AC_ARG_WITH(entropy-timeout,
1140         [  --with-entropy-timeout  Specify entropy gathering command timeout (msec)],
1141         [
1142                 if test "x$withval" != "xno" ; then
1143                         entropy_timeout=$withval
1144                 fi
1145         ]       
1146 )
1147 AC_DEFINE_UNQUOTED(ENTROPY_TIMEOUT_MSEC, $entropy_timeout)
1148
1149 SSH_PRIVSEP_USER=sshd
1150 AC_ARG_WITH(privsep-user,
1151         [  --with-privsep-user=user Specify non-privileged user for privilege separation],
1152         [
1153                 if test -n "$withval"; then
1154                         SSH_PRIVSEP_USER=$withval
1155                 fi
1156         ]       
1157 )
1158 AC_DEFINE_UNQUOTED(SSH_PRIVSEP_USER, "$SSH_PRIVSEP_USER")
1159 AC_SUBST(SSH_PRIVSEP_USER)
1160
1161 # We do this little dance with the search path to insure
1162 # that programs that we select for use by installed programs
1163 # (which may be run by the super-user) come from trusted
1164 # locations before they come from the user's private area.
1165 # This should help avoid accidentally configuring some
1166 # random version of a program in someone's personal bin.
1167
1168 OPATH=$PATH
1169 PATH=/bin:/usr/bin
1170 test -h /bin 2> /dev/null && PATH=/usr/bin
1171 test -d /sbin && PATH=$PATH:/sbin
1172 test -d /usr/sbin && PATH=$PATH:/usr/sbin
1173 PATH=$PATH:/etc:$OPATH
1174
1175 # These programs are used by the command hashing source to gather entropy 
1176 OSSH_PATH_ENTROPY_PROG(PROG_LS, ls)
1177 OSSH_PATH_ENTROPY_PROG(PROG_NETSTAT, netstat)
1178 OSSH_PATH_ENTROPY_PROG(PROG_ARP, arp)
1179 OSSH_PATH_ENTROPY_PROG(PROG_IFCONFIG, ifconfig)
1180 OSSH_PATH_ENTROPY_PROG(PROG_JSTAT, jstat)
1181 OSSH_PATH_ENTROPY_PROG(PROG_PS, ps)
1182 OSSH_PATH_ENTROPY_PROG(PROG_SAR, sar)
1183 OSSH_PATH_ENTROPY_PROG(PROG_W, w)
1184 OSSH_PATH_ENTROPY_PROG(PROG_WHO, who)
1185 OSSH_PATH_ENTROPY_PROG(PROG_LAST, last)
1186 OSSH_PATH_ENTROPY_PROG(PROG_LASTLOG, lastlog)
1187 OSSH_PATH_ENTROPY_PROG(PROG_DF, df)
1188 OSSH_PATH_ENTROPY_PROG(PROG_VMSTAT, vmstat)
1189 OSSH_PATH_ENTROPY_PROG(PROG_UPTIME, uptime)
1190 OSSH_PATH_ENTROPY_PROG(PROG_IPCS, ipcs)
1191 OSSH_PATH_ENTROPY_PROG(PROG_TAIL, tail)
1192 # restore PATH
1193 PATH=$OPATH
1194
1195 # Where does ssh-rand-helper get its randomness from?
1196 INSTALL_SSH_PRNG_CMDS=""
1197 if test ! -z "$INSTALL_SSH_RAND_HELPER" ; then
1198         if test ! -z "$PRNGD_PORT" ; then
1199                 RAND_HELPER_MSG="TCP localhost:$PRNGD_PORT"
1200         elif test ! -z "$PRNGD_SOCKET" ; then
1201                 RAND_HELPER_MSG="Unix domain socket \"$PRNGD_SOCKET\""
1202         else
1203                 RAND_HELPER_MSG="Command hashing (timeout $entropy_timeout)"
1204                 RAND_HELPER_CMDHASH=yes
1205                 INSTALL_SSH_PRNG_CMDS="yes"
1206         fi
1207 fi
1208 AC_SUBST(INSTALL_SSH_PRNG_CMDS)
1209
1210
1211 # Cheap hack to ensure NEWS-OS libraries are arranged right.
1212 if test ! -z "$SONY" ; then
1213   LIBS="$LIBS -liberty";
1214 fi
1215
1216 # Checks for data types
1217 AC_CHECK_SIZEOF(char, 1)
1218 AC_CHECK_SIZEOF(short int, 2)
1219 AC_CHECK_SIZEOF(int, 4)
1220 AC_CHECK_SIZEOF(long int, 4)
1221 AC_CHECK_SIZEOF(long long int, 8)
1222
1223 # Sanity check long long for some platforms (AIX)
1224 if test "x$ac_cv_sizeof_long_long_int" = "x4" ; then
1225         ac_cv_sizeof_long_long_int=0
1226 fi
1227
1228 # More checks for data types
1229 AC_CACHE_CHECK([for u_int type], ac_cv_have_u_int, [
1230         AC_TRY_COMPILE(
1231                 [ #include <sys/types.h> ], 
1232                 [ u_int a; a = 1;], 
1233                 [ ac_cv_have_u_int="yes" ],
1234                 [ ac_cv_have_u_int="no" ]
1235         )
1236 ])
1237 if test "x$ac_cv_have_u_int" = "xyes" ; then
1238         AC_DEFINE(HAVE_U_INT)
1239         have_u_int=1
1240 fi
1241
1242 AC_CACHE_CHECK([for intXX_t types], ac_cv_have_intxx_t, [
1243         AC_TRY_COMPILE(
1244                 [ #include <sys/types.h> ], 
1245                 [ int8_t a; int16_t b; int32_t c; a = b = c = 1;], 
1246                 [ ac_cv_have_intxx_t="yes" ],
1247                 [ ac_cv_have_intxx_t="no" ]
1248         )
1249 ])
1250 if test "x$ac_cv_have_intxx_t" = "xyes" ; then
1251         AC_DEFINE(HAVE_INTXX_T)
1252         have_intxx_t=1
1253 fi
1254
1255 if (test -z "$have_intxx_t" && \
1256            test "x$ac_cv_header_stdint_h" = "xyes")
1257 then
1258     AC_MSG_CHECKING([for intXX_t types in stdint.h])
1259         AC_TRY_COMPILE(
1260                 [ #include <stdint.h> ], 
1261                 [ int8_t a; int16_t b; int32_t c; a = b = c = 1;], 
1262                 [
1263                         AC_DEFINE(HAVE_INTXX_T)
1264                         AC_MSG_RESULT(yes)
1265                 ],
1266                 [ AC_MSG_RESULT(no) ]
1267         )
1268 fi
1269
1270 AC_CACHE_CHECK([for int64_t type], ac_cv_have_int64_t, [
1271         AC_TRY_COMPILE(
1272                 [
1273 #include <sys/types.h>
1274 #ifdef HAVE_STDINT_H
1275 # include <stdint.h>
1276 #endif
1277 #include <sys/socket.h>
1278 #ifdef HAVE_SYS_BITYPES_H
1279 # include <sys/bitypes.h>
1280 #endif
1281                 ], 
1282                 [ int64_t a; a = 1;], 
1283                 [ ac_cv_have_int64_t="yes" ],
1284                 [ ac_cv_have_int64_t="no" ]
1285         )
1286 ])
1287 if test "x$ac_cv_have_int64_t" = "xyes" ; then
1288         AC_DEFINE(HAVE_INT64_T)
1289 fi
1290
1291 AC_CACHE_CHECK([for u_intXX_t types], ac_cv_have_u_intxx_t, [
1292         AC_TRY_COMPILE(
1293                 [ #include <sys/types.h> ], 
1294                 [ u_int8_t a; u_int16_t b; u_int32_t c; a = b = c = 1;], 
1295                 [ ac_cv_have_u_intxx_t="yes" ],
1296                 [ ac_cv_have_u_intxx_t="no" ]
1297         )
1298 ])
1299 if test "x$ac_cv_have_u_intxx_t" = "xyes" ; then
1300         AC_DEFINE(HAVE_U_INTXX_T)
1301         have_u_intxx_t=1
1302 fi
1303
1304 if test -z "$have_u_intxx_t" ; then
1305     AC_MSG_CHECKING([for u_intXX_t types in sys/socket.h])
1306         AC_TRY_COMPILE(
1307                 [ #include <sys/socket.h> ], 
1308                 [ u_int8_t a; u_int16_t b; u_int32_t c; a = b = c = 1;], 
1309                 [
1310                         AC_DEFINE(HAVE_U_INTXX_T)
1311                         AC_MSG_RESULT(yes)
1312                 ],
1313                 [ AC_MSG_RESULT(no) ]
1314         )
1315 fi
1316
1317 AC_CACHE_CHECK([for u_int64_t types], ac_cv_have_u_int64_t, [
1318         AC_TRY_COMPILE(
1319                 [ #include <sys/types.h> ], 
1320                 [ u_int64_t a; a = 1;], 
1321                 [ ac_cv_have_u_int64_t="yes" ],
1322                 [ ac_cv_have_u_int64_t="no" ]
1323         )
1324 ])
1325 if test "x$ac_cv_have_u_int64_t" = "xyes" ; then
1326         AC_DEFINE(HAVE_U_INT64_T)
1327         have_u_int64_t=1
1328 fi
1329
1330 if test -z "$have_u_int64_t" ; then
1331     AC_MSG_CHECKING([for u_int64_t type in sys/bitypes.h])
1332         AC_TRY_COMPILE(
1333                 [ #include <sys/bitypes.h> ], 
1334                 [ u_int64_t a; a = 1],
1335                 [
1336                         AC_DEFINE(HAVE_U_INT64_T)
1337                         AC_MSG_RESULT(yes)
1338                 ],
1339                 [ AC_MSG_RESULT(no) ]
1340         )
1341 fi
1342
1343 if test -z "$have_u_intxx_t" ; then
1344         AC_CACHE_CHECK([for uintXX_t types], ac_cv_have_uintxx_t, [
1345                 AC_TRY_COMPILE(
1346                         [
1347 #include <sys/types.h>
1348                         ], 
1349                         [ uint8_t a; uint16_t b; uint32_t c; a = b = c = 1; ], 
1350                         [ ac_cv_have_uintxx_t="yes" ],
1351                         [ ac_cv_have_uintxx_t="no" ]
1352                 )
1353         ])
1354         if test "x$ac_cv_have_uintxx_t" = "xyes" ; then
1355                 AC_DEFINE(HAVE_UINTXX_T)
1356         fi
1357 fi
1358
1359 if test -z "$have_uintxx_t" ; then
1360     AC_MSG_CHECKING([for uintXX_t types in stdint.h])
1361         AC_TRY_COMPILE(
1362                 [ #include <stdint.h> ], 
1363                 [ uint8_t a; uint16_t b; uint32_t c; a = b = c = 1;], 
1364                 [
1365                         AC_DEFINE(HAVE_UINTXX_T)
1366                         AC_MSG_RESULT(yes)
1367                 ],
1368                 [ AC_MSG_RESULT(no) ]
1369         )
1370 fi
1371
1372 if (test -z "$have_u_intxx_t" || test -z "$have_intxx_t" && \
1373            test "x$ac_cv_header_sys_bitypes_h" = "xyes")
1374 then
1375         AC_MSG_CHECKING([for intXX_t and u_intXX_t types in sys/bitypes.h])
1376         AC_TRY_COMPILE(
1377                 [
1378 #include <sys/bitypes.h>
1379                 ], 
1380                 [
1381                         int8_t a; int16_t b; int32_t c;
1382                         u_int8_t e; u_int16_t f; u_int32_t g;
1383                         a = b = c = e = f = g = 1;
1384                 ], 
1385                 [
1386                         AC_DEFINE(HAVE_U_INTXX_T)
1387                         AC_DEFINE(HAVE_INTXX_T)
1388                         AC_MSG_RESULT(yes)
1389                 ],
1390                 [AC_MSG_RESULT(no)]
1391         ) 
1392 fi
1393
1394
1395 AC_CACHE_CHECK([for u_char], ac_cv_have_u_char, [
1396         AC_TRY_COMPILE(
1397                 [
1398 #include <sys/types.h>
1399                 ],
1400                 [ u_char foo; foo = 125; ],
1401                 [ ac_cv_have_u_char="yes" ],
1402                 [ ac_cv_have_u_char="no" ]
1403         )
1404 ])
1405 if test "x$ac_cv_have_u_char" = "xyes" ; then
1406         AC_DEFINE(HAVE_U_CHAR)
1407 fi
1408
1409 TYPE_SOCKLEN_T
1410
1411 AC_CHECK_TYPES(sig_atomic_t,,,[#include <signal.h>])
1412
1413 AC_CACHE_CHECK([for size_t], ac_cv_have_size_t, [
1414         AC_TRY_COMPILE(
1415                 [
1416 #include <sys/types.h>
1417                 ],
1418                 [ size_t foo; foo = 1235; ],
1419                 [ ac_cv_have_size_t="yes" ],
1420                 [ ac_cv_have_size_t="no" ]
1421         )
1422 ])
1423 if test "x$ac_cv_have_size_t" = "xyes" ; then
1424         AC_DEFINE(HAVE_SIZE_T)
1425 fi
1426
1427 AC_CACHE_CHECK([for ssize_t], ac_cv_have_ssize_t, [
1428         AC_TRY_COMPILE(
1429                 [
1430 #include <sys/types.h>
1431                 ],
1432                 [ ssize_t foo; foo = 1235; ],
1433                 [ ac_cv_have_ssize_t="yes" ],
1434                 [ ac_cv_have_ssize_t="no" ]
1435         )
1436 ])
1437 if test "x$ac_cv_have_ssize_t" = "xyes" ; then
1438         AC_DEFINE(HAVE_SSIZE_T)
1439 fi
1440
1441 AC_CACHE_CHECK([for clock_t], ac_cv_have_clock_t, [
1442         AC_TRY_COMPILE(
1443                 [
1444 #include <time.h>
1445                 ],
1446                 [ clock_t foo; foo = 1235; ],
1447                 [ ac_cv_have_clock_t="yes" ],
1448                 [ ac_cv_have_clock_t="no" ]
1449         )
1450 ])
1451 if test "x$ac_cv_have_clock_t" = "xyes" ; then
1452         AC_DEFINE(HAVE_CLOCK_T)
1453 fi
1454
1455 AC_CACHE_CHECK([for sa_family_t], ac_cv_have_sa_family_t, [
1456         AC_TRY_COMPILE(
1457                 [
1458 #include <sys/types.h>
1459 #include <sys/socket.h>
1460                 ],
1461                 [ sa_family_t foo; foo = 1235; ],
1462                 [ ac_cv_have_sa_family_t="yes" ],
1463                 [ AC_TRY_COMPILE(
1464                   [
1465 #include <sys/types.h>
1466 #include <sys/socket.h>
1467 #include <netinet/in.h>
1468                 ],
1469                 [ sa_family_t foo; foo = 1235; ],
1470                 [ ac_cv_have_sa_family_t="yes" ],
1471
1472                 [ ac_cv_have_sa_family_t="no" ]
1473         )]
1474         )
1475 ])
1476 if test "x$ac_cv_have_sa_family_t" = "xyes" ; then
1477         AC_DEFINE(HAVE_SA_FAMILY_T)
1478 fi
1479
1480 AC_CACHE_CHECK([for pid_t], ac_cv_have_pid_t, [
1481         AC_TRY_COMPILE(
1482                 [
1483 #include <sys/types.h>
1484                 ],
1485                 [ pid_t foo; foo = 1235; ],
1486                 [ ac_cv_have_pid_t="yes" ],
1487                 [ ac_cv_have_pid_t="no" ]
1488         )
1489 ])
1490 if test "x$ac_cv_have_pid_t" = "xyes" ; then
1491         AC_DEFINE(HAVE_PID_T)
1492 fi
1493
1494 AC_CACHE_CHECK([for mode_t], ac_cv_have_mode_t, [
1495         AC_TRY_COMPILE(
1496                 [
1497 #include <sys/types.h>
1498                 ],
1499                 [ mode_t foo; foo = 1235; ],
1500                 [ ac_cv_have_mode_t="yes" ],
1501                 [ ac_cv_have_mode_t="no" ]
1502         )
1503 ])
1504 if test "x$ac_cv_have_mode_t" = "xyes" ; then
1505         AC_DEFINE(HAVE_MODE_T)
1506 fi
1507
1508
1509 AC_CACHE_CHECK([for struct sockaddr_storage], ac_cv_have_struct_sockaddr_storage, [
1510         AC_TRY_COMPILE(
1511                 [
1512 #include <sys/types.h>
1513 #include <sys/socket.h>
1514                 ],
1515                 [ struct sockaddr_storage s; ],
1516                 [ ac_cv_have_struct_sockaddr_storage="yes" ],
1517                 [ ac_cv_have_struct_sockaddr_storage="no" ]
1518         )
1519 ])
1520 if test "x$ac_cv_have_struct_sockaddr_storage" = "xyes" ; then
1521         AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE)
1522 fi
1523
1524 AC_CACHE_CHECK([for struct sockaddr_in6], ac_cv_have_struct_sockaddr_in6, [
1525         AC_TRY_COMPILE(
1526                 [
1527 #include <sys/types.h>
1528 #include <netinet/in.h>
1529                 ],
1530                 [ struct sockaddr_in6 s; s.sin6_family = 0; ],
1531                 [ ac_cv_have_struct_sockaddr_in6="yes" ],
1532                 [ ac_cv_have_struct_sockaddr_in6="no" ]
1533         )
1534 ])
1535 if test "x$ac_cv_have_struct_sockaddr_in6" = "xyes" ; then
1536         AC_DEFINE(HAVE_STRUCT_SOCKADDR_IN6)
1537 fi
1538
1539 AC_CACHE_CHECK([for struct in6_addr], ac_cv_have_struct_in6_addr, [
1540         AC_TRY_COMPILE(
1541                 [
1542 #include <sys/types.h>
1543 #include <netinet/in.h>
1544                 ],
1545                 [ struct in6_addr s; s.s6_addr[0] = 0; ],
1546                 [ ac_cv_have_struct_in6_addr="yes" ],
1547                 [ ac_cv_have_struct_in6_addr="no" ]
1548         )
1549 ])
1550 if test "x$ac_cv_have_struct_in6_addr" = "xyes" ; then
1551         AC_DEFINE(HAVE_STRUCT_IN6_ADDR)
1552 fi
1553
1554 AC_CACHE_CHECK([for struct addrinfo], ac_cv_have_struct_addrinfo, [
1555         AC_TRY_COMPILE(
1556                 [
1557 #include <sys/types.h>
1558 #include <sys/socket.h>
1559 #include <netdb.h>
1560                 ],
1561                 [ struct addrinfo s; s.ai_flags = AI_PASSIVE; ],
1562                 [ ac_cv_have_struct_addrinfo="yes" ],
1563                 [ ac_cv_have_struct_addrinfo="no" ]
1564         )
1565 ])
1566 if test "x$ac_cv_have_struct_addrinfo" = "xyes" ; then
1567         AC_DEFINE(HAVE_STRUCT_ADDRINFO)
1568 fi
1569
1570 AC_CACHE_CHECK([for struct timeval], ac_cv_have_struct_timeval, [
1571         AC_TRY_COMPILE(
1572                 [ #include <sys/time.h> ], 
1573                 [ struct timeval tv; tv.tv_sec = 1;], 
1574                 [ ac_cv_have_struct_timeval="yes" ],
1575                 [ ac_cv_have_struct_timeval="no" ]
1576         )
1577 ])
1578 if test "x$ac_cv_have_struct_timeval" = "xyes" ; then
1579         AC_DEFINE(HAVE_STRUCT_TIMEVAL)
1580         have_struct_timeval=1
1581 fi
1582
1583 AC_CHECK_TYPES(struct timespec)
1584
1585 # We need int64_t or else certian parts of the compile will fail.
1586 if test "x$ac_cv_have_int64_t" = "xno" -a \
1587         "x$ac_cv_sizeof_long_int" != "x8" -a \
1588         "x$ac_cv_sizeof_long_long_int" = "x0" ; then
1589         echo "OpenSSH requires int64_t support.  Contact your vendor or install"
1590         echo "an alternative compiler (I.E., GCC) before continuing."
1591         echo ""
1592         exit 1;
1593 else
1594 dnl test snprintf (broken on SCO w/gcc)
1595         AC_TRY_RUN(
1596                 [
1597 #include <stdio.h>
1598 #include <string.h>
1599 #ifdef HAVE_SNPRINTF
1600 main()
1601 {
1602         char buf[50];
1603         char expected_out[50];
1604         int mazsize = 50 ;
1605 #if (SIZEOF_LONG_INT == 8)
1606         long int num = 0x7fffffffffffffff;
1607 #else
1608         long long num = 0x7fffffffffffffffll;
1609 #endif
1610         strcpy(expected_out, "9223372036854775807");
1611         snprintf(buf, mazsize, "%lld", num);
1612         if(strcmp(buf, expected_out) != 0)
1613                 exit(1);
1614         exit(0);
1615 }
1616 #else
1617 main() { exit(0); }
1618 #endif
1619                 ], [ true ], [ AC_DEFINE(BROKEN_SNPRINTF) ]
1620         )
1621 fi
1622
1623 dnl Checks for structure members
1624 OSSH_CHECK_HEADER_FOR_FIELD(ut_host, utmp.h, HAVE_HOST_IN_UTMP)
1625 OSSH_CHECK_HEADER_FOR_FIELD(ut_host, utmpx.h, HAVE_HOST_IN_UTMPX)
1626 OSSH_CHECK_HEADER_FOR_FIELD(syslen, utmpx.h, HAVE_SYSLEN_IN_UTMPX)
1627 OSSH_CHECK_HEADER_FOR_FIELD(ut_pid, utmp.h, HAVE_PID_IN_UTMP)
1628 OSSH_CHECK_HEADER_FOR_FIELD(ut_type, utmp.h, HAVE_TYPE_IN_UTMP)
1629 OSSH_CHECK_HEADER_FOR_FIELD(ut_type, utmpx.h, HAVE_TYPE_IN_UTMPX)
1630 OSSH_CHECK_HEADER_FOR_FIELD(ut_tv, utmp.h, HAVE_TV_IN_UTMP)
1631 OSSH_CHECK_HEADER_FOR_FIELD(ut_id, utmp.h, HAVE_ID_IN_UTMP)
1632 OSSH_CHECK_HEADER_FOR_FIELD(ut_id, utmpx.h, HAVE_ID_IN_UTMPX)
1633 OSSH_CHECK_HEADER_FOR_FIELD(ut_addr, utmp.h, HAVE_ADDR_IN_UTMP)
1634 OSSH_CHECK_HEADER_FOR_FIELD(ut_addr, utmpx.h, HAVE_ADDR_IN_UTMPX)
1635 OSSH_CHECK_HEADER_FOR_FIELD(ut_addr_v6, utmp.h, HAVE_ADDR_V6_IN_UTMP)
1636 OSSH_CHECK_HEADER_FOR_FIELD(ut_addr_v6, utmpx.h, HAVE_ADDR_V6_IN_UTMPX)
1637 OSSH_CHECK_HEADER_FOR_FIELD(ut_exit, utmp.h, HAVE_EXIT_IN_UTMP)
1638 OSSH_CHECK_HEADER_FOR_FIELD(ut_time, utmp.h, HAVE_TIME_IN_UTMP)
1639 OSSH_CHECK_HEADER_FOR_FIELD(ut_time, utmpx.h, HAVE_TIME_IN_UTMPX)
1640 OSSH_CHECK_HEADER_FOR_FIELD(ut_tv, utmpx.h, HAVE_TV_IN_UTMPX)
1641
1642 AC_CHECK_MEMBERS([struct stat.st_blksize])
1643
1644 AC_CACHE_CHECK([for ss_family field in struct sockaddr_storage],
1645                 ac_cv_have_ss_family_in_struct_ss, [
1646         AC_TRY_COMPILE(
1647                 [
1648 #include <sys/types.h>
1649 #include <sys/socket.h>
1650                 ],
1651                 [ struct sockaddr_storage s; s.ss_family = 1; ],
1652                 [ ac_cv_have_ss_family_in_struct_ss="yes" ],
1653                 [ ac_cv_have_ss_family_in_struct_ss="no" ],
1654         )
1655 ])
1656 if test "x$ac_cv_have_ss_family_in_struct_ss" = "xyes" ; then
1657         AC_DEFINE(HAVE_SS_FAMILY_IN_SS)
1658 fi
1659
1660 AC_CACHE_CHECK([for __ss_family field in struct sockaddr_storage],
1661                 ac_cv_have___ss_family_in_struct_ss, [
1662         AC_TRY_COMPILE(
1663                 [
1664 #include <sys/types.h>
1665 #include <sys/socket.h>
1666                 ],
1667                 [ struct sockaddr_storage s; s.__ss_family = 1; ],
1668                 [ ac_cv_have___ss_family_in_struct_ss="yes" ],
1669                 [ ac_cv_have___ss_family_in_struct_ss="no" ]
1670         )
1671 ])
1672 if test "x$ac_cv_have___ss_family_in_struct_ss" = "xyes" ; then
1673         AC_DEFINE(HAVE___SS_FAMILY_IN_SS)
1674 fi
1675
1676 AC_CACHE_CHECK([for pw_class field in struct passwd],
1677                 ac_cv_have_pw_class_in_struct_passwd, [
1678         AC_TRY_COMPILE(
1679                 [
1680 #include <pwd.h>
1681                 ],
1682                 [ struct passwd p; p.pw_class = 0; ],
1683                 [ ac_cv_have_pw_class_in_struct_passwd="yes" ],
1684                 [ ac_cv_have_pw_class_in_struct_passwd="no" ]
1685         )
1686 ])
1687 if test "x$ac_cv_have_pw_class_in_struct_passwd" = "xyes" ; then
1688         AC_DEFINE(HAVE_PW_CLASS_IN_PASSWD)
1689 fi
1690
1691 AC_CACHE_CHECK([for pw_expire field in struct passwd],
1692                 ac_cv_have_pw_expire_in_struct_passwd, [
1693         AC_TRY_COMPILE(
1694                 [
1695 #include <pwd.h>
1696                 ],
1697                 [ struct passwd p; p.pw_expire = 0; ],
1698                 [ ac_cv_have_pw_expire_in_struct_passwd="yes" ],
1699                 [ ac_cv_have_pw_expire_in_struct_passwd="no" ]
1700         )
1701 ])
1702 if test "x$ac_cv_have_pw_expire_in_struct_passwd" = "xyes" ; then
1703         AC_DEFINE(HAVE_PW_EXPIRE_IN_PASSWD)
1704 fi
1705
1706 AC_CACHE_CHECK([for pw_change field in struct passwd],
1707                 ac_cv_have_pw_change_in_struct_passwd, [
1708         AC_TRY_COMPILE(
1709                 [
1710 #include <pwd.h>
1711                 ],
1712                 [ struct passwd p; p.pw_change = 0; ],
1713                 [ ac_cv_have_pw_change_in_struct_passwd="yes" ],
1714                 [ ac_cv_have_pw_change_in_struct_passwd="no" ]
1715         )
1716 ])
1717 if test "x$ac_cv_have_pw_change_in_struct_passwd" = "xyes" ; then
1718         AC_DEFINE(HAVE_PW_CHANGE_IN_PASSWD)
1719 fi
1720
1721 dnl make sure we're using the real structure members and not defines
1722 AC_CACHE_CHECK([for msg_accrights field in struct msghdr],
1723                 ac_cv_have_accrights_in_msghdr, [
1724         AC_TRY_RUN(
1725                 [
1726 #include <sys/types.h>
1727 #include <sys/socket.h>
1728 #include <sys/uio.h>
1729 int main() {
1730 #ifdef msg_accrights
1731 exit(1);
1732 #endif
1733 struct msghdr m;
1734 m.msg_accrights = 0;
1735 exit(0);
1736 }
1737                 ],
1738                 [ ac_cv_have_accrights_in_msghdr="yes" ],
1739                 [ ac_cv_have_accrights_in_msghdr="no" ]
1740         )
1741 ])
1742 if test "x$ac_cv_have_accrights_in_msghdr" = "xyes" ; then
1743         AC_DEFINE(HAVE_ACCRIGHTS_IN_MSGHDR)
1744 fi
1745
1746 AC_CACHE_CHECK([for msg_control field in struct msghdr],
1747                 ac_cv_have_control_in_msghdr, [
1748         AC_TRY_RUN(
1749                 [
1750 #include <sys/types.h>
1751 #include <sys/socket.h>
1752 #include <sys/uio.h>
1753 int main() {
1754 #ifdef msg_control
1755 exit(1);
1756 #endif
1757 struct msghdr m;
1758 m.msg_control = 0;
1759 exit(0);
1760 }
1761                 ],
1762                 [ ac_cv_have_control_in_msghdr="yes" ],
1763                 [ ac_cv_have_control_in_msghdr="no" ]
1764         )
1765 ])
1766 if test "x$ac_cv_have_control_in_msghdr" = "xyes" ; then
1767         AC_DEFINE(HAVE_CONTROL_IN_MSGHDR)
1768 fi
1769
1770 AC_CACHE_CHECK([if libc defines __progname], ac_cv_libc_defines___progname, [
1771         AC_TRY_LINK([], 
1772                 [ extern char *__progname; printf("%s", __progname); ], 
1773                 [ ac_cv_libc_defines___progname="yes" ],
1774                 [ ac_cv_libc_defines___progname="no" ]
1775         )
1776 ])
1777 if test "x$ac_cv_libc_defines___progname" = "xyes" ; then
1778         AC_DEFINE(HAVE___PROGNAME)
1779 fi
1780
1781 AC_CACHE_CHECK([whether $CC implements __FUNCTION__], ac_cv_cc_implements___FUNCTION__, [
1782         AC_TRY_LINK([
1783 #include <stdio.h>
1784 ], 
1785                 [ printf("%s", __FUNCTION__); ], 
1786                 [ ac_cv_cc_implements___FUNCTION__="yes" ],
1787                 [ ac_cv_cc_implements___FUNCTION__="no" ]
1788         )
1789 ])
1790 if test "x$ac_cv_cc_implements___FUNCTION__" = "xyes" ; then
1791         AC_DEFINE(HAVE___FUNCTION__)
1792 fi
1793
1794 AC_CACHE_CHECK([whether $CC implements __func__], ac_cv_cc_implements___func__, [
1795         AC_TRY_LINK([
1796 #include <stdio.h>
1797 ], 
1798                 [ printf("%s", __func__); ], 
1799                 [ ac_cv_cc_implements___func__="yes" ],
1800                 [ ac_cv_cc_implements___func__="no" ]
1801         )
1802 ])
1803 if test "x$ac_cv_cc_implements___func__" = "xyes" ; then
1804         AC_DEFINE(HAVE___func__)
1805 fi
1806
1807 AC_CACHE_CHECK([whether getopt has optreset support],
1808                 ac_cv_have_getopt_optreset, [
1809         AC_TRY_LINK(
1810                 [
1811 #include <getopt.h>
1812                 ],
1813                 [ extern int optreset; optreset = 0; ],
1814                 [ ac_cv_have_getopt_optreset="yes" ],
1815                 [ ac_cv_have_getopt_optreset="no" ]
1816         )
1817 ])
1818 if test "x$ac_cv_have_getopt_optreset" = "xyes" ; then
1819         AC_DEFINE(HAVE_GETOPT_OPTRESET)
1820 fi
1821
1822 AC_CACHE_CHECK([if libc defines sys_errlist], ac_cv_libc_defines_sys_errlist, [
1823         AC_TRY_LINK([], 
1824                 [ extern const char *const sys_errlist[]; printf("%s", sys_errlist[0]);], 
1825                 [ ac_cv_libc_defines_sys_errlist="yes" ],
1826                 [ ac_cv_libc_defines_sys_errlist="no" ]
1827         )
1828 ])
1829 if test "x$ac_cv_libc_defines_sys_errlist" = "xyes" ; then
1830         AC_DEFINE(HAVE_SYS_ERRLIST)
1831 fi
1832
1833
1834 AC_CACHE_CHECK([if libc defines sys_nerr], ac_cv_libc_defines_sys_nerr, [
1835         AC_TRY_LINK([], 
1836                 [ extern int sys_nerr; printf("%i", sys_nerr);], 
1837                 [ ac_cv_libc_defines_sys_nerr="yes" ],
1838                 [ ac_cv_libc_defines_sys_nerr="no" ]
1839         )
1840 ])
1841 if test "x$ac_cv_libc_defines_sys_nerr" = "xyes" ; then
1842         AC_DEFINE(HAVE_SYS_NERR)
1843 fi
1844
1845 SCARD_MSG="no" 
1846 # Check whether user wants sectok support
1847 AC_ARG_WITH(sectok,
1848         [  --with-sectok           Enable smartcard support using libsectok],
1849         [
1850                 if test "x$withval" != "xno" ; then
1851                         if test "x$withval" != "xyes" ; then
1852                                 CPPFLAGS="$CPPFLAGS -I${withval}"
1853                                 LDFLAGS="$LDFLAGS -L${withval}"
1854                                 if test ! -z "$need_dash_r" ; then
1855                                         LDFLAGS="$LDFLAGS -R${withval}"
1856                                 fi
1857                                 if test ! -z "$blibpath" ; then
1858                                         blibpath="$blibpath:${withval}"
1859                                 fi
1860                         fi
1861                         AC_CHECK_HEADERS(sectok.h)
1862                         if test "$ac_cv_header_sectok_h" != yes; then
1863                                 AC_MSG_ERROR(Can't find sectok.h)
1864                         fi
1865                         AC_CHECK_LIB(sectok, sectok_open)
1866                         if test "$ac_cv_lib_sectok_sectok_open" != yes; then
1867                                 AC_MSG_ERROR(Can't find libsectok)
1868                         fi
1869                         AC_DEFINE(SMARTCARD)
1870                         AC_DEFINE(USE_SECTOK)
1871                         SCARD_MSG="yes, using sectok" 
1872                 fi
1873         ]
1874 )
1875
1876 # Check whether user wants OpenSC support
1877 AC_ARG_WITH(opensc,
1878         AC_HELP_STRING([--with-opensc=PFX],
1879                        [Enable smartcard support using OpenSC]),
1880         opensc_config_prefix="$withval", opensc_config_prefix="")
1881 if test x$opensc_config_prefix != x ; then
1882   OPENSC_CONFIG=$opensc_config_prefix/bin/opensc-config
1883   AC_PATH_PROG(OPENSC_CONFIG, opensc-config, no)
1884   if test "$OPENSC_CONFIG" != "no"; then
1885     LIBOPENSC_CFLAGS=`$OPENSC_CONFIG --cflags`
1886     LIBOPENSC_LIBS=`$OPENSC_CONFIG --libs`
1887     CPPFLAGS="$CPPFLAGS $LIBOPENSC_CFLAGS"
1888     LDFLAGS="$LDFLAGS $LIBOPENSC_LIBS"
1889     AC_DEFINE(SMARTCARD)
1890     AC_DEFINE(USE_OPENSC)
1891     SCARD_MSG="yes, using OpenSC" 
1892   fi
1893 fi
1894
1895 # Check whether user wants DNS support
1896 DNS_MSG="no" 
1897 AC_ARG_WITH(dns,
1898         [  --with-dns              Support for fetching keys from DNS (experimental)],
1899         [
1900                 if test "x$withval" != "xno" ; then
1901                         DNS_MSG="yes"
1902                         AC_DEFINE(DNS)
1903                         AC_SEARCH_LIBS(getrrsetbyname, resolv, 
1904                                 [AC_DEFINE(HAVE_GETRRSETBYNAME)],
1905                                 [
1906                                         # Needed by our getrrsetbyname()
1907                                         AC_SEARCH_LIBS(res_query, resolv)
1908                                         AC_SEARCH_LIBS(dn_expand, resolv)
1909                                 ])
1910                 fi
1911         ]
1912 )
1913
1914 # Check whether user wants Kerberos 5 support
1915 KRB5_MSG="no" 
1916 AC_ARG_WITH(kerberos5,
1917         [  --with-kerberos5=PATH   Enable Kerberos 5 support],
1918         [
1919                 if test "x$withval" != "xno" ; then
1920                         if test "x$withval" = "xyes" ; then
1921                                 KRB5ROOT="/usr/local"
1922                         else
1923                                 KRB5ROOT=${withval}
1924                         fi
1925                         CPPFLAGS="$CPPFLAGS -I${KRB5ROOT}/include"
1926                         LDFLAGS="$LDFLAGS -L${KRB5ROOT}/lib"
1927                         AC_DEFINE(KRB5)
1928                         KRB5_MSG="yes"
1929                         AC_MSG_CHECKING(whether we are using Heimdal)
1930                         AC_TRY_COMPILE([ #include <krb5.h> ],
1931                                        [ char *tmp = heimdal_version; ],
1932                                        [ AC_MSG_RESULT(yes)
1933                                          AC_DEFINE(HEIMDAL)
1934                                          K5LIBS="-lkrb5 -ldes -lcom_err -lasn1 -lroken"
1935                                        ],
1936                                        [ AC_MSG_RESULT(no)
1937                                          K5LIBS="-lkrb5 -lk5crypto -lcom_err"
1938                                        ]
1939                         )
1940                         if test ! -z "$need_dash_r" ; then
1941                                 LDFLAGS="$LDFLAGS -R${KRB5ROOT}/lib"
1942                         fi
1943                         if test ! -z "$blibpath" ; then
1944                                 blibpath="$blibpath:${KRB5ROOT}/lib"
1945                         fi
1946                         AC_SEARCH_LIBS(dn_expand, resolv)
1947
1948                         KRB5=yes
1949                 fi
1950         ]
1951 )
1952 LIBS="$LIBS $K5LIBS"
1953
1954 # Looking for programs, paths and files
1955
1956 PRIVSEP_PATH=/var/empty
1957 AC_ARG_WITH(privsep-path,
1958         [  --with-privsep-path=xxx Path for privilege separation chroot (default=/var/empty)],
1959         [
1960                 if test "x$withval" != "$no" ; then
1961                         PRIVSEP_PATH=$withval
1962                 fi
1963         ]
1964 )
1965 AC_SUBST(PRIVSEP_PATH)
1966
1967 AC_ARG_WITH(xauth,
1968         [  --with-xauth=PATH       Specify path to xauth program ],
1969         [
1970                 if test "x$withval" != "xno" ; then
1971                         xauth_path=$withval
1972                 fi
1973         ],
1974         [
1975                 TestPath="$PATH"
1976                 TestPath="${TestPath}${PATH_SEPARATOR}/usr/X/bin"
1977                 TestPath="${TestPath}${PATH_SEPARATOR}/usr/bin/X11"
1978                 TestPath="${TestPath}${PATH_SEPARATOR}/usr/X11R6/bin"
1979                 TestPath="${TestPath}${PATH_SEPARATOR}/usr/openwin/bin"
1980                 AC_PATH_PROG(xauth_path, xauth, , $TestPath)
1981                 if (test ! -z "$xauth_path" && test -x "/usr/openwin/bin/xauth") ; then
1982                         xauth_path="/usr/openwin/bin/xauth"
1983                 fi
1984         ]
1985 )
1986
1987 STRIP_OPT=-s
1988 AC_ARG_ENABLE(strip,
1989         [  --disable-strip         Disable calling strip(1) on install],
1990         [
1991                 if test "x$enableval" = "xno" ; then
1992                         STRIP_OPT=
1993                 fi
1994         ]
1995 )
1996 AC_SUBST(STRIP_OPT)
1997
1998 if test -z "$xauth_path" ; then
1999         XAUTH_PATH="undefined"
2000         AC_SUBST(XAUTH_PATH)
2001 else
2002         AC_DEFINE_UNQUOTED(XAUTH_PATH, "$xauth_path")
2003         XAUTH_PATH=$xauth_path
2004         AC_SUBST(XAUTH_PATH)
2005 fi
2006
2007 # Check for mail directory (last resort if we cannot get it from headers)
2008 if test ! -z "$MAIL" ; then
2009         maildir=`dirname $MAIL`
2010         AC_DEFINE_UNQUOTED(MAIL_DIRECTORY, "$maildir")
2011 fi
2012
2013 if test -z "$no_dev_ptmx" ; then
2014         if test "x$disable_ptmx_check" != "xyes" ; then
2015                 AC_CHECK_FILE("/dev/ptmx", 
2016                         [
2017                                 AC_DEFINE_UNQUOTED(HAVE_DEV_PTMX)
2018                                 have_dev_ptmx=1
2019                         ]
2020                 )
2021         fi
2022 fi
2023 AC_CHECK_FILE("/dev/ptc", 
2024         [
2025                 AC_DEFINE_UNQUOTED(HAVE_DEV_PTS_AND_PTC)
2026                 have_dev_ptc=1
2027         ]
2028 )
2029
2030 # Options from here on. Some of these are preset by platform above
2031 AC_ARG_WITH(mantype,
2032         [  --with-mantype=man|cat|doc  Set man page type],
2033         [
2034                 case "$withval" in
2035                 man|cat|doc)
2036                         MANTYPE=$withval
2037                         ;;
2038                 *)
2039                         AC_MSG_ERROR(invalid man type: $withval)
2040                         ;;
2041                 esac
2042         ]
2043 )
2044 if test -z "$MANTYPE"; then
2045         TestPath="/usr/bin${PATH_SEPARATOR}/usr/ucb"
2046         AC_PATH_PROGS(NROFF, nroff awf, /bin/false, $TestPath)
2047         if ${NROFF} -mdoc ${srcdir}/ssh.1 >/dev/null 2>&1; then
2048                 MANTYPE=doc
2049         elif ${NROFF} -man ${srcdir}/ssh.1 >/dev/null 2>&1; then
2050                 MANTYPE=man
2051         else
2052                 MANTYPE=cat
2053         fi
2054 fi
2055 AC_SUBST(MANTYPE)
2056 if test "$MANTYPE" = "doc"; then
2057         mansubdir=man;
2058 else
2059         mansubdir=$MANTYPE;
2060 fi
2061 AC_SUBST(mansubdir)
2062
2063 # Check whether to enable MD5 passwords
2064 MD5_MSG="no" 
2065 AC_ARG_WITH(md5-passwords,
2066         [  --with-md5-passwords    Enable use of MD5 passwords],
2067         [
2068                 if test "x$withval" != "xno" ; then
2069                         AC_DEFINE(HAVE_MD5_PASSWORDS)
2070                         MD5_MSG="yes" 
2071                 fi
2072         ]
2073 )
2074
2075 # Whether to disable shadow password support
2076 AC_ARG_WITH(shadow,
2077         [  --without-shadow        Disable shadow password support],
2078         [
2079                 if test "x$withval" = "xno" ; then      
2080                         AC_DEFINE(DISABLE_SHADOW)
2081                         disable_shadow=yes
2082                 fi
2083         ]
2084 )
2085
2086 if test -z "$disable_shadow" ; then
2087         AC_MSG_CHECKING([if the systems has expire shadow information])
2088         AC_TRY_COMPILE(
2089         [
2090 #include <sys/types.h>
2091 #include <shadow.h>
2092         struct spwd sp;
2093         ],[ sp.sp_expire = sp.sp_lstchg = sp.sp_inact = 0; ],
2094         [ sp_expire_available=yes ], []
2095         )
2096
2097         if test "x$sp_expire_available" = "xyes" ; then
2098                 AC_MSG_RESULT(yes)
2099                 AC_DEFINE(HAS_SHADOW_EXPIRE)
2100         else
2101                 AC_MSG_RESULT(no)
2102         fi
2103 fi
2104
2105 # Use ip address instead of hostname in $DISPLAY
2106 if test ! -z "$IPADDR_IN_DISPLAY" ; then
2107         DISPLAY_HACK_MSG="yes"
2108         AC_DEFINE(IPADDR_IN_DISPLAY)
2109 else
2110         DISPLAY_HACK_MSG="no" 
2111         AC_ARG_WITH(ipaddr-display,
2112                 [  --with-ipaddr-display   Use ip address instead of hostname in \$DISPLAY],
2113                 [
2114                         if test "x$withval" != "xno" ; then     
2115                                 AC_DEFINE(IPADDR_IN_DISPLAY)
2116                                 DISPLAY_HACK_MSG="yes" 
2117                         fi
2118                 ]
2119         )
2120 fi
2121
2122 dnl BSD systems use /etc/login.conf so --with-default-path= has no effect
2123 if test $ac_cv_func_login_getcapbool = "yes" -a \
2124         $ac_cv_header_login_cap_h = "yes" ; then
2125         USES_LOGIN_CONF=yes
2126 fi
2127 # Whether to mess with the default path
2128 SERVER_PATH_MSG="(default)" 
2129 AC_ARG_WITH(default-path,
2130         [  --with-default-path=    Specify default \$PATH environment for server],
2131         [
2132                 if test "$USES_LOGIN_CONF" = "yes" ; then
2133                         AC_MSG_WARN([
2134 --with-default-path=PATH has no effect on this system.
2135 Edit /etc/login.conf instead.])
2136                 elif test "x$withval" != "xno" ; then   
2137                         user_path="$withval"
2138                         SERVER_PATH_MSG="$withval" 
2139                 fi
2140         ],
2141         [ if test "$USES_LOGIN_CONF" = "yes" ; then
2142         AC_MSG_WARN([Make sure the path to scp is in /etc/login.conf])
2143         else
2144         AC_TRY_RUN(
2145                 [
2146 /* find out what STDPATH is */
2147 #include <stdio.h>
2148 #ifdef HAVE_PATHS_H
2149 # include <paths.h>
2150 #endif
2151 #ifndef _PATH_STDPATH
2152 # ifdef _PATH_USERPATH  /* Irix */
2153 #  define _PATH_STDPATH _PATH_USERPATH
2154 # else
2155 #  define _PATH_STDPATH "/usr/bin:/bin:/usr/sbin:/sbin"
2156 # endif
2157 #endif
2158 #include <sys/types.h>
2159 #include <sys/stat.h>
2160 #include <fcntl.h>
2161 #define DATA "conftest.stdpath"
2162
2163 main()
2164 {
2165         FILE *fd;
2166         int rc;
2167         
2168         fd = fopen(DATA,"w");
2169         if(fd == NULL)
2170                 exit(1);
2171         
2172         if ((rc = fprintf(fd,"%s", _PATH_STDPATH)) < 0)
2173                 exit(1);
2174
2175         exit(0);
2176 }
2177                 ], [ user_path=`cat conftest.stdpath` ],
2178                 [ user_path="/usr/bin:/bin:/usr/sbin:/sbin" ],
2179                 [ user_path="/usr/bin:/bin:/usr/sbin:/sbin" ]
2180         )
2181 # make sure $bindir is in USER_PATH so scp will work
2182                 t_bindir=`eval echo ${bindir}`
2183                 case $t_bindir in
2184                         NONE/*) t_bindir=`echo $t_bindir | sed "s~NONE~$prefix~"` ;;
2185                 esac
2186                 case $t_bindir in
2187                         NONE/*) t_bindir=`echo $t_bindir | sed "s~NONE~$ac_default_prefix~"` ;;
2188                 esac
2189                 echo $user_path | grep ":$t_bindir"  > /dev/null 2>&1
2190                 if test $? -ne 0  ; then
2191                         echo $user_path | grep "^$t_bindir"  > /dev/null 2>&1
2192                         if test $? -ne 0  ; then
2193                                 user_path=$user_path:$t_bindir
2194                                 AC_MSG_RESULT(Adding $t_bindir to USER_PATH so scp will work)
2195                         fi
2196                 fi
2197         fi ]
2198 )
2199 if test "$USES_LOGIN_CONF" != "yes" ; then
2200         AC_DEFINE_UNQUOTED(USER_PATH, "$user_path")
2201         AC_SUBST(user_path)
2202 fi
2203
2204 # Set superuser path separately to user path
2205 AC_ARG_WITH(superuser-path,
2206         [  --with-superuser-path=  Specify different path for super-user],
2207         [
2208                 if test "x$withval" != "xno" ; then
2209                         AC_DEFINE_UNQUOTED(SUPERUSER_PATH, "$withval")
2210                         superuser_path=$withval
2211                 fi
2212         ]
2213 )
2214
2215
2216 AC_MSG_CHECKING([if we need to convert IPv4 in IPv6-mapped addresses])
2217 IPV4_IN6_HACK_MSG="no" 
2218 AC_ARG_WITH(4in6,
2219         [  --with-4in6             Check for and convert IPv4 in IPv6 mapped addresses],
2220         [
2221                 if test "x$withval" != "xno" ; then
2222                         AC_MSG_RESULT(yes)
2223                         AC_DEFINE(IPV4_IN_IPV6)
2224                         IPV4_IN6_HACK_MSG="yes" 
2225                 else
2226                         AC_MSG_RESULT(no)
2227                 fi
2228         ],[
2229                 if test "x$inet6_default_4in6" = "xyes"; then
2230                         AC_MSG_RESULT([yes (default)])
2231                         AC_DEFINE(IPV4_IN_IPV6)
2232                         IPV4_IN6_HACK_MSG="yes" 
2233                 else
2234                         AC_MSG_RESULT([no (default)])
2235                 fi
2236         ]
2237 )
2238
2239 # Whether to enable BSD auth support
2240 BSD_AUTH_MSG=no
2241 AC_ARG_WITH(bsd-auth,
2242         [  --with-bsd-auth         Enable BSD auth support],
2243         [
2244                 if test "x$withval" != "xno" ; then     
2245                         AC_DEFINE(BSD_AUTH)
2246                         BSD_AUTH_MSG=yes
2247                 fi
2248         ]
2249 )
2250
2251 # Where to place sshd.pid
2252 piddir=/var/run
2253 # make sure the directory exists
2254 if test ! -d $piddir ; then     
2255         piddir=`eval echo ${sysconfdir}`
2256         case $piddir in
2257                 NONE/*) piddir=`echo $piddir | sed "s~NONE~$ac_default_prefix~"` ;;
2258         esac
2259 fi
2260
2261 AC_ARG_WITH(pid-dir,
2262         [  --with-pid-dir=PATH     Specify location of ssh.pid file],
2263         [
2264                 if test "x$withval" != "xno" ; then     
2265                         piddir=$withval
2266                         if test ! -d $piddir ; then     
2267                         AC_MSG_WARN([** no $piddir directory on this system **])
2268                         fi
2269                 fi
2270         ]
2271 )
2272
2273 AC_DEFINE_UNQUOTED(_PATH_SSH_PIDDIR, "$piddir")
2274 AC_SUBST(piddir)
2275
2276 dnl allow user to disable some login recording features
2277 AC_ARG_ENABLE(lastlog,
2278         [  --disable-lastlog       disable use of lastlog even if detected [no]],
2279         [
2280                 if test "x$enableval" = "xno" ; then
2281                         AC_DEFINE(DISABLE_LASTLOG)
2282                 fi
2283         ]
2284 )
2285 AC_ARG_ENABLE(utmp,
2286         [  --disable-utmp          disable use of utmp even if detected [no]],
2287         [
2288                 if test "x$enableval" = "xno" ; then
2289                         AC_DEFINE(DISABLE_UTMP)
2290                 fi
2291         ]
2292 )
2293 AC_ARG_ENABLE(utmpx,
2294         [  --disable-utmpx         disable use of utmpx even if detected [no]],
2295         [
2296                 if test "x$enableval" = "xno" ; then
2297                         AC_DEFINE(DISABLE_UTMPX)
2298                 fi
2299         ]
2300 )
2301 AC_ARG_ENABLE(wtmp,
2302         [  --disable-wtmp          disable use of wtmp even if detected [no]],
2303         [
2304                 if test "x$enableval" = "xno" ; then
2305                         AC_DEFINE(DISABLE_WTMP)
2306                 fi
2307         ]
2308 )
2309 AC_ARG_ENABLE(wtmpx,
2310         [  --disable-wtmpx         disable use of wtmpx even if detected [no]],
2311         [
2312                 if test "x$enableval" = "xno" ; then
2313                         AC_DEFINE(DISABLE_WTMPX)
2314                 fi
2315         ]
2316 )
2317 AC_ARG_ENABLE(libutil,
2318         [  --disable-libutil       disable use of libutil (login() etc.) [no]],
2319         [
2320                 if test "x$enableval" = "xno" ; then
2321                         AC_DEFINE(DISABLE_LOGIN)
2322                 fi
2323         ]
2324 )
2325 AC_ARG_ENABLE(pututline,
2326         [  --disable-pututline     disable use of pututline() etc. ([uw]tmp) [no]],
2327         [
2328                 if test "x$enableval" = "xno" ; then
2329                         AC_DEFINE(DISABLE_PUTUTLINE) 
2330                 fi
2331         ]
2332 )
2333 AC_ARG_ENABLE(pututxline,
2334         [  --disable-pututxline    disable use of pututxline() etc. ([uw]tmpx) [no]],
2335         [
2336                 if test "x$enableval" = "xno" ; then
2337                         AC_DEFINE(DISABLE_PUTUTXLINE)
2338                 fi
2339         ]
2340 )
2341 AC_ARG_WITH(lastlog,
2342   [  --with-lastlog=FILE|DIR specify lastlog location [common locations]],
2343         [
2344                 if test "x$withval" = "xno" ; then      
2345                         AC_DEFINE(DISABLE_LASTLOG)
2346                 else
2347                         conf_lastlog_location=$withval
2348                 fi
2349         ]
2350 )
2351
2352 dnl lastlog, [uw]tmpx? detection
2353 dnl  NOTE: set the paths in the platform section to avoid the
2354 dnl   need for command-line parameters
2355 dnl lastlog and [uw]tmp are subject to a file search if all else fails
2356
2357 dnl lastlog detection
2358 dnl  NOTE: the code itself will detect if lastlog is a directory
2359 AC_MSG_CHECKING([if your system defines LASTLOG_FILE])
2360 AC_TRY_COMPILE([
2361 #include <sys/types.h>
2362 #include <utmp.h>
2363 #ifdef HAVE_LASTLOG_H
2364 #  include <lastlog.h>
2365 #endif
2366 #ifdef HAVE_PATHS_H
2367 #  include <paths.h>
2368 #endif
2369 #ifdef HAVE_LOGIN_H
2370 # include <login.h>
2371 #endif
2372         ],
2373         [ char *lastlog = LASTLOG_FILE; ],
2374         [ AC_MSG_RESULT(yes) ],
2375         [
2376                 AC_MSG_RESULT(no)
2377                 AC_MSG_CHECKING([if your system defines _PATH_LASTLOG])
2378                 AC_TRY_COMPILE([
2379 #include <sys/types.h>
2380 #include <utmp.h>
2381 #ifdef HAVE_LASTLOG_H
2382 #  include <lastlog.h>
2383 #endif
2384 #ifdef HAVE_PATHS_H
2385 #  include <paths.h>
2386 #endif
2387                 ],
2388                 [ char *lastlog = _PATH_LASTLOG; ],
2389                 [ AC_MSG_RESULT(yes) ],
2390                 [
2391                         AC_MSG_RESULT(no)
2392                         system_lastlog_path=no
2393                 ])
2394         ]
2395 )
2396
2397 if test -z "$conf_lastlog_location"; then
2398         if test x"$system_lastlog_path" = x"no" ; then
2399                 for f in /var/log/lastlog /usr/adm/lastlog /var/adm/lastlog /etc/security/lastlog ; do
2400                                 if (test -d "$f" || test -f "$f") ; then
2401                                         conf_lastlog_location=$f
2402                                 fi
2403                 done
2404                 if test -z "$conf_lastlog_location"; then
2405                         AC_MSG_WARN([** Cannot find lastlog **])
2406                         dnl Don't define DISABLE_LASTLOG - that means we don't try wtmp/wtmpx
2407                 fi
2408         fi
2409 fi
2410
2411 if test -n "$conf_lastlog_location"; then
2412         AC_DEFINE_UNQUOTED(CONF_LASTLOG_FILE, "$conf_lastlog_location")
2413 fi      
2414
2415 dnl utmp detection
2416 AC_MSG_CHECKING([if your system defines UTMP_FILE])
2417 AC_TRY_COMPILE([
2418 #include <sys/types.h>
2419 #include <utmp.h>
2420 #ifdef HAVE_PATHS_H
2421 #  include <paths.h>
2422 #endif
2423         ],
2424         [ char *utmp = UTMP_FILE; ],
2425         [ AC_MSG_RESULT(yes) ],
2426         [ AC_MSG_RESULT(no)
2427           system_utmp_path=no ]
2428 )
2429 if test -z "$conf_utmp_location"; then
2430         if test x"$system_utmp_path" = x"no" ; then
2431                 for f in /etc/utmp /usr/adm/utmp /var/run/utmp; do
2432                         if test -f $f ; then
2433                                 conf_utmp_location=$f
2434                         fi
2435                 done
2436                 if test -z "$conf_utmp_location"; then
2437                         AC_DEFINE(DISABLE_UTMP)
2438                 fi
2439         fi
2440 fi
2441 if test -n "$conf_utmp_location"; then
2442         AC_DEFINE_UNQUOTED(CONF_UTMP_FILE, "$conf_utmp_location")
2443 fi      
2444
2445 dnl wtmp detection
2446 AC_MSG_CHECKING([if your system defines WTMP_FILE])
2447 AC_TRY_COMPILE([
2448 #include <sys/types.h>
2449 #include <utmp.h>
2450 #ifdef HAVE_PATHS_H
2451 #  include <paths.h>
2452 #endif
2453         ],
2454         [ char *wtmp = WTMP_FILE; ],
2455         [ AC_MSG_RESULT(yes) ],
2456         [ AC_MSG_RESULT(no)
2457           system_wtmp_path=no ]
2458 )
2459 if test -z "$conf_wtmp_location"; then
2460         if test x"$system_wtmp_path" = x"no" ; then
2461                 for f in /usr/adm/wtmp /var/log/wtmp; do
2462                         if test -f $f ; then
2463                                 conf_wtmp_location=$f
2464                         fi
2465                 done
2466                 if test -z "$conf_wtmp_location"; then
2467                         AC_DEFINE(DISABLE_WTMP)
2468                 fi
2469         fi
2470 fi
2471 if test -n "$conf_wtmp_location"; then
2472         AC_DEFINE_UNQUOTED(CONF_WTMP_FILE, "$conf_wtmp_location")
2473 fi      
2474
2475
2476 dnl utmpx detection - I don't know any system so perverse as to require
2477 dnl  utmpx, but not define UTMPX_FILE (ditto wtmpx.) No doubt it's out
2478 dnl  there, though.
2479 AC_MSG_CHECKING([if your system defines UTMPX_FILE])
2480 AC_TRY_COMPILE([
2481 #include <sys/types.h>
2482 #include <utmp.h>
2483 #ifdef HAVE_UTMPX_H
2484 #include <utmpx.h>
2485 #endif
2486 #ifdef HAVE_PATHS_H
2487 #  include <paths.h>
2488 #endif
2489         ],
2490         [ char *utmpx = UTMPX_FILE; ],
2491         [ AC_MSG_RESULT(yes) ],
2492         [ AC_MSG_RESULT(no)
2493           system_utmpx_path=no ]
2494 )
2495 if test -z "$conf_utmpx_location"; then
2496         if test x"$system_utmpx_path" = x"no" ; then
2497                 AC_DEFINE(DISABLE_UTMPX)
2498         fi
2499 else
2500         AC_DEFINE_UNQUOTED(CONF_UTMPX_FILE, "$conf_utmpx_location")
2501 fi      
2502
2503 dnl wtmpx detection
2504 AC_MSG_CHECKING([if your system defines WTMPX_FILE])
2505 AC_TRY_COMPILE([
2506 #include <sys/types.h>
2507 #include <utmp.h>
2508 #ifdef HAVE_UTMPX_H
2509 #include <utmpx.h>
2510 #endif
2511 #ifdef HAVE_PATHS_H
2512 #  include <paths.h>
2513 #endif
2514         ],
2515         [ char *wtmpx = WTMPX_FILE; ],
2516         [ AC_MSG_RESULT(yes) ],
2517         [ AC_MSG_RESULT(no)
2518           system_wtmpx_path=no ]
2519 )
2520 if test -z "$conf_wtmpx_location"; then
2521         if test x"$system_wtmpx_path" = x"no" ; then
2522                 AC_DEFINE(DISABLE_WTMPX)
2523         fi
2524 else
2525         AC_DEFINE_UNQUOTED(CONF_WTMPX_FILE, "$conf_wtmpx_location")
2526 fi      
2527
2528
2529 if test ! -z "$blibpath" ; then
2530         LDFLAGS="$LDFLAGS $blibflags$blibpath"
2531         AC_MSG_WARN([Please check and edit blibpath in LDFLAGS in Makefile])
2532 fi
2533
2534 dnl remove pam and dl because they are in $LIBPAM
2535 if test "$PAM_MSG" = yes ; then
2536         LIBS=`echo $LIBS | sed 's/-lpam //'`
2537 fi
2538 if test "$ac_cv_lib_pam_pam_set_item" = yes ; then
2539         LIBS=`echo $LIBS | sed 's/-ldl //'`
2540 fi
2541
2542 AC_EXEEXT
2543 AC_CONFIG_FILES([Makefile openbsd-compat/Makefile scard/Makefile ssh_prng_cmds])
2544 AC_OUTPUT
2545
2546 # Print summary of options
2547
2548 # Someone please show me a better way :)
2549 A=`eval echo ${prefix}` ; A=`eval echo ${A}`
2550 B=`eval echo ${bindir}` ; B=`eval echo ${B}`
2551 C=`eval echo ${sbindir}` ; C=`eval echo ${C}`
2552 D=`eval echo ${sysconfdir}` ; D=`eval echo ${D}`
2553 E=`eval echo ${libexecdir}/ssh-askpass` ; E=`eval echo ${E}`
2554 F=`eval echo ${mandir}/${mansubdir}X` ; F=`eval echo ${F}`
2555 G=`eval echo ${piddir}` ; G=`eval echo ${G}`
2556 H=`eval echo ${PRIVSEP_PATH}` ; H=`eval echo ${H}`
2557 I=`eval echo ${user_path}` ; I=`eval echo ${I}`
2558 J=`eval echo ${superuser_path}` ; J=`eval echo ${J}`
2559
2560 echo ""
2561 echo "OpenSSH has been configured with the following options:"
2562 echo "                     User binaries: $B"
2563 echo "                   System binaries: $C"
2564 echo "               Configuration files: $D"
2565 echo "                   Askpass program: $E"
2566 echo "                      Manual pages: $F"
2567 echo "                          PID file: $G"
2568 echo "  Privilege separation chroot path: $H"
2569 if test "$USES_LOGIN_CONF" = "yes" ; then
2570 echo "   At runtime, sshd will use the path defined in /etc/login.conf"
2571 else
2572 echo "            sshd default user PATH: $I"
2573 fi
2574 if test ! -z "$superuser_path" ; then
2575 echo "          sshd superuser user PATH: $J"
2576 fi
2577 echo "                    Manpage format: $MANTYPE"
2578 echo "                       DNS support: $DNS_MSG"
2579 echo "                       PAM support: $PAM_MSG"
2580 echo "                 KerberosV support: $KRB5_MSG"
2581 echo "                 Smartcard support: $SCARD_MSG"
2582 echo "                     S/KEY support: $SKEY_MSG"
2583 echo "              TCP Wrappers support: $TCPW_MSG"
2584 echo "              MD5 password support: $MD5_MSG"
2585 echo "       IP address in \$DISPLAY hack: $DISPLAY_HACK_MSG"
2586 echo "           Translate v4 in v6 hack: $IPV4_IN6_HACK_MSG"
2587 echo "                  BSD Auth support: $BSD_AUTH_MSG"
2588 echo "              Random number source: $RAND_MSG"
2589 if test ! -z "$USE_RAND_HELPER" ; then
2590 echo "     ssh-rand-helper collects from: $RAND_HELPER_MSG"
2591 fi
2592
2593 echo ""
2594
2595 echo "              Host: ${host}"
2596 echo "          Compiler: ${CC}"
2597 echo "    Compiler flags: ${CFLAGS}"
2598 echo "Preprocessor flags: ${CPPFLAGS}"
2599 echo "      Linker flags: ${LDFLAGS}"
2600 echo "         Libraries: ${LIBWRAP} ${LIBPAM} ${LIBS}"
2601
2602 echo ""
2603
2604 if test "x$PAM_MSG" = "xyes" ; then
2605         echo "PAM is enabled. You may need to install a PAM control file "
2606         echo "for sshd, otherwise password authentication may fail. "
2607         echo "Example PAM control files can be found in the contrib/ " 
2608         echo "subdirectory"
2609         echo ""
2610 fi
2611
2612 if test ! -z "$RAND_HELPER_CMDHASH" ; then
2613         echo "WARNING: you are using the builtin random number collection "
2614         echo "service. Please read WARNING.RNG and request that your OS "
2615         echo "vendor includes kernel-based random number collection in "
2616         echo "future versions of your OS."
2617         echo ""
2618 fi
2619
This page took 2.876218 seconds and 5 git commands to generate.