add doc about interaction with RAMRUN to README.Debian in response to #581393
[debian/sudo] / configure.in
1 dnl
2 dnl Process this file with GNU autoconf to produce a configure script.
3 dnl
4 dnl Copyright (c) 1994-1996,1998-2010 Todd C. Miller <Todd.Miller@courtesan.com>
5 dnl
6 AC_INIT([sudo], [1.7.2p6], [http://www.sudo.ws/bugs/], [sudo])
7 AC_CONFIG_HEADER(config.h pathnames.h)
8 dnl
9 dnl This won't work before AC_INIT
10 dnl
11 AC_MSG_NOTICE([Configuring Sudo version $PACKAGE_VERSION])
12 dnl
13 dnl Variables that get substituted in the Makefile and man pages
14 dnl
15 AC_SUBST(HAVE_BSM_AUDIT)
16 AC_SUBST(LIBTOOL)
17 AC_SUBST(CFLAGS)
18 AC_SUBST(PROGS)
19 AC_SUBST(CPPFLAGS)
20 AC_SUBST(LDFLAGS)
21 AC_SUBST(SUDO_LDFLAGS)
22 AC_SUBST(SUDO_OBJS)
23 AC_SUBST(LIBS)
24 AC_SUBST(SUDO_LIBS)
25 AC_SUBST(NET_LIBS)
26 AC_SUBST(AFS_LIBS)
27 AC_SUBST(GETGROUPS_LIB)
28 AC_SUBST(OSDEFS)
29 AC_SUBST(AUTH_OBJS)
30 AC_SUBST(MANTYPE)
31 AC_SUBST(MAN_POSTINSTALL)
32 AC_SUBST(SUDOERS_MODE)
33 AC_SUBST(SUDOERS_UID)
34 AC_SUBST(SUDOERS_GID)
35 AC_SUBST(DEV)
36 AC_SUBST(SELINUX)
37 AC_SUBST(BAMAN)
38 AC_SUBST(LCMAN)
39 AC_SUBST(SEMAN)
40 AC_SUBST(devdir)
41 AC_SUBST(mansectsu)
42 AC_SUBST(mansectform)
43 AC_SUBST(mansrcdir)
44 AC_SUBST(NOEXECFILE)
45 AC_SUBST(NOEXECDIR)
46 AC_SUBST(noexec_file)
47 AC_SUBST(INSTALL_NOEXEC)
48 AC_SUBST(DONT_LEAK_PATH_INFO)
49 AC_SUBST(BSDAUTH_USAGE)
50 AC_SUBST(SELINUX_USAGE)
51 AC_SUBST(LDAP)
52 AC_SUBST(LOGINCAP_USAGE)
53 AC_SUBST(NONUNIX_GROUPS_IMPL)
54 dnl
55 dnl Variables that get substituted in docs (not overridden by environment)
56 dnl
57 AC_SUBST(timedir)dnl initial value from SUDO_TIMEDIR
58 AC_SUBST(timeout)
59 AC_SUBST(password_timeout)
60 AC_SUBST(sudo_umask)
61 AC_SUBST(passprompt)
62 AC_SUBST(long_otp_prompt)
63 AC_SUBST(lecture)
64 AC_SUBST(logfac)
65 AC_SUBST(goodpri)
66 AC_SUBST(badpri)
67 AC_SUBST(loglen)
68 AC_SUBST(ignore_dot)
69 AC_SUBST(mail_no_user)
70 AC_SUBST(mail_no_host)
71 AC_SUBST(mail_no_perms)
72 AC_SUBST(mailto)
73 AC_SUBST(mailsub)
74 AC_SUBST(badpass_message)
75 AC_SUBST(fqdn)
76 AC_SUBST(runas_default)
77 AC_SUBST(env_editor)
78 AC_SUBST(passwd_tries)
79 AC_SUBST(tty_tickets)
80 AC_SUBST(insults)
81 AC_SUBST(root_sudo)
82 AC_SUBST(path_info)
83 AC_SUBST(ldap_conf)
84 AC_SUBST(ldap_secret)
85 AC_SUBST(nsswitch_conf)
86 AC_SUBST(netsvc_conf)
87 AC_SUBST(secure_path)
88 dnl
89 dnl Initial values for above
90 dnl
91 timeout=5
92 password_timeout=5
93 sudo_umask=0022
94 passprompt="Password:"
95 long_otp_prompt=off
96 lecture=once
97 logfac=local2
98 goodpri=notice
99 badpri=alert
100 loglen=80
101 ignore_dot=off
102 mail_no_user=on
103 mail_no_host=off
104 mail_no_perms=off
105 mailto=root
106 mailsub='*** SECURITY information for %h ***'
107 badpass_message='Sorry, try again.'
108 fqdn=off
109 runas_default=root
110 env_editor=off
111 passwd_tries=3
112 tty_tickets=off
113 insults=off
114 root_sudo=on
115 path_info=on
116 secure_path="not set"
117 INSTALL_NOEXEC=
118 devdir='$(srcdir)'
119 dnl
120 dnl Initial values for Makefile variables listed above
121 dnl May be overridden by environment variables..
122 dnl
123 PROGS="sudo visudo"
124 : ${MANTYPE='man'}
125 : ${mansrcdir='.'}
126 : ${SUDOERS_MODE='0440'}
127 : ${SUDOERS_UID='0'}
128 : ${SUDOERS_GID='0'}
129 DEV="#"
130 LDAP="#"
131 SELINUX="#"
132 BAMAN='.\" '
133 LCMAN='.\" '
134 SEMAN='.\" '
135 AUTH_OBJS=
136 AUTH_REG=
137 AUTH_EXCL=
138 AUTH_EXCL_DEF=
139 AUTH_DEF=passwd
140
141 dnl
142 dnl Other vaiables
143 dnl
144 CHECKSHADOW=true
145 shadow_defs=
146 shadow_funcs=
147 shadow_libs=
148 shadow_libs_optional=
149
150 dnl
151 dnl Override default configure dirs...
152 dnl
153 if test X"$prefix" = X"NONE"; then
154     test "$mandir" = '${datarootdir}/man' && mandir='$(prefix)/man'
155 else
156     test "$mandir" = '${datarootdir}/man' && mandir='$(datarootdir)/man'
157 fi
158 test "$bindir" = '${exec_prefix}/bin' && bindir='$(exec_prefix)/bin'
159 test "$sbindir" = '${exec_prefix}/sbin' && sbindir='$(exec_prefix)/sbin'
160 test "$sysconfdir" = '${prefix}/etc' -a X"$with_stow" != X"yes" && sysconfdir='/etc'
161
162 dnl
163 dnl Deprecated --with options (these all warn or generate an error)
164 dnl
165
166 AC_ARG_WITH(otp-only, [AS_HELP_STRING([--with-otp-only], [deprecated])],
167 [case $with_otp_only in
168     yes)        with_passwd="no"
169                 AC_MSG_NOTICE([--with-otp-only option deprecated, treating as --without-passwd])
170                 ;;
171 esac])
172
173 AC_ARG_WITH(alertmail, [AS_HELP_STRING([--with-alertmail], [deprecated])],
174 [case $with_alertmail in
175     *)          with_mailto="$with_alertmail"
176                 AC_MSG_NOTICE([--with-alertmail option deprecated, treating as --mailto])
177                 ;;
178 esac])
179
180 dnl
181 dnl Options for --with
182 dnl
183
184 AC_ARG_WITH(CC, [AS_HELP_STRING([--with-CC], [C compiler to use])],
185 [case $with_CC in
186     yes)        AC_MSG_ERROR(["must give --with-CC an argument."])
187                 ;;
188     no)         AC_MSG_ERROR(["illegal argument: --without-CC."])
189                 ;;
190     *)          CC=$with_CC
191                 ;;
192 esac])
193
194 AC_ARG_WITH(rpath, [AS_HELP_STRING([--with-rpath], [pass -R flag in addition to -L for lib paths])],
195 [case $with_rpath in
196     yes|no)     ;;
197     *)          AC_MSG_ERROR(["--with-rpath does not take an argument."])
198                 ;;
199 esac])
200
201 AC_ARG_WITH(blibpath, [AS_HELP_STRING([--with-blibpath[=PATH]], [pass -blibpath flag to ld for additional lib paths])],
202 [case $with_blibpath in
203     yes|no)     ;;
204     *)          AC_MSG_NOTICE([will pass -blibpath:${with_blibpath} to the loader.])
205                 ;;
206 esac])
207
208 dnl
209 dnl Handle BSM auditing support.
210 dnl
211 AC_ARG_WITH(bsm-audit, [AS_HELP_STRING([--with-bsm-audit], [enable BSM audit support])],
212 [case $with_bsm_audit in
213     yes)        AC_DEFINE(HAVE_BSM_AUDIT)
214                 SUDO_LIBS="${SUDO_LIBS} -lbsm"
215                 SUDO_OBJS="${SUDO_OBJS} bsm_audit.o"
216                 ;;
217     no)         ;;
218     *)          AC_MSG_ERROR(["--with-bsm-audit does not take an argument."])
219                 ;;
220 esac])
221
222 AC_ARG_WITH(incpath, [AS_HELP_STRING([--with-incpath], [additional places to look for include files])],
223 [case $with_incpath in
224     yes)        AC_MSG_ERROR(["must give --with-incpath an argument."])
225                 ;;
226     no)         AC_MSG_ERROR(["--without-incpath not supported."])
227                 ;;
228     *)          AC_MSG_NOTICE([Adding ${with_incpath} to CPPFLAGS])
229                 for i in ${with_incpath}; do
230                     CPPFLAGS="${CPPFLAGS} -I${i}"
231                 done
232                 ;;
233 esac])
234
235 AC_ARG_WITH(libpath, [AS_HELP_STRING([--with-libpath], [additional places to look for libraries])],
236 [case $with_libpath in
237     yes)        AC_MSG_ERROR(["must give --with-libpath an argument."])
238                 ;;
239     no)         AC_MSG_ERROR(["--without-libpath not supported."])
240                 ;;
241     *)          AC_MSG_NOTICE([Adding ${with_libpath} to LDFLAGS])
242                 ;;
243 esac])
244
245 AC_ARG_WITH(libraries, [AS_HELP_STRING([--with-libraries], [additional libraries to link with])],
246 [case $with_libraries in
247     yes)        AC_MSG_ERROR(["must give --with-libraries an argument."])
248                 ;;
249     no)         AC_MSG_ERROR(["--without-libraries not supported."])
250                 ;;
251     *)          AC_MSG_NOTICE([Adding ${with_libraries} to LIBS])
252                 ;;
253 esac])
254
255 AC_ARG_WITH(devel, [AS_HELP_STRING([--with-devel], [add development options])],
256 [case $with_devel in
257     yes)        AC_MSG_NOTICE([Setting up for development: -Wall, flex, yacc])
258                 PROGS="${PROGS} testsudoers"
259                 OSDEFS="${OSDEFS} -DSUDO_DEVEL"
260                 DEV=""
261                 devdir=.
262                 ;;
263     no)         ;;
264     *)          AC_MSG_WARN([Ignoring unknown argument to --with-devel: $with_devel])
265                 ;;
266 esac])
267
268 AC_ARG_WITH(efence, [AS_HELP_STRING([--with-efence], [link with -lefence for malloc() debugging])],
269 [case $with_efence in
270     yes)        AC_MSG_NOTICE([Sudo will link with -lefence (Electric Fence)])
271                 LIBS="${LIBS} -lefence"
272                 if test -f /usr/local/lib/libefence.a; then
273                     with_libpath="${with_libpath} /usr/local/lib"
274                 fi
275                 ;;
276     no)         ;;
277     *)          AC_MSG_WARN([Ignoring unknown argument to --with-efence: $with_efence])
278                 ;;
279 esac])
280
281 AC_ARG_WITH(csops, [AS_HELP_STRING([--with-csops], [add CSOps standard options])],
282 [case $with_csops in
283     yes)        AC_MSG_NOTICE([Adding CSOps standard options])
284                 CHECKSIA=false
285                 with_ignore_dot=yes
286                 insults=on
287                 with_classic_insults=yes
288                 with_csops_insults=yes
289                 with_env_editor=yes
290                 : ${mansectsu='8'}
291                 : ${mansectform='5'}
292                 ;;
293     no)         ;;
294     *)          AC_MSG_WARN([Ignoring unknown argument to --with-csops: $with_csops])
295                 ;;
296 esac])
297
298 AC_ARG_WITH(passwd, [AS_HELP_STRING([--without-passwd], [don't use passwd/shadow file for authentication])],
299 [case $with_passwd in
300     yes|no)     AC_MSG_CHECKING(whether to use shadow/passwd file authentication)
301                 AC_MSG_RESULT($with_passwd)
302                 AUTH_DEF=""
303                 test "$with_passwd" = "yes" && AUTH_REG="$AUTH_REG passwd"
304                 ;;
305     *)          AC_MSG_ERROR(["Sorry, --with-passwd does not take an argument."])
306                 ;;
307 esac])
308
309 AC_ARG_WITH(skey, [AS_HELP_STRING([--with-skey[=DIR]], [enable S/Key support ])],
310 [case $with_skey in
311     no)         with_skey=""
312                 ;;
313     *)          AC_DEFINE(HAVE_SKEY)
314                 AC_MSG_CHECKING(whether to try S/Key authentication)
315                 AC_MSG_RESULT(yes)
316                 AUTH_REG="$AUTH_REG S/Key"
317                 ;;
318 esac])
319
320 AC_ARG_WITH(opie, [AS_HELP_STRING([--with-opie[=DIR]], [enable OPIE support ])],
321 [case $with_opie in
322     no)         with_opie=""
323                 ;;
324     *)          AC_DEFINE(HAVE_OPIE)
325                 AC_MSG_CHECKING(whether to try NRL OPIE authentication)
326                 AC_MSG_RESULT(yes)
327                 AUTH_REG="$AUTH_REG NRL_OPIE"
328                 ;;
329 esac])
330
331 AC_ARG_WITH(long-otp-prompt, [AS_HELP_STRING([--with-long-otp-prompt], [use a two line OTP (skey/opie) prompt])],
332 [case $with_long_otp_prompt in
333     yes)        AC_DEFINE(LONG_OTP_PROMPT)
334                 AC_MSG_CHECKING(whether to use a two line prompt for OTP authentication)
335                 AC_MSG_RESULT(yes)
336                 long_otp_prompt=on
337                 ;;
338     no)         long_otp_prompt=off
339                 ;;
340     *)          AC_MSG_ERROR(["--with-long-otp-prompt does not take an argument."])
341                 ;;
342 esac])
343
344 AC_ARG_WITH(SecurID, [AS_HELP_STRING([--with-SecurID[[=DIR]]], [enable SecurID support])],
345 [case $with_SecurID in
346     no)         with_SecurID="";;
347     *)          AC_DEFINE(HAVE_SECURID)
348                 AC_MSG_CHECKING(whether to use SecurID for authentication)
349                 AC_MSG_RESULT(yes)
350                 AUTH_EXCL="$AUTH_EXCL SecurID"
351                 ;;
352 esac])
353
354 AC_ARG_WITH(fwtk, [AS_HELP_STRING([--with-fwtk[[=DIR]]], [enable FWTK AuthSRV support])],
355 [case $with_fwtk in
356     no)         with_fwtk="";;
357     *)          AC_DEFINE(HAVE_FWTK)
358                 AC_MSG_CHECKING(whether to use FWTK AuthSRV for authentication)
359                 AC_MSG_RESULT(yes)
360                 AUTH_EXCL="$AUTH_EXCL FWTK"
361                 ;;
362 esac])
363
364 AC_ARG_WITH(kerb4, [AS_HELP_STRING([--with-kerb4[[=DIR]]], [enable Kerberos IV support])],
365 [case $with_kerb4 in
366     no)         with_kerb4="";;
367     *)          AC_MSG_CHECKING(whether to try kerberos IV authentication)
368                 AC_MSG_RESULT(yes)
369                 AUTH_REG="$AUTH_REG kerb4"
370                 ;;
371 esac])
372
373 AC_ARG_WITH(kerb5, [AS_HELP_STRING([--with-kerb5[[=DIR]]], [enable Kerberos V support])],
374 [case $with_kerb5 in
375     no)         with_kerb5="";;
376     *)          AC_MSG_CHECKING(whether to try Kerberos V authentication)
377                 AC_MSG_RESULT(yes)
378                 AUTH_REG="$AUTH_REG kerb5"
379                 ;;
380 esac])
381
382 AC_ARG_WITH(aixauth, [AS_HELP_STRING([--with-aixauth], [enable AIX general authentication support])],
383 [case $with_aixauth in
384     yes)        AUTH_EXCL="$AUTH_EXCL AIX_AUTH";;
385     no)         ;;
386     *)          AC_MSG_ERROR(["--with-aixauth does not take an argument."])
387                 ;;
388 esac])
389
390 AC_ARG_WITH(pam, [AS_HELP_STRING([--with-pam], [enable PAM support])],
391 [case $with_pam in
392     yes)        AUTH_EXCL="$AUTH_EXCL PAM";;
393     no)         ;;
394     *)          AC_MSG_ERROR(["--with-pam does not take an argument."])
395                 ;;
396 esac])
397
398 AC_ARG_WITH(AFS, [AS_HELP_STRING([--with-AFS], [enable AFS support])],
399 [case $with_AFS in
400     yes)        AC_DEFINE(HAVE_AFS)
401                 AC_MSG_CHECKING(whether to try AFS (kerberos) authentication)
402                 AC_MSG_RESULT(yes)
403                 AUTH_REG="$AUTH_REG AFS"
404                 ;;
405     no)         ;;
406     *)          AC_MSG_ERROR(["--with-AFS does not take an argument."])
407                 ;;
408 esac])
409
410 AC_ARG_WITH(DCE, [AS_HELP_STRING([--with-DCE], [enable DCE support])],
411 [case $with_DCE in
412     yes)        AC_DEFINE(HAVE_DCE)
413                 AC_MSG_CHECKING(whether to try DCE (kerberos) authentication)
414                 AC_MSG_RESULT(yes)
415                 AUTH_REG="$AUTH_REG DCE"
416                 ;;
417     no)         ;;
418     *)          AC_MSG_ERROR(["--with-DCE does not take an argument."])
419                 ;;
420 esac])
421
422 AC_ARG_WITH(logincap, [AS_HELP_STRING([--with-logincap], [enable BSD login class support])],
423 [case $with_logincap in
424     yes|no)     ;;
425     *)          AC_MSG_ERROR(["--with-logincap does not take an argument."])
426                 ;;
427 esac])
428
429 AC_ARG_WITH(bsdauth, [AS_HELP_STRING([--with-bsdauth], [enable BSD authentication support])],
430 [case $with_bsdauth in
431     yes)        AUTH_EXCL="$AUTH_EXCL BSD_AUTH";;
432     no)         ;;
433     *)          AC_MSG_ERROR(["--with-bsdauth does not take an argument."])
434                 ;;
435 esac])
436
437 AC_ARG_WITH(project, [AS_HELP_STRING([--with-project], [enable Solaris project support])],
438 [case $with_project in
439     yes|no)     ;;
440     no) ;;
441     *)          AC_MSG_ERROR(["--with-project does not take an argument."])
442                 ;;
443 esac])
444
445 AC_MSG_CHECKING(whether to lecture users the first time they run sudo)
446 AC_ARG_WITH(lecture, [AS_HELP_STRING([--without-lecture], [don't print lecture for first-time sudoer])],
447 [case $with_lecture in
448     yes|short|always)   lecture=once
449                 ;;
450     no|none|never)      lecture=never
451                 ;;
452     *)          AC_MSG_ERROR(["unknown argument to --with-lecture: $with_lecture"])
453                 ;;
454 esac])
455 if test "$lecture" = "once"; then
456     AC_MSG_RESULT(yes)
457 else
458     AC_DEFINE(NO_LECTURE)
459     AC_MSG_RESULT(no)
460 fi
461
462 AC_MSG_CHECKING(whether sudo should log via syslog or to a file by default)
463 AC_ARG_WITH(logging, [AS_HELP_STRING([--with-logging], [log via syslog, file, or both])],
464 [case $with_logging in
465     yes)        AC_MSG_ERROR(["must give --with-logging an argument."])
466                 ;;
467     no)         AC_MSG_ERROR(["--without-logging not supported."])
468                 ;;
469     syslog)     AC_DEFINE(LOGGING, SLOG_SYSLOG)
470                 AC_MSG_RESULT(syslog)
471                 ;;
472     file)       AC_DEFINE(LOGGING, SLOG_FILE)
473                 AC_MSG_RESULT(file)
474                 ;;
475     both)       AC_DEFINE(LOGGING, SLOG_BOTH)
476                 AC_MSG_RESULT(both)
477                 ;;
478     *)          AC_MSG_ERROR(["unknown argument to --with-logging: $with_logging"])
479                 ;;
480 esac], [AC_DEFINE(LOGGING, SLOG_SYSLOG) AC_MSG_RESULT(syslog)])
481
482 AC_MSG_CHECKING(which syslog facility sudo should log with)
483 AC_ARG_WITH(logfac, [AS_HELP_STRING([--with-logfac], [syslog facility to log with (default is "local2")])],
484 [case $with_logfac in
485     yes)        AC_MSG_ERROR(["must give --with-logfac an argument."])
486                 ;;
487     no)         AC_MSG_ERROR(["--without-logfac not supported."])
488                 ;;
489     authpriv|auth|daemon|user|local0|local1|local2|local3|local4|local5|local6|local7)          logfac=$with_logfac
490                 ;;
491     *)          AC_MSG_ERROR(["$with_logfac is not a supported syslog facility."])
492                 ;;
493 esac])
494 AC_DEFINE_UNQUOTED(LOGFAC, "$logfac", [The syslog facility sudo will use.])
495 AC_MSG_RESULT($logfac)
496
497 AC_MSG_CHECKING(at which syslog priority to log commands)
498 AC_ARG_WITH(goodpri, [AS_HELP_STRING([--with-goodpri], [syslog priority for commands (def is "notice")])],
499 [case $with_goodpri in
500     yes)        AC_MSG_ERROR(["must give --with-goodpri an argument."])
501                 ;;
502     no)         AC_MSG_ERROR(["--without-goodpri not supported."])
503                 ;;
504     alert|crit|debug|emerg|err|info|notice|warning)
505                 goodpri=$with_goodpri
506                 ;;
507     *)          AC_MSG_ERROR(["$with_goodpri is not a supported syslog priority."])
508                 ;;
509 esac])
510 AC_DEFINE_UNQUOTED(PRI_SUCCESS, "$goodpri", [The syslog priority sudo will use for successful attempts.])
511 AC_MSG_RESULT($goodpri)
512
513 AC_MSG_CHECKING(at which syslog priority to log failures)
514 AC_ARG_WITH(badpri, [AS_HELP_STRING([--with-badpri], [syslog priority for failures (def is "alert")])],
515 [case $with_badpri in
516     yes)        AC_MSG_ERROR(["must give --with-badpri an argument."])
517                 ;;
518     no)         AC_MSG_ERROR(["--without-badpri not supported."])
519                 ;;
520     alert|crit|debug|emerg|err|info|notice|warning)
521                 badpri=$with_badpri
522                 ;;
523     *)          AC_MSG_ERROR([$with_badpri is not a supported syslog priority.])
524                 ;;
525 esac])
526 AC_DEFINE_UNQUOTED(PRI_FAILURE, "$badpri", [The syslog priority sudo will use for unsuccessful attempts/errors.])
527 AC_MSG_RESULT($badpri)
528
529 AC_ARG_WITH(logpath, [AS_HELP_STRING([--with-logpath], [path to the sudo log file])],
530 [case $with_logpath in
531     yes)        AC_MSG_ERROR(["must give --with-logpath an argument."])
532                 ;;
533     no)         AC_MSG_ERROR(["--without-logpath not supported."])
534                 ;;
535 esac])
536
537 AC_MSG_CHECKING(how long a line in the log file should be)
538 AC_ARG_WITH(loglen, [AS_HELP_STRING([--with-loglen], [maximum length of a log file line (default is 80)])],
539 [case $with_loglen in
540     yes)        AC_MSG_ERROR(["must give --with-loglen an argument."])
541                 ;;
542     no)         AC_MSG_ERROR(["--without-loglen not supported."])
543                 ;;
544     [[0-9]]*)   loglen=$with_loglen
545                 ;;
546     *)          AC_MSG_ERROR(["you must enter a number, not $with_loglen"])
547                 ;;
548 esac])
549 AC_DEFINE_UNQUOTED(MAXLOGFILELEN, $loglen, [The max number of chars per log file line (for line wrapping).])
550 AC_MSG_RESULT($loglen)
551
552 AC_MSG_CHECKING(whether sudo should ignore '.' or '' in \$PATH)
553 AC_ARG_WITH(ignore-dot, [AS_HELP_STRING([--with-ignore-dot], [ignore '.' in the PATH])],
554 [case $with_ignore_dot in
555     yes)        ignore_dot=on
556                 ;;
557     no)         ignore_dot=off
558                 ;;
559     *)          AC_MSG_ERROR(["--with-ignore-dot does not take an argument."])
560                 ;;
561 esac])
562 if test "$ignore_dot" = "on"; then
563     AC_DEFINE(IGNORE_DOT_PATH)
564     AC_MSG_RESULT(yes)
565 else
566     AC_MSG_RESULT(no)
567 fi
568
569 AC_MSG_CHECKING(whether to send mail when a user is not in sudoers)
570 AC_ARG_WITH(mail-if-no-user, [AS_HELP_STRING([--without-mail-if-no-user], [do not send mail if user not in sudoers])],
571 [case $with_mail_if_no_user in
572     yes)        mail_no_user=on
573                 ;;
574     no)         mail_no_user=off
575                 ;;
576     *)          AC_MSG_ERROR(["--with-mail-if-no-user does not take an argument."])
577                 ;;
578 esac])
579 if test "$mail_no_user" = "on"; then
580     AC_DEFINE(SEND_MAIL_WHEN_NO_USER)
581     AC_MSG_RESULT(yes)
582 else
583     AC_MSG_RESULT(no)
584 fi
585
586 AC_MSG_CHECKING(whether to send mail when user listed but not for this host)
587 AC_ARG_WITH(mail-if-no-host, [AS_HELP_STRING([--with-mail-if-no-host], [send mail if user in sudoers but not for this host])],
588 [case $with_mail_if_no_host in
589     yes)        mail_no_host=on
590                 ;;
591     no)         mail_no_host=off
592                 ;;
593     *)          AC_MSG_ERROR(["--with-mail-if-no-host does not take an argument."])
594                 ;;
595 esac])
596 if test "$mail_no_host" = "on"; then
597     AC_DEFINE(SEND_MAIL_WHEN_NO_HOST)
598     AC_MSG_RESULT(yes)
599 else
600     AC_MSG_RESULT(no)
601 fi
602
603 AC_MSG_CHECKING(whether to send mail when a user tries a disallowed command)
604 AC_ARG_WITH(mail-if-noperms, [AS_HELP_STRING([--with-mail-if-noperms], [send mail if user not allowed to run command])],
605 [case $with_mail_if_noperms in
606     yes)        mail_noperms=on
607                 ;;
608     no)         mail_noperms=off
609                 ;;
610     *)          AC_MSG_ERROR(["--with-mail-if-noperms does not take an argument."])
611                 ;;
612 esac])
613 if test "$mail_noperms" = "on"; then
614     AC_DEFINE(SEND_MAIL_WHEN_NOT_OK)
615     AC_MSG_RESULT(yes)
616 else
617     AC_MSG_RESULT(no)
618 fi
619
620 AC_MSG_CHECKING(who should get the mail that sudo sends)
621 AC_ARG_WITH(mailto, [AS_HELP_STRING([--with-mailto], [who should get sudo mail (default is "root")])],
622 [case $with_mailto in
623     yes)        AC_MSG_ERROR(["must give --with-mailto an argument."])
624                 ;;
625     no)         AC_MSG_ERROR(["--without-mailto not supported."])
626                 ;;
627     *)          mailto=$with_mailto
628                 ;;
629 esac])
630 AC_DEFINE_UNQUOTED(MAILTO, "$mailto", [The user or email address that sudo mail is sent to.])
631 AC_MSG_RESULT([$mailto])
632
633 AC_ARG_WITH(mailsubject, [AS_HELP_STRING([--with-mailsubject], [subject of sudo mail])],
634 [case $with_mailsubject in
635     yes)        AC_MSG_ERROR(["must give --with-mailsubject an argument."])
636                 ;;
637     no)         AC_MSG_WARN([Sorry, --without-mailsubject not supported.])
638                 ;;
639     *)          mailsub="$with_mailsubject"
640                 AC_MSG_CHECKING(sudo mail subject)
641                 AC_MSG_RESULT([Using alert mail subject: $mailsub])
642                 ;;
643 esac])
644 AC_DEFINE_UNQUOTED(MAILSUBJECT, "$mailsub", [The subject of the mail sent by sudo to the MAILTO user/address.])
645
646 AC_MSG_CHECKING(for bad password prompt)
647 AC_ARG_WITH(passprompt, [AS_HELP_STRING([--with-passprompt], [default password prompt])],
648 [case $with_passprompt in
649     yes)        AC_MSG_ERROR(["must give --with-passprompt an argument."])
650                 ;;
651     no)         AC_MSG_WARN([Sorry, --without-passprompt not supported.])
652                 ;;
653     *)          passprompt="$with_passprompt"
654 esac])
655 AC_MSG_RESULT($passprompt)
656 AC_DEFINE_UNQUOTED(PASSPROMPT, "$passprompt", [The default password prompt.])
657
658 AC_MSG_CHECKING(for bad password message)
659 AC_ARG_WITH(badpass-message, [AS_HELP_STRING([--with-badpass-message], [message the user sees when the password is wrong])],
660 [case $with_badpass_message in
661     yes)        AC_MSG_ERROR(["Must give --with-badpass-message an argument."])
662                 ;;
663     no)         AC_MSG_WARN([Sorry, --without-badpass-message not supported.])
664                 ;;
665     *)          badpass_message="$with_badpass_message"
666                 ;;
667 esac])
668 AC_DEFINE_UNQUOTED(INCORRECT_PASSWORD, "$badpass_message", [The message given when a bad password is entered.])
669 AC_MSG_RESULT([$badpass_message])
670
671 AC_MSG_CHECKING(whether to expect fully qualified hosts in sudoers)
672 AC_ARG_WITH(fqdn, [AS_HELP_STRING([--with-fqdn], [expect fully qualified hosts in sudoers])],
673 [case $with_fqdn in
674     yes)        fqdn=on
675                 ;;
676     no)         fqdn=off
677                 ;;
678     *)          AC_MSG_ERROR(["--with-fqdn does not take an argument."])
679                 ;;
680 esac])
681 if test "$fqdn" = "on"; then
682     AC_DEFINE(FQDN)
683     AC_MSG_RESULT(yes)
684 else
685     AC_MSG_RESULT(no)
686 fi
687
688 AC_ARG_WITH(timedir, [AS_HELP_STRING([--with-timedir], [path to the sudo timestamp dir])],
689 [case $with_timedir in
690     yes)        AC_MSG_ERROR(["must give --with-timedir an argument."])
691                 ;;
692     no)         AC_MSG_ERROR(["--without-timedir not supported."])
693                 ;;
694 esac])
695
696 AC_ARG_WITH(sendmail, [AS_HELP_STRING([--with-sendmail], [set path to sendmail])
697 AS_HELP_STRING([--without-sendmail], [do not send mail at all])],
698 [case $with_sendmail in
699     yes)        with_sendmail=""
700                 ;;
701     no)         ;;
702     *)          SUDO_DEFINE_UNQUOTED(_PATH_SUDO_SENDMAIL, "$with_sendmail")
703                 ;;
704 esac])
705
706 AC_ARG_WITH(sudoers-mode, [AS_HELP_STRING([--with-sudoers-mode], [mode of sudoers file (defaults to 0440)])],
707 [case $with_sudoers_mode in
708     yes)        AC_MSG_ERROR(["must give --with-sudoers-mode an argument."])
709                 ;;
710     no)         AC_MSG_ERROR(["--without-sudoers-mode not supported."])
711                 ;;
712     [[1-9]]*)   SUDOERS_MODE=0${with_sudoers_mode}
713                 ;;
714     0*)         SUDOERS_MODE=$with_sudoers_mode
715                 ;;
716     *)          AC_MSG_ERROR(["you must use an octal mode, not a name."])
717                 ;;
718 esac])
719
720 AC_ARG_WITH(sudoers-uid, [AS_HELP_STRING([--with-sudoers-uid], [uid that owns sudoers file (defaults to 0)])],
721 [case $with_sudoers_uid in
722     yes)        AC_MSG_ERROR(["must give --with-sudoers-uid an argument."])
723                 ;;
724     no)         AC_MSG_ERROR(["--without-sudoers-uid not supported."])
725                 ;;
726     [[0-9]]*)   SUDOERS_UID=$with_sudoers_uid
727                 ;;
728     *)          AC_MSG_ERROR(["you must use an unsigned numeric uid, not a name."])
729                 ;;
730 esac])
731
732 AC_ARG_WITH(sudoers-gid, [AS_HELP_STRING([--with-sudoers-gid], [gid that owns sudoers file (defaults to 0)])],
733 [case $with_sudoers_gid in
734     yes)        AC_MSG_ERROR(["must give --with-sudoers-gid an argument."])
735                 ;;
736     no)         AC_MSG_ERROR(["--without-sudoers-gid not supported."])
737                 ;;
738     [[0-9]]*)   SUDOERS_GID=$with_sudoers_gid
739                 ;;
740     *)          AC_MSG_ERROR(["you must use an unsigned numeric gid, not a name."])
741                 ;;
742 esac])
743
744 AC_MSG_CHECKING(for umask programs should be run with)
745 AC_ARG_WITH(umask, [AS_HELP_STRING([--with-umask], [umask with which the prog should run (default is 022)])
746 AS_HELP_STRING([--without-umask], [Preserves the umask of the user invoking sudo.])],
747 [case $with_umask in
748     yes)        AC_MSG_ERROR(["must give --with-umask an argument."])
749                 ;;
750     no)         sudo_umask=0777
751                 ;;
752     [[0-9]]*)   sudo_umask=$with_umask
753                 ;;
754     *)          AC_MSG_ERROR(["you must enter a numeric mask."])
755                 ;;
756 esac])
757 AC_DEFINE_UNQUOTED(SUDO_UMASK, $sudo_umask, [The umask that the root-run prog should use.])
758 if test "$sudo_umask" = "0777"; then
759     AC_MSG_RESULT(user)
760 else
761     AC_MSG_RESULT($sudo_umask)
762 fi
763
764 AC_MSG_CHECKING(for default user to run commands as)
765 AC_ARG_WITH(runas-default, [AS_HELP_STRING([--with-runas-default], [User to run commands as (default is "root")])],
766 [case $with_runas_default in
767     yes)        AC_MSG_ERROR(["must give --with-runas-default an argument."])
768                 ;;
769     no)         AC_MSG_ERROR(["--without-runas-default not supported."])
770                 ;;
771     *)          runas_default="$with_runas_default"
772                 ;;
773 esac])
774 AC_DEFINE_UNQUOTED(RUNAS_DEFAULT, "$runas_default", [The user sudo should run commands as by default.])
775 AC_MSG_RESULT([$runas_default])
776
777 AC_ARG_WITH(exempt, [AS_HELP_STRING([--with-exempt=group], [no passwd needed for users in this group])],
778 [case $with_exempt in
779     yes)        AC_MSG_ERROR(["must give --with-exempt an argument."])
780                 ;;
781     no)         AC_MSG_ERROR(["--without-exempt not supported."])
782                 ;;
783     *)          AC_DEFINE_UNQUOTED(EXEMPTGROUP, "$with_exempt", [If defined, users in this group need not enter a passwd (ie "sudo").])
784                 AC_MSG_CHECKING(for group to be exempt from password)
785                 AC_MSG_RESULT([$with_exempt])
786                 ;;
787 esac])
788
789 AC_MSG_CHECKING(for editor that visudo should use)
790 AC_ARG_WITH(editor, [AS_HELP_STRING([--with-editor=path], [Default editor for visudo (defaults to vi)])],
791 [case $with_editor in
792     yes)        AC_MSG_ERROR(["must give --with-editor an argument."])
793                 ;;
794     no)         AC_MSG_ERROR(["--without-editor not supported."])
795                 ;;
796     *)          AC_DEFINE_UNQUOTED(EDITOR, "$with_editor", [A colon-separated list of pathnames to be used as the editor for visudo.])
797                 AC_MSG_RESULT([$with_editor])
798                 ;;
799 esac], [AC_DEFINE(EDITOR, _PATH_VI) AC_MSG_RESULT(vi)])
800
801 AC_MSG_CHECKING(whether to obey EDITOR and VISUAL environment variables)
802 AC_ARG_WITH(env-editor, [AS_HELP_STRING([--with-env-editor], [Use the environment variable EDITOR for visudo])],
803 [case $with_env_editor in
804     yes)        env_editor=on
805                 ;;
806     no)         env_editor=off
807                 ;;
808     *)          AC_MSG_ERROR(["--with-env-editor does not take an argument."])
809                 ;;
810 esac])
811 if test "$env_editor" = "on"; then
812     AC_DEFINE(ENV_EDITOR)
813     AC_MSG_RESULT(yes)
814 else
815     AC_MSG_RESULT(no)
816 fi
817
818 AC_MSG_CHECKING(number of tries a user gets to enter their password)
819 AC_ARG_WITH(passwd-tries, [AS_HELP_STRING([--with-passwd-tries], [number of tries to enter password (default is 3)])],
820 [case $with_passwd_tries in
821     yes)        ;;
822     no)         AC_MSG_ERROR(["--without-editor not supported."])
823                 ;;
824     [[1-9]]*)   passwd_tries=$with_passwd_tries
825                 ;;
826     *)          AC_MSG_ERROR(["you must enter the numer of tries, > 0"])
827                 ;;
828 esac])
829 AC_DEFINE_UNQUOTED(TRIES_FOR_PASSWORD, $passwd_tries, [The number of tries a user gets to enter their password.])
830 AC_MSG_RESULT($passwd_tries)
831
832 AC_MSG_CHECKING(time in minutes after which sudo will ask for a password again)
833 AC_ARG_WITH(timeout, [AS_HELP_STRING([--with-timeout], [minutes before sudo asks for passwd again (def is 5 minutes)])],
834 [case $with_timeout in
835     yes)        ;;
836     no)         timeout=0
837                 ;;
838     [[0-9]]*)   timeout=$with_timeout
839                 ;;
840     *)          AC_MSG_ERROR(["you must enter the numer of minutes."])
841                 ;;
842 esac])
843 AC_DEFINE_UNQUOTED(TIMEOUT, $timeout, [The number of minutes before sudo asks for a password again.])
844 AC_MSG_RESULT($timeout)
845
846 AC_MSG_CHECKING(time in minutes after the password prompt will time out)
847 AC_ARG_WITH(password-timeout, [AS_HELP_STRING([--with-password-timeout], [passwd prompt timeout in minutes (default is 5 minutes)])],
848 [case $with_password_timeout in
849     yes)        ;;
850     no)         password_timeout=0
851                 ;;
852     [[0-9]]*)   password_timeout=$with_password_timeout
853                 ;;
854     *)          AC_MSG_ERROR(["you must enter the numer of minutes."])
855                 ;;
856 esac])
857 AC_DEFINE_UNQUOTED(PASSWORD_TIMEOUT, $password_timeout, [The passwd prompt timeout (in minutes).])
858 AC_MSG_RESULT($password_timeout)
859
860 AC_MSG_CHECKING(whether to use per-tty ticket files)
861 AC_ARG_WITH(tty-tickets, [AS_HELP_STRING([--with-tty-tickets], [use a different ticket file for each tty])],
862 [case $with_tty_tickets in
863     yes)        tty_tickets=on
864                 ;;
865     no)         tty_tickets=off
866                 ;;
867     *)          AC_MSG_ERROR(["--with-tty-tickets does not take an argument."])
868                 ;;
869 esac])
870 if test "$tty_tickets" = "on"; then
871     AC_DEFINE(USE_TTY_TICKETS)
872     AC_MSG_RESULT(yes)
873 else
874     AC_MSG_RESULT(no)
875 fi
876
877 AC_MSG_CHECKING(whether to include insults)
878 AC_ARG_WITH(insults, [AS_HELP_STRING([--with-insults], [insult the user for entering an incorrect password])],
879 [case $with_insults in
880     yes)        insults=on
881                 with_classic_insults=yes
882                 with_csops_insults=yes
883                 ;;
884     no)         insults=off
885                 ;;
886     *)          AC_MSG_ERROR(["--with-insults does not take an argument."])
887                 ;;
888 esac])
889 if test "$insults" = "on"; then
890     AC_DEFINE(USE_INSULTS)
891     AC_MSG_RESULT(yes)
892 else
893     AC_MSG_RESULT(no)
894 fi
895
896 AC_ARG_WITH(all-insults, [AS_HELP_STRING([--with-all-insults], [include all the sudo insult sets])],
897 [case $with_all_insults in
898     yes)        with_classic_insults=yes
899                 with_csops_insults=yes
900                 with_hal_insults=yes
901                 with_goons_insults=yes
902                 ;;
903     no)         ;;
904     *)          AC_MSG_ERROR(["--with-all-insults does not take an argument."])
905                 ;;
906 esac])
907
908 AC_ARG_WITH(classic-insults, [AS_HELP_STRING([--with-classic-insults], [include the insults from the "classic" sudo])],
909 [case $with_classic_insults in
910     yes)        AC_DEFINE(CLASSIC_INSULTS)
911                 ;;
912     no)         ;;
913     *)          AC_MSG_ERROR(["--with-classic-insults does not take an argument."])
914                 ;;
915 esac])
916
917 AC_ARG_WITH(csops-insults, [AS_HELP_STRING([--with-csops-insults], [include CSOps insults])],
918 [case $with_csops_insults in
919     yes)        AC_DEFINE(CSOPS_INSULTS)
920                 ;;
921     no)         ;;
922     *)          AC_MSG_ERROR(["--with-csops-insults does not take an argument."])
923                 ;;
924 esac])
925
926 AC_ARG_WITH(hal-insults, [AS_HELP_STRING([--with-hal-insults], [include 2001-like insults])],
927 [case $with_hal_insults in
928     yes)        AC_DEFINE(HAL_INSULTS)
929                 ;;
930     no)         ;;
931     *)          AC_MSG_ERROR(["--with-hal-insults does not take an argument."])
932                 ;;
933 esac])
934
935 AC_ARG_WITH(goons-insults, [AS_HELP_STRING([--with-goons-insults], [include the insults from the "Goon Show"])],
936 [case $with_goons_insults in
937     yes)        AC_DEFINE(GOONS_INSULTS)
938                 ;;
939     no)         ;;
940     *)          AC_MSG_ERROR(["--with-goons-insults does not take an argument."])
941                 ;;
942 esac])
943
944 AC_ARG_WITH(nsswitch, [AS_HELP_STRING([--with-nsswitch[[=PATH]]], [path to nsswitch.conf])],
945 [case $with_nsswitch in
946     no)         ;;
947     yes)        with_nsswitch="/etc/nsswitch.conf"
948                 ;;
949     *)          ;;
950 esac])
951
952 AC_ARG_WITH(ldap, [AS_HELP_STRING([--with-ldap[[=DIR]]], [enable LDAP support])],
953 [case $with_ldap in
954     no)         ;;
955     *)          AC_DEFINE(HAVE_LDAP)
956                 AC_MSG_CHECKING(whether to use sudoers from LDAP)
957                 AC_MSG_RESULT(yes)
958                 ;;
959 esac])
960
961 AC_ARG_WITH(ldap-conf-file, [AS_HELP_STRING([--with-ldap-conf-file], [path to LDAP configuration file])])
962 SUDO_DEFINE_UNQUOTED(_PATH_LDAP_CONF, "${with_ldap_conf_file-/etc/ldap.conf}", [Path to the ldap.conf file])
963 ldap_conf=${with_ldap_conf_file-'/etc/ldap.conf'}
964
965 AC_ARG_WITH(ldap-secret-file, [AS_HELP_STRING([--with-ldap-secret-file], [path to LDAP secret password file])])
966 SUDO_DEFINE_UNQUOTED(_PATH_LDAP_SECRET, "${with_ldap_secret_file-/etc/ldap.secret}", [Path to the ldap.secret file])
967 ldap_secret=${with_ldap_secret_file-'/etc/ldap.secret'}
968
969 AC_ARG_WITH(pc-insults, [AS_HELP_STRING([--with-pc-insults], [replace politically incorrect insults with less offensive ones])],
970 [case $with_pc_insults in
971     yes)        AC_DEFINE(PC_INSULTS)
972                 ;;
973     no)         ;;
974     *)          AC_MSG_ERROR(["--with-pc-insults does not take an argument."])
975                 ;;
976 esac])
977
978 dnl include all insult sets on one line
979 if test "$insults" = "on"; then
980     AC_MSG_CHECKING(which insult sets to include)
981     i=""
982     test "$with_goons_insults" = "yes" && i="goons ${i}"
983     test "$with_hal_insults" = "yes" && i="hal ${i}"
984     test "$with_csops_insults" = "yes" && i="csops ${i}"
985     test "$with_classic_insults" = "yes" && i="classic ${i}"
986     AC_MSG_RESULT([$i])
987 fi
988
989 AC_MSG_CHECKING(whether to override the user's path)
990 AC_ARG_WITH(secure-path, [AS_HELP_STRING([--with-secure-path], [override the user's path with a built-in one])],
991 [case $with_secure_path in
992     yes)        with_secure_path="/bin:/usr/ucb:/usr/bin:/usr/sbin:/sbin:/usr/etc:/etc"
993                 AC_DEFINE_UNQUOTED(SECURE_PATH, "$with_secure_path")
994                 AC_MSG_RESULT([$with_secure_path])
995                 secure_path="set to $with_secure_path"
996                 ;;
997     no)         AC_MSG_RESULT(no)
998                 ;;
999     *)          AC_DEFINE_UNQUOTED(SECURE_PATH, "$with_secure_path")
1000                 AC_MSG_RESULT([$with_secure_path])
1001                 secure_path="set to F<$with_secure_path>"
1002                 ;;
1003 esac], AC_MSG_RESULT(no))
1004
1005 AC_MSG_CHECKING(whether to get ip addresses from the network interfaces)
1006 AC_ARG_WITH(interfaces, [AS_HELP_STRING([--without-interfaces], [don't try to read the ip addr of ether interfaces])],
1007 [case $with_interfaces in
1008     yes)        AC_MSG_RESULT(yes)
1009                 ;;
1010     no)         AC_DEFINE(STUB_LOAD_INTERFACES)
1011                 AC_MSG_RESULT(no)
1012                 ;;
1013     *)          AC_MSG_ERROR(["--with-interfaces does not take an argument."])
1014                 ;;
1015 esac], AC_MSG_RESULT(yes))
1016
1017 AC_MSG_CHECKING(whether stow should be used)
1018 AC_ARG_WITH(stow, [AS_HELP_STRING([--with-stow], [properly handle GNU stow packaging])],
1019 [case $with_stow in
1020     yes)        AC_MSG_RESULT(yes)
1021                 AC_DEFINE(USE_STOW)
1022                 ;;
1023     no)         AC_MSG_RESULT(no)
1024                 ;;
1025     *)          AC_MSG_ERROR(["--with-stow does not take an argument."])
1026                 ;;
1027 esac], AC_MSG_RESULT(no))
1028
1029 AC_MSG_CHECKING(whether to use an askpass helper)
1030 AC_ARG_WITH(askpass, [AS_HELP_STRING([--with-askpass=PATH], [Fully qualified pathname of askpass helper])],
1031 [case $with_askpass in
1032     yes)        AC_MSG_ERROR(["--with-askpass takes a path as an argument."])
1033                 ;;
1034     no)         ;;
1035     *)          AC_DEFINE_UNQUOTED(_PATH_SUDO_ASKPASS, "$with_askpass", [The fully qualified pathname of askpass])
1036                 ;;
1037 esac], AC_MSG_RESULT(no))
1038
1039 dnl
1040 dnl If enabled, set LIBVAS_SO, LIBVAS_RPATH and USING_NONUNIX_GROUPS
1041 dnl
1042 AC_ARG_WITH(libvas, [AS_HELP_STRING([--with-libvas=NAME], [Name of the libvas shared library (default=libvas.so)])],
1043 [case $with_libvas in
1044     yes)        with_libvas=libvas.so
1045                 ;;
1046     no)         ;;
1047     *)          AC_DEFINE_UNQUOTED([LIBVAS_SO], ["$with_with_libvas"], [The name of libvas.so])
1048                 ;;
1049 esac
1050 if test X"$with_libvas" != X"no"; then
1051     AC_DEFINE_UNQUOTED([LIBVAS_SO], ["$with_libvas"], [The name of libvas.so])
1052     AC_DEFINE(USING_NONUNIX_GROUPS)
1053     NONUNIX_GROUPS_IMPL="vasgroups.o"
1054     AC_ARG_WITH([libvas-rpath],
1055        [AS_HELP_STRING([--with-libvas-rpath=PATH],
1056                        [Path to look for libvas in [default=/opt/quest/lib]])],
1057        [LIBVAS_RPATH=$withval],
1058        [LIBVAS_RPATH=/opt/quest/lib])
1059 fi
1060 ])
1061
1062 dnl
1063 dnl Options for --enable
1064 dnl
1065
1066 AC_MSG_CHECKING(whether to do user authentication by default)
1067 AC_ARG_ENABLE(authentication,
1068 [AS_HELP_STRING([--disable-authentication], [Do not require authentication by default])],
1069 [ case "$enableval" in
1070     yes)        AC_MSG_RESULT(yes)
1071                 ;;
1072     no)         AC_MSG_RESULT(no)
1073                 AC_DEFINE(NO_AUTHENTICATION)
1074                 ;;
1075     *)          AC_MSG_RESULT(no)
1076                 AC_MSG_WARN([Ignoring unknown argument to --enable-authentication: $enableval])
1077                 ;;
1078   esac
1079 ], AC_MSG_RESULT(yes))
1080
1081 AC_MSG_CHECKING(whether to disable running the mailer as root)
1082 AC_ARG_ENABLE(root-mailer,
1083 [AS_HELP_STRING([--disable-root-mailer], [Don't run the mailer as root, run as the user])],
1084 [ case "$enableval" in
1085     yes)        AC_MSG_RESULT(no)
1086                 ;;
1087     no)         AC_MSG_RESULT(yes)
1088                 AC_DEFINE(NO_ROOT_MAILER)
1089                 ;;
1090     *)          AC_MSG_RESULT(no)
1091                 AC_MSG_WARN([Ignoring unknown argument to --enable-root-mailer: $enableval])
1092                 ;;
1093   esac
1094 ], AC_MSG_RESULT(no))
1095
1096 AC_ARG_ENABLE(setreuid,
1097 [AS_HELP_STRING([--disable-setreuid], [Don't try to use the setreuid() function])],
1098 [ case "$enableval" in
1099     no)         SKIP_SETREUID=yes
1100                 ;;
1101     *)          ;;
1102   esac
1103 ])
1104
1105 AC_ARG_ENABLE(setresuid,
1106 [AS_HELP_STRING([--disable-setresuid], [Don't try to use the setresuid() function])],
1107 [ case "$enableval" in
1108     no)         SKIP_SETRESUID=yes
1109                 ;;
1110     *)          ;;
1111   esac
1112 ])
1113
1114 AC_MSG_CHECKING(whether to disable shadow password support)
1115 AC_ARG_ENABLE(shadow,
1116 [AS_HELP_STRING([--disable-shadow], [Never use shadow passwords])],
1117 [ case "$enableval" in
1118     yes)        AC_MSG_RESULT(no)
1119                 ;;
1120     no)         AC_MSG_RESULT(yes)
1121                 CHECKSHADOW="false"
1122                 ;;
1123     *)          AC_MSG_RESULT(no)
1124                 AC_MSG_WARN([Ignoring unknown argument to --enable-shadow: $enableval])
1125                 ;;
1126   esac
1127 ], AC_MSG_RESULT(no))
1128
1129 AC_MSG_CHECKING(whether root should be allowed to use sudo)
1130 AC_ARG_ENABLE(root-sudo,
1131 [AS_HELP_STRING([--disable-root-sudo], [Don't allow root to run sudo])],
1132 [ case "$enableval" in
1133     yes)        AC_MSG_RESULT(yes)
1134                 ;;
1135     no)         AC_DEFINE(NO_ROOT_SUDO)
1136                 AC_MSG_RESULT(no)
1137                 root_sudo=off
1138                 ;;
1139     *)          AC_MSG_ERROR(["--enable-root-sudo does not take an argument."])
1140                 ;;
1141   esac
1142 ], AC_MSG_RESULT(yes))
1143
1144 AC_MSG_CHECKING(whether to log the hostname in the log file)
1145 AC_ARG_ENABLE(log-host,
1146 [AS_HELP_STRING([--enable-log-host], [Log the hostname in the log file])],
1147 [ case "$enableval" in
1148     yes)        AC_MSG_RESULT(yes)
1149                 AC_DEFINE(HOST_IN_LOG)
1150                 ;;
1151     no)         AC_MSG_RESULT(no)
1152                 ;;
1153     *)          AC_MSG_RESULT(no)
1154                 AC_MSG_WARN([Ignoring unknown argument to --enable-log-host: $enableval])
1155                 ;;
1156   esac
1157 ], AC_MSG_RESULT(no))
1158
1159 AC_MSG_CHECKING(whether to invoke a shell if sudo is given no arguments)
1160 AC_ARG_ENABLE(noargs-shell,
1161 [AS_HELP_STRING([--enable-noargs-shell], [If sudo is given no arguments run a shell])],
1162 [ case "$enableval" in
1163     yes)        AC_MSG_RESULT(yes)
1164                 AC_DEFINE(SHELL_IF_NO_ARGS)
1165                 ;;
1166     no)         AC_MSG_RESULT(no)
1167                 ;;
1168     *)          AC_MSG_RESULT(no)
1169                 AC_MSG_WARN([Ignoring unknown argument to --enable-noargs-shell: $enableval])
1170                 ;;
1171   esac
1172 ], AC_MSG_RESULT(no))
1173
1174 AC_MSG_CHECKING(whether to set \$HOME to target user in shell mode)
1175 AC_ARG_ENABLE(shell-sets-home,
1176 [AS_HELP_STRING([--enable-shell-sets-home], [Set $HOME to target user in shell mode])],
1177 [ case "$enableval" in
1178     yes)        AC_MSG_RESULT(yes)
1179                 AC_DEFINE(SHELL_SETS_HOME)
1180                 ;;
1181     no)         AC_MSG_RESULT(no)
1182                 ;;
1183     *)          AC_MSG_RESULT(no)
1184                 AC_MSG_WARN([Ignoring unknown argument to --enable-shell-sets-home: $enableval])
1185                 ;;
1186   esac
1187 ], AC_MSG_RESULT(no))
1188
1189 AC_MSG_CHECKING(whether to disable 'command not found' messages)
1190 AC_ARG_ENABLE(path_info,
1191 [AS_HELP_STRING([--disable-path-info], [Print 'command not allowed' not 'command not found'])],
1192 [ case "$enableval" in
1193     yes)        AC_MSG_RESULT(no)
1194                 ;;
1195     no)         AC_MSG_RESULT(yes)
1196                 AC_DEFINE(DONT_LEAK_PATH_INFO)
1197                 path_info=off
1198                 ;;
1199     *)          AC_MSG_RESULT(no)
1200                 AC_MSG_WARN([Ignoring unknown argument to --enable-path-info: $enableval])
1201                 ;;
1202   esac
1203 ], AC_MSG_RESULT(no))
1204
1205 AC_MSG_CHECKING(whether to enable environment debugging)
1206 AC_ARG_ENABLE(env_debug,
1207 [AS_HELP_STRING([--enable-env-debug], [Whether to enable environment debugging.])],
1208 [ case "$enableval" in
1209     yes)        AC_MSG_RESULT(yes)
1210                 AC_DEFINE(ENV_DEBUG)
1211                 ;;
1212     no)         AC_MSG_RESULT(no)
1213                 ;;
1214     *)          AC_MSG_RESULT(no)
1215                 AC_MSG_WARN([Ignoring unknown argument to --enable-env-debug: $enableval])
1216                 ;;
1217   esac
1218 ], AC_MSG_RESULT(no))
1219
1220 AC_ARG_WITH(selinux, [AS_HELP_STRING([--with-selinux], [enable SELinux support])],
1221 [case $with_selinux in
1222     yes)        SELINUX_USAGE="[[-r role]] [[-t type]] "
1223                 AC_DEFINE(HAVE_SELINUX)
1224                 SUDO_LIBS="${SUDO_LIBS} -lselinux"
1225                 SUDO_OBJS="${SUDO_OBJS} selinux.o"
1226                 PROGS="${PROGS} sesh"
1227                 SELINUX=""
1228                 SEMAN=""
1229                 ;;
1230     no)         ;;
1231     *)          AC_MSG_ERROR(["--with-selinux does not take an argument."])
1232                 ;;
1233 esac])
1234
1235 dnl
1236 dnl gss_krb5_ccache_name() may not work on Heimdal so we don't use it by default
1237 dnl
1238 AC_ARG_ENABLE(gss_krb5_ccache_name,
1239 [AS_HELP_STRING([--enable-gss-krb5-ccache-name], [Use GSS-API to set the Kerberos V cred cache name])],
1240 [check_gss_krb5_ccache_name=$enableval], [check_gss_krb5_ccache_name=no])
1241
1242 dnl
1243 dnl If we don't have egrep we can't do anything...
1244 dnl
1245 AC_CHECK_PROG(EGREPPROG, egrep, egrep)
1246 if test -z "$EGREPPROG"; then
1247     AC_MSG_ERROR([Sorry, configure requires egrep to run.])
1248 fi
1249
1250 dnl
1251 dnl Prevent configure from adding the -g flag unless in devel mode
1252 dnl
1253 if test "$with_devel" != "yes"; then
1254     ac_cv_prog_cc_g=no
1255 fi
1256
1257 dnl
1258 dnl C compiler checks
1259 dnl
1260 AC_ISC_POSIX
1261 AC_PROG_CPP
1262
1263 dnl
1264 dnl Libtool magic; enable shared libs and disable static libs
1265 dnl
1266 AC_CANONICAL_HOST
1267 AC_DISABLE_STATIC
1268 AC_LIBTOOL_DLOPEN
1269 AC_PROG_LIBTOOL
1270
1271 dnl
1272 dnl Defer with_noexec until after libtool magic runs
1273 dnl
1274 if test "$enable_shared" = "no"; then
1275     with_noexec=no
1276 else
1277     eval _shrext="$shrext_cmds"
1278 fi
1279 AC_MSG_CHECKING(path to sudo_noexec.so)
1280 AC_ARG_WITH(noexec, [AS_HELP_STRING([--with-noexec[=PATH]], [fully qualified pathname of sudo_noexec.so])],
1281 [case $with_noexec in
1282     yes)        with_noexec="$libexecdir/sudo_noexec$_shrext"
1283                 ;;
1284     no)         ;;
1285     *)          ;;
1286 esac], [with_noexec="$libexecdir/sudo_noexec$_shrext"])
1287 AC_MSG_RESULT($with_noexec)
1288 NOEXECFILE="sudo_noexec$_shrext"
1289 NOEXECDIR="`echo $with_noexec|sed 's:^\(.*\)/[[^/]]*:\1:'`"
1290
1291 dnl
1292 dnl It is now safe to modify CFLAGS and CPPFLAGS
1293 dnl
1294 if test "$with_devel" = "yes" -a -n "$GCC"; then
1295     CFLAGS="${CFLAGS} -Wall"
1296 fi
1297
1298 dnl
1299 dnl Find programs we use
1300 dnl
1301 AC_CHECK_PROG(UNAMEPROG, uname, uname)
1302 AC_CHECK_PROG(TRPROG, tr, tr)
1303 AC_CHECK_PROG(NROFFPROG, nroff, nroff)
1304 if test -z "$NROFFPROG"; then
1305     MANTYPE="cat"
1306     mansrcdir='$(srcdir)'
1307 fi
1308
1309 dnl
1310 dnl What kind of beastie are we being run on?
1311 dnl Barf if config.cache was generated on another host.
1312 dnl
1313 if test -n "$sudo_cv_prev_host"; then
1314     if test "$sudo_cv_prev_host" != "$host"; then
1315         AC_MSG_ERROR([config.cache was created on a different host; remove it and re-run configure.])
1316     else
1317         AC_MSG_CHECKING(previous host type)
1318         AC_CACHE_VAL(sudo_cv_prev_host, sudo_cv_prev_host="$host")
1319         AC_MSG_RESULT([$sudo_cv_prev_host])
1320     fi
1321 else
1322     # this will produce no output since there is no cached value
1323     AC_CACHE_VAL(sudo_cv_prev_host, sudo_cv_prev_host="$host")
1324 fi
1325
1326 dnl
1327 dnl We want to be able to differentiate between different rev's
1328 dnl
1329 if test -n "$host_os"; then
1330     OS=`echo $host_os | sed 's/[[0-9]].*//'`
1331     OSREV=`echo $host_os | sed 's/^[[^0-9\.]]*\([[0-9\.]]*\).*$/\1/'`
1332     OSMAJOR=`echo $OSREV | sed 's/\..*$//'`
1333 else
1334     OS="unknown"
1335     OSREV=0
1336     OSMAJOR=0
1337 fi
1338
1339 case "$host" in
1340     *-*-sunos4*)
1341                 # getcwd(3) opens a pipe to getpwd(1)!?!
1342                 BROKEN_GETCWD=1
1343
1344                 # system headers lack prototypes but gcc helps...
1345                 if test -n "$GCC"; then
1346                     OSDEFS="${OSDEFS} -D__USE_FIXED_PROTOTYPES__"
1347                 fi
1348
1349                 shadow_funcs="getpwanam issecure"
1350                 ;;
1351     *-*-solaris2*)
1352                 # To get the crypt(3) prototype (so we pass -Wall)
1353                 OSDEFS="${OSDEFS} -D__EXTENSIONS__"
1354                 # AFS support needs -lucb
1355                 if test "$with_AFS" = "yes"; then
1356                     AFS_LIBS="-lc -lucb"
1357                 fi
1358                 : ${mansectsu='1m'}
1359                 : ${mansectform='4'}
1360                 : ${with_rpath='yes'}
1361                 test -z "$with_pam" && AUTH_EXCL_DEF="PAM"
1362                 ;;
1363     *-*-aix*)
1364                 # To get all prototypes (so we pass -Wall)
1365                 OSDEFS="${OSDEFS} -D_XOPEN_EXTENDED_SOURCE -D_ALL_SOURCE"
1366                 SUDO_LDFLAGS="${SUDO_LDFLAGS} -Wl,-bI:\$(srcdir)/aixcrypt.exp"
1367                 if test X"$with_blibpath" != X"no"; then
1368                     AC_MSG_CHECKING([if linker accepts -Wl,-blibpath])
1369                     O_LDFLAGS="$LDFLAGS"
1370                     LDFLAGS="$O_LDFLAGS -Wl,-blibpath:/usr/lib:/lib"
1371                     AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])], [
1372                         if test -n "$with_blibpath" -a "$with_blibpath" != "yes"; then
1373                             blibpath="$with_blibpath"
1374                         elif test -n "$GCC"; then
1375                             blibpath="/usr/lib:/lib:/usr/local/lib"
1376                         else
1377                             blibpath="/usr/lib:/lib"
1378                         fi
1379                         AC_MSG_RESULT(yes)
1380                     ], [AC_MSG_RESULT(no)])
1381                 fi
1382                 LDFLAGS="$O_LDFLAGS"
1383
1384                 # Use authenticate(3) as the default authentication method
1385                 if test X"$with_aixauth" = X""; then
1386                     AC_CHECK_FUNCS(authenticate, [AUTH_EXCL_DEF="AIX_AUTH"])
1387                 fi
1388
1389                 # AIX analog of nsswitch.conf, enabled by default
1390                 AC_ARG_WITH(netsvc, [AS_HELP_STRING([--with-netsvc[[=PATH]]], [path to netsvc.conf])],
1391                 [case $with_netsvc in
1392                     no)         ;;
1393                     yes)        with_netsvc="/etc/netsvc.conf"
1394                                 ;;
1395                     *)          ;;
1396                 esac])
1397                 if test -z "$with_nsswitch" -a -z "$with_netsvc"; then
1398                     with_netsvc="/etc/netsvc.conf"
1399                 fi
1400
1401                 # AIX-specific functions
1402                 AC_CHECK_FUNCS(getuserattr)
1403                 SUDO_OBJS="$SUDO_OBJS aix.o"
1404                 ;;
1405     *-*-hiuxmpp*)
1406                 : ${mansectsu='1m'}
1407                 : ${mansectform='4'}
1408                 ;;
1409     *-*-hpux*)
1410                 # AFS support needs -lBSD
1411                 if test "$with_AFS" = "yes"; then
1412                     AFS_LIBS="-lc -lBSD"
1413                 fi
1414                 : ${mansectsu='1m'}
1415                 : ${mansectform='4'}
1416
1417                 # HP-UX bundled compiler can't generate shared objects
1418                 if test "x$ac_cv_prog_cc_c89" = "xno"; then
1419                     with_noexec=no
1420                 fi
1421
1422                 # Use the +DAportable flag if it is supported
1423                 _CFLAGS="$CFLAGS"
1424                 CFLAGS="$CFLAGS +DAportable"
1425                 AC_CACHE_CHECK([whether $CC understands +DAportable],
1426                     [sudo_cv_var_daportable],
1427                     [AC_TRY_LINK([], [], [sudo_cv_var_daportable=yes],
1428                                  [sudo_cv_var_daportable=no])]
1429                 )
1430                 if test X"$sudo_cv_var_daportable" != X"yes"; then
1431                     CFLAGS="$_CFLAGS"
1432                 fi
1433
1434                 case "$host" in
1435                         *-*-hpux[1-8].*)
1436                             AC_DEFINE(BROKEN_SYSLOG)
1437
1438                             # Not sure if setuid binaries are safe in < 9.x
1439                             if test -n "$GCC"; then
1440                                 SUDO_LDFLAGS="${SUDO_LDFLAGS} -static"
1441                             else
1442                                 SUDO_LDFLAGS="${SUDO_LDFLAGS} -Wl,-a,archive"
1443                             fi
1444                         ;;
1445                         *-*-hpux9.*)
1446                             AC_DEFINE(BROKEN_SYSLOG)
1447
1448                             shadow_funcs="getspwuid"
1449
1450                             # DCE support (requires ANSI C compiler)
1451                             if test "$with_DCE" = "yes"; then
1452                                 # order of libs in 9.X is important. -lc_r must be last
1453                                 SUDO_LIBS="${SUDO_LIBS} -ldce -lM -lc_r"
1454                                 LIBS="${LIBS} -ldce -lM -lc_r"
1455                                 CPPFLAGS="${CPPFLAGS} -D_REENTRANT -I/usr/include/reentrant"
1456                             fi
1457                         ;;
1458                         *-*-hpux10.*)
1459                             shadow_funcs="getprpwnam iscomsec"
1460                             shadow_libs="-lsec"
1461                         ;;
1462                         *)
1463                             shadow_funcs="getspnam iscomsec"
1464                             shadow_libs="-lsec"
1465                             test -z "$with_pam" && AUTH_EXCL_DEF="PAM"
1466                         ;;
1467                 esac
1468                 ;;
1469     *-dec-osf*)
1470                 # ignore envariables wrt dynamic lib path
1471                 SUDO_LDFLAGS="${SUDO_LDFLAGS} -Wl,-no_library_replacement"
1472
1473                 : ${CHECKSIA='true'}
1474                 AC_MSG_CHECKING(whether to disable sia support on Digital UNIX)
1475                 AC_ARG_ENABLE(sia,
1476                 [AS_HELP_STRING([--disable-sia], [Disable SIA on Digital UNIX])],
1477                 [ case "$enableval" in
1478                     yes)        AC_MSG_RESULT(no)
1479                                 CHECKSIA=true
1480                                 ;;
1481                     no)         AC_MSG_RESULT(yes)
1482                                 CHECKSIA=false
1483                                 ;;
1484                     *)          AC_MSG_RESULT(no)
1485                                 AC_MSG_WARN([Ignoring unknown argument to --enable-sia: $enableval])
1486                                 ;;
1487                   esac
1488                 ], AC_MSG_RESULT(no))
1489
1490                 shadow_funcs="getprpwnam dispcrypt"
1491                 # OSF/1 4.x and higher need -ldb too
1492                 if test $OSMAJOR -lt 4; then
1493                     shadow_libs="-lsecurity -laud -lm"
1494                 else
1495                     shadow_libs="-lsecurity -ldb -laud -lm"
1496                 fi
1497
1498                 # use SIA by default, if we have it
1499                 test "$CHECKSIA" = "true" && AUTH_EXCL_DEF="SIA"
1500
1501                 #
1502                 # Some versions of Digital Unix ship with a broken
1503                 # copy of prot.h, which we need for shadow passwords.
1504                 # XXX - make should remove this as part of distclean
1505                 #
1506                 AC_MSG_CHECKING([for broken prot.h])
1507                 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1508 #include <sys/types.h>
1509 #include <sys/security.h>
1510 #include <prot.h>
1511                 ]], [[exit(0);]])], [AC_MSG_RESULT(no)], [AC_MSG_RESULT([yes, fixing locally])
1512                 sed 's:<acl.h>:<sys/acl.h>:g' < /usr/include/prot.h > prot.h
1513                 ])
1514                 : ${mansectsu='8'}
1515                 : ${mansectform='4'}
1516                 ;;
1517     *-*-irix*)
1518                 OSDEFS="${OSDEFS} -D_BSD_TYPES"
1519                 if test -z "$NROFFPROG"; then
1520                     MAN_POSTINSTALL='   /bin/rm -f $(mandirsu)/sudo.$(mansectsu).z $(mandirsu)/visudo.$(mansectsu).z $(mandirform)/sudoers.$(mansectform).z ; /usr/bin/pack $(mandirsu)/sudo.$(mansectsu) $(mandirsu)/visudo.$(mansectsu) $(mandirform)/sudoers.$(mansectform)'
1521                     if test "$prefix" = "/usr/local" -a "$mandir" = '$(prefix)/man'; then
1522                         if test -d /usr/share/catman/local; then
1523                             mandir="/usr/share/catman/local"
1524                         else
1525                             mandir="/usr/catman/local"
1526                         fi
1527                     fi
1528                 else
1529                     if test "$prefix" = "/usr/local" -a "$mandir" = '$(prefix)/man'; then
1530                         if test -d "/usr/share/man/local"; then
1531                             mandir="/usr/share/man/local"
1532                         else
1533                             mandir="/usr/man/local"
1534                         fi
1535                     fi
1536                 fi
1537                 # IRIX <= 4 needs -lsun
1538                 if test "$OSMAJOR" -le 4; then
1539                     AC_CHECK_LIB(sun, getpwnam, [LIBS="${LIBS} -lsun"])
1540                 fi
1541                 : ${mansectsu='1m'}
1542                 : ${mansectform='4'}
1543                 ;;
1544     *-*-linux*|*-*-k*bsd*-gnu)
1545                 OSDEFS="${OSDEFS} -D_GNU_SOURCE"
1546                 # Some Linux versions need to link with -lshadow
1547                 shadow_funcs="getspnam"
1548                 shadow_libs_optional="-lshadow"
1549                 test -z "$with_pam" && AUTH_EXCL_DEF="PAM"
1550                 ;;
1551     *-convex-bsd*)
1552                 OSDEFS="${OSDEFS} -D_CONVEX_SOURCE"
1553                 if test -z "$GCC"; then
1554                     CFLAGS="${CFLAGS} -D__STDC__"
1555                 fi
1556
1557                 shadow_defs="-D_AUDIT -D_ACL -DSecureWare"
1558                 shadow_funcs="getprpwnam"
1559                 shadow_libs="-lprot"
1560                 ;;
1561     *-*-ultrix*)
1562                 OS="ultrix"
1563                 shadow_funcs="getauthuid"
1564                 shadow_libs="-lauth"
1565                 ;;
1566     *-*-riscos*)
1567                 LIBS="${LIBS} -lsun -lbsd"
1568                 CPPFLAGS="${CPPFLAGS} -I/usr/include -I/usr/include/bsd"
1569                 OSDEFS="${OSDEFS} -D_MIPS"
1570                 : ${mansectsu='1m'}
1571                 : ${mansectform='4'}
1572                 ;;
1573     *-*-isc*)
1574                 OSDEFS="${OSDEFS} -D_ISC"
1575                 LIB_CRYPT=1
1576                 SUDO_LIBS="${SUDO_LIBS} -lcrypt"
1577                 LIBS="${LIBS} -lcrypt"
1578
1579                 shadow_funcs="getspnam"
1580                 shadow_libs="-lsec"
1581
1582                 : ${mansectsu='1m'}
1583                 : ${mansectform='4'}
1584                 ;;
1585     *-*-sco*|*-sco-*)
1586                 shadow_funcs="getprpwnam"
1587                 shadow_libs="-lprot -lx"
1588                 : ${mansectsu='1m'}
1589                 : ${mansectform='4'}
1590                 ;;
1591     m88k-motorola-sysv*)
1592                 # motorolla's cc (a variant of gcc) does -O but not -O2
1593                 CFLAGS=`echo $CFLAGS | sed 's/-O2/-O/g'`
1594                 : ${mansectsu='1m'}
1595                 : ${mansectform='4'}
1596                 ;;
1597     *-sequent-sysv*)
1598                 shadow_funcs="getspnam"
1599                 shadow_libs="-lsec"
1600                 : ${mansectsu='1m'}
1601                 : ${mansectform='4'}
1602                 : ${with_rpath='yes'}
1603                 ;;
1604     *-ncr-sysv4*|*-ncr-sysvr4*)
1605                 AC_CHECK_LIB(c89, strcasecmp, AC_DEFINE(HAVE_STRCASECMP) [LIBS="${LIBS} -lc89"; ac_cv_func_strcasecmp=yes])
1606                 : ${mansectsu='1m'}
1607                 : ${mansectform='4'}
1608                 : ${with_rpath='yes'}
1609                 ;;
1610     *-ccur-sysv4*|*-ccur-sysvr4*)
1611                 LIBS="${LIBS} -lgen"
1612                 SUDO_LIBS="${SUDO_LIBS} -lgen"
1613                 : ${mansectsu='1m'}
1614                 : ${mansectform='4'}
1615                 : ${with_rpath='yes'}
1616                 ;;
1617     *-*-bsdi*)
1618                 SKIP_SETREUID=yes
1619                 # Use shlicc for BSD/OS [23].x unless asked to do otherwise
1620                 if test "${with_CC+set}" != set -a "$ac_cv_prog_CC" = gcc; then
1621                     case "$OSMAJOR" in
1622                         2|3)    AC_MSG_NOTICE([using shlicc as CC])
1623                                 ac_cv_prog_CC=shlicc
1624                                 CC="$ac_cv_prog_CC"
1625                                 ;;
1626                     esac
1627                 fi
1628                 # Check for newer BSD auth API (just check for >= 3.0?)
1629                 if test -z "$with_bsdauth"; then
1630                     AC_CHECK_FUNCS(auth_challenge, [AUTH_EXCL_DEF="BSD_AUTH"])
1631                 fi
1632                 ;;
1633     *-*-freebsd*)
1634                 # FreeBSD has a real setreuid(2) starting with 2.1 and
1635                 # backported to 2.0.5.  We just take 2.1 and above...
1636                 case "$OSREV" in
1637                 0.*|1.*|2.0*)
1638                     SKIP_SETREUID=yes
1639                     ;;
1640                 esac
1641                 if test "$with_skey" = "yes"; then
1642                      SUDO_LIBS="${SUDO_LIBS} -lmd"
1643                 fi
1644                 CHECKSHADOW="false"
1645                 test -z "$with_pam" && AUTH_EXCL_DEF="PAM"
1646                 : ${with_logincap='maybe'}
1647                 ;;
1648     *-*-*openbsd*)
1649                 # OpenBSD has a real setreuid(2) starting with 3.3 but
1650                 # we will use setreuid(2) instead.
1651                 SKIP_SETREUID=yes
1652                 CHECKSHADOW="false"
1653                 # OpenBSD >= 3.0 supports BSD auth
1654                 if test -z "$with_bsdauth"; then
1655                     case "$OSREV" in
1656                     [0-2].*)
1657                         ;;
1658                     *)
1659                         AUTH_EXCL_DEF="BSD_AUTH"
1660                         ;;
1661                     esac
1662                 fi
1663                 : ${with_logincap='maybe'}
1664                 ;;
1665     *-*-*netbsd*)
1666                 # NetBSD has a real setreuid(2) starting with 1.3.2
1667                 case "$OSREV" in
1668                 0.9*|1.[012]*|1.3|1.3.1)
1669                     SKIP_SETREUID=yes
1670                     ;;
1671                 esac
1672                 CHECKSHADOW="false"
1673                 test -z "$with_pam" && AUTH_EXCL_DEF="PAM"
1674                 : ${with_logincap='maybe'}
1675                 ;;
1676     *-*-dragonfly*)
1677                 if test "$with_skey" = "yes"; then
1678                      SUDO_LIBS="${SUDO_LIBS} -lmd"
1679                 fi
1680                 CHECKSHADOW="false"
1681                 test -z "$with_pam" && AUTH_EXCL_DEF="PAM"
1682                 : ${with_logincap='yes'}
1683                 ;;
1684     *-*-*bsd*)
1685                 CHECKSHADOW="false"
1686                 ;;
1687     *-*-darwin*)
1688                 SKIP_SETREUID=yes
1689                 CHECKSHADOW="false"
1690                 test -z "$with_pam" && AUTH_EXCL_DEF="PAM"
1691                 : ${with_logincap='yes'}
1692                 ;;
1693     *-*-nextstep*)
1694                 # lockf() on is broken on the NeXT -- use flock instead
1695                 ac_cv_func_lockf=no
1696                 ac_cv_func_flock=yes
1697                 ;;
1698     *-*-*sysv4*)
1699                 : ${mansectsu='1m'}
1700                 : ${mansectform='4'}
1701                 : ${with_rpath='yes'}
1702                 ;;
1703     *-*-sysv*)
1704                 : ${mansectsu='1m'}
1705                 : ${mansectform='4'}
1706                 ;;
1707     *-gnu*)
1708                 OSDEFS="${OSDEFS} -D_GNU_SOURCE"
1709                 ;;
1710 esac
1711
1712 dnl
1713 dnl Check for mixing mutually exclusive and regular auth methods
1714 dnl
1715 AUTH_REG=${AUTH_REG# }
1716 AUTH_EXCL=${AUTH_EXCL# }
1717 if test -n "$AUTH_EXCL"; then
1718     set -- $AUTH_EXCL
1719     if test $# != 1; then
1720         AC_MSG_ERROR([More than one mutually exclusive authentication method specified: $AUTH_EXCL])
1721     fi
1722     if test -n "$AUTH_REG"; then
1723         AC_MSG_ERROR([Cannot mix mutually exclusive ($AUTH_EXCL) and regular ($AUTH_REG) authentication methods])
1724     fi
1725 fi
1726 dnl
1727 dnl Only one of S/Key and OPIE may be specified
1728 dnl
1729 if test X"${with_skey}${with_opie}" = X"yesyes"; then
1730     AC_MSG_ERROR(["cannot use both S/Key and OPIE"])
1731 fi
1732
1733 dnl
1734 dnl Use BSD-style man sections by default
1735 dnl
1736 : ${mansectsu='8'}
1737 : ${mansectform='5'}
1738
1739 dnl
1740 dnl Add in any libpaths or libraries specified via configure
1741 dnl
1742 if test -n "$with_libpath"; then
1743     for i in ${with_libpath}; do
1744         SUDO_APPEND_LIBPATH(LDFLAGS, [$i])
1745     done
1746 fi
1747 if test -n "$with_libraries"; then
1748     for i in ${with_libraries}; do
1749         case $i in
1750             -l*)        ;;
1751             *.a)        ;;
1752             *.o)        ;;
1753             *)  i="-l${i}";;
1754         esac
1755         LIBS="${LIBS} ${i}"
1756     done
1757 fi
1758
1759 dnl
1760 dnl C compiler checks (to be done after os checks)
1761 dnl
1762 AC_PROG_GCC_TRADITIONAL
1763 AC_C_CONST
1764 AC_C_VOLATILE
1765 dnl
1766 dnl Program checks
1767 dnl
1768 AC_PROG_YACC
1769 AC_PATH_PROG([FLEX], [flex], [flex])
1770 SUDO_PROG_MV
1771 SUDO_PROG_BSHELL
1772 if test -z "$with_sendmail"; then
1773     SUDO_PROG_SENDMAIL
1774 fi
1775 if test -z "$with_editor"; then
1776     SUDO_PROG_VI
1777 fi
1778 dnl
1779 dnl Header file checks
1780 dnl
1781 AC_HEADER_STDC
1782 AC_HEADER_DIRENT
1783 AC_HEADER_TIME
1784 AC_CHECK_HEADERS(malloc.h paths.h utime.h netgroup.h sys/sockio.h sys/bsdtypes.h sys/select.h)
1785 dnl ultrix termio/termios are broken
1786 if test "$OS" != "ultrix"; then
1787     AC_SYS_POSIX_TERMIOS
1788     if test "$ac_cv_sys_posix_termios" = "yes"; then
1789         AC_DEFINE(HAVE_TERMIOS_H)
1790     else
1791         AC_CHECK_HEADERS(termio.h)
1792     fi
1793 fi
1794 if test ${with_logincap-'no'} != "no"; then
1795     AC_CHECK_HEADERS(login_cap.h, [LOGINCAP_USAGE='[[-c class|-]] '; LCMAN=""
1796         case "$OS" in
1797             freebsd|netbsd)     SUDO_LIBS="${SUDO_LIBS} -lutil"
1798             ;;
1799         esac
1800     ])
1801 fi
1802 if test ${with_project-'no'} != "no"; then
1803     AC_CHECK_HEADER(project.h, AC_DEFINE(HAVE_PROJECT_H)
1804         [SUDO_LIBS="${SUDO_LIBS} -lproject"], -)
1805 fi
1806 dnl
1807 dnl typedef checks
1808 dnl
1809 AC_TYPE_MODE_T
1810 AC_TYPE_UID_T
1811 AC_CHECK_TYPE([__signed char], [], [AC_CHECK_TYPE([signed char], [AC_DEFINE(__signed, signed)], [AC_DEFINE(__signed, [])])])
1812 AC_CHECK_TYPE([sig_atomic_t], [], [AC_DEFINE(sig_atomic_t, int)], [#include <sys/types.h>
1813 #include <signal.h>])
1814 AC_CHECK_TYPES([sigaction_t], [AC_DEFINE(HAVE_SIGACTION_T)], [], [#include <sys/types.h>
1815 #include <signal.h>])
1816 AC_CHECK_TYPE([struct timespec], [AC_DEFINE(HAVE_TIMESPEC)], [], [#include <sys/types.h>
1817 #if TIME_WITH_SYS_TIME
1818 # include <sys/time.h>
1819 #endif
1820 #include <time.h>])
1821 AC_CHECK_TYPES([struct in6_addr], [AC_DEFINE(HAVE_IN6_ADDR)], [], [#include <sys/types.h>
1822 #include <netinet/in.h>])
1823 SUDO_TYPE_SIZE_T
1824 SUDO_TYPE_SSIZE_T
1825 SUDO_TYPE_DEV_T
1826 SUDO_TYPE_INO_T
1827 SUDO_UID_T_LEN
1828 SUDO_TYPE_LONG_LONG
1829 SUDO_SOCK_SA_LEN
1830 dnl
1831 dnl only set RETSIGTYPE if it is not set already
1832 dnl
1833 case "$DEFS" in
1834     *"RETSIGTYPE"*)     ;;
1835     *)                  AC_TYPE_SIGNAL;;
1836 esac
1837 dnl
1838 dnl Function checks
1839 dnl
1840 AC_FUNC_GETGROUPS
1841 AC_CHECK_FUNCS(strchr strrchr memchr memcpy memset sysconf tzset \
1842                strftime setrlimit initgroups getgroups fstat gettimeofday \
1843                setlocale getaddrinfo setsid setenv setrlimit64)
1844 AC_CHECK_FUNCS(unsetenv, SUDO_FUNC_UNSETENV_VOID)
1845 SUDO_FUNC_PUTENV_CONST
1846 if test -z "$SKIP_SETRESUID"; then
1847     AC_CHECK_FUNCS(setresuid, [SKIP_SETREUID=yes])
1848 fi
1849 if test -z "$SKIP_SETREUID"; then
1850     AC_CHECK_FUNCS(setreuid, [SKIP_SETEUID=yes])
1851 fi
1852 if test -z "$SKIP_SETEUID"; then
1853     AC_CHECK_FUNCS(seteuid)
1854 fi
1855 if test X"$with_interfaces" != X"no"; then
1856     AC_CHECK_FUNCS(getifaddrs, [AC_CHECK_FUNCS(freeifaddrs)])
1857 fi
1858 if test -z "$BROKEN_GETCWD"; then
1859     AC_REPLACE_FUNCS(getcwd)
1860 fi
1861 AC_CHECK_FUNCS(glob, [AC_MSG_CHECKING(for GLOB_BRACE and GLOB_TILDE in glob.h)
1862 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <glob.h>]], [[int i = GLOB_BRACE | GLOB_TILDE; (void)i;]])], [AC_DEFINE(HAVE_EXTENDED_GLOB)
1863     AC_MSG_RESULT(yes)], [AC_LIBOBJ(glob)
1864     AC_MSG_RESULT(no)])], [AC_LIBOBJ(glob)])
1865 AC_CHECK_FUNCS(lockf flock, [break])
1866 AC_CHECK_FUNCS(waitpid wait3, [break])
1867 AC_CHECK_FUNCS(innetgr _innetgr, [AC_CHECK_FUNCS(getdomainname) [break]])
1868 AC_CHECK_FUNCS(utimes, [AC_CHECK_FUNCS(futimes futimesat, [break])], [AC_CHECK_FUNCS(futime) AC_LIBOBJ(utimes)])
1869 SUDO_FUNC_FNMATCH([AC_DEFINE(HAVE_FNMATCH)], [AC_LIBOBJ(fnmatch)])
1870 SUDO_FUNC_ISBLANK
1871 AC_REPLACE_FUNCS(memrchr strerror strcasecmp sigaction strlcpy strlcat)
1872 AC_CHECK_FUNCS(closefrom, [], [AC_LIBOBJ(closefrom)
1873     AC_CHECK_DECL(F_CLOSEM, AC_DEFINE(HAVE_FCNTL_CLOSEM), [],
1874         [ #include <limits.h>
1875           #include <fcntl.h> ])
1876 ])
1877 AC_CHECK_FUNCS(mkstemp, [], [SUDO_OBJS="${SUDO_OBJS} mkstemp.o"
1878     AC_CHECK_FUNCS(random lrand48, [break])
1879 ])
1880 AC_CHECK_FUNCS(snprintf vsnprintf asprintf vasprintf, , [NEED_SNPRINTF=1])
1881 if test X"$ac_cv_type_struct_timespec" != X"no"; then
1882     AC_CHECK_MEMBER([struct stat.st_mtim], [AC_DEFINE(HAVE_ST_MTIM)]
1883         [AC_CHECK_MEMBER([struct stat.st_mtim.st__tim], AC_DEFINE(HAVE_ST__TIM))],
1884         [AC_CHECK_MEMBER([struct stat.st_mtimespec], AC_DEFINE([HAVE_ST_MTIMESPEC]))])
1885     AC_MSG_CHECKING([for two-parameter timespecsub])
1886     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
1887 #include <sys/time.h>]], [[struct timespec ts1, ts2;
1888 ts1.tv_sec = 1; ts1.tv_nsec = 0; ts2.tv_sec = 0; ts2.tv_nsec = 0;
1889 #ifndef timespecsub
1890 #error missing timespecsub
1891 #endif
1892 timespecsub(&ts1, &ts2);]])], [AC_DEFINE(HAVE_TIMESPECSUB2)
1893     AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)])
1894 fi
1895 dnl
1896 dnl Check for the dirfd function/macro.  If not found, look for dd_fd in DIR.
1897 dnl
1898 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
1899 #include <$ac_header_dirent>]], [[DIR *d; (void)dirfd(d);]])], [AC_DEFINE(HAVE_DIRFD)], [AC_TRY_LINK([#include <sys/types.h>
1900 #include <$ac_header_dirent>], [DIR d; memset(&d, 0, sizeof(d)); return(d.dd_fd);], [AC_DEFINE(HAVE_DD_FD)])])
1901 dnl
1902 dnl If NEED_SNPRINTF is set, add snprintf.c to LIBOBJS
1903 dnl (it contains snprintf, vsnprintf, asprintf, and vasprintf)
1904 dnl
1905 if test -n "$NEED_SNPRINTF"; then
1906     AC_LIBOBJ(snprintf)
1907 fi
1908 dnl
1909 dnl If socket(2) not in libc, check -lsocket and -linet
1910 dnl May need to link with *both* -lnsl and -lsocket due to unresolved symbols
1911 dnl In this case we look for main(), not socket() to avoid using a cached value
1912 dnl
1913 AC_CHECK_FUNC(socket, , [AC_CHECK_LIB(socket, socket, [NET_LIBS="${NET_LIBS} -lsocket"; LIBS="${LIBS} -lsocket"], AC_CHECK_LIB(inet, socket, [NET_LIBS="${NET_LIBS} -linet"; LIBS="${LIBS} -linet"], AC_MSG_WARN(unable to find socket() trying -lsocket -lnsl)
1914 AC_CHECK_LIB(socket, socket, [NET_LIBS="${NET_LIBS} -lsocket -lnsl"; LIBS="${LIBS} -lsocket -lnsl"], , -lnsl)))])
1915 dnl
1916 dnl If inet_addr(3) not in libc, check -lnsl and -linet
1917 dnl May need to link with *both* -lnsl and -lsocket due to unresolved symbols
1918 dnl
1919 AC_CHECK_FUNC(inet_addr, , [AC_CHECK_FUNC(__inet_addr, , AC_CHECK_LIB(nsl, inet_addr, [NET_LIBS="${NET_LIBS} -lnsl"; LIBS="${LIBS} -lnsl"], AC_CHECK_LIB(inet, inet_addr, [NET_LIBS="${NET_LIBS} -linet"; LIBS="${LIBS} -linet"], AC_MSG_WARN(unable to find inet_addr() trying -lsocket -lnsl)
1920 AC_CHECK_LIB(socket, inet_addr, [NET_LIBS="${NET_LIBS} -lsocket -lnsl"; LIBS="${LIBS} -lsocket -lnsl"], , -lnsl))))])
1921 dnl
1922 dnl If syslog(3) not in libc, check -lsocket, -lnsl and -linet
1923 dnl
1924 AC_CHECK_FUNC(syslog, , [AC_CHECK_LIB(socket, syslog, [NET_LIBS="${NET_LIBS} -lsocket"; LIBS="${LIBS} -lsocket"], AC_CHECK_LIB(nsl, syslog, [NET_LIBS="${NET_LIBS} -lnsl"; LIBS="${LIBS} -lnsl"], AC_CHECK_LIB(inet, syslog, [NET_LIBS="${NET_LIBS} -linet"; LIBS="${LIBS} -linet"])))])
1925 dnl
1926 dnl Check for getprogname() or __progname
1927 dnl
1928 AC_CHECK_FUNCS(getprogname, , [
1929     AC_MSG_CHECKING([for __progname])
1930     AC_CACHE_VAL(sudo_cv___progname, [
1931     AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[extern char *__progname; (void)puts(__progname);]])], [sudo_cv___progname=yes], [sudo_cv___progname=no])])
1932     if test "$sudo_cv___progname" = "yes"; then
1933         AC_DEFINE(HAVE___PROGNAME)
1934     else
1935         AC_LIBOBJ(getprogname)
1936     fi
1937     AC_MSG_RESULT($sudo_cv___progname)
1938 ])
1939
1940 dnl
1941 dnl nsswitch.conf and its equivalents
1942 dnl
1943 netsvc_conf='/etc/netsvc.conf'
1944 nsswitch_conf='/etc/nsswitch.conf'
1945 if test ${with_netsvc-"no"} != "no"; then
1946     SUDO_DEFINE_UNQUOTED(_PATH_NETSVC_CONF, "${with_netsvc-/etc/netsvc.conf}")
1947     netsvc_conf=${with_netsvc-/etc/netsvc.conf}
1948 elif test ${with_nsswitch-"yes"} != "no"; then
1949     SUDO_DEFINE_UNQUOTED(_PATH_NSSWITCH_CONF, "${with_nsswitch-/etc/nsswitch.conf}")
1950     nsswitch_conf=${with_nsswitch-/etc/nsswitch.conf}
1951 fi
1952
1953 dnl
1954 dnl Mutually exclusive auth checks come first, followed by
1955 dnl non-exclusive ones.  Note: passwd must be last of all!
1956 dnl
1957
1958 dnl
1959 dnl Convert default authentication methods to with_* if
1960 dnl no explicit authentication scheme was specified.
1961 dnl
1962 if test -z "${AUTH_EXCL}${AUTH_REG}" -a -n "$AUTH_EXCL_DEF"; then
1963     for auth in $AUTH_EXCL_DEF; do
1964         case $auth in
1965             AIX_AUTH)   with_aixauth=maybe;;
1966             BSD_AUTH)   with_bsdauth=maybe;;
1967             PAM)        with_pam=maybe;;
1968             SIA)        CHECKSIA=true;;
1969         esac
1970     done
1971 fi
1972
1973 dnl
1974 dnl PAM support.  Systems that use PAM by default set with_pam=default
1975 dnl and we do the actual tests here.
1976 dnl
1977 if test ${with_pam-"no"} != "no"; then
1978     dnl
1979     dnl Linux may need this
1980     dnl
1981     AC_CHECK_LIB([dl], [main], [SUDO_LIBS="${SUDO_LIBS} -lpam -ldl"], [SUDO_LIBS="${SUDO_LIBS} -lpam"])
1982     ac_cv_lib_dl=ac_cv_lib_dl_main
1983
1984     dnl
1985     dnl Some PAM implementations (MacOS X for example) put the PAM headers
1986     dnl in /usr/include/pam instead of /usr/include/security...
1987     dnl
1988     AC_CHECK_HEADERS([security/pam_appl.h] [pam/pam_appl.h], [with_pam=yes; break])
1989     if test "$with_pam" = "yes"; then
1990         AC_DEFINE(HAVE_PAM)
1991         AUTH_OBJS="$AUTH_OBJS pam.o";
1992         AUTH_EXCL=PAM
1993         AC_MSG_CHECKING(whether to use PAM session support)
1994         AC_ARG_ENABLE(pam_session,
1995         [AS_HELP_STRING([--disable-pam-session], [Disable PAM session support])],
1996             [ case "$enableval" in
1997                 yes)    AC_MSG_RESULT(yes)
1998                         ;;
1999                 no)             AC_MSG_RESULT(no)
2000                             AC_DEFINE([NO_PAM_SESSION], [], [PAM session support disabled])
2001                             ;;
2002                 *)              AC_MSG_RESULT(no)
2003                             AC_MSG_WARN([Ignoring unknown argument to --enable-pam-session: $enableval])
2004                             ;;
2005             esac], AC_MSG_RESULT(yes))
2006         case $host in
2007             *-*-linux*|*-*-solaris*)
2008                     # dgettext() may be defined to dgettext_libintl in the
2009                     # header file, so first check that it links w/ additional
2010                     # libs, then try with -lintl
2011                     AC_LINK_IFELSE([AC_LANG_PROGRAM(
2012                     [[#include <libintl.h>]], [(void)dgettext((char *)0, (char *)0);])],
2013                     [AC_DEFINE(HAVE_DGETTEXT)],
2014                     [AC_CHECK_LIB(intl, dgettext, [LIBS="${LIBS} -lintl"]
2015                         [AC_DEFINE(HAVE_DGETTEXT)])])
2016                     ;;
2017         esac
2018     fi
2019 fi
2020
2021 dnl
2022 dnl AIX general authentication
2023 dnl If set to "maybe" only enable if no other exclusive method in use.
2024 dnl
2025 if test ${with_aixauth-'no'} != "no"; then
2026     if test X"$with_aixauth" != X"maybe" -o X"$AUTH_EXCL" = X""; then
2027         AC_MSG_NOTICE([using AIX general authentication])
2028         AC_DEFINE(HAVE_AIXAUTH)
2029         AUTH_OBJS="$AUTH_OBJS aix_auth.o";
2030         SUDO_LIBS="${SUDO_LIBS} -ls"
2031         AUTH_EXCL=AIX_AUTH
2032     fi
2033 fi
2034
2035 dnl
2036 dnl BSD authentication
2037 dnl If set to "maybe" only enable if no other exclusive method in use.
2038 dnl
2039 if test ${with_bsdauth-'no'} != "no"; then
2040     AC_CHECK_HEADER(bsd_auth.h, AC_DEFINE(HAVE_BSD_AUTH_H)
2041         [AUTH_OBJS="$AUTH_OBJS bsdauth.o"]
2042         [BSDAUTH_USAGE='[[-a auth_type]] ']
2043         [AUTH_EXCL=BSD_AUTH; BAMAN=""],
2044         [AC_MSG_ERROR([BSD authentication was specified but bsd_auth.h could not be found])])
2045 fi
2046
2047 dnl
2048 dnl SIA authentication for Tru64 Unix
2049 dnl
2050 if test ${CHECKSIA-'false'} = "true"; then
2051     AC_CHECK_FUNCS(sia_ses_init, [found=true], [found=false])
2052     if test "$found" = "true"; then
2053         AUTH_EXCL=SIA
2054         AUTH_OBJS="$AUTH_OBJS sia.o"
2055     fi
2056 fi
2057
2058 dnl
2059 dnl extra FWTK libs + includes
2060 dnl
2061 if test ${with_fwtk-'no'} != "no"; then
2062     if test "$with_fwtk" != "yes"; then
2063         SUDO_APPEND_LIBPATH(SUDO_LDFLAGS, [${with_fwtk}])
2064         CPPFLAGS="${CPPFLAGS} -I${with_fwtk}"
2065         with_fwtk=yes
2066     fi
2067     SUDO_LIBS="${SUDO_LIBS} -lauth -lfwall"
2068     AUTH_OBJS="$AUTH_OBJS fwtk.o"
2069 fi
2070
2071 dnl
2072 dnl extra SecurID lib + includes
2073 dnl
2074 if test ${with_SecurID-'no'} != "no"; then
2075     if test "$with_SecurID" != "yes"; then
2076         :
2077     elif test -d /usr/ace/examples; then
2078         with_SecurID=/usr/ace/examples
2079     else
2080         with_SecurID=/usr/ace
2081     fi
2082     CPPFLAGS="${CPPFLAGS} -I${with_SecurID}"
2083     _LDFLAGS="${LDFLAGS}"
2084     SUDO_APPEND_LIBPATH(LDFLAGS, [${with_SecurID}])
2085     #
2086     # Determine whether to use the new or old SecurID API
2087     #
2088     AC_CHECK_LIB(aceclnt, SD_Init,
2089         [
2090             AUTH_OBJS="$AUTH_OBJS securid5.o";
2091             SUDO_LIBS="${SUDO_LIBS} -laceclnt -lpthread"
2092         ]
2093         [
2094             SUDO_APPEND_LIBPATH(SUDO_LDFLAGS, [${with_SecurID}])
2095         ], [
2096             AUTH_OBJS="$AUTH_OBJS securid.o";
2097             SUDO_LIBS="${SUDO_LIBS} ${with_SecurID}/sdiclient.a"
2098         ],
2099         [
2100             -lpthread
2101         ]
2102     )
2103     LDFLAGS="${_LDFLAGS}"
2104 fi
2105
2106 dnl
2107 dnl Non-mutually exclusive auth checks come next.
2108 dnl Note: passwd must be last of all!
2109 dnl
2110
2111 dnl
2112 dnl Convert default authentication methods to with_* if
2113 dnl no explicit authentication scheme was specified.
2114 dnl
2115 if test -z "${AUTH_EXCL}" -a -n "$AUTH_DEF"; then
2116     for auth in $AUTH_DEF; do
2117         case $auth in
2118             passwd)     : ${with_passwd='maybe'};;
2119         esac
2120     done
2121 fi
2122
2123 dnl
2124 dnl Kerberos IV
2125 dnl
2126 if test ${with_kerb4-'no'} != "no"; then
2127     AC_DEFINE(HAVE_KERB4)
2128     dnl
2129     dnl Use the specified directory, if any, else search for correct inc dir
2130     dnl
2131     O_LDFLAGS="$LDFLAGS"
2132     if test "$with_kerb4" = "yes"; then
2133         found=no
2134         O_CPPFLAGS="$CPPFLAGS"
2135         for dir in "" "kerberosIV/" "krb4/" "kerberos4/" "kerberosv4/"; do
2136             CPPFLAGS="$O_CPPFLAGS -I/usr/include/${dir}"
2137             AC_PREPROC_IFELSE([#include <krb.h>], [found=yes; break])
2138         done
2139         test X"$found" = X"no" && CPPFLAGS="$O_CPPFLAGS"
2140     else
2141         SUDO_APPEND_LIBPATH(LDFLAGS, [${with_kerb4}/lib])
2142         SUDO_APPEND_LIBPATH(SUDO_LDFLAGS, [${with_kerb4}/lib])
2143         CPPFLAGS="$CPPFLAGS -I${with_kerb4}/include"
2144         AC_CHECK_HEADER([krb.h], [found=yes], [found=no])
2145     fi
2146     if test X"$found" = X"no"; then
2147         AC_MSG_WARN([Unable to locate Kerberos IV include files, you will have to edit the Makefile and add -I/path/to/krb/includes to CPPFLAGS])
2148     fi
2149
2150     dnl
2151     dnl Check for -ldes vs. -ldes425
2152     dnl
2153     AC_CHECK_LIB(des, des_cbc_encrypt, [K4LIBS="-ldes"], [
2154         AC_CHECK_LIB(des425, des_cbc_encrypt, [K4LIBS="-ldes425"], [K4LIBS=""])
2155     ])
2156     dnl
2157     dnl Try to determine whether we have KTH or MIT/CNS Kerberos IV
2158     dnl
2159     AC_MSG_CHECKING(whether we are using KTH Kerberos IV)
2160     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <krb.h>]], [[const char *tmp = krb4_version;]])], [
2161             AC_MSG_RESULT(yes)
2162             K4LIBS="${K4LIBS} -lcom_err"
2163             AC_CHECK_LIB(roken, main, [K4LIBS="${K4LIBS} -lroken"])
2164         ], [
2165             AC_MSG_RESULT(no)
2166         ]
2167     )
2168     dnl
2169     dnl The actual Kerberos IV lib might be -lkrb or -lkrb4
2170     dnl
2171     AC_CHECK_LIB(krb, main, [K4LIBS="-lkrb $K4LIBS"], [
2172         AC_CHECK_LIB(krb4, main, [K4LIBS="-lkrb4 $K4LIBS"],
2173             [K4LIBS="-lkrb $K4LIBS"]
2174             [AC_MSG_WARN([Unable to locate Kerberos IV libraries, you will have to edit the Makefile and add -L/path/to/krb/libs to SUDO_LDFLAGS and possibly add Kerberos libs to SUDO_LIBS])]
2175         , [$K4LIBS])
2176     ], [$K4LIBS])
2177     LDFLAGS="$O_LDFLAGS"
2178     SUDO_LIBS="${SUDO_LIBS} $K4LIBS"
2179     AUTH_OBJS="$AUTH_OBJS kerb4.o"
2180 fi
2181
2182 dnl
2183 dnl Kerberos V
2184 dnl There is an easy way and a hard way...
2185 dnl
2186 if test ${with_kerb5-'no'} != "no"; then
2187     AC_CHECK_PROG(KRB5CONFIG, krb5-config, yes, "")
2188     if test -n "$KRB5CONFIG"; then
2189         AC_DEFINE(HAVE_KERB5)
2190         AUTH_OBJS="$AUTH_OBJS kerb5.o"
2191         CPPFLAGS="$CPPFLAGS `krb5-config --cflags`"
2192         SUDO_LIBS="$SUDO_LIBS `krb5-config --libs`"
2193         dnl
2194         dnl Try to determine whether we have Heimdal or MIT Kerberos
2195         dnl
2196         AC_MSG_CHECKING(whether we are using Heimdal)
2197         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <krb5.h>]], [[const char *tmp = heimdal_version;]])], [
2198                 AC_MSG_RESULT(yes)
2199                 AC_DEFINE(HAVE_HEIMDAL)
2200             ], [
2201                 AC_MSG_RESULT(no)
2202             ]
2203         )
2204     fi
2205 fi
2206 if test ${with_kerb5-'no'} != "no" -a -z "$KRB5CONFIG"; then
2207     AC_DEFINE(HAVE_KERB5)
2208     dnl
2209     dnl Use the specified directory, if any, else search for correct inc dir
2210     dnl
2211     if test "$with_kerb5" = "yes"; then
2212         found=no
2213         O_CPPFLAGS="$CPPFLAGS"
2214         for dir in "" "kerberosV/" "krb5/" "kerberos5/" "kerberosv5/"; do
2215             CPPFLAGS="$O_CPPFLAGS -I/usr/include/${dir}"
2216             AC_PREPROC_IFELSE([#include <krb5.h>], [found=yes; break])
2217         done
2218         if test X"$found" = X"no"; then
2219             CPPFLAGS="$O_CPPFLAGS"
2220             AC_MSG_WARN([Unable to locate Kerberos V include files, you will have to edit the Makefile and add -I/path/to/krb/includes to CPPFLAGS])
2221         fi
2222     else
2223         dnl XXX - try to include krb5.h here too
2224         SUDO_APPEND_LIBPATH(SUDO_LDFLAGS, [${with_kerb5}/lib])
2225         CPPFLAGS="$CPPFLAGS -I${with_kerb5}/include"
2226     fi
2227
2228     dnl
2229     dnl Try to determine whether we have Heimdal or MIT Kerberos
2230     dnl
2231     AC_MSG_CHECKING(whether we are using Heimdal)
2232     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <krb5.h>]], [[const char *tmp = heimdal_version;]])], [
2233             AC_MSG_RESULT(yes)
2234             AC_DEFINE(HAVE_HEIMDAL)
2235             # XXX - need to check whether -lcrypo is needed!
2236             SUDO_LIBS="${SUDO_LIBS} -lkrb5 -lcrypto -ldes -lcom_err -lasn1"
2237             AC_CHECK_LIB(roken, main, [SUDO_LIBS="${SUDO_LIBS} -lroken"])
2238         ], [
2239             AC_MSG_RESULT(no)
2240             SUDO_LIBS="${SUDO_LIBS} -lkrb5 -lk5crypto -lcom_err"
2241             AC_CHECK_LIB(krb5support, main, [SUDO_LIBS="${SUDO_LIBS} -lkrb5support"])
2242     ])
2243     AUTH_OBJS="$AUTH_OBJS kerb5.o"
2244     _LIBS="$LIBS"
2245     LIBS="${LIBS} ${SUDO_LIBS}"
2246     AC_CHECK_FUNCS(krb5_verify_user krb5_init_secure_context)
2247     AC_CHECK_FUNCS(krb5_get_init_creds_opt_alloc, [
2248         AC_CACHE_CHECK([whether krb5_get_init_creds_opt_free takes a context],
2249             sudo_cv_krb5_get_init_creds_opt_free_two_args, [
2250                 AC_TRY_COMPILE([#include <krb5.h>],
2251                     [krb5_get_init_creds_opt_free(NULL, NULL);],
2252                     [sudo_cv_krb5_get_init_creds_opt_free_two_args=yes],
2253                     [sudo_cv_krb5_get_init_creds_opt_free_two_args=no]
2254                 )
2255             ]
2256         )
2257     ])
2258     if test X"$sudo_cv_krb5_get_init_creds_opt_free_two_args" = X"yes"; then
2259         AC_DEFINE(HAVE_KRB5_GET_INIT_CREDS_OPT_FREE_TWO_ARGS)
2260     fi
2261     LIBS="$_LIBS"
2262 fi
2263
2264 dnl
2265 dnl extra AFS libs and includes
2266 dnl
2267 if test ${with_AFS-'no'} = "yes"; then
2268
2269     # looks like the "standard" place for AFS libs is /usr/afsws/lib
2270     AFSLIBDIRS="/usr/lib/afs /usr/afsws/lib /usr/afsws/lib/afs"
2271     for i in $AFSLIBDIRS; do
2272         if test -d ${i}; then
2273             SUDO_APPEND_LIBPATH(SUDO_LDFLAGS, [$i])
2274             FOUND_AFSLIBDIR=true
2275         fi
2276     done
2277     if test -z "$FOUND_AFSLIBDIR"; then
2278         AC_MSG_WARN([Unable to locate AFS libraries, you will have to edit the Makefile and add -L/path/to/afs/libs to SUDO_LDFLAGS or rerun configure with the --with-libpath options.])
2279     fi
2280
2281     # Order is important here.  Note that we build AFS_LIBS from right to left
2282     # since AFS_LIBS may be initialized with BSD compat libs that must go last
2283     AFS_LIBS="-laudit ${AFS_LIBS}"
2284     for i in $AFSLIBDIRS; do
2285         if test -f ${i}/util.a; then
2286             AFS_LIBS="${i}/util.a ${AFS_LIBS}"
2287             FOUND_UTIL_A=true
2288             break;
2289         fi
2290     done
2291     if test -z "$FOUND_UTIL_A"; then
2292         AFS_LIBS="-lutil ${AFS_LIBS}"
2293     fi
2294     AFS_LIBS="-lkauth -lprot -lubik -lauth -lrxkad -lsys -ldes -lrx -llwp -lcom_err ${AFS_LIBS}"
2295
2296     # AFS includes may live in /usr/include on some machines...
2297     for i in /usr/afsws/include; do
2298         if test -d ${i}; then
2299             CPPFLAGS="${CPPFLAGS} -I${i}"
2300             FOUND_AFSINCDIR=true
2301         fi
2302     done
2303
2304     if test -z "$FOUND_AFSLIBDIR"; then
2305         AC_MSG_WARN([Unable to locate AFS include dir, you may have to edit the Makefile and add -I/path/to/afs/includes to CPPFLAGS or rerun configure with the --with-incpath options.])
2306     fi
2307
2308     AUTH_OBJS="$AUTH_OBJS afs.o"
2309 fi
2310
2311 dnl
2312 dnl extra DCE obj + lib
2313 dnl Order of libs in HP-UX 10.x is important, -ldce must be last.
2314 dnl
2315 if test ${with_DCE-'no'} = "yes"; then
2316     DCE_OBJS="${DCE_OBJS} dce_pwent.o"
2317     SUDO_LIBS="${SUDO_LIBS} -ldce"
2318     AUTH_OBJS="$AUTH_OBJS dce.o"
2319 fi
2320
2321 dnl
2322 dnl extra S/Key lib and includes
2323 dnl
2324 if test ${with_skey-'no'} = "yes"; then
2325     O_LDFLAGS="$LDFLAGS"
2326     if test "$with_skey" != "yes"; then
2327         CPPFLAGS="${CPPFLAGS} -I${with_skey}/include"
2328         SUDO_APPEND_LIBPATH(LDFLAGS, [${with_skey}/lib])
2329         SUDO_APPEND_LIBPATH(SUDO_LDFLAGS, [${with_skey}/lib])
2330         AC_PREPROC_IFELSE([#include <skey.h>], [found=yes], [found=no])
2331     else
2332         found=no
2333         O_CPPFLAGS="$CPPFLAGS"
2334         for dir in "" "/usr/local" "/usr/contrib"; do
2335             test -n "$dir" && CPPFLAGS="$O_CPPFLAGS -I${dir}/include"
2336             AC_PREPROC_IFELSE([#include <skey.h>], [found=yes; break])
2337         done
2338         if test "$found" = "no" -o -z "$dir"; then
2339             CPPFLAGS="$O_CPPFLAGS"
2340         else
2341             SUDO_APPEND_LIBPATH(LDFLAGS, [${dir}/lib])
2342             SUDO_APPEND_LIBPATH(SUDO_LDFLAGS, [${dir}/lib])
2343         fi
2344     fi
2345     if test "$found" = "no"; then
2346         AC_MSG_WARN([Unable to locate skey.h, you will have to edit the Makefile and add -I/path/to/skey/includes to CPPFLAGS])
2347     fi
2348     AC_CHECK_LIB(skey, main, [found=yes], [AC_MSG_WARN([Unable to locate libskey.a, you will have to edit the Makefile and add -L/path/to/skey/lib to SUDO_LDFLAGS])])
2349     AC_CHECK_LIB(skey, skeyaccess, AC_DEFINE(HAVE_SKEYACCESS))
2350     LDFLAGS="$O_LDFLAGS"
2351     SUDO_LIBS="${SUDO_LIBS} -lskey"
2352     AUTH_OBJS="$AUTH_OBJS rfc1938.o"
2353 fi
2354
2355 dnl
2356 dnl extra OPIE lib and includes
2357 dnl
2358 if test ${with_opie-'no'} = "yes"; then
2359     O_LDFLAGS="$LDFLAGS"
2360     if test "$with_opie" != "yes"; then
2361         CPPFLAGS="${CPPFLAGS} -I${with_opie}/include"
2362         SUDO_APPEND_LIBPATH(LDFLAGS, [${with_opie}/lib])
2363         SUDO_APPEND_LIBPATH(SUDO_LDFLAGS, [${with_opie}/lib])
2364         AC_PREPROC_IFELSE([#include <opie.h>], [found=yes], [found=no])
2365     else
2366         found=no
2367         O_CPPFLAGS="$CPPFLAGS"
2368         for dir in "" "/usr/local" "/usr/contrib"; do
2369             test -n "$dir" && CPPFLAGS="$O_CPPFLAGS -I${dir}/include"
2370             AC_PREPROC_IFELSE([#include <opie.h>], [found=yes; break])
2371         done
2372         if test "$found" = "no" -o -z "$dir"; then
2373             CPPFLAGS="$O_CPPFLAGS"
2374         else
2375             SUDO_APPEND_LIBPATH(LDFLAGS, [${dir}/lib])
2376             SUDO_APPEND_LIBPATH(SUDO_LDFLAGS, [${dir}/lib])
2377         fi
2378     fi
2379     if test "$found" = "no"; then
2380         AC_MSG_WARN([Unable to locate opie.h, you will have to edit the Makefile and add -I/path/to/opie/includes to CPPFLAGS])
2381     fi
2382     AC_CHECK_LIB(opie, main, [found=yes], [AC_MSG_WARN([Unable to locate libopie.a, you will have to edit the Makefile and add -L/path/to/opie/lib to SUDO_LDFLAGS])])
2383     LDFLAGS="$O_LDFLAGS"
2384     SUDO_LIBS="${SUDO_LIBS} -lopie"
2385     AUTH_OBJS="$AUTH_OBJS rfc1938.o"
2386 fi
2387
2388 dnl
2389 dnl Check for shadow password routines if we have not already done so.
2390 dnl If there is a specific list of functions to check we do that first.
2391 dnl Otherwise, we check for SVR4-style and then SecureWare-style.
2392 dnl
2393 if test ${with_passwd-'no'} != "no"; then
2394     dnl
2395     dnl if crypt(3) not in libc, look elsewhere
2396     dnl
2397     if test -z "$LIB_CRYPT" -a "$with_passwd" != "no"; then
2398         AC_SEARCH_LIBS([crypt], [crypt crypt_d ufc], [test -n "$ac_lib" && SUDO_LIBS="${SUDO_LIBS} $ac_res"])
2399     fi
2400
2401     if test "$CHECKSHADOW" = "true" -a -n "$shadow_funcs"; then
2402         _LIBS="$LIBS"
2403         LIBS="$LIBS $shadow_libs"
2404         found=no
2405         AC_CHECK_FUNCS($shadow_funcs, [found=yes])
2406         if test "$found" = "yes"; then
2407             SUDO_LIBS="$SUDO_LIBS $shadow_libs"
2408         elif test -n "$shadow_libs_optional"; then
2409             LIBS="$LIBS $shadow_libs_optional"
2410             AC_CHECK_FUNCS($shadow_funcs, [found=yes])
2411             if test "$found" = "yes"; then
2412                 SUDO_LIBS="$SUDO_LIBS $shadow_libs $shadow_libs_optional"
2413             fi
2414         fi
2415         if test "$found" = "yes"; then
2416             case "$shadow_funcs" in
2417                 *getprpwnam*) SECUREWARE=1;;
2418             esac
2419             test -n "$shadow_defs" && OSDEFS="${OSDEFS} $shadow_defs"
2420         else
2421             LIBS="$_LIBS"
2422         fi
2423         CHECKSHADOW=false
2424     fi
2425     if test "$CHECKSHADOW" = "true"; then
2426         AC_SEARCH_LIBS([getspnam], [gen], [AC_DEFINE(HAVE_GETSPNAM)] [CHECKSHADOW=false; test -n "$ac_lib" && SUDO_LIBS="${SUDO_LIBS} $ac_res"])
2427     fi
2428     if test "$CHECKSHADOW" = "true"; then
2429         AC_SEARCH_LIBS([getprpwnam], [sec security prot], [AC_DEFINE(HAVE_GETPRPWNAM)] [CHECKSHADOW=false; SECUREWARE=1; test -n "$ac_lib" && SUDO_LIBS="${SUDO_LIBS} $ac_res"])
2430     fi
2431     if test -n "$SECUREWARE"; then
2432         AC_CHECK_FUNCS(bigcrypt set_auth_parameters initprivs)
2433         AUTH_OBJS="$AUTH_OBJS secureware.o"
2434     fi
2435 fi
2436
2437 dnl
2438 dnl extra lib and .o file for LDAP support
2439 dnl
2440 if test ${with_ldap-'no'} != "no"; then
2441     _LDFLAGS="$LDFLAGS"
2442     if test "$with_ldap" != "yes"; then
2443         SUDO_APPEND_LIBPATH(SUDO_LDFLAGS, [${with_ldap}/lib])
2444         SUDO_APPEND_LIBPATH(LDFLAGS, [${with_ldap}/lib])
2445         CPPFLAGS="${CPPFLAGS} -I${with_ldap}/include"
2446         with_ldap=yes
2447     fi
2448     SUDO_OBJS="${SUDO_OBJS} ldap.o"
2449     LDAP=""
2450
2451     AC_MSG_CHECKING([for LDAP libraries])
2452     LDAP_LIBS=""
2453     _LIBS="$LIBS"
2454     found=no
2455     for l in -lldap -llber '-lssl -lcrypto'; do
2456         LIBS="${LIBS} $l"
2457         LDAP_LIBS="${LDAP_LIBS} $l"
2458         AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
2459         #include <lber.h>
2460         #include <ldap.h>]], [[(void)ldap_init(0, 0)]])], [found=yes; break])
2461     done
2462     dnl if nothing linked just try with -lldap
2463     if test "$found" = "no"; then
2464         LIBS="${_LIBS} -lldap"
2465         LDAP_LIBS="-lldap"
2466         AC_MSG_RESULT([not found, using -lldap])
2467     else
2468         AC_MSG_RESULT([$LDAP_LIBS])
2469     fi
2470     dnl check if we need to link with -llber for ber_set_option
2471     OLIBS="$LIBS"
2472     AC_SEARCH_LIBS([ber_set_option], [lber], [found=yes], [found=no])
2473     if test X"$found" = X"yes" -a X"$LIBS" != X"$OLIBS"; then
2474         LDAP_LIBS="$LDAP_LIBS -llber"
2475     fi
2476     dnl check if ldap.h includes lber.h for us
2477     AC_MSG_CHECKING([whether lber.h is needed])
2478     AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
2479     #include <ldap.h>]], [[(void)ldap_init(0, 0)]])], [AC_MSG_RESULT([no])], [
2480     AC_MSG_RESULT([yes])
2481     AC_DEFINE(HAVE_LBER_H)])
2482
2483     AC_CHECK_HEADERS([sasl/sasl.h] [sasl.h], [AC_CHECK_FUNCS(ldap_sasl_interactive_bind_s)], [break])
2484     AC_CHECK_HEADERS([ldap_ssl.h] [mps/ldap_ssl.h], [break], [], [#include <ldap.h>])
2485     AC_CHECK_FUNCS(ldap_initialize ldap_start_tls_s ldapssl_init ldapssl_set_strength ldap_search_ext_s ldap_unbind_ext_s ldap_str2dn ldap_create ldap_sasl_bind_s ldap_ssl_client_init ldap_start_tls_s_np)
2486
2487     if test X"$check_gss_krb5_ccache_name" = X"yes"; then
2488         AC_CHECK_LIB(gssapi, gss_krb5_ccache_name,
2489             AC_DEFINE(HAVE_GSS_KRB5_CCACHE_NAME)
2490             [LDAP_LIBS="${LDAP_LIBS} -lgssapi"],
2491             AC_CHECK_LIB(gssapi_krb5, gss_krb5_ccache_name,
2492                 AC_DEFINE(HAVE_GSS_KRB5_CCACHE_NAME)
2493                 [LDAP_LIBS="${LDAP_LIBS} -lgssapi_krb5"])
2494         )
2495
2496         # gssapi headers may be separate or part of Kerberos V
2497         found=no
2498         O_CPPFLAGS="$CPPFLAGS"
2499         for dir in "" "kerberosV" "krb5" "kerberos5" "kerberosv5"; do
2500             test X"$dir" != X"" && CPPFLAGS="$O_CPPFLAGS -I/usr/include/${dir}"
2501             AC_PREPROC_IFELSE([#include <gssapi/gssapi.h>], [found="gssapi/gssapi.h"; break], [AC_PREPROC_IFELSE([#include <gssapi.h>], [found="gssapi.h"; break])])
2502         done
2503         if test X"$found" != X"no"; then
2504             AC_CHECK_HEADERS([$found])
2505             if test X"$found" = X"gssapi/gssapi.h"; then
2506                 AC_CHECK_HEADERS([gssapi/gssapi_krb5.h])
2507             fi
2508         else
2509             CPPFLAGS="$O_CPPFLAGS"
2510             AC_MSG_WARN([Unable to locate gssapi.h, you will have to edit the Makefile and add -I/path/to/gssapi/includes to CPPFLAGS])
2511         fi
2512     fi
2513
2514     SUDO_LIBS="${SUDO_LIBS} ${LDAP_LIBS}"
2515     LIBS="$_LIBS"
2516     LDFLAGS="$_LDFLAGS"
2517 fi
2518
2519 dnl
2520 dnl Add LIBVAS_RPATH to LDFLAGS
2521 dnl GNU ld accepts -R/path/ as an alias for -rpath /path/
2522 dnl
2523 if test X"$LIBVAS_RPATH" != X""; then
2524     if test -n "$blibpath"; then
2525         blibpath_add="${blibpath_add}:$LIBVAS_RPATH"
2526     else
2527         LDFLAGS="$LDFLAGS -R$LIBVAS_RPATH"
2528     fi
2529 fi
2530
2531 dnl
2532 dnl Add $blibpath to SUDO_LDFLAGS if specified by the user or if we
2533 dnl added -L dirpaths to SUDO_LDFLAGS.
2534 dnl
2535 if test -n "$blibpath"; then
2536     if test -n "$blibpath_add"; then
2537         SUDO_LDFLAGS="$SUDO_LDFLAGS -Wl,-blibpath:${blibpath}${blibpath_add}"
2538     elif test -n "$with_blibpath" -a "$with_blibpath" != "yes"; then
2539         SUDO_LDFLAGS="$SUDO_LDFLAGS -Wl,-blibpath:${blibpath}"
2540     fi
2541 fi
2542
2543 dnl
2544 dnl Check for log file and timestamp locations
2545 dnl
2546 SUDO_LOGFILE
2547 SUDO_TIMEDIR
2548
2549 dnl
2550 dnl Use passwd (and secureware) auth modules?
2551 dnl
2552 case "$with_passwd" in
2553 yes|maybe)
2554     AUTH_OBJS="$AUTH_OBJS passwd.o"
2555     ;;
2556 *)
2557     AC_DEFINE(WITHOUT_PASSWD)
2558     if test -z "$AUTH_OBJS"; then
2559         AC_MSG_ERROR([no authentication methods defined.])
2560     fi
2561     ;;
2562 esac
2563 AUTH_OBJS=${AUTH_OBJS# }
2564 _AUTH=`echo "$AUTH_OBJS" | sed 's/\.o//g'`
2565 AC_MSG_NOTICE([using the following authentication methods: $_AUTH])
2566
2567 dnl
2568 dnl LIBS may contain duplicates from SUDO_LIBS or NET_LIBS so prune it.
2569 dnl
2570 if test -n "$LIBS"; then
2571     L="$LIBS"
2572     LIBS=
2573     for l in ${L}; do
2574         dupe=0
2575         for sl in ${SUDO_LIBS} ${NET_LIBS}; do
2576             test $l = $sl && dupe=1
2577         done
2578         test $dupe = 0 && LIBS="${LIBS} $l"
2579     done
2580 fi
2581
2582 dnl
2583 dnl Set exec_prefix
2584 dnl
2585 test "$exec_prefix" = "NONE" && exec_prefix='$(prefix)'
2586
2587 dnl
2588 dnl Defer setting _PATH_SUDO_NOEXEC until after exec_prefix is set
2589 dnl XXX - this is gross!
2590 dnl
2591 if test X"$with_noexec" != X"no" -o X"$with_selinux" != X"no"; then
2592     oexec_prefix="$exec_prefix"
2593     if test "$exec_prefix" = '$(prefix)'; then
2594         if test "$prefix" = "NONE"; then
2595             exec_prefix="$ac_default_prefix"
2596         else
2597             exec_prefix="$prefix"
2598         fi
2599     fi
2600     if test X"$with_noexec" != X"no"; then
2601         PROGS="${PROGS} sudo_noexec.la"
2602         INSTALL_NOEXEC="install-noexec"
2603
2604         eval noexec_file="$with_noexec"
2605         AC_DEFINE_UNQUOTED(_PATH_SUDO_NOEXEC, "$noexec_file", [The fully qualified pathname of sudo_noexec.so])
2606     fi
2607     if test X"$with_selinux" != X"no"; then
2608         eval sesh_file="$libexecdir/sesh"
2609         AC_DEFINE_UNQUOTED(_PATH_SUDO_SESH, "$sesh_file", [The fully qualified pathname of sesh])
2610     fi
2611     exec_prefix="$oexec_prefix"
2612 fi
2613
2614 dnl
2615 dnl Substitute into the Makefile and man pages
2616 dnl
2617 AC_CONFIG_FILES([Makefile sudo.man visudo.man sudoers.man sudoers.ldap.man sudo_usage.h])
2618 AC_OUTPUT
2619
2620 dnl
2621 dnl Spew any text the user needs to know about
2622 dnl
2623 if test "$with_pam" = "yes"; then
2624     case $host in
2625         *-*-linux*)
2626             AC_MSG_NOTICE([You will need to customize sample.pam and install it as /etc/pam.d/sudo])
2627             ;;
2628     esac
2629 fi
2630
2631 dnl
2632 dnl Autoheader templates
2633 dnl
2634 AH_TEMPLATE(BROKEN_SYSLOG, [Define to 1 if the `syslog' function returns a non-zero int to denote failure.])
2635 AH_TEMPLATE(CLASSIC_INSULTS, [Define to 1 if you want the insults from the "classic" version sudo.])
2636 AH_TEMPLATE(CSOPS_INSULTS, [Define to 1 if you want insults culled from the twisted minds of CSOps.])
2637 AH_TEMPLATE(DONT_LEAK_PATH_INFO, [Define to 1 if you want sudo to display "command not allowed" instead of "command not found" when a command cannot be found.])
2638 AH_TEMPLATE(ENV_EDITOR, [Define to 1 if you want visudo to honor the EDITOR and VISUAL env variables.])
2639 AH_TEMPLATE(FQDN, [Define to 1 if you want to require fully qualified hosts in sudoers.])
2640 AH_TEMPLATE(GOONS_INSULTS, [Define to 1 if you want insults from the "Goon Show".])
2641 AH_TEMPLATE(HAL_INSULTS, [Define to 1 if you want 2001-like insults.])
2642 AH_TEMPLATE(HAVE_AFS, [Define to 1 if you use AFS.])
2643 AH_TEMPLATE(HAVE_AIXAUTH, [Define to 1 if you use AIX general authentication.])
2644 AH_TEMPLATE(HAVE_BSD_AUTH_H, [Define to 1 if you use BSD authentication.])
2645 AH_TEMPLATE(HAVE_BSM_AUDIT, [Define to 1 to enable BSM auditing.])
2646 AH_TEMPLATE(HAVE_DCE, [Define to 1 if you use OSF DCE.])
2647 AH_TEMPLATE(HAVE_DD_FD, [Define to 1 if your `DIR' contains dd_fd.])
2648 AH_TEMPLATE(HAVE_DIRFD, [Define to 1 if you have the `dirfd' function or macro.])
2649 AH_TEMPLATE(HAVE_DGETTEXT, [Define to 1 if you have the `dgettext' function.])
2650 AH_TEMPLATE(HAVE_DISPCRYPT, [Define to 1 if you have the `dispcrypt' function.])
2651 AH_TEMPLATE(HAVE_EXTENDED_GLOB, [Define to 1 if your glob.h defines the GLOB_BRACE and GLOB_TILDE flags.])
2652 AH_TEMPLATE(HAVE_FCNTL_CLOSEM, [Define to 1 if your system has the F_CLOSEM fcntl.])
2653 AH_TEMPLATE(HAVE_FNMATCH, [Define to 1 if you have the `fnmatch' function.])
2654 AH_TEMPLATE(HAVE_FWTK, [Define to 1 if you use the FWTK authsrv daemon.])
2655 AH_TEMPLATE(HAVE_GETAUTHUID, [Define to 1 if you have the `getauthuid' function. (ULTRIX 4.x  shadow passwords)])
2656 AH_TEMPLATE(HAVE_GETPRPWNAM, [Define to 1 if you have the `getprpwnam' function.  (SecureWare-style shadow passwords)])
2657 AH_TEMPLATE(HAVE_GETPWANAM, [Define to 1 if you have the `getpwanam' function. (SunOS 4.x shadow passwords)])
2658 AH_TEMPLATE(HAVE_GETSPNAM, [Define to 1 if you have the `getspnam' function (SVR4-style shadow passwords)])
2659 AH_TEMPLATE(HAVE_GETSPWUID, [Define to 1 if you have the `getspwuid' function. (HP-UX <= 9.X shadow passwords)])
2660 AH_TEMPLATE(HAVE_GSS_KRB5_CCACHE_NAME, [Define to 1 if you have the `gss_krb5_ccache_name' function.])
2661 AH_TEMPLATE(HAVE_HEIMDAL, [Define to 1 if your Kerberos is Heimdal.])
2662 AH_TEMPLATE(HAVE_IN6_ADDR, [Define to 1 if <netinet/in.h> contains struct in6_addr.])
2663 AH_TEMPLATE(HAVE_ISCOMSEC, [Define to 1 if you have the `iscomsec' function. (HP-UX >= 10.x check for shadow enabled)])
2664 AH_TEMPLATE(HAVE_ISSECURE, [Define to 1 if you have the `issecure' function. (SunOS 4.x check for shadow enabled)])
2665 AH_TEMPLATE(HAVE_KERB4, [Define to 1 if you use Kerberos IV.])
2666 AH_TEMPLATE(HAVE_KERB5, [Define to 1 if you use Kerberos V.])
2667 AH_TEMPLATE(HAVE_KRB5_GET_INIT_CREDS_OPT_ALLOC, [Define to 1 if you have the `krb5_get_init_creds_opt_alloc' function.])
2668 AH_TEMPLATE(HAVE_KRB5_GET_INIT_CREDS_OPT_FREE_TWO_ARGS, [Define to 1 if your `krb5_get_init_creds_opt_free' function takes two arguments.])
2669 AH_TEMPLATE(HAVE_KRB5_INIT_SECURE_CONTEXT, [Define to 1 if you have the `krb5_init_secure_context' function.])
2670 AH_TEMPLATE(HAVE_KRB5_VERIFY_USER, [Define to 1 if you have the `krb5_verify_user' function.])
2671 AH_TEMPLATE(HAVE_LBER_H, [Define to 1 if your LDAP needs <lber.h>. (OpenLDAP does not)])
2672 AH_TEMPLATE(HAVE_LDAP, [Define to 1 if you use LDAP for sudoers.])
2673 AH_TEMPLATE(HAVE_OPIE, [Define to 1 if you use NRL OPIE.])
2674 AH_TEMPLATE(HAVE_PAM, [Define to 1 if you use PAM authentication.])
2675 AH_TEMPLATE(HAVE_PROJECT_H, [Define to 1 if you have the <project.h> header file.])
2676 AH_TEMPLATE(HAVE_SECURID, [Define to 1 if you use SecurID for authentication.])
2677 AH_TEMPLATE(HAVE_SELINUX, [Define to 1 to enable SELinux RBAC support.])
2678 AH_TEMPLATE(HAVE_SIGACTION_T, [Define to 1 if <signal.h> has the sigaction_t typedef.])
2679 AH_TEMPLATE(HAVE_SKEY, [Define to 1 if you use S/Key.])
2680 AH_TEMPLATE(HAVE_SKEYACCESS, [Define to 1 if your S/Key library has skeyaccess().])
2681 AH_TEMPLATE(HAVE_ST__TIM, [Define to 1 if your struct stat uses an st__tim union])
2682 AH_TEMPLATE(HAVE_ST_MTIM, [Define to 1 if your struct stat has an st_mtim member])
2683 AH_TEMPLATE(HAVE_ST_MTIMESPEC, [Define to 1 if your struct stat has an st_mtimespec member])
2684 AH_TEMPLATE(HAVE_TERMIOS_H, [Define to 1 if you have the <termios.h> header file and the `tcgetattr' function.])
2685 AH_TEMPLATE(HAVE_TIMESPEC, [Define to 1 if you have struct timespec in sys/time.h])
2686 AH_TEMPLATE(HAVE_TIMESPECSUB2, [Define to 1 if you have a timespecsub macro or function that takes two arguments (not three)])
2687 AH_TEMPLATE(HAVE___PROGNAME, [Define to 1 if your crt0.o defines the __progname symbol for you.])
2688 AH_TEMPLATE(HOST_IN_LOG, [Define to 1 if you want the hostname to be entered into the log file.])
2689 AH_TEMPLATE(IGNORE_DOT_PATH, [Define to 1 if you want to ignore '.' and empty PATH elements])
2690 AH_TEMPLATE(LOGGING, [Define to SLOG_SYSLOG, SLOG_FILE, or SLOG_BOTH.])
2691 AH_TEMPLATE(LONG_OTP_PROMPT, [Define to 1 if you want a two line OTP (S/Key or OPIE) prompt.])
2692 AH_TEMPLATE(NO_AUTHENTICATION, [Define to 1 if you don't want sudo to prompt for a password by default.])
2693 AH_TEMPLATE(NO_LECTURE, [Define to 1 if you don't want users to get the lecture the first they user sudo.])
2694 AH_TEMPLATE(NO_ROOT_MAILER, [Define to avoid runing the mailer as root.])
2695 AH_TEMPLATE(NO_ROOT_SUDO, [Define to 1 if root should not be allowed to use sudo.])
2696 AH_TEMPLATE(PC_INSULTS, [Define to 1 to replace politically incorrect insults with less offensive ones.])
2697 AH_TEMPLATE(SECURE_PATH, [Define to 1 to override the user's path with a built-in one.])
2698 AH_TEMPLATE(SEND_MAIL_WHEN_NOT_OK, [Define to 1 to send mail when the user is not allowed to run a command.])
2699 AH_TEMPLATE(SEND_MAIL_WHEN_NO_HOST, [Define to 1 to send mail when the user is not allowed to run sudo on this host.])
2700 AH_TEMPLATE(SEND_MAIL_WHEN_NO_USER, [Define to 1 to send mail when the user is not in the sudoers file.])
2701 AH_TEMPLATE(SHELL_IF_NO_ARGS, [Define to 1 if you want sudo to start a shell if given no arguments.])
2702 AH_TEMPLATE(SHELL_SETS_HOME, [Define to 1 if you want sudo to set $HOME in shell mode.])
2703 AH_TEMPLATE(STUB_LOAD_INTERFACES, [Define to 1 if the code in interfaces.c does not compile for you.])
2704 AH_TEMPLATE(USE_INSULTS, [Define to 1 if you want to insult the user for entering an incorrect password.])
2705 AH_TEMPLATE(USE_STOW, [Define to 1 if you use GNU stow packaging.])
2706 AH_TEMPLATE(USE_TTY_TICKETS, [Define to 1 if you want a different ticket file for each tty.])
2707 AH_TEMPLATE(WITHOUT_PASSWD, [Define to avoid using the passwd/shadow file for authentication.])
2708 AH_TEMPLATE(sig_atomic_t, [Define to `int' if <signal.h> does not define.])
2709 AH_TEMPLATE(__signed, [Define to `signed' or nothing if compiler does not support a signed type qualifier.])
2710 AH_TEMPLATE(USING_NONUNIX_GROUPS, [Define to 1 if using a non-Unix group lookup implementation.])
2711
2712 dnl
2713 dnl Bits to copy verbatim into config.h.in
2714 dnl
2715 AH_TOP([#ifndef _SUDO_CONFIG_H
2716 #define _SUDO_CONFIG_H])
2717
2718 AH_BOTTOM([/*
2719  * Macros to pull sec and nsec parts of mtime from struct stat.
2720  * We need to be able to convert between timeval and timespec
2721  * so the last 3 digits of tv_nsec are not significant.
2722  */
2723 #ifdef HAVE_ST_MTIM
2724 # ifdef HAVE_ST__TIM
2725 #  define mtim_getsec(_x)       ((_x).st_mtim.st__tim.tv_sec)
2726 #  define mtim_getnsec(_x)      (((_x).st_mtim.st__tim.tv_nsec / 1000) * 1000)
2727 # else
2728 #  define mtim_getsec(_x)       ((_x).st_mtim.tv_sec)
2729 #  define mtim_getnsec(_x)      (((_x).st_mtim.tv_nsec / 1000) * 1000)
2730 # endif
2731 #else
2732 # ifdef HAVE_ST_MTIMESPEC
2733 #  define mtim_getsec(_x)       ((_x).st_mtimespec.tv_sec)
2734 #  define mtim_getnsec(_x)      (((_x).st_mtimespec.tv_nsec / 1000) * 1000)
2735 # else
2736 #  define mtim_getsec(_x)       ((_x).st_mtime)
2737 #  define mtim_getnsec(_x)      (0)
2738 # endif /* HAVE_ST_MTIMESPEC */
2739 #endif /* HAVE_ST_MTIM */
2740
2741 /*
2742  * Emulate a subset of waitpid() if we don't have it.
2743  */
2744 #ifdef HAVE_WAITPID
2745 # define sudo_waitpid(p, s, o)  waitpid(p, s, o)
2746 #else
2747 # ifdef HAVE_WAIT3
2748 #  define sudo_waitpid(p, s, o) wait3(s, o, NULL)
2749 # endif
2750 #endif
2751
2752 /* GNU stow needs /etc/sudoers to be a symlink. */
2753 #ifdef USE_STOW
2754 # define stat_sudoers   stat
2755 #else
2756 # define stat_sudoers   lstat
2757 #endif
2758
2759 /* Macros to set/clear/test flags. */
2760 #undef SET
2761 #define SET(t, f)       ((t) |= (f))
2762 #undef CLR
2763 #define CLR(t, f)       ((t) &= ~(f))
2764 #undef ISSET
2765 #define ISSET(t, f)     ((t) & (f))
2766
2767 /* New ANSI-style OS defs for HP-UX and ConvexOS. */
2768 #if defined(hpux) && !defined(__hpux)
2769 # define __hpux         1
2770 #endif /* hpux */
2771
2772 #if defined(convex) && !defined(__convex__)
2773 # define __convex__     1
2774 #endif /* convex */
2775
2776 /* BSD compatibility on some SVR4 systems. */
2777 #ifdef __svr4__
2778 # define BSD_COMP
2779 #endif /* __svr4__ */
2780
2781 #endif /* _SUDO_CONFIG_H */])