Imported Upstream version 1.6.6
[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.349 2002/04/18 15:41:30 millert Exp $
4 dnl
5 dnl Copyright (c) 1994-1996,1998-2002 Todd C. Miller <Todd.Miller@courtesan.com>
6 dnl
7 AC_INIT(sudo, 1.6.6)
8 AC_CONFIG_HEADER(config.h pathnames.h)
9 dnl
10 dnl This won't work before AC_INIT()
11 dnl
12 echo "Configuring Sudo version 1.6.6"
13 dnl
14 dnl Variables that get substituted in the Makefile and man pages
15 dnl
16 AC_SUBST(CFLAGS)dnl
17 AC_SUBST(PROGS)dnl
18 AC_SUBST(CPPFLAGS)dnl
19 AC_SUBST(LDFLAGS)dnl
20 AC_SUBST(SUDO_LDFLAGS)dnl
21 AC_SUBST(LIBS)dnl
22 AC_SUBST(SUDO_LIBS)dnl
23 AC_SUBST(NET_LIBS)dnl
24 AC_SUBST(AFS_LIBS)dnl
25 AC_SUBST(OSDEFS)dnl
26 AC_SUBST(AUTH_OBJS)dnl
27 AC_SUBST(LIBOBJS)dnl
28 AC_SUBST(MANTYPE)dnl
29 AC_SUBST(MAN_POSTINSTALL)dnl
30 AC_SUBST(SUDOERS_MODE)dnl
31 AC_SUBST(SUDOERS_UID)dnl
32 AC_SUBST(SUDOERS_GID)dnl
33 AC_SUBST(DEV)
34 AC_SUBST(mansectsu)
35 AC_SUBST(mansectform)
36 AC_SUBST(mansrcdir)
37 dnl
38 dnl Variables that get substituted in docs (not overridden by environment)
39 dnl
40 AC_SUBST(timedir)dnl initial value from SUDO_TIMEDIR
41 AC_SUBST(timeout)
42 AC_SUBST(password_timeout)
43 AC_SUBST(sudo_umask)
44 AC_SUBST(passprompt)
45 AC_SUBST(long_otp_prompt)
46 AC_SUBST(lecture)
47 AC_SUBST(logfac)
48 AC_SUBST(goodpri)
49 AC_SUBST(badpri)
50 AC_SUBST(loglen)
51 AC_SUBST(ignore_dot)
52 AC_SUBST(mail_no_user)
53 AC_SUBST(mail_no_host)
54 AC_SUBST(mail_no_perms)
55 AC_SUBST(mailto)
56 AC_SUBST(mailsub)
57 AC_SUBST(badpass_message)
58 AC_SUBST(fqdn)
59 AC_SUBST(runas_default)
60 AC_SUBST(env_editor)
61 AC_SUBST(passwd_tries)
62 AC_SUBST(tty_tickets)
63 AC_SUBST(insults)
64 dnl
65 dnl Initial values for above
66 dnl
67 timeout=5
68 password_timeout=5
69 sudo_umask=0022
70 passprompt="Password:"
71 long_otp_prompt=off
72 lecture=on
73 logfac=local2
74 goodpri=notice
75 badpri=alert
76 loglen=80
77 ignore_dot=off
78 mail_no_user=on
79 mail_no_host=off
80 mail_no_perms=off
81 mailto=root
82 mailsub='*** SECURITY information for %h ***'
83 badpass_message='Sorry, try again.'
84 fqdn=off
85 runas_default=root
86 env_editor=off
87 passwd_tries=3
88 tty_tickets=off
89 insults=off
90 dnl
91 dnl Initial values for Makefile variables listed above
92 dnl May be overridden by environment variables..
93 dnl
94 PROGS="sudo visudo"
95 test -n "$MANTYPE" || MANTYPE="man"
96 test -n "$mansrcdir" || mansrcdir="."
97 test -n "$SUDOERS_MODE" || SUDOERS_MODE=0440
98 test -n "$SUDOERS_UID" || SUDOERS_UID=0
99 test -n "$SUDOERS_GID" || SUDOERS_GID=0
100 DEV="#"
101
102 dnl
103 dnl Other vaiables
104 dnl
105 CHECKSHADOW=true
106 CHECKSIA=true
107
108 dnl
109 dnl Override default configure dirs...
110 dnl
111 test "$mandir" = '${prefix}/man' && mandir='$(prefix)/man'
112 test "$bindir" = '${exec_prefix}/bin' && bindir='$(exec_prefix)/bin'
113 test "$sbindir" = '${exec_prefix}/sbin' && sbindir='$(exec_prefix)/sbin'
114 test "$sysconfdir" = '${prefix}/etc' && sysconfdir='/etc'
115
116 dnl
117 dnl Deprecated --with options (these all warn or generate an error)
118 dnl
119
120 AC_ARG_WITH(otp-only, [  --with-otp-only         deprecated],
121 [case $with_otp_only in
122     yes)        with_passwd=no
123                 AC_DEFINE(WITHOUT_PASSWD, 1, [Define to avoid using the passwd/shadow file for authentication.])
124                 AC_MSG_WARN([--with-otp-only option deprecated, treating as --without-passwd])
125                 ;;
126 esac])
127
128 AC_ARG_WITH(alertmail, [  --with-alertmail        deprecated],
129 [case $with_alertmail in
130     *)          with_mailto="$with_alertmail"
131                 AC_MSG_WARN([--with-alertmail option deprecated, treating as --mailto])
132                 ;;
133 esac])
134
135 dnl
136 dnl Options for --with
137 dnl
138
139 AC_ARG_WITH(CC, [  --with-CC               C compiler to use],
140 [case $with_CC in
141     yes)        AC_MSG_ERROR(["must give --with-CC an argument."])
142                 ;;
143     no)         AC_MSG_ERROR(["illegal argument: --without-CC."])
144                 ;;
145     *)          CC=$with_CC
146                 ;;
147 esac])
148
149 AC_ARG_WITH(incpath, [  --with-incpath          additional places to look for include files],
150 [case $with_incpath in  
151     yes)        AC_MSG_ERROR(["must give --with-incpath an argument."])
152                 ;;
153     no)         AC_MSG_ERROR(["--without-incpath not supported."])
154                 ;;
155     *)          echo "Adding ${with_incpath} to CPPFLAGS"
156                 for i in ${with_incpath}; do
157                     CPPFLAGS="${CPPFLAGS} -I${i}"
158                 done
159                 ;;
160 esac])
161
162 AC_ARG_WITH(libpath, [  --with-libpath          additional places to look for libraries],
163 [case $with_libpath in  
164     yes)        AC_MSG_ERROR(["must give --with-libpath an argument."])
165                 ;;
166     no)         AC_MSG_ERROR(["--without-libpath not supported."])
167                 ;;
168     *)          echo "Adding ${with_libpath} to LDFLAGS"
169                 for i in ${with_libpath}; do
170                     LDFLAGS="${LDFLAGS} -L${i}"
171                 done
172                 ;;
173 esac])
174
175 AC_ARG_WITH(libraries, [  --with-libraries        additional libraries to link with],
176 [case $with_libraries in  
177     yes)        AC_MSG_ERROR(["must give --with-libraries an argument."])
178                 ;;
179     no)         AC_MSG_ERROR(["--without-libraries not supported."])
180                 ;;
181     *)          echo "Adding ${with_libraries} to LIBS"
182                 for i in ${with_libraries}; do
183                     case $i in
184                         -l*)    ;;
185                         *.a)    ;;
186                         *.o)    ;;
187                         *)      i="-l${i}";;
188                     esac
189                     LIBS="${LIBS} ${i}"
190                 done
191                 ;;
192 esac])
193
194 AC_ARG_WITH(devel, [  --with-devel            add developement options],
195 [case $with_devel in  
196     yes)        echo 'Setting up for developement: -Wall, flex, yacc'
197                 PROGS="${PROGS} testsudoers"
198                 OSDEFS="${OSDEFS} -DSUDO_DEVEL"
199                 DEV=""
200                 ;;
201     no)         ;;
202     *)          echo "Ignoring unknown argument to --with-devel: $with_devel"
203                 ;;
204 esac])
205
206 AC_ARG_WITH(efence, [  --with-efence           link with -lefence for malloc() debugging],
207 [case $with_efence in  
208     yes)        echo 'Sudo will link with -lefence (Electric Fence)'
209                 LIBS="${LIBS} -lefence"
210                 if test -f /usr/local/lib/libefence.a; then
211                     LDFLAGS="${LDFLAGS} -L/usr/local/lib"
212                 fi
213                 ;;
214     no)         ;;
215     *)          echo "Ignoring unknown argument to --with-efence: $with_efence"
216                 ;;
217 esac])
218
219 AC_ARG_WITH(csops, [  --with-csops            add CSOps standard options],
220 [case $with_csops in  
221     yes)        echo 'Adding CSOps standard options'
222                 CHECKSIA=false
223                 with_ignore_dot=yes
224                 insults=on
225                 with_classic_insults=yes
226                 with_csops_insults=yes
227                 with_env_editor=yes
228                 ;;
229     no)         ;;
230     *)          echo "Ignoring unknown argument to --with-csops: $with_csops"
231                 ;;
232 esac])
233
234 AC_ARG_WITH(passwd, [  --without-passwd        don't use passwd/shadow file for authentication],
235 [case $with_passwd in
236     yes)        ;;
237     no)         AC_DEFINE(WITHOUT_PASSWD)
238                 AC_MSG_CHECKING(whether to use shadow/passwd file authentication)
239                 AC_MSG_RESULT(no)
240                 ;;
241     *)          AC_MSG_ERROR(["Sorry, --with-passwd does not take an argument."])
242                 ;;
243 esac])
244
245 AC_ARG_WITH(skey, [  --with-skey             enable S/Key support ],
246 [case $with_skey in
247     yes)        if test -n "$with_opie"; then
248                     AC_MSG_ERROR(["cannot use both S/Key and OPIE"])
249                 fi
250                 AC_DEFINE(HAVE_SKEY, 1, [Define if you use S/Key.])
251                 AC_MSG_CHECKING(whether to try S/Key authentication)
252                 AC_MSG_RESULT(yes)
253                 AUTH_OBJS="${AUTH_OBJS} rfc1938.o"
254                 ;;
255     no)         ;;
256     *)          echo "Ignoring unknown argument to --with-skey: $with_skey"
257                 ;;
258 esac])
259
260 AC_ARG_WITH(opie, [  --with-opie             enable OPIE support ],
261 [case $with_opie in
262     yes)        if test -n "$with_skey"; then
263                     AC_MSG_ERROR(["cannot use both S/Key and OPIE"])
264                 fi
265                 AC_DEFINE(HAVE_OPIE, 1, [Define if you use NRL OPIE.])
266                 AC_MSG_CHECKING(whether to try NRL OPIE authentication)
267                 AC_MSG_RESULT(yes)
268                 AUTH_OBJS="${AUTH_OBJS} rfc1938.o"
269                 ;;
270     no)         ;;
271     *)          echo "Ignoring unknown argument to --with-opie: $with_opie"
272                 ;;
273 esac])
274
275 AC_ARG_WITH(long-otp-prompt, [  --with-long-otp-prompt  use a two line OTP (skey/opie) prompt],
276 [case $with_long_otp_prompt in
277     yes)        AC_DEFINE(LONG_OTP_PROMPT, 1, [Define if you want a two line OTP (S/Key or OPIE) prompt.])
278                 AC_MSG_CHECKING(whether to use a two line prompt for OTP authentication)
279                 AC_MSG_RESULT(yes)
280                 long_otp_prompt=on
281                 ;;
282     no)         long_otp_prompt=off
283                 ;;
284     *)          AC_MSG_ERROR(["--with-long-otp-prompt does not take an argument."])
285                 ;;
286 esac])
287
288 AC_ARG_WITH(SecurID, [  --with-SecurID          enable SecurID support],
289 [case $with_SecurID in
290     no)         ;;
291     *)          AC_DEFINE(HAVE_SECURID, 1, [Define if you use SecurID.])
292                 AC_MSG_CHECKING(whether to use SecurID for authentication)
293                 AC_MSG_RESULT(yes)
294                 with_passwd=no
295                 AUTH_OBJS="securid.o"
296                 ;;
297 esac])
298
299 AC_ARG_WITH(fwtk, [  --with-fwtk             enable FWTK AuthSRV support],
300 [case $with_fwtk in
301     no)         ;;
302     *)          AC_DEFINE(HAVE_FWTK, 1, [Define if you use the FWTK authsrv daemon.])
303                 AC_MSG_CHECKING(whether to use FWTK AuthSRV for authentication)
304                 AC_MSG_RESULT(yes)
305                 with_passwd=no
306                 AUTH_OBJS="fwtk.o"
307                 if test "$with_fwtk" != "yes"; then
308                     SUDO_LDFLAGS="${SUDO_LDFLAGS} -L${with_fwtk}"
309                     CPPFLAGS="${CPPFLAGS} -I${with_fwtk}"
310                     with_fwtk=yes
311                 fi
312                 ;;
313 esac])
314
315 AC_ARG_WITH(kerb4, [  --with-kerb4            enable kerberos v4 support],
316 [case $with_kerb4 in
317     yes)        AC_MSG_CHECKING(whether to try Kerberos 4 authentication)
318                 AC_MSG_RESULT(yes)
319                 ;;
320     no)         ;;
321     *)          AC_MSG_ERROR(["--with-kerb4 does not take an argument."])
322                 ;;
323 esac])
324
325 AC_ARG_WITH(kerb5, [  --with-kerb5            enable kerberos v5 support],
326 [case $with_kerb5 in
327     yes)        AC_MSG_CHECKING(whether to try Kerberos 5 authentication)
328                 AC_MSG_RESULT(yes)
329                 ;;
330     no)         ;;
331     *)          AC_MSG_ERROR(["--with-kerb5 does not take an argument."])
332                 ;;
333 esac])
334
335 AC_ARG_WITH(authenticate, [  --with-authenticate     enable AIX general authentication support],
336 [case $with_authenticate in
337     yes)        AC_DEFINE(HAVE_AUTHENTICATE, 1, [Define if you use AIX general authentication.])
338                 AC_MSG_CHECKING(whether to use AIX general authentication)
339                 AC_MSG_RESULT(yes)
340                 with_passwd=no
341                 AUTH_OBJS="aix_auth.o"
342                 ;;
343     no)         ;;
344     *)          AC_MSG_ERROR(["--with-authenticate does not take an argument."])
345                 ;;
346 esac])
347
348 AC_ARG_WITH(pam, [  --with-pam              enable PAM support],
349 [case $with_pam in
350     yes)        AC_DEFINE(HAVE_PAM, 1, [Define if you use PAM.])
351                 AC_MSG_CHECKING(whether to use PAM authentication)
352                 AC_MSG_RESULT(yes)
353                 with_passwd=no
354                 AUTH_OBJS="pam.o"
355                 ;;
356     no)         ;;
357     *)          AC_MSG_ERROR(["--with-pam does not take an argument."])
358                 ;;
359 esac])
360
361 AC_ARG_WITH(AFS, [  --with-AFS              enable AFS support],
362 [case $with_AFS in
363     yes)        AC_DEFINE(HAVE_AFS, 1, [Define if you use AFS.])
364                 AC_MSG_CHECKING(whether to try AFS (kerberos) authentication)
365                 AC_MSG_RESULT(yes)
366                 AUTH_OBJS="${AUTH_OBJS} afs.o"
367                 ;;
368     no)         ;;
369     *)          AC_MSG_ERROR(["--with-AFS does not take an argument."])
370                 ;;
371 esac])
372
373 AC_ARG_WITH(DCE, [  --with-DCE              enable DCE support],
374 [case $with_DCE in
375     yes)        AC_DEFINE(HAVE_DCE, 1, [Define if you use OSF DCE.])
376                 AC_MSG_CHECKING(whether to try DCE (kerberos) authentication)
377                 AC_MSG_RESULT(yes)
378                 AUTH_OBJS="${AUTH_OBJS} dce.o"
379                 ;;
380     no)         ;;
381     *)          AC_MSG_ERROR(["--with-DCE does not take an argument."])
382                 ;;
383 esac])
384
385 AC_ARG_WITH(logincap, [  --with-logincap         enable BSD login class support],
386 [case $with_logincap in
387     yes|no)     ;;
388     *)          AC_MSG_ERROR(["--with-logincap does not take an argument."])
389                 ;;
390 esac])
391
392 AC_ARG_WITH(bsdauth, [  --with-bsdauth          enable BSD authentication support],
393 [case $with_bsdauth in
394     yes)        with_logincap=yes
395                 ;;
396     no)         ;;
397     *)          AC_MSG_ERROR(["--with-bsdauth does not take an argument."])
398                 ;;
399 esac])
400
401 AC_MSG_CHECKING(whether to lecture users the first time they run sudo)
402 AC_ARG_WITH(lecture, [  --without-lecture       don't print lecture for first-time sudoer],
403 [case $with_lecture in  
404     yes|short)  lecture=on
405                 ;;
406     no|none)    lecture=off
407                 ;;
408     *)          AC_MSG_ERROR(["unknown argument to --with-lecture: $with_lecture"])
409                 ;;
410 esac])
411 if test "$lecture" = "on"; then
412     AC_MSG_RESULT(yes)
413 else
414     AC_DEFINE(NO_LECTURE, 1, [Define if you don't want users to get the lecture the first they user sudo.])
415     AC_MSG_RESULT(no)
416 fi
417
418 AC_MSG_CHECKING(whether sudo should log via syslog or to a file by default)
419 AC_ARG_WITH(logging, [  --with-logging          log via syslog, file, or both],
420 [case $with_logging in  
421     yes)        AC_MSG_ERROR(["must give --with-logging an argument."])
422                 ;;
423     no)         AC_MSG_ERROR(["--without-logging not supported."])
424                 ;;
425     syslog)     AC_DEFINE(LOGGING, SLOG_SYSLOG, [Define to SLOG_SYSLOG, SLOG_FILE, or SLOG_BOTH.])
426                 AC_MSG_RESULT(syslog)
427                 ;;
428     file)       AC_DEFINE(LOGGING, SLOG_FILE)
429                 AC_MSG_RESULT(file)
430                 ;;
431     both)       AC_DEFINE(LOGGING, SLOG_BOTH)
432                 AC_MSG_RESULT(both)
433                 ;;
434     *)          AC_MSG_ERROR(["unknown argument to --with-logging: $with_logging"])
435                 ;;
436 esac], [AC_DEFINE(LOGGING, SLOG_SYSLOG) AC_MSG_RESULT(syslog)])
437
438 AC_MSG_CHECKING(which syslog facility sudo should log with)
439 AC_ARG_WITH(logfac, [  --with-logfac           syslog facility to log with (default is "local2")],
440 [case $with_logfac in  
441     yes)        AC_MSG_ERROR(["must give --with-logfac an argument."])
442                 ;;
443     no)         AC_MSG_ERROR(["--without-logfac not supported."])
444                 ;;
445     authpriv|auth|daemon|user|local0|local1|local2|local3|local4|local5|local6|local7)          logfac=$with_logfac
446                 ;;
447     *)          AC_MSG_ERROR(["$with_logfac is not a supported syslog facility."])
448                 ;;
449 esac])
450 AC_DEFINE_UNQUOTED(LOGFAC, "$logfac", [The syslog facility sudo will use.])
451 AC_MSG_RESULT($logfac)
452
453 AC_MSG_CHECKING(at which syslog priority to log commands)
454 AC_ARG_WITH(goodpri, [  --with-goodpri          syslog priority for commands (def is "notice")],
455 [case $with_goodpri in  
456     yes)        AC_MSG_ERROR(["must give --with-goodpri an argument."])
457                 ;;
458     no)         AC_MSG_ERROR(["--without-goodpri not supported."])
459                 ;;
460     alert|crit|debug|emerg|err|info|notice|warning)
461                 goodpri=$with_goodpri
462                 ;;
463     *)          AC_MSG_ERROR(["$with_goodpri is not a supported syslog priority."])
464                 ;;
465 esac])
466 AC_DEFINE_UNQUOTED(PRI_SUCCESS, "$goodpri", [The syslog priority sudo will use for successful attempts.])
467 AC_MSG_RESULT($goodpri)
468
469 AC_MSG_CHECKING(at which syslog priority to log failures)
470 AC_ARG_WITH(badpri, [  --with-badpri           syslog priority for failures (def is "alert")],
471 [case $with_badpri in  
472     yes)        AC_MSG_ERROR(["must give --with-badpri an argument."])
473                 ;;
474     no)         AC_MSG_ERROR(["--without-badpri not supported."])
475                 ;;
476     alert|crit|debug|emerg|err|info|notice|warning)
477                 badpri=$with_badpri
478                 ;;
479     *)          AC_MSG_ERROR([$with_badpri is not a supported syslog priority.])
480                 ;;
481 esac])
482 AC_DEFINE_UNQUOTED(PRI_FAILURE, "$badpri", [The syslog priority sudo will use for unsuccessful attempts/errors.])
483 AC_MSG_RESULT(badpri)
484
485 AC_ARG_WITH(logpath, [  --with-logpath          path to the sudo log file],
486 [case $with_logpath in  
487     yes)        AC_MSG_ERROR(["must give --with-logpath an argument."])
488                 ;;
489     no)         AC_MSG_ERROR(["--without-logpath not supported."])
490                 ;;
491 esac])
492
493 AC_MSG_CHECKING(how long a line in the log file should be)
494 AC_ARG_WITH(loglen, [  --with-loglen           maximum length of a log file line (default is 80)],
495 [case $with_loglen in  
496     yes)        AC_MSG_ERROR(["must give --with-loglen an argument."])
497                 ;;
498     no)         AC_MSG_ERROR(["--without-loglen not supported."])
499                 ;;
500     [[0-9]]*)   loglen=$with_loglen
501                 ;;
502     *)          AC_MSG_ERROR(["you must enter a number, not $with_loglen"])
503                 ;;
504 esac])
505 AC_DEFINE_UNQUOTED(MAXLOGFILELEN, $loglen, [The max number of chars per log file line (for line wrapping).])
506 AC_MSG_RESULT($loglen)
507
508 AC_MSG_CHECKING(whether sudo should ignore '.' or '' in \$PATH)
509 AC_ARG_WITH(ignore-dot, [  --with-ignore-dot       ignore '.' in the PATH],
510 [case $with_ignore_dot in  
511     yes)        ignore_dot=on
512                 ;;
513     no)         ignore_dot=off
514                 ;;
515     *)          AC_MSG_ERROR(["--with-ignore-dot does not take an argument."])
516                 ;;
517 esac])
518 if test "$ignore_dot" = "on"; then
519     AC_DEFINE(IGNORE_DOT_PATH, 1, [Define if you want to ignore '.' and empty \$PATH elements])
520     AC_MSG_RESULT(yes)
521 else
522     AC_MSG_RESULT(no)
523 fi
524
525 AC_MSG_CHECKING(whether to send mail when a user is not in sudoers)
526 AC_ARG_WITH(mail-if-no-user, [  --without-mail-if-no-user do not send mail if user not in sudoers],
527 [case $with_mail_if_no_user in  
528     yes)        mail_no_user=on
529                 ;;
530     no)         mail_no_user=off
531                 ;;
532     *)          AC_MSG_ERROR(["--with-mail-if-no-user does not take an argument."])
533                 ;;
534 esac])
535 if test "$mail_no_user" = "on"; then
536     AC_DEFINE(SEND_MAIL_WHEN_NO_USER, 1, [Define to send mail when the user is not in the sudoers file.])
537     AC_MSG_RESULT(yes)
538 else
539     AC_MSG_RESULT(no)
540 fi
541
542 AC_MSG_CHECKING(whether to send mail when user listed but not for this host)
543 AC_ARG_WITH(mail-if-no-host, [  --with-mail-if-no-host  send mail if user in sudoers but not for this host],
544 [case $with_mail_if_no_host in  
545     yes)        mail_no_host=on
546                 ;;
547     no)         mail_no_host=off
548                 ;;
549     *)          AC_MSG_ERROR(["--with-mail-if-no-host does not take an argument."])
550                 ;;
551 esac])
552 if test "$mail_no_host" = "on"; then
553     AC_DEFINE(SEND_MAIL_WHEN_NO_HOST, 1, [Define to send mail when the user is not not allowed to run sudo on this host.])
554     AC_MSG_RESULT(yes)
555 else
556     AC_MSG_RESULT(no)
557 fi
558
559 AC_MSG_CHECKING(whether to send mail when a user tries a disallowed command)
560 AC_ARG_WITH(mail-if-noperms, [  --with-mail-if-noperms  send mail if user not allowed to run command],
561 [case $with_mail_if_noperms in  
562     yes)        mail_noperms=on
563                 ;;
564     no)         mail_noperms=off
565                 ;;
566     *)          AC_MSG_ERROR(["--with-mail-if-noperms does not take an argument."])
567                 ;;
568 esac])
569 if test "$mail_noperms" = "on"; then
570     AC_DEFINE(SEND_MAIL_WHEN_NOT_OK, 1, [Define to send mail when the user is not not allowed to run a command.])
571     AC_MSG_RESULT(yes)
572 else
573     AC_MSG_RESULT(no)
574 fi
575
576 AC_MSG_CHECKING(who should get the mail that sudo sends)
577 AC_ARG_WITH(mailto, [  --with-mailto           who should get sudo mail (default is "root")],
578 [case $with_mailto in  
579     yes)        AC_MSG_ERROR(["must give --with-mailto an argument."])
580                 ;;
581     no)         AC_MSG_ERROR(["--without-mailto not supported."])
582                 ;;
583     *)          mailto=$with_mailto
584                 ;;
585 esac])
586 AC_DEFINE_UNQUOTED(MAILTO, "$mailto", [The user or email address that sudo mail is sent to.])
587 AC_MSG_RESULT([$mailto])
588
589 AC_ARG_WITH(mailsubject, [  --with-mailsubject      subject of sudo mail],
590 [case $with_mailsubject in  
591     yes)        AC_MSG_ERROR(["must give --with-mailsubject an argument."])
592                 ;;
593     no)         echo "Sorry, --without-mailsubject not supported."
594                 ;;
595     *)          mailsub="$with_mailsubject"
596                 AC_MSG_CHECKING(sudo mail subject)
597                 AC_MSG_RESULT([Using alert mail subject: $mailsub])
598                 ;;
599 esac])
600 AC_DEFINE_UNQUOTED(MAILSUBJECT, "$mailsub", [The subject of the mail sent by sudo to the MAILTO user/address.])
601
602 AC_MSG_CHECKING(for bad password prompt)
603 AC_ARG_WITH(passprompt, [  --with-passprompt       default password prompt],
604 [case $with_passprompt in  
605     yes)        AC_MSG_ERROR(["must give --with-passprompt an argument."])
606                 ;;
607     no)         echo "Sorry, --without-passprompt not supported."
608                 ;;
609     *)          passprompt="$with_passprompt"
610 esac])
611 AC_MSG_RESULT($passprompt)
612 AC_DEFINE_UNQUOTED(PASSPROMPT, "$passprompt", [The default password prompt.])
613
614 AC_MSG_CHECKING(for bad password message)
615 AC_ARG_WITH(badpass-message, [  --with-badpass-message  message the user sees when the password is wrong],
616 [case $with_badpass_message in  
617     yes)        AC_MSG_ERROR(["Must give --with-badpass-message an argument."])
618                 ;;
619     no)         echo "Sorry, --without-badpass-message not supported."
620                 ;;
621     *)          badpass_message="$with_badpass_message"
622                 ;;
623 esac])
624 AC_DEFINE_UNQUOTED(INCORRECT_PASSWORD, "$badpass_message", [The message given when a bad password is entered.])
625 AC_MSG_RESULT([$badpass_message])
626
627 AC_MSG_CHECKING(whether to expect fully qualified hosts in sudoers)
628 AC_ARG_WITH(fqdn, [  --with-fqdn             expect fully qualified hosts in sudoers],
629 [case $with_fqdn in  
630     yes)        fqdn=on
631                 ;;
632     no)         fqdn=off
633                 ;;
634     *)          AC_MSG_ERROR(["--with-fqdn does not take an argument."])
635                 ;;
636 esac])
637 if test "$fqdn" = "on"; then
638     AC_DEFINE(FQDN, 1, [Define if you want to require fully qualified hosts in sudoers.])
639     AC_MSG_RESULT(yes)
640 else
641     AC_MSG_RESULT(no)
642 fi
643
644 AC_ARG_WITH(timedir, [  --with-timedir          path to the sudo timestamp dir],
645 [case $with_timedir in  
646     yes)        AC_MSG_ERROR(["must give --with-timedir an argument."])
647                 ;;
648     no)         AC_MSG_ERROR(["--without-timedir not supported."])
649                 ;;
650 esac])
651
652 AC_ARG_WITH(sendmail, [  --with-sendmail=path    set path to sendmail
653   --without-sendmail      do not send mail at all],
654 [case $with_sendmail in  
655     yes)        with_sendmail=""
656                 ;;
657     no)         ;;
658     *)          SUDO_DEFINE_UNQUOTED(_PATH_SUDO_SENDMAIL, "$with_sendmail")
659                 ;;
660 esac])
661
662 AC_ARG_WITH(sudoers-mode, [  --with-sudoers-mode     mode of sudoers file (defaults to 0440)],
663 [case $with_sudoers_mode in  
664     yes)        AC_MSG_ERROR(["must give --with-sudoers-mode an argument."])
665                 ;;
666     no)         AC_MSG_ERROR(["--without-sudoers-mode not supported."])
667                 ;;
668     [[1-9]]*)   SUDOERS_MODE=0${with_sudoers_mode}
669                 ;;
670     0*)         SUDOERS_MODE=$with_sudoers_mode
671                 ;;
672     *)          AC_MSG_ERROR(["you must use a numeric uid, not a name."])
673                 ;;
674 esac])
675
676 AC_ARG_WITH(sudoers-uid, [  --with-sudoers-uid      uid that owns sudoers file (defaults to 0)],
677 [case $with_sudoers_uid in  
678     yes)        AC_MSG_ERROR(["must give --with-sudoers-uid an argument."])
679                 ;;
680     no)         AC_MSG_ERROR(["--without-sudoers-uid not supported."])
681                 ;;
682     [[0-9]]*)   SUDOERS_UID=$with_sudoers_uid
683                 ;;
684     *)          AC_MSG_ERROR(["you must use a numeric uid, not a name."])
685                 ;;
686 esac])
687
688 AC_ARG_WITH(sudoers-gid, [  --with-sudoers-gid      gid that owns sudoers file (defaults to 0)],
689 [case $with_sudoers_gid in  
690     yes)        AC_MSG_ERROR(["must give --with-sudoers-gid an argument."])
691                 ;;
692     no)         AC_MSG_ERROR(["--without-sudoers-gid not supported."])
693                 ;;
694     [[0-9]]*)   SUDOERS_GID=$with_sudoers_gid
695                 ;;
696     *)          AC_MSG_ERROR(["you must use a numeric gid, not a name."])
697                 ;;
698 esac])
699
700 AC_MSG_CHECKING(for umask programs should be run with)
701 AC_ARG_WITH(umask, [  --with-umask            umask with which the prog should run (default is 022)
702   --without-umask         Preserves the umask of the user invoking sudo.],
703 [case $with_umask in  
704     yes)        AC_MSG_ERROR(["must give --with-umask an argument."])
705                 ;;
706     no)         sudo_umask=0777
707                 ;;
708     [[0-9]]*)   sudo_umask=$with_umask
709                 ;;
710     *)          AC_MSG_ERROR(["you must enter a numeric mask."])
711                 ;;
712 esac])
713 AC_DEFINE_UNQUOTED(SUDO_UMASK, $sudo_umask, [The umask that the root-run prog should use.])
714 if test "$sudo_umask" = "0777"; then
715     AC_MSG_RESULT(user)
716 else
717     AC_MSG_RESULT($sudo_umask)
718 fi
719
720 AC_MSG_CHECKING(for default user to run commands as)
721 AC_ARG_WITH(runas-default, [  --with-runas-default    User to run commands as (default is "root")],
722 [case $with_runas_default in  
723     yes)        AC_MSG_ERROR(["must give --with-runas-default an argument."])
724                 ;;
725     no)         AC_MSG_ERROR(["--without-runas-default not supported."])
726                 ;;
727     *)          runas_default="$with_runas_default"
728                 ;;
729 esac])
730 AC_DEFINE_UNQUOTED(RUNAS_DEFAULT, "$runas_default", [The user sudo should run commands as by default.])
731 AC_MSG_RESULT([$runas_default])
732
733 AC_ARG_WITH(exempt, [  --with-exempt=group     no passwd needed for users in this group],
734 [case $with_exempt in  
735     yes)        AC_MSG_ERROR(["must give --with-exempt an argument."])
736                 ;;
737     no)         AC_MSG_ERROR(["--without-exempt not supported."])
738                 ;;
739     *)          AC_DEFINE_UNQUOTED(EXEMPTGROUP, "$with_exempt", [If defined, users in this group need not enter a passwd (ie "sudo").])
740                 AC_MSG_CHECKING(for group to be exempt from password)
741                 AC_MSG_RESULT([$with_exempt])
742                 ;;
743 esac])
744
745 AC_MSG_CHECKING(for editor that visudo should use)
746 AC_ARG_WITH(editor, [  --with-editor=path      Default editor for visudo (defaults to vi)],
747 [case $with_editor in  
748     yes)        AC_MSG_ERROR(["must give --with-editor an argument."])
749                 ;;
750     no)         AC_MSG_ERROR(["--without-editor not supported."])
751                 ;;
752     *)          AC_DEFINE_UNQUOTED(EDITOR, "$with_editor", [A colon-separated list of pathnames to be used as the editor for visudo.])
753                 AC_MSG_RESULT([$with_editor])
754                 ;;
755 esac], [AC_DEFINE(EDITOR, _PATH_VI) AC_MSG_RESULT(vi)])
756
757 AC_MSG_CHECKING(whether to obey EDITOR and VISUAL environment variables)
758 AC_ARG_WITH(env-editor, [  --with-env-editor       Use the environment variable EDITOR for visudo],
759 [case $with_env_editor in  
760     yes)        env_editor=on
761                 ;;
762     no)         env_editor=off
763                 ;;
764     *)          AC_MSG_ERROR(["--with-env-editor does not take an argument."])
765                 ;;
766 esac])
767 if test "$env_editor" = "on"; then
768     AC_DEFINE(ENV_EDITOR, 1, [Define if you want visudo to honor the EDITOR and VISUAL env variables.])
769     AC_MSG_RESULT(yes)
770 else
771     AC_MSG_RESULT(no)
772 fi
773
774 AC_MSG_CHECKING(number of tries a user gets to enter their password)
775 AC_ARG_WITH(passwd-tries, [  --with-passwd-tries     number of tries to enter password (default is 3)],
776 [case $with_passwd_tries in  
777     yes)        ;;
778     no)         AC_MSG_ERROR(["--without-editor not supported."])
779                 ;;
780     [[1-9]]*)   passwd_tries=$with_passwd_tries
781                 ;;
782     *)          AC_MSG_ERROR(["you must enter the numer of tries, > 0"])
783                 ;;
784 esac])
785 AC_DEFINE_UNQUOTED(TRIES_FOR_PASSWORD, $passwd_tries, [The number of tries a user gets to enter their password.])
786 AC_MSG_RESULT($passwd_tries)
787
788 AC_MSG_CHECKING(time in minutes after which sudo will ask for a password again)
789 AC_ARG_WITH(timeout, [  --with-timeout          minutes before sudo asks for passwd again (def is 5 minutes)],
790 [echo $with_timeout; case $with_timeout in  
791     yes)        ;;
792     no)         timeout=0
793                 ;;
794     [[0-9]]*)   timeout=$with_timeout
795                 ;;
796     *)          AC_MSG_ERROR(["you must enter the numer of minutes."])
797                 ;;
798 esac])
799 AC_DEFINE_UNQUOTED(TIMEOUT, $timeout, [The number of minutes before sudo asks for a password again.])
800 AC_MSG_RESULT($timeout)
801
802 AC_MSG_CHECKING(time in minutes after the password prompt will time out)
803 AC_ARG_WITH(password-timeout, [  --with-password-timeout passwd prompt timeout in minutes (default is 5 minutes)],
804 [case $with_password_timeout in  
805     yes)        ;;
806     no)         password_timeout=0
807                 ;;
808     [[0-9]]*)   password_timeout=$with_password_timeout
809                 ;;
810     *)          AC_MSG_ERROR(["you must enter the numer of minutes."])
811                 ;;
812 esac])
813 AC_DEFINE_UNQUOTED(PASSWORD_TIMEOUT, $password_timeout, [The passwd prompt timeout (in minutes).])
814 AC_MSG_RESULT($password_timeout)
815
816 AC_ARG_WITH(execv, [  --with-execv            use execv() instead of execvp()],
817 [case $with_execv in  
818     yes)        AC_MSG_CHECKING(whether to use execvp or execv)
819                 AC_MSG_RESULT(execv)
820                 AC_DEFINE(USE_EXECV, 1, [Define if you wish to use execv() instead of execvp() when running programs.])
821                 ;;
822     no)         ;;
823     *)          AC_MSG_ERROR(["--with-execv does not take an argument."])
824                 ;;
825 esac])
826
827 AC_MSG_CHECKING(whether to use per-tty ticket files)
828 AC_ARG_WITH(tty-tickets, [  --with-tty-tickets      use a different ticket file for each tty],
829 [case $with_tty_tickets in  
830     yes)        tty_tickets=on
831                 ;;
832     no)         tty_tickets=off
833                 ;;
834     *)          AC_MSG_ERROR(["--with-tty-tickets does not take an argument."])
835                 ;;
836 esac])
837 if test "$tty_tickets" = "on"; then
838     AC_DEFINE(USE_TTY_TICKETS, 1, [Define if you want a different ticket file for each tty.])
839     AC_MSG_RESULT(yes)
840 else
841     AC_MSG_RESULT(no)
842 fi
843
844 AC_MSG_CHECKING(whether to include insults)
845 AC_ARG_WITH(insults, [  --with-insults          insult the user for entering an incorrect password],
846 [case $with_insults in  
847     yes)        insults=on
848                 with_classic_insults=yes
849                 with_csops_insults=yes
850                 ;;
851     no)         insults=off
852                 ;;
853     *)          AC_MSG_ERROR(["--with-insults does not take an argument."])
854                 ;;
855 esac])
856 if test "$insults" = "on"; then
857     AC_DEFINE(USE_INSULTS, 1, [Define if you want to insult the user for entering an incorrect password.])
858     AC_MSG_RESULT(yes)
859 else
860     AC_MSG_RESULT(no)
861 fi
862
863 AC_ARG_WITH(all-insults, [  --with-all-insults      include all the sudo insult sets],
864 [case $with_all_insults in  
865     yes)        with_classic_insults=yes
866                 with_csops_insults=yes
867                 with_hal_insults=yes
868                 with_goons_insults=yes
869                 ;;
870     no)         ;;
871     *)          AC_MSG_ERROR(["--with-all-insults does not take an argument."])
872                 ;;
873 esac])
874
875 AC_ARG_WITH(classic-insults, [  --with-classic-insults  include the insults from the "classic" sudo],
876 [case $with_classic_insults in  
877     yes)        AC_DEFINE(CLASSIC_INSULTS, 1, [Define if you want the insults from the "classic" version sudo.])
878                 ;;
879     no)         ;;
880     *)          AC_MSG_ERROR(["--with-classic-insults does not take an argument."])
881                 ;;
882 esac])
883
884 AC_ARG_WITH(csops-insults, [  --with-csops-insults    include CSOps insults],
885 [case $with_csops_insults in  
886     yes)        AC_DEFINE(CSOPS_INSULTS, 1, [Define if you want insults culled from the twisted minds of CSOps.])
887                 ;;
888     no)         ;;
889     *)          AC_MSG_ERROR(["--with-csops-insults does not take an argument."])
890                 ;;
891 esac])
892
893 AC_ARG_WITH(hal-insults, [  --with-hal-insults      include 2001-like insults],
894 [case $with_hal_insults in  
895     yes)        AC_DEFINE(HAL_INSULTS, 1, [Define if you want 2001-like insults.])
896                 ;;
897     no)         ;;
898     *)          AC_MSG_ERROR(["--with-hal-insults does not take an argument."])
899                 ;;
900 esac])
901
902 AC_ARG_WITH(goons-insults, [  --with-goons-insults    include the insults from the "Goon Show"],
903 [case $with_goons_insults in  
904     yes)        AC_DEFINE(GOONS_INSULTS, 1, [Define if you want insults from the "Goon Show".])
905                 ;;
906     no)         ;;
907     *)          AC_MSG_ERROR(["--with-goons-insults does not take an argument."])
908                 ;;
909 esac])
910
911 dnl include all insult sets on one line
912 if test "$insults" = "on"; then
913     AC_MSG_CHECKING(which insult sets to include)
914     i=""
915     test "$with_goons_insults" = "yes" && i="goons ${i}"
916     test "$with_hal_insults" = "yes" && i="hal ${i}"
917     test "$with_csops_insults" = "yes" && i="csops ${i}"
918     test "$with_classic_insults" = "yes" && i="classic ${i}"
919     AC_MSG_RESULT([$i])
920 fi
921
922 AC_MSG_CHECKING(whether to override the user's path)
923 AC_ARG_WITH(secure-path, [  --with-secure-path      override the user's path with a builtin one],
924 [case $with_secure_path in  
925     yes)        AC_DEFINE_UNQUOTED(SECURE_PATH, "/bin:/usr/ucb:/usr/bin:/usr/sbin:/sbin:/usr/etc:/etc", [Define to override the user's path with a builtin one.])
926                 AC_MSG_RESULT([:/usr/ucb:/usr/bin:/usr/sbin:/sbin:/usr/etc:/etc])
927                 ;;
928     no)         AC_MSG_RESULT(no)
929                 ;;
930     *)          AC_DEFINE_UNQUOTED(SECURE_PATH, "$with_secure_path")
931                 AC_MSG_RESULT([$with_secure_path])
932                 ;;
933 esac], AC_MSG_RESULT(no))
934
935 AC_MSG_CHECKING(whether to get ip addresses from the network interfaces)
936 AC_ARG_WITH(interfaces, [  --without-interfaces    don't try to read the ip addr of ether interfaces],
937 [case $with_interfaces in  
938     yes)        AC_MSG_RESULT(yes)
939                 ;;
940     no)         AC_DEFINE(STUB_LOAD_INTERFACES, 1, [Define if the code in interfaces.c does not compile for you.])
941                 AC_MSG_RESULT(no)
942                 ;;
943     *)          AC_MSG_ERROR(["--with-interfaces does not take an argument."])
944                 ;;
945 esac], AC_MSG_RESULT(yes))
946
947 dnl
948 dnl Options for --enable
949 dnl
950
951 AC_MSG_CHECKING(whether to do user authentication by default)
952 AC_ARG_ENABLE(authentication,
953 [  --disable-authentication
954                           Do not require authentication by default],
955 [ case "$enableval" in
956     yes)        AC_MSG_RESULT(yes)
957                 ;;
958     no)         AC_MSG_RESULT(no)
959                 AC_DEFINE(NO_AUTHENTICATION, 1, [Define if you don't want sudo to prompt for a password by default.])
960                 ;;
961     *)          AC_MSG_RESULT(no)
962                 echo "Ignoring unknown argument to --enable-authentication: $enableval"
963                 ;;
964   esac
965 ], AC_MSG_RESULT(yes))
966
967 AC_MSG_CHECKING(whether to disable running the mailer as root)
968 AC_ARG_ENABLE(root-mailer,
969 [  --disable-root-mailer   Don't run the mailer as root, run as the user],
970 [ case "$enableval" in
971     yes)        AC_MSG_RESULT(no)
972                 ;;
973     no)         AC_MSG_RESULT(yes)
974                 AC_DEFINE(NO_ROOT_MAILER, 1, [Define to avoid runing the mailer as root.])
975                 ;;
976     *)          AC_MSG_RESULT(no)
977                 echo "Ignoring unknown argument to --enable-root-mailer: $enableval"
978                 ;;
979   esac
980 ], AC_MSG_RESULT(no))
981
982 AC_ARG_ENABLE(setreuid,
983 [  --disable-setreuid      Don't try to use the setreuid() function],
984 [ case "$enableval" in
985     no)         BROKEN_SETREUID=1
986                 ;;
987     *)          ;;
988   esac
989 ])
990
991 AC_MSG_CHECKING(whether to disable use of POSIX saved ids)
992 AC_ARG_ENABLE(saved-ids,
993 [  --disable-saved-ids     Don't try to use POSIX saved ids],
994 [ case "$enableval" in
995     yes)        AC_MSG_RESULT(no)
996                 ;;
997     no)         AC_MSG_RESULT(yes)
998                 AC_DEFINE(NO_SAVED_IDS, 1, [Define to avoid using POSIX saved ids.])
999                 ;;
1000     *)          AC_MSG_RESULT(no)
1001                 echo "Ignoring unknown argument to --enable-saved-ids: $enableval"
1002                 ;;
1003   esac
1004 ], AC_MSG_RESULT(no))
1005
1006 AC_MSG_CHECKING(whether to disable shadow password support)
1007 AC_ARG_ENABLE(shadow,
1008 [  --disable-shadow        Never use shadow passwords],
1009 [ case "$enableval" in
1010     yes)        AC_MSG_RESULT(no)
1011                 ;;
1012     no)         AC_MSG_RESULT(yes)
1013                 CHECKSHADOW="false"
1014                 ;;
1015     *)          AC_MSG_RESULT(no)
1016                 echo "Ignoring unknown argument to --enable-shadow: $enableval"
1017                 ;;
1018   esac
1019 ], AC_MSG_RESULT(no))
1020
1021 AC_MSG_CHECKING(whether root should be allowed to use sudo)
1022 AC_ARG_ENABLE(root-sudo,
1023 [  --disable-root-sudo     Don't allow root to run sudo],
1024 [ case "$enableval" in  
1025     yes)        AC_MSG_RESULT(yes)
1026                 ;;
1027     no)         AC_DEFINE(NO_ROOT_SUDO, 1, [Define if root should not be allowed to use sudo.])
1028                 AC_MSG_RESULT(no)
1029                 ;;
1030     *)          AC_MSG_ERROR(["--enable-root-sudo does not take an argument."])
1031                 ;;
1032   esac
1033 ], AC_MSG_RESULT(yes))
1034
1035 AC_MSG_CHECKING(whether to log the hostname in the log file)
1036 AC_ARG_ENABLE(log-host,
1037 [  --enable-log-host       Log the hostname in the log file],
1038 [ case "$enableval" in
1039     yes)        AC_MSG_RESULT(yes)
1040                 AC_DEFINE(HOST_IN_LOG, 1, [Define if you want the hostname to be entered into the log file.])
1041                 ;;
1042     no)         AC_MSG_RESULT(no)
1043                 ;;
1044     *)          AC_MSG_RESULT(no)
1045                 echo "Ignoring unknown argument to --enable-log-host: $enableval"
1046                 ;;
1047   esac
1048 ], AC_MSG_RESULT(no))
1049
1050 AC_MSG_CHECKING(whether to invoke a shell if sudo is given no arguments)
1051 AC_ARG_ENABLE(noargs-shell,
1052 [  --enable-noargs-shell   If sudo is given no arguments run a shell],
1053 [ case "$enableval" in
1054     yes)        AC_MSG_RESULT(yes)
1055                 AC_DEFINE(SHELL_IF_NO_ARGS, 1, [Define if you want sudo to start a shell if given no arguments.])
1056                 ;;
1057     no)         AC_MSG_RESULT(no)
1058                 ;;
1059     *)          AC_MSG_RESULT(no)
1060                 echo "Ignoring unknown argument to --enable-noargs-shell: $enableval"
1061                 ;;
1062   esac
1063 ], AC_MSG_RESULT(no))
1064
1065 AC_MSG_CHECKING(whether to set \$HOME to target user in shell mode)
1066 AC_ARG_ENABLE(shell-sets-home,
1067 [  --enable-shell-sets-home
1068                           set $HOME to target user in shell mode],
1069 [ case "$enableval" in
1070     yes)        AC_MSG_RESULT(yes)
1071                 AC_DEFINE(SHELL_SETS_HOME, 1, [Define if you want sudo to set $HOME in shell mode.])
1072                 ;;
1073     no)         AC_MSG_RESULT(no)
1074                 ;;
1075     *)          AC_MSG_RESULT(no)
1076                 echo "Ignoring unknown argument to --enable-shell-sets-home: $enableval"
1077                 ;;
1078   esac
1079 ], AC_MSG_RESULT(no))
1080
1081 AC_MSG_CHECKING(whether to disable 'command not found' messages)
1082 AC_ARG_ENABLE(path_info,
1083 [  --disable-path-info     Print 'command not allowed' not 'command not found'],
1084 [ case "$enableval" in
1085     yes)        AC_MSG_RESULT(no)
1086                 ;;
1087     no)         AC_MSG_RESULT(yes)
1088                 AC_DEFINE(DONT_LEAK_PATH_INFO, 1, [Define if you want sudo to display "command not allowed" instead of "command not found" when a command cannot be found.])
1089                 ;;
1090     *)          AC_MSG_RESULT(no)
1091                 echo "Ignoring unknown argument to --enable-path-info: $enableval"
1092                 ;;
1093   esac
1094 ], AC_MSG_RESULT(no))
1095
1096 dnl
1097 dnl If we don't have egrep we can't do anything...
1098 dnl
1099 AC_CHECK_PROG(EGREPPROG, egrep, egrep, )
1100 if test -z "$EGREPPROG"; then
1101     echo "Sorry, configure requires egrep to run."
1102     exit
1103 fi
1104
1105 dnl
1106 dnl Prevent configure from adding the -g flag unless in devel mode
1107 dnl
1108 if test "$with_devel" != "yes"; then
1109     ac_cv_prog_cc_g=no
1110 fi
1111
1112 dnl
1113 dnl C compiler checks
1114 dnl XXX - the cross-compiler check gets false positives so we override it
1115 dnl
1116 AC_ISC_POSIX
1117 ac_cv_prog_cc_cross="no"
1118 cross_compiling="no"
1119 AC_PROG_CC_STDC
1120 ac_cv_prog_cc_cross="no"
1121 cross_compiling="no"
1122 AC_PROG_CPP
1123
1124 dnl
1125 dnl It is now safe to modify CFLAGS and CPPFLAGS
1126 dnl
1127 if test "$with_devel" = "yes" -a -n "$GCC"; then
1128     CFLAGS="${CFLAGS} -Wall"
1129 fi
1130
1131 dnl
1132 dnl Find programs we use
1133 dnl
1134 AC_CHECK_PROG(UNAMEPROG, uname, uname, )
1135 AC_CHECK_PROG(TRPROG, tr, tr, )
1136 AC_CHECK_PROG(SEDPROG, sed, sed, )
1137 AC_CHECK_PROG(NROFFPROG, nroff, nroff, )
1138 if test -z "$NROFFPROG"; then
1139     MANTYPE="cat"
1140     mansrcdir='$(srcdir)'
1141 fi
1142
1143 dnl
1144 dnl What kind of beastie are we being run on?
1145 dnl Barf if config.cache was generated on another host.
1146 dnl
1147 AC_CANONICAL_HOST
1148 if test -n "$sudo_cv_prev_host"; then
1149     if test "$sudo_cv_prev_host" != "$host"; then
1150         echo ""
1151         echo "Fatal Error: config.cache exists from another platform!"
1152         echo "Please remove it and re-run configure."
1153         echo ""
1154         exit 1
1155     else
1156         AC_MSG_CHECKING(previous host type)
1157         AC_CACHE_VAL(sudo_cv_prev_host, sudo_cv_prev_host="$host")
1158         echo $sudo_cv_prev_host
1159     fi
1160 else
1161     # this will produce no output since there is no cached value
1162     AC_CACHE_VAL(sudo_cv_prev_host, sudo_cv_prev_host="$host")
1163 fi
1164
1165 dnl
1166 dnl We want to be able to differentiate between different rev's
1167 dnl
1168 if test -n "$host_os"; then
1169     OS=`echo $host_os | sed 's/[[0-9]].*//'`
1170     OSREV=`echo $host_os | sed 's/^[[^0-9]]*\([[0-9]][[0-9]]*\).*$/\1/'`
1171 else
1172     OS="unknown"
1173     OSREV=0
1174 fi
1175
1176 case "$host" in
1177     *-*-sunos4*)
1178                 # getcwd(3) opens a pipe to getpwd(1)!?!
1179                 BROKEN_GETCWD=1
1180
1181                 # system headers lack prototypes but gcc helps...
1182                 if test -n "$GCC"; then
1183                     CPPFLAGS="${CPPFLAGS} -D__USE_FIXED_PROTOTYPES__"
1184                 fi
1185
1186                 # check for password adjunct functions (shadow passwords)
1187                 if test "$CHECKSHADOW" = "true"; then
1188                     AC_CHECK_FUNCS(getpwanam issecure, , [break])
1189                     AH_TEMPLATE([HAVE_GETPWANAM], [Define if you have the `getpwanam' function. (SunOS 4.x shadow passwords)])
1190                     AH_TEMPLATE([HAVE_ISSECURE], [Define if you have the `issecure' function. (SunOS 4.x check for shadow enabled)])
1191                     CHECKSHADOW="false"
1192                 fi
1193                 ;;
1194     *-*-solaris2*)
1195                 # To get the crypt(3) prototype (so we pass -Wall)
1196                 CPPFLAGS="${CPPFLAGS} -D__EXTENSIONS__"
1197                 # AFS support needs -lucb
1198                 if test "$with_AFS" = "yes"; then
1199                     AFS_LIBS="-lc -lucb"
1200                 fi
1201                 test -n "$mansectsu" || mansectsu=1m
1202                 test -n "$mansectform" || mansectform=4
1203                 ;;
1204     *-*-aix*)
1205                 # To get all prototypes (so we pass -Wall)
1206                 CPPFLAGS="${CPPFLAGS} -D_XOPEN_EXTENDED_SOURCE"
1207                 SUDO_DEFINE(_ALL_SOURCE)
1208                 SUDO_LDFLAGS="${SUDO_LDFLAGS} -Wl,-bI:\$(srcdir)/aixcrypt.exp"
1209                 ;;
1210     *-*-hiuxmpp*)
1211                 if test "$CHECKSHADOW" = "true"; then
1212                     AC_CHECK_LIB(sec, getprpwnam, AC_DEFINE(HAVE_GETPRPWNAM) [SUDO_LIBS="${SUDO_LIBS} -lsec"; LIBS="${LIBS} -lsec"; SECUREWARE=1], AC_CHECK_LIB(security, getprpwnam, AC_DEFINE(HAVE_GETPRPWNAM) [SUDO_LIBS="${SUDO_LIBS} -lsecurity"; LIBS="${LIBS} -lsecurity"; SECUREWARE=1]))
1213                     CHECKSHADOW="false"
1214                 fi
1215                 test -n "$mansectsu" || mansectsu=1m
1216                 test -n "$mansectform" || mansectform=4
1217                 ;;
1218     *-*-hpux1[[0-9]]*)
1219                 if test "$CHECKSHADOW" = "true"; then
1220                     AC_CHECK_LIB(sec, getprpwnam, AC_DEFINE(HAVE_GETPRPWNAM) AC_CHECK_LIB(sec, iscomsec, AC_DEFINE(HAVE_ISCOMSEC, 1, [Define if you have the `iscomsec' function. (HP-UX >= 10.x check for shadow enabled)])) [SUDO_LIBS="${SUDO_LIBS} -lsec"; LIBS="${LIBS} -lsec"; SECUREWARE=1])
1221                     CHECKSHADOW="false"
1222                 fi
1223
1224                 # AFS support needs -lBSD
1225                 if test "$with_AFS" = "yes"; then
1226                     AFS_LIBS="-lc -lBSD"
1227                 fi
1228                 test -n "$mansectsu" || mansectsu=1m
1229                 test -n "$mansectform" || mansectform=4
1230                 ;;
1231     *-*-hpux9*)
1232                 AC_DEFINE(BROKEN_SYSLOG, 1, [Define if the `syslog' function returns a non-zero int to denote failure.])
1233
1234                 if test "$CHECKSHADOW" = "true"; then
1235                     AC_CHECK_FUNCS(getspwuid)
1236                     AH_TEMPLATE([HAVE_GETSPWUID], [Define if you have the `getspwuid' function. (HP-UX <= 9.X shadow passwords)])
1237                     CHECKSHADOW="false"
1238                 fi
1239
1240                 # DCE support (requires ANSI C compiler)
1241                 if test "$with_DCE" = "yes"; then
1242                     # order of libs in 9.X is important. -lc_r must be last
1243                     SUDO_LIBS="${SUDO_LIBS} -ldce -lM -lc_r"
1244                     LIBS="${LIBS} -ldce -lM -lc_r"
1245                     CPPFLAGS="${CPPFLAGS} -D_REENTRANT -I/usr/include/reentrant"
1246                 fi
1247
1248                 # AFS support needs -lBSD
1249                 if test "$with_AFS" = "yes"; then
1250                     AFS_LIBS="-lc -lBSD"
1251                 fi
1252                 test -n "$mansectsu" || mansectsu=1m
1253                 test -n "$mansectform" || mansectform=4
1254                 ;;
1255     *-*-hpux*)
1256                 AC_DEFINE(BROKEN_SYSLOG)
1257
1258                 # Not sure if setuid binaries are safe in < 9.x
1259                 if test -n "$GCC"; then
1260                     SUDO_LDFLAGS="${SUDO_LDFLAGS} -static"
1261                 else
1262                     SUDO_LDFLAGS="${SUDO_LDFLAGS} -Wl,-a,archive"
1263                 fi
1264
1265                 # AFS support needs -lBSD
1266                 if test "$with_AFS" = "yes"; then
1267                     AFS_LIBS="-lc -lBSD"
1268                 fi
1269                 test -n "$mansectsu" || mansectsu=1m
1270                 test -n "$mansectform" || mansectform=4
1271                 ;;
1272     *-dec-osf*)
1273                 # ignore envariables wrt dynamic lib path
1274                 SUDO_LDFLAGS="${SUDO_LDFLAGS} -Wl,-no_library_replacement"
1275
1276                 AC_MSG_CHECKING(whether to disable sia support on Digital UNIX)
1277                 AC_ARG_ENABLE(sia,
1278                 [  --disable-sia           Never use SIA on Digital UNIX],
1279                 [ case "$enableval" in
1280                     yes)        AC_MSG_RESULT(no)
1281                                 ;;
1282                     no)         AC_MSG_RESULT(yes)
1283                                 CHECKSIA=false
1284                                 ;;
1285                     *)          AC_MSG_RESULT(no)
1286                                 echo "Ignoring unknown argument to --enable-sia: $enableval"
1287                                 ;;
1288                   esac
1289                 ], AC_MSG_RESULT(no))
1290
1291                 # use SIA by default, if we have it, else SecureWare
1292                 # unless overridden on the command line
1293                 if test "$CHECKSIA" = "true"; then
1294                     AC_CHECK_FUNC(sia_ses_init, AC_DEFINE(HAVE_SIA, 1, [Define if you use SIA.]) [
1295                     if test -n "$with_skey" -o -n "$with_opie" -o -n "$with_otp_only" -o -n "$with_long_otp_prompt" -o -n "$with_SecurID" -o -n "$with_fwtk" -o -n "$with_kerb4" -o -n "$with_kerb5" -o -n "$with_pam" -o -n "$with_AFS" -o -n "$with_DCE"; then
1296                         AC_MSG_ERROR(["you cannot mix SIA and other authentication schemes.  You can turn off SIA support via the --disable-sia option"])
1297                     fi]; CHECKSHADOW=false)
1298                 fi
1299                 if test "$CHECKSHADOW" = "true"; then
1300                     AC_CHECK_LIB(security, getprpwnam, SECUREWARE=1)
1301                     CHECKSHADOW="false"
1302                 fi
1303
1304                 if test -n "$SECUREWARE"; then
1305                     AC_DEFINE(HAVE_GETPRPWNAM, 1, [Define if you have the `getprpwnam' function.  (SecureWare-style shadow passwords)])
1306                     # -ldb includes bogus versions of snprintf/vsnprintf
1307                     AC_CHECK_FUNCS(snprintf, , [NEED_SNPRINTF=1])
1308                     AC_CHECK_FUNCS(vsnprintf, , [NEED_SNPRINTF=1])
1309                     # 4.x and higher need -ldb too...
1310                     AC_CHECK_LIB(db, dbopen, [SUDO_LIBS="${SUDO_LIBS} -lsecurity -ldb -laud -lm"; LIBS="${LIBS} -lsecurity -ldb -laud -lm"], [SUDO_LIBS="${SUDO_LIBS} -lsecurity -ldb -laud -lm"; LIBS="${LIBS} -lsecurity -ldb -laud -lm"])
1311                     AC_CHECK_FUNCS(dispcrypt)
1312                     AC_MSG_CHECKING([for broken /usr/include/prot.h])
1313                     AC_TRY_COMPILE([
1314 #include <sys/types.h>
1315 #include <sys/security.h>
1316 #include <prot.h>
1317                     ], [exit(0);], AC_MSG_RESULT(no),
1318                     [AC_MSG_RESULT([yes, fixing locally])
1319                     sed 's:<acl.h>:<sys/acl.h>:g' < /usr/include/prot.h > prot.h
1320                     ])
1321                 elif test "$CHECKSIA" = "true"; then
1322                     with_passwd=no
1323                     AUTH_OBJS="sia.o"
1324                 fi
1325                 test -n "$mansectsu" || mansectsu=8
1326                 test -n "$mansectform" || mansectform=4
1327                 ;;
1328     *-*-irix*)
1329                 CPPFLAGS="${CPPFLAGS} -D_BSD_TYPES"
1330                 if test -z "$NROFFPROG"; then
1331                     MAN_POSTINSTALL='   /bin/rm -f $(mandir8)/sudo.$(mansect8).z $(mandir8)/visudo.$(mansect8).z $(mandir5)/sudoers.$(mansect5).z ; /usr/bin/pack $(mandir8)/sudo.$(mansect8) $(mandir8)/visudo.$(mansect8) $(mandir5)/sudoers.$(mansect5)'
1332                     if test "$prefix" = "/usr/local" -a "$mandir" = '$(prefix)/man'; then
1333                         if test -d /usr/share/catman/local; then
1334                             mandir="/usr/share/catman/local"
1335                         else
1336                             mandir="/usr/catman/local"
1337                         fi
1338                     fi
1339                 else
1340                     if test "$prefix" = "/usr/local" -a "$mandir" = '$(prefix)/man'; then
1341                         if test -d "/usr/share/man/local"; then
1342                             mandir="/usr/share/man/local"
1343                         else
1344                             mandir="/usr/man/local"
1345                         fi
1346                     fi
1347                 fi
1348                 # IRIX <= 4 needs -lsun
1349                 if test "$OSREV" -le 4; then
1350                     AC_CHECK_LIB(sun, getpwnam, [LIBS="${LIBS} -lsun"])
1351                 fi
1352                 test -n "$mansectsu" || mansectsu=1m
1353                 test -n "$mansectform" || mansectform=4
1354                 ;;
1355     *-*-linux*)
1356                 # Some Linux versions need to link with -lshadow
1357                 if test "$CHECKSHADOW" = "true"; then
1358                     AC_CHECK_FUNCS(getspnam, , [AC_CHECK_LIB(shadow, getspnam, AC_DEFINE(HAVE_GETSPNAM) [SUDO_LIBS="${SUDO_LIBS} -lshadow"; LIBS="${LIBS} -lshadow"])])
1359                     CHECKSHADOW="false"
1360                 fi
1361                 ;;
1362     *-convex-bsd*)
1363                 SUDO_DEFINE(_CONVEX_SOURCE)
1364                 if test -z "$GCC"; then
1365                     CFLAGS="${CFLAGS} -D__STDC__"
1366                 fi
1367
1368                 if test "$CHECKSHADOW" = "true"; then
1369                     AC_CHECK_LIB(sec, getprpwnam, AC_DEFINE(HAVE_GETPRPWNAM) [SUDO_LIBS="${SUDO_LIBS} -lprot"; LIBS="${LIBS} -lprot"; OSDEFS="${OSDEFS} -D_AUDIT -D_ACL -DSecureWare"; SECUREWARE=1])
1370                     CHECKSHADOW="false"
1371                 fi
1372                 ;;
1373     *-*-ultrix*)
1374                 OS="ultrix"
1375                 if test "$CHECKSHADOW" = "true"; then
1376                     AC_CHECK_LIB(auth, getauthuid, AC_DEFINE(HAVE_GETAUTHUID, 1, [Define if you have the `getauthuid' function.  (ULTRIX 4.x shadow passwords)]) [SUDO_LIBS="${SUDO_LIBS} -lauth"; LIBS="${LIBS} -lauth"])
1377                     CHECKSHADOW="false"
1378                 fi
1379                 ;;
1380     *-*-riscos*)
1381                 LIBS="${LIBS} -lsun -lbsd"
1382                 CPPFLAGS="${CPPFLAGS} -I/usr/include -I/usr/include/bsd"
1383                 OSDEFS="${OSDEFS} -D_MIPS"
1384                 test -n "$mansectsu" || mansectsu=1m
1385                 test -n "$mansectform" || mansectform=4
1386                 ;;
1387     *-*-isc*)
1388                 OSDEFS="${OSDEFS} -D_ISC"
1389                 LIB_CRYPT=1
1390                 SUDO_LIBS="${SUDO_LIBS} -lcrypt"
1391                 LIBS="${LIBS} -lcrypt"
1392
1393                 if test "$CHECKSHADOW" = "true"; then
1394                     AC_CHECK_LIB(sec, getspnam, AC_DEFINE(HAVE_GETSPNAM) [SUDO_LIBS="${SUDO_LIBS} -lsec"; LIBS="${LIBS} -lsec"])
1395                     CHECKSHADOW="false"
1396                 fi
1397                 test -n "$mansectsu" || mansectsu=1m
1398                 test -n "$mansectform" || mansectform=4
1399                 ;;
1400     *-*-sco*|*-sco-*)
1401                 if test "$CHECKSHADOW" = "true"; then
1402                     AC_CHECK_LIB(prot, getprpwnam, AC_DEFINE(HAVE_GETPRPWNAM) [SUDO_LIBS="${SUDO_LIBS} -lprot -lx"; LIBS="${LIBS} -lprot -lx"; SECUREWARE=1], , -lx)
1403                     AC_CHECK_LIB(gen, getspnam, AC_DEFINE(HAVE_GETSPNAM) [SUDO_LIBS="${SUDO_LIBS} -lgen"; LIBS="${LIBS} -lgen"])
1404                     CHECKSHADOW="false"
1405                 fi
1406                 test -n "$mansectsu" || mansectsu=1m
1407                 test -n "$mansectform" || mansectform=4
1408                 ;;
1409     m88k-motorola-sysv*)
1410                 # motorolla's cc (a variant of gcc) does -O but not -O2
1411                 CFLAGS=`echo $CFLAGS | sed 's/-O2/-O/g'`
1412                 test -n "$mansectsu" || mansectsu=1m
1413                 test -n "$mansectform" || mansectform=4
1414                 ;;
1415     *-sequent-sysv*)
1416                 if test "$CHECKSHADOW" = "true"; then
1417                     AC_CHECK_LIB(sec, getspnam, AC_DEFINE(HAVE_GETSPNAM) [SUDO_LIBS="${SUDO_LIBS} -lsec"; LIBS="${LIBS} -lsec"])
1418                     CHECKSHADOW="false"
1419                 fi
1420                 test -n "$mansectsu" || mansectsu=1m
1421                 test -n "$mansectform" || mansectform=4
1422                 ;;
1423     *-ncr-sysv4*|*-ncr-sysvr4*)
1424                 AC_CHECK_LIB(c89, strcasecmp, AC_DEFINE(HAVE_STRCASECMP) [LIBS="${LIBS} -lc89"; ac_cv_func_strcasecmp=yes])
1425                 test -n "$mansectsu" || mansectsu=1m
1426                 test -n "$mansectform" || mansectform=4
1427                 ;;
1428     *-ccur-sysv4*|*-ccur-sysvr4*)
1429                 LIBS="${LIBS} -lgen"
1430                 SUDO_LIBS="${SUDO_LIBS} -lgen"
1431                 test -n "$mansectsu" || mansectsu=1m
1432                 test -n "$mansectform" || mansectform=4
1433                 ;;
1434     *-*-bsdi*)
1435                 BROKEN_SETREUID=yes
1436                 # Use shlicc for BSD/OS [23].x unless asked to do otherwise
1437                 if test "${with_CC+set}" != set -a "$ac_cv_prog_CC" = gcc; then
1438                     case "$OSREV" in
1439                         2|3)    echo 'using shlicc as CC'
1440                                 ac_cv_prog_CC=shlicc
1441                                 CC="$ac_cv_prog_CC"
1442                                 ;;
1443                     esac
1444                 fi
1445                 ;;
1446     *-*-freebsd*)
1447                 # FreeBSD has a real setreuid(2) starting with 2.1 and
1448                 # backported to 2.0.5.  We just take 2.1 and above...
1449                 case "`echo $host_os | sed 's/^freebsd\([[0-9\.]]*\).*$/\1/'`" in
1450                 0.*|1.*|2.0*)
1451                     BROKEN_SETREUID=yes
1452                     ;;
1453                 esac
1454                 if test "$with_logincap" = "yes"; then
1455                     SUDO_LIBS="${SUDO_LIBS} -lutil"
1456                 fi
1457                 if test "$with_skey" = "yes"; then
1458                      SUDO_LIBS="${SUDO_LIBS} -lmd"
1459                 fi
1460                 if test "$CHECKSHADOW" = "true"; then
1461                     CHECKSHADOW="false"
1462                 fi
1463                 ;;
1464     *-*-*openbsd*)
1465                 BROKEN_SETREUID=yes
1466                 if test "$CHECKSHADOW" = "true"; then
1467                     CHECKSHADOW="false"
1468                 fi
1469                 ;;
1470     *-*-*netbsd*)
1471                 # NetBSD has a real setreuid(2) starting with 1.3.2
1472                 case "`echo $host_os | sed 's/^netbsd\([[0-9\.]]*\).*$/\1/'`" in
1473                 0.9*|1.[012]*|1.3|1.3.1)
1474                     BROKEN_SETREUID=yes
1475                     ;;
1476                 esac
1477                 if test "$CHECKSHADOW" = "true"; then
1478                     CHECKSHADOW="false"
1479                 fi
1480                 ;;
1481     *-*-*bsd*)
1482                 if test "$CHECKSHADOW" = "true"; then
1483                     CHECKSHADOW="false"
1484                 fi
1485                 ;;
1486     *-*-nextstep*)
1487                 # lockf() on is broken on the NeXT -- use flock instead
1488                 ac_cv_func_lockf=no
1489                 ac_cv_func_flock=yes
1490                 ;;
1491     *-*-sysv*)
1492                 test -n "$mansectsu" || mansectsu=1m
1493                 test -n "$mansectform" || mansectform=4
1494                 ;;
1495 esac
1496
1497 dnl
1498 dnl Use BSD-style man sections by default
1499 dnl
1500 test -n "$mansectsu" || mansectsu=8
1501 test -n "$mansectform" || mansectform=5
1502
1503 dnl
1504 dnl Check for shadow password routines if we have not already done so.
1505 dnl We check for SVR4-style first and then SecureWare-style.
1506 dnl
1507 if test "$CHECKSHADOW" = "true"; then
1508     AC_CHECK_FUNCS(getspnam, [CHECKSHADOW="false"], [AC_CHECK_LIB(gen, getspnam, AC_DEFINE(HAVE_GETSPNAM, 1, [Define if you have the `getspnam' function (SVR4-style shadow passwords)]) [SUDO_LIBS="${SUDO_LIBS} -lgen"; LIBS="${LIBS} -lgen"])])
1509 fi
1510 if test "$CHECKSHADOW" = "true"; then
1511     AC_CHECK_FUNC(getprpwnam, [AC_DEFINE(HAVE_GETPRPWNAM) [CHECKSHADOW="false"; SECUREWARE=1], AC_CHECK_LIB(sec, getprpwnam, AC_DEFINE(HAVE_GETPRPWNAM) [CHECKSHADOW="false"; SECUREWARE=1; SUDO_LIBS="${SUDO_LIBS} -lsec"; LIBS="${LIBS} -lsec"], AC_CHECK_LIB(security, getprpwnam, AC_DEFINE(HAVE_GETPRPWNAM) [CHECKSHADOW="false"; SECUREWARE=1; SUDO_LIBS="${SUDO_LIBS} -lsecurity"; LIBS="${LIBS} -lsecurity"], AC_CHECK_LIB(prot, getprpwnam, AC_DEFINE(HAVE_GETPRPWNAM) [CHECKSHADOW="false"; SECUREWARE=1; SUDO_LIBS="${SUDO_LIBS} -lprot"; LIBS="${LIBS} -lprot"])))])
1512 fi
1513
1514 dnl
1515 dnl C compiler checks (to be done after os checks)
1516 dnl
1517 AC_PROG_GCC_TRADITIONAL
1518 AC_C_CONST
1519 AC_C_VOLATILE
1520 dnl
1521 dnl Program checks
1522 dnl
1523 AC_PROG_YACC
1524 SUDO_PROG_MV
1525 SUDO_PROG_BSHELL
1526 if test -z "$with_sendmail"; then
1527     SUDO_PROG_SENDMAIL
1528 fi
1529 if test -z "$with_editor"; then
1530     SUDO_PROG_VI
1531 fi
1532 dnl
1533 dnl Header file checks
1534 dnl
1535 AC_HEADER_STDC
1536 AC_HEADER_DIRENT
1537 AC_CHECK_HEADERS(malloc.h paths.h utime.h netgroup.h sys/sockio.h sys/bsdtypes.h sys/select.h)
1538 dnl ultrix termio/termios are broken
1539 if test "$OS" != "ultrix"; then
1540     AC_SYS_POSIX_TERMIOS
1541     if test "$ac_cv_sys_posix_termios" = "yes"; then
1542         AC_DEFINE(HAVE_TERMIOS_H, 1, [Define if you have the <termios.h> header file and the `tcgetattr' function.])
1543     else
1544         AC_CHECK_HEADERS(termio.h)
1545     fi
1546 fi
1547 if test "$with_logincap" = "yes"; then
1548     AC_CHECK_HEADERS(login_cap.h)
1549 fi
1550 if test "$with_bsdauth" = "yes"; then
1551     AC_CHECK_HEADER(bsd_auth.h, AC_DEFINE(HAVE_BSD_AUTH_H, 1, [Define if you use BSD authentication.]) [with_passwd=no; AUTH_OBJS=bsdauth.o])
1552 fi
1553 dnl
1554 dnl typedef checks
1555 dnl
1556 AC_TYPE_MODE_T
1557 AC_TYPE_UID_T
1558 AC_CHECK_TYPES([sig_atomic_t], , [AC_DEFINE(sig_atomic_t, int, [Define to `int' if <signal.h> does not define.])], [#include <sys/types.h>
1559 #include <signal.h>])
1560 AC_CHECK_TYPES([sigaction_t], [AC_DEFINE(HAVE_SIGACTION_T, 1, [Define if <signal.h> has the sigaction_t typedef.])], ,[#include <sys/types.h>
1561 #include <signal.h>])
1562 SUDO_TYPE_SIZE_T
1563 SUDO_TYPE_SSIZE_T
1564 SUDO_TYPE_DEV_T
1565 SUDO_TYPE_INO_T
1566 SUDO_FULL_VOID
1567 SUDO_UID_T_LEN
1568 SUDO_LONG_LONG
1569 SUDO_SOCK_SA_LEN
1570 dnl
1571 dnl only set RETSIGTYPE if it is not set already
1572 dnl
1573 case "$DEFS" in
1574     *"RETSIGTYPE"*)     ;;
1575     *)                  AC_TYPE_SIGNAL;;
1576 esac
1577 dnl
1578 dnl Function checks
1579 dnl
1580 AC_CHECK_FUNCS(strchr strrchr memchr memcpy memset sysconf tzset \
1581                seteuid setegid strftime setrlimit initgroups fstat)
1582 if test -z "$BROKEN_SETREUID"; then
1583     AC_CHECK_FUNCS(setreuid)
1584 fi
1585 if test X"$with_interfaces" != X"no"; then
1586     AC_CHECK_FUNCS(getifaddrs, AC_CHECK_FUNCS(freeifaddrs))
1587 fi
1588 if test -n "$SECUREWARE"; then
1589     AC_CHECK_FUNCS(bigcrypt set_auth_parameters initprivs)
1590 fi
1591 if test -z "$BROKEN_GETCWD"; then
1592     AC_REPLACE_FUNCS(getcwd)
1593 fi
1594 AC_CHECK_FUNCS(lockf flock, [break])
1595 AC_CHECK_FUNCS(waitpid wait3, [break])
1596 AC_CHECK_FUNCS(innetgr _innetgr, AC_CHECK_FUNCS(getdomainname) [break])
1597 AC_CHECK_FUNCS(lsearch, , [AC_CHECK_LIB(compat, lsearch, AC_CHECK_HEADER(search.h, AC_DEFINE(HAVE_LSEARCH) [LIBS="${LIBS} -lcompat"], AC_LIBOBJ(lsearch)), AC_LIBOBJ(lsearch))])
1598 AC_CHECK_FUNCS(utime, SUDO_FUNC_UTIME_POSIX, AC_LIBOBJ(utime))
1599 SUDO_FUNC_FNMATCH(AC_DEFINE(HAVE_FNMATCH, 1, [Define if you have the `fnmatch' function.]), AC_LIBOBJ(fnmatch))
1600 SUDO_FUNC_ISBLANK
1601 AC_REPLACE_FUNCS(strerror strcasecmp sigaction)
1602 AC_CHECK_FUNCS(snprintf vsnprintf asprintf vasprintf, , [NEED_SNPRINTF=1])
1603 dnl
1604 dnl If NEED_SNPRINTF is set, add snprintf.c to LIBOBJS
1605 dnl (it contains snprintf, vsnprintf, asprintf, and vasprintf)
1606 dnl
1607 if test -n "$NEED_SNPRINTF"; then
1608     AC_LIBOBJ(snprintf)
1609 fi
1610 dnl
1611 dnl if crypt(3) not in libc, look elsewhere
1612 dnl
1613 if test -z "$LIB_CRYPT"; then
1614     AC_CHECK_FUNC(crypt, , [AC_CHECK_LIB(crypt, crypt, [SUDO_LIBS="${SUDO_LIBS} -lcrypt"; LIBS="${LIBS} -lcrypt"], AC_CHECK_LIB(crypt_d, crypt, [SUDO_LIBS="${SUDO_LIBS} -lcrypt_d"; LIBS="${LIBS} -lcrypt_d"], AC_CHECK_LIB(ufc, crypt, [SUDO_LIBS="${SUDO_LIBS} -lufc"; LIBS="${LIBS} -lufc"])))])
1615 fi
1616 dnl
1617 dnl If socket(2) not in libc, check -lsocket and -linet
1618 dnl May need to link with *both* -lnsl and -lsocket due to unresolved symbols
1619 dnl In this case we look for main(), not socket() to avoid using a cached value
1620 dnl
1621 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)
1622 AC_CHECK_LIB(socket, socket, [NET_LIBS="${NET_LIBS} -lsocket -lnsl"; LIBS="${LIBS} -lsocket -lnsl"], , -lnsl)))])
1623 dnl
1624 dnl If inet_addr(3) not in libc, check -lnsl and -linet
1625 dnl May need to link with *both* -lnsl and -lsocket due to unresolved symbols
1626 dnl
1627 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)
1628 AC_CHECK_LIB(socket, inet_addr, [NET_LIBS="${NET_LIBS} -lsocket -lnsl"; LIBS="${LIBS} -lsocket -lnsl"], , -lnsl))))])
1629 dnl
1630 dnl If syslog(3) not in libc, check -lsocket, -lnsl and -linet
1631 dnl
1632 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"])))])
1633 dnl
1634 dnl Bison and DCE use alloca(3), if not in libc, use the sudo one (from gcc)
1635 dnl (gcc includes its own alloca(3) but other compilers may not)
1636 dnl
1637 if test "$with_DCE" = "yes" -o "$ac_cv_prog_YACC" = "bison -y"; then
1638     AC_FUNC_ALLOCA
1639 fi
1640
1641 dnl
1642 dnl Kerberos 5
1643 dnl
1644 if test "$with_kerb5" = "yes"; then
1645     AC_DEFINE(HAVE_KERB5, 1, [Define if you use Kerberos V.])
1646     if test -f "/usr/local/include/krb5.h"; then
1647         CPPFLAGS="$CPPFLAGS -I/usr/local/include"
1648     elif test -f "/usr/local/kerberos/include/krb5.h"; then
1649         CPPFLAGS="$CPPFLAGS -I/usr/local/kerberos/include"
1650     elif test -f "/usr/krb5/include/krb5.h"; then
1651         CPPFLAGS="$CPPFLAGS -I/usr/krb5/include"
1652     elif test -f "/usr/local/krb5/include/krb5.h"; then
1653         CPPFLAGS="$CPPFLAGS -I/usr/local/krb5/include"
1654     else
1655         echo 'Unable to locate kerberos 5 include files, you will have to edit the Makefile and add -I/path/to/krb/includes to CPPFLAGS'
1656     fi
1657
1658     if test -f "/usr/local/lib/libkrb5.a"; then
1659         SUDO_LDFLAGS="${SUDO_LDFLAGS} -L/usr/local/lib"
1660     elif test -f "/usr/local/kerberos/lib/libkrb5.a"; then
1661         SUDO_LDFLAGS="${SUDO_LDFLAGS} -L/usr/local/kerberos/lib"
1662     elif test -f "/usr/krb5/lib/libkrb5.a"; then
1663         SUDO_LDFLAGS="${SUDO_LDFLAGS} -L/usr/krb5/lib"
1664     elif test -f "/usr/local/krb5/lib/libkrb5.a"; then
1665         SUDO_LDFLAGS="${SUDO_LDFLAGS} -L/usr/local/krb5/lib"
1666     else
1667         echo 'Unable to locate kerberos 5 libraries, you will have to edit the Makefile and add -L/path/to/krb/libs to SUDO_LDFLAGS'
1668     fi
1669
1670     SUDO_LIBS="${SUDO_LIBS} -lkrb5 -lk5crypto -lcom_err"
1671     AUTH_OBJS="${AUTH_OBJS} kerb5.o"
1672 fi
1673
1674 dnl
1675 dnl PAM libs
1676 dnl
1677 if test "$with_pam" = "yes"; then
1678     AC_HAVE_LIBRARY(dl, SUDO_LIBS="${SUDO_LIBS} -ldl -lpam", SUDO_LIBS="${SUDO_LIBS} -lpam")
1679 fi
1680
1681 dnl
1682 dnl Find kerberos 4 includes and libs or complain
1683 dnl
1684 if test "$with_kerb4" = "yes"; then
1685     AC_DEFINE(HAVE_KERB4, 1, [Define if you use Kerberos IV.])
1686     if test -f "/usr/include/kerberosIV/krb.h"; then
1687         CPPFLAGS="${CPPFLAGS} -I/usr/include/kerberosIV"
1688     elif test -f "/usr/local/include/kerberosIV/krb.h"; then
1689         CPPFLAGS="${CPPFLAGS} -I/usr/local/include/kerberosIV"
1690     elif test -f "/usr/kerberos/include/krb.h"; then
1691         CPPFLAGS="${CPPFLAGS} -I/usr/kerberos/include"
1692     elif test -f "/usr/local/kerberos/include/krb.h"; then
1693         CPPFLAGS="${CPPFLAGS} -I/usr/local/kerberos/include"
1694     else
1695         echo 'Unable to locate kerberos 4 include files, you will have to edit the Makefile and add -I/path/to/krb/includes to CPPFLAGS'
1696     fi
1697
1698     if test -d "/usr/kerberos/lib"; then
1699         SUDO_LDFLAGS="${SUDO_LDFLAGS} -L/usr/kerberos/lib"
1700     elif test -d "/usr/lib/kerberos"; then
1701         SUDO_LDFLAGS="${SUDO_LDFLAGS} -L/usr/lib/kerberos"
1702     elif test -f "/usr/local/lib/libkrb.a"; then
1703         SUDO_LDFLAGS="${SUDO_LDFLAGS} -L/usr/local/lib"
1704     elif test ! -f "/usr/lib/libkrb.a"; then
1705         echo 'Unable to locate kerberos 4 libraries, you will have to edit the Makefile and add -L/path/to/krb/libs to SUDO_LDFLAGS'
1706     fi
1707
1708     AC_HAVE_LIBRARY(des, SUDO_LIBS="${SUDO_LIBS} -lkrb -ldes", SUDO_LIBS="${SUDO_LIBS} -lkrb")
1709     AUTH_OBJS="${AUTH_OBJS} kerb4.o"
1710 fi
1711
1712 dnl
1713 dnl extra AFS libs and includes
1714 dnl
1715 if test "$with_AFS" = "yes"; then
1716
1717     # looks like the "standard" place for AFS libs is /usr/afsws/lib
1718     AFSLIBDIRS="/usr/lib/afs /usr/afsws/lib /usr/afsws/lib/afs"
1719     for i in $AFSLIBDIRS; do
1720         if test -d ${i}; then
1721             SUDO_LDFLAGS="${SUDO_LDFLAGS} -L${i}"
1722             FOUND_AFSLIBDIR=true
1723         fi
1724     done
1725     if test -z "$FOUND_AFSLIBDIR"; then
1726         echo '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.'
1727     fi
1728
1729     # Order is important here.  Note that we build AFS_LIBS from right to left
1730     # since AFS_LIBS may be initialized with BSD compat libs that must go last
1731     AFS_LIBS="-laudit ${AFS_LIBS}"
1732     for i in $AFSLIBDIRS; do
1733         if test -f ${i}/util.a; then
1734             AFS_LIBS="${i}/util.a ${AFS_LIBS}"
1735             FOUND_UTIL_A=true
1736             break;
1737         fi
1738     done
1739     if test -z "$FOUND_UTIL_A"; then
1740         AFS_LIBS="-lutil ${AFS_LIBS}"
1741     fi
1742     AFS_LIBS="-lkauth -lprot -lubik -lauth -lrxkad -lsys -ldes -lrx -llwp -lcom_err ${AFS_LIBS}"
1743
1744     # AFS includes may live in /usr/include on some machines...
1745     for i in /usr/afsws/include; do
1746         if test -d ${i}; then
1747             CPPFLAGS="${CPPFLAGS} -I${i}"
1748             FOUND_AFSINCDIR=true
1749         fi
1750     done
1751
1752     if test -z "$FOUND_AFSLIBDIR"; then
1753         echo '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.'
1754     fi
1755 fi
1756
1757 dnl
1758 dnl extra DCE obj + lib
1759 dnl Order of libs in HP-UX 10.x is important, -ldce must be last.
1760 dnl
1761 if test "$with_DCE" = "yes"; then
1762     DCE_OBJS="${DCE_OBJS} dce_pwent.o"
1763     SUDO_LIBS="${SUDO_LIBS} -ldce"
1764 fi
1765
1766 dnl
1767 dnl extra S/Key lib and includes
1768 dnl
1769 if test "$with_skey" = "yes"; then
1770     SUDO_LIBS="${SUDO_LIBS} -lskey"
1771     if test -f /usr/include/skey.h -a -f /usr/lib/libskey.a; then
1772         :
1773     elif test -f /usr/local/include/skey.h; then
1774         CPPFLAGS="${CPPFLAGS} -I/usr/local/include"
1775         SUDO_LDFLAGS="${SUDO_LDFLAGS} -L/usr/local/lib"
1776     elif test "$with_csops" = "yes" -a -f /tools/cs/skey/include/skey.h -a -f /tools/cs/skey/lib/libskey.a; then
1777         CPPFLAGS="${CPPFLAGS} -I/tools/cs/skey/include"
1778         SUDO_LDFLAGS="${SUDO_LDFLAGS} -L/tools/cs/skey/lib"
1779     else
1780         echo 'Unable to locate libskey.a and/or skey.h, you will have to edit the Makefile and add -L/path/to/skey/lib to SUDO_LDFLAGS and/or -I/path/to/skey.h to CPPFLAGS'
1781     fi
1782     AC_CHECK_LIB(skey, skeyaccess, AC_DEFINE(HAVE_SKEYACCESS, 1, [Define if your S/Key library has skeyaccess().]))
1783 fi
1784
1785 dnl
1786 dnl extra OPIE lib and includes
1787 dnl
1788 if test "$with_opie" = "yes"; then
1789     SUDO_LIBS="${SUDO_LIBS} -lopie"
1790     if test -f /usr/include/opie.h -a -f /usr/lib/libopie.a; then
1791         :
1792     elif test -f /usr/local/include/opie.h; then
1793         CPPFLAGS="${CPPFLAGS} -I/usr/local/include"
1794         SUDO_LDFLAGS="${SUDO_LDFLAGS} -L/usr/local/lib"
1795     else
1796         echo 'Unable to locate libopie.a and/or opie.h, you will have to edit the Makefile and add -L/path/to/opie/lib to SUDO_LDFLAGS and/or -I/path/to/opie.h to CPPFLAGS'
1797     fi
1798 fi
1799
1800 dnl
1801 dnl extra SecurID lib + includes
1802 dnl
1803 if test -n "$with_SecurID" -a "$with_SecurID" != "no"; then
1804     if test "$with_SecurID" != "yes"; then
1805         SUDO_LIBS="${SUDO_LIBS} ${with_SecurID}/sdiclient.a"
1806         CPPFLAGS="${CPPFLAGS} -I${with_SecurID}"
1807     elif test -f /usr/ace/examples/sdiclient.a; then
1808         SUDO_LIBS="${SUDO_LIBS} /usr/ace/examples/sdiclient.a"
1809         CPPFLAGS="${CPPFLAGS} -I/usr/ace/examples"
1810     else
1811         SUDO_LIBS="${SUDO_LIBS} /usr/ace/sdiclient.a"
1812         CPPFLAGS="${CPPFLAGS} -I/usr/ace"
1813     fi
1814 fi
1815
1816 dnl
1817 dnl extra FWTK libs + includes
1818 dnl
1819 if test "$with_fwtk" = "yes"; then
1820     SUDO_LIBS="${SUDO_LIBS} -lauth -lfwall"
1821 fi
1822
1823 dnl
1824 dnl extra 'authenticate' lib (AIX only?)
1825 dnl
1826 if test "$with_authenticate" = "yes"; then
1827     SUDO_LIBS="${SUDO_LIBS} -ls"
1828 fi
1829
1830 dnl
1831 dnl Check for log file and timestamp locations
1832 dnl
1833 SUDO_LOGFILE
1834 SUDO_TIMEDIR
1835
1836 dnl
1837 dnl Use passwd (and secureware) auth modules?
1838 dnl
1839 if test "$with_passwd" = "no"; then
1840     AC_DEFINE(WITHOUT_PASSWD, 1. [Define to avoid using the passwd/shadow file for authentication.])
1841     if test -z "$AUTH_OBJS"; then
1842         AC_MSG_ERROR([no authentication methods defined.])
1843     fi
1844 else
1845     if test -n "$SECUREWARE"; then
1846         AUTH_OBJS="${AUTH_OBJS} passwd.o secureware.o"
1847     else
1848         AUTH_OBJS="${AUTH_OBJS} passwd.o"
1849     fi
1850 fi
1851
1852 dnl
1853 dnl LIBS may contain duplicates from SUDO_LIBS or NET_LIBS so prune it.
1854 dnl
1855 if test -n "$LIBS"; then
1856     L="$LIBS"
1857     LIBS=
1858     for l in ${L}; do
1859         dupe=0
1860         for sl in ${SUDO_LIBS} ${NET_LIBS}; do
1861             test $l = $sl && dupe=1
1862         done
1863         test $dupe = 0 && LIBS="${LIBS} $l"
1864     done
1865 fi
1866
1867 dnl
1868 dnl Set exec_prefix
1869 dnl
1870 test "$exec_prefix" = "NONE" && exec_prefix='$(prefix)'
1871
1872 dnl
1873 dnl Substitute into the Makefile and man pages
1874 dnl
1875 AC_OUTPUT([Makefile sudo.man visudo.man sudoers.man])
1876
1877 dnl
1878 dnl Spew any text the user needs to know about
1879 dnl
1880 if test "$with_pam" = "yes"; then
1881     echo ""
1882     case $host in
1883         *-*-linux*)
1884             echo "You will need to customize sample.pam and install it as /etc/pam.d/sudo"
1885             ;;
1886     esac
1887     echo ""
1888 fi
1889
1890 dnl
1891 dnl Special bits for autoheader   
1892 dnl
1893 AH_VERBATIM([_GNU_SOURCE],
1894 [/* Enable GNU extensions on systems that have them. */
1895 #ifndef _GNU_SOURCE
1896 # define _GNU_SOURCE    1
1897 #endif])
1898
1899 AH_VERBATIM([_ALL_SOURCE],
1900 [/* Enable non-POSIX extensions on AIX. */
1901 #ifndef _ALL_SOURCE
1902 # undef _ALL_SOURCE
1903 #endif])
1904
1905 AH_VERBATIM([_CONVEX_SOURCE],
1906 [/* Enable non-POSIX extensions on ConvexOS. */
1907 #ifndef _CONVEX_SOURCE
1908 # undef _CONVEX_SOURCE
1909 #endif])
1910
1911 AH_TOP([#ifndef _SUDO_CONFIG_H
1912 #define _SUDO_CONFIG_H])
1913
1914 AH_BOTTOM([/*
1915  * Emulate a subset of waitpid() if we don't have it.
1916  */
1917 #ifdef HAVE_WAITPID
1918 # define sudo_waitpid(p, s, o)  waitpid(p, s, o)
1919 #else
1920 # ifdef HAVE_WAIT3
1921 #  define sudo_waitpid(p, s, o) wait3(s, o, NULL)
1922 # endif
1923 #endif
1924
1925 /* Solaris doesn't use const qualifiers in PAM. */
1926 #ifdef sun
1927 # define PAM_CONST
1928 #else
1929 # define PAM_CONST      const
1930 #endif
1931
1932 #ifdef USE_EXECV
1933 # define EXEC   execv
1934 #else
1935 # define EXEC   execvp
1936 #endif /* USE_EXECV */
1937
1938 /* New ANSI-style OS defs for HP-UX and ConvexOS. */
1939 #if defined(hpux) && !defined(__hpux)
1940 # define __hpux         1
1941 #endif /* hpux */
1942
1943 #if defined(convex) && !defined(__convex__)
1944 # define __convex__     1
1945 #endif /* convex */
1946
1947 /* BSD compatibility on some SVR4 systems. */
1948 #ifdef __svr4__
1949 # define BSD_COMP
1950 #endif /* __svr4__ */
1951
1952 #endif /* _SUDO_CONFIG_H */])