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