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