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