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