update control to reflect move of primary repo to collab-maint
[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-2012 Todd C. Miller <Todd.Miller@courtesan.com>
5 dnl
6 AC_INIT([sudo], [1.8.5p2], [http://www.sudo.ws/bugs/], [sudo])
7 AC_CONFIG_HEADER([config.h pathnames.h])
8 dnl
9 dnl Note: this must come after 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([SUDOERS_LDFLAGS])
23 AC_SUBST([LTLDFLAGS])
24 AC_SUBST([COMMON_OBJS])
25 AC_SUBST([SUDOERS_OBJS])
26 AC_SUBST([SUDO_OBJS])
27 AC_SUBST([LIBS])
28 AC_SUBST([SUDO_LIBS])
29 AC_SUBST([SUDOERS_LIBS])
30 AC_SUBST([NET_LIBS])
31 AC_SUBST([AFS_LIBS])
32 AC_SUBST([REPLAY_LIBS])
33 AC_SUBST([GETGROUPS_LIB])
34 AC_SUBST([OSDEFS])
35 AC_SUBST([AUTH_OBJS])
36 AC_SUBST([MANTYPE])
37 AC_SUBST([MAN_POSTINSTALL])
38 AC_SUBST([SUDOERS_MODE])
39 AC_SUBST([SUDOERS_UID])
40 AC_SUBST([SUDOERS_GID])
41 AC_SUBST([DEVEL])
42 AC_SUBST([BAMAN])
43 AC_SUBST([LCMAN])
44 AC_SUBST([SEMAN])
45 AC_SUBST([devdir])
46 AC_SUBST([mansectsu])
47 AC_SUBST([mansectform])
48 AC_SUBST([mansrcdir])
49 AC_SUBST([NOEXECFILE])
50 AC_SUBST([NOEXECDIR])
51 AC_SUBST([PLUGINDIR])
52 AC_SUBST([SOEXT])
53 AC_SUBST([noexec_file])
54 AC_SUBST([INSTALL_NOEXEC])
55 AC_SUBST([DONT_LEAK_PATH_INFO])
56 AC_SUBST([BSDAUTH_USAGE])
57 AC_SUBST([SELINUX_USAGE])
58 AC_SUBST([LDAP])
59 AC_SUBST([LOGINCAP_USAGE])
60 AC_SUBST([ZLIB])
61 AC_SUBST([ZLIB_SRC])
62 AC_SUBST([LIBTOOL_DEPS])
63 AC_SUBST([ac_config_libobj_dir])
64 AC_SUBST([CONFIGURE_ARGS])
65 AC_SUBST([LIBDL])
66 AC_SUBST([LT_STATIC])
67 AC_SUBST([LIBINTL])
68 AC_SUBST([SUDO_NLS])
69 AC_SUBST([COMPAT_TEST_PROGS])
70 dnl
71 dnl Variables that get substituted in docs (not overridden by environment)
72 dnl
73 AC_SUBST([iolog_dir])dnl real initial value from SUDO_IO_LOGDIR
74 AC_SUBST([timedir])dnl real initial value from SUDO_TIMEDIR
75 AC_SUBST([timeout])
76 AC_SUBST([password_timeout])
77 AC_SUBST([sudo_umask])
78 AC_SUBST([umask_override])
79 AC_SUBST([passprompt])
80 AC_SUBST([long_otp_prompt])
81 AC_SUBST([lecture])
82 AC_SUBST([logfac])
83 AC_SUBST([goodpri])
84 AC_SUBST([badpri])
85 AC_SUBST([loglen])
86 AC_SUBST([ignore_dot])
87 AC_SUBST([mail_no_user])
88 AC_SUBST([mail_no_host])
89 AC_SUBST([mail_no_perms])
90 AC_SUBST([mailto])
91 AC_SUBST([mailsub])
92 AC_SUBST([badpass_message])
93 AC_SUBST([fqdn])
94 AC_SUBST([runas_default])
95 AC_SUBST([env_editor])
96 AC_SUBST([env_reset])
97 AC_SUBST([passwd_tries])
98 AC_SUBST([tty_tickets])
99 AC_SUBST([insults])
100 AC_SUBST([root_sudo])
101 AC_SUBST([path_info])
102 AC_SUBST([ldap_conf])
103 AC_SUBST([ldap_secret])
104 AC_SUBST([nsswitch_conf])
105 AC_SUBST([netsvc_conf])
106 AC_SUBST([secure_path])
107 AC_SUBST([editor])
108 #
109 # Begin initial values for man page substitution
110 #
111 iolog_dir=/var/log/sudo-io
112 timedir=/var/adm/sudo
113 timeout=5
114 password_timeout=5
115 sudo_umask=0022
116 umask_override=off
117 passprompt="Password:"
118 long_otp_prompt=off
119 lecture=once
120 logfac=auth
121 goodpri=notice
122 badpri=alert
123 loglen=80
124 ignore_dot=off
125 mail_no_user=on
126 mail_no_host=off
127 mail_no_perms=off
128 mailto=root
129 mailsub="*** SECURITY information for %h ***"
130 badpass_message="Sorry, try again."
131 fqdn=off
132 runas_default=root
133 env_editor=off
134 env_reset=on
135 editor=vi
136 passwd_tries=3
137 tty_tickets=on
138 insults=off
139 root_sudo=on
140 path_info=on
141 ldap_conf=/etc/ldap.conf
142 ldap_secret=/etc/ldap.secret
143 netsvc_conf=/etc/netsvc.conf
144 noexec_file=/usr/local/libexec/sudo_noexec.so
145 nsswitch_conf=/etc/nsswitch.conf
146 secure_path="not set"
147 #
148 # End initial values for man page substitution
149 #
150 dnl
151 dnl Initial values for Makefile variables listed above
152 dnl May be overridden by environment variables..
153 dnl
154 INSTALL_NOEXEC=
155 devdir='$(srcdir)'
156 PROGS="sudo"
157 : ${MANTYPE='man'}
158 : ${mansrcdir='.'}
159 : ${SUDOERS_MODE='0440'}
160 : ${SUDOERS_UID='0'}
161 : ${SUDOERS_GID='0'}
162 DEVEL=
163 LDAP="#"
164 BAMAN=0
165 LCMAN=0
166 SEMAN=0
167 LIBINTL=
168 ZLIB=
169 ZLIB_SRC=
170 AUTH_OBJS=
171 AUTH_REG=
172 AUTH_EXCL=
173 AUTH_EXCL_DEF=
174 AUTH_DEF=passwd
175 SUDO_NLS=disabled
176
177 dnl
178 dnl Other vaiables
179 dnl
180 CHECKSHADOW=true
181 shadow_defs=
182 shadow_funcs=
183 shadow_libs=
184 shadow_libs_optional=
185 CONFIGURE_ARGS="$@"
186
187 dnl
188 dnl LD_PRELOAD equivalents
189 dnl
190 RTLD_PRELOAD_VAR="LD_PRELOAD"
191 RTLD_PRELOAD_ENABLE_VAR=
192 RTLD_PRELOAD_DELIM=":"
193 RTLD_PRELOAD_DEFAULT=
194
195 dnl
196 dnl libc replacement functions live in compat
197 dnl
198 AC_CONFIG_LIBOBJ_DIR(compat)
199
200 dnl
201 dnl Deprecated --with options (these all warn or generate an error)
202 dnl
203
204 AC_ARG_WITH(otp-only, [AS_HELP_STRING([--with-otp-only], [deprecated])],
205 [case $with_otp_only in
206     yes)        with_passwd="no"
207                 AC_MSG_NOTICE([--with-otp-only option deprecated, treating as --without-passwd])
208                 ;;
209 esac])
210
211 AC_ARG_WITH(alertmail, [AS_HELP_STRING([--with-alertmail], [deprecated])],
212 [case $with_alertmail in
213     *)          with_mailto="$with_alertmail"
214                 AC_MSG_NOTICE([--with-alertmail option deprecated, treating as --mailto])
215                 ;;
216 esac])
217
218 dnl
219 dnl Options for --with
220 dnl
221
222 AC_ARG_WITH(devel, [AS_HELP_STRING([--with-devel], [add development options])],
223 [case $with_devel in
224     yes)        AC_MSG_NOTICE([Setting up for development: -Wall, flex, yacc])
225                 OSDEFS="${OSDEFS} -DSUDO_DEVEL"
226                 DEVEL="true"
227                 devdir=.
228                 ;;
229     no)         ;;
230     *)          AC_MSG_WARN([Ignoring unknown argument to --with-devel: $with_devel])
231                 ;;
232 esac])
233
234 AC_ARG_WITH(CC, [AS_HELP_STRING([--with-CC], [C compiler to use])],
235 [case $with_CC in
236     *)          AC_MSG_ERROR([the --with-CC option is no longer supported, please set the CC environment variable instead.])
237                 ;;
238 esac])
239
240 AC_ARG_WITH(rpath, [AS_HELP_STRING([--with-rpath], [pass -R flag in addition to -L for lib paths])],
241 [case $with_rpath in
242     yes|no)     ;;
243     *)          AC_MSG_ERROR(["--with-rpath does not take an argument."])
244                 ;;
245 esac])
246
247 AC_ARG_WITH(blibpath, [AS_HELP_STRING([--with-blibpath[=PATH]], [pass -blibpath flag to ld for additional lib paths])],
248 [case $with_blibpath in
249     yes|no)     ;;
250     *)          AC_MSG_NOTICE([will pass -blibpath:${with_blibpath} to the loader.])
251                 ;;
252 esac])
253
254 dnl
255 dnl Handle BSM auditing support.
256 dnl
257 AC_ARG_WITH(bsm-audit, [AS_HELP_STRING([--with-bsm-audit], [enable BSM audit support])],
258 [case $with_bsm_audit in
259     yes)        AC_DEFINE(HAVE_BSM_AUDIT)
260                 SUDOERS_LIBS="${SUDOERS_LIBS} -lbsm"
261                 SUDOERS_OBJS="${SUDOERS_OBJS} bsm_audit.lo"
262                 ;;
263     no)         ;;
264     *)          AC_MSG_ERROR(["--with-bsm-audit does not take an argument."])
265                 ;;
266 esac])
267
268 dnl
269 dnl Handle Linux auditing support.
270 dnl
271 AC_ARG_WITH(linux-audit, [AS_HELP_STRING([--with-linux-audit], [enable Linux audit support])],
272 [case $with_linux_audit in
273     yes)        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <libaudit.h>]], [[int i = AUDIT_USER_CMD; (void)i;]])], [
274                     AC_DEFINE(HAVE_LINUX_AUDIT)
275                     SUDO_LIBS="${SUDO_LIBS} -laudit"
276                     SUDOERS_LIBS="${SUDO_LIBS} -laudit"
277                     SUDOERS_OBJS="${SUDOERS_OBJS} linux_audit.lo"
278                 ], [
279                     AC_MSG_ERROR([unable to find AUDIT_USER_CMD in libaudit.h for --with-linux-audit])
280                 ])
281                 ;;
282     no)         ;;
283     *)          AC_MSG_ERROR(["--with-linux-audit does not take an argument."])
284                 ;;
285 esac])
286
287 AC_ARG_WITH(incpath, [AS_HELP_STRING([--with-incpath], [additional places to look for include files])],
288 [case $with_incpath in
289     yes)        AC_MSG_ERROR(["must give --with-incpath an argument."])
290                 ;;
291     no)         AC_MSG_ERROR(["--without-incpath not supported."])
292                 ;;
293     *)          AC_MSG_NOTICE([Adding ${with_incpath} to CPPFLAGS])
294                 for i in ${with_incpath}; do
295                     CPPFLAGS="${CPPFLAGS} -I${i}"
296                 done
297                 ;;
298 esac])
299
300 AC_ARG_WITH(libpath, [AS_HELP_STRING([--with-libpath], [additional places to look for libraries])],
301 [case $with_libpath in
302     yes)        AC_MSG_ERROR(["must give --with-libpath an argument."])
303                 ;;
304     no)         AC_MSG_ERROR(["--without-libpath not supported."])
305                 ;;
306     *)          AC_MSG_NOTICE([Adding ${with_libpath} to LDFLAGS])
307                 ;;
308 esac])
309
310 AC_ARG_WITH(libraries, [AS_HELP_STRING([--with-libraries], [additional libraries to link with])],
311 [case $with_libraries in
312     yes)        AC_MSG_ERROR(["must give --with-libraries an argument."])
313                 ;;
314     no)         AC_MSG_ERROR(["--without-libraries not supported."])
315                 ;;
316     *)          AC_MSG_NOTICE([Adding ${with_libraries} to LIBS])
317                 ;;
318 esac])
319
320 AC_ARG_WITH(efence, [AS_HELP_STRING([--with-efence], [link with -lefence for malloc() debugging])],
321 [case $with_efence in
322     yes)        AC_MSG_NOTICE([Sudo will link with -lefence (Electric Fence)])
323                 LIBS="${LIBS} -lefence"
324                 if test -f /usr/local/lib/libefence.a; then
325                     with_libpath="${with_libpath} /usr/local/lib"
326                 fi
327                 ;;
328     no)         ;;
329     *)          AC_MSG_WARN([Ignoring unknown argument to --with-efence: $with_efence])
330                 ;;
331 esac])
332
333 AC_ARG_WITH(csops, [AS_HELP_STRING([--with-csops], [add CSOps standard options])],
334 [case $with_csops in
335     yes)        AC_MSG_NOTICE([Adding CSOps standard options])
336                 CHECKSIA=false
337                 with_ignore_dot=yes
338                 insults=on
339                 with_classic_insults=yes
340                 with_csops_insults=yes
341                 with_env_editor=yes
342                 : ${mansectsu='8'}
343                 : ${mansectform='5'}
344                 ;;
345     no)         ;;
346     *)          AC_MSG_WARN([Ignoring unknown argument to --with-csops: $with_csops])
347                 ;;
348 esac])
349
350 AC_ARG_WITH(passwd, [AS_HELP_STRING([--without-passwd], [don't use passwd/shadow file for authentication])],
351 [case $with_passwd in
352     yes|no)     AC_MSG_CHECKING(whether to use shadow/passwd file authentication)
353                 AC_MSG_RESULT($with_passwd)
354                 AUTH_DEF=""
355                 test "$with_passwd" = "yes" && AUTH_REG="$AUTH_REG passwd"
356                 ;;
357     *)          AC_MSG_ERROR(["Sorry, --with-passwd does not take an argument."])
358                 ;;
359 esac])
360
361 AC_ARG_WITH(skey, [AS_HELP_STRING([--with-skey[=DIR]], [enable S/Key support ])],
362 [case $with_skey in
363     no)         ;;
364     *)          AC_DEFINE(HAVE_SKEY)
365                 AC_MSG_CHECKING(whether to try S/Key authentication)
366                 AC_MSG_RESULT(yes)
367                 AUTH_REG="$AUTH_REG S/Key"
368                 ;;
369 esac])
370
371 AC_ARG_WITH(opie, [AS_HELP_STRING([--with-opie[=DIR]], [enable OPIE support ])],
372 [case $with_opie in
373     no)         ;;
374     *)          AC_DEFINE(HAVE_OPIE)
375                 AC_MSG_CHECKING(whether to try NRL OPIE authentication)
376                 AC_MSG_RESULT(yes)
377                 AUTH_REG="$AUTH_REG NRL_OPIE"
378                 ;;
379 esac])
380
381 AC_ARG_WITH(long-otp-prompt, [AS_HELP_STRING([--with-long-otp-prompt], [use a two line OTP (skey/opie) prompt])],
382 [case $with_long_otp_prompt in
383     yes)        AC_DEFINE(LONG_OTP_PROMPT)
384                 AC_MSG_CHECKING(whether to use a two line prompt for OTP authentication)
385                 AC_MSG_RESULT(yes)
386                 long_otp_prompt=on
387                 ;;
388     no)         long_otp_prompt=off
389                 ;;
390     *)          AC_MSG_ERROR(["--with-long-otp-prompt does not take an argument."])
391                 ;;
392 esac])
393
394 AC_ARG_WITH(SecurID, [AS_HELP_STRING([--with-SecurID[[=DIR]]], [enable SecurID support])],
395 [case $with_SecurID in
396     no)         ;;
397     *)          AC_DEFINE(HAVE_SECURID)
398                 AC_MSG_CHECKING(whether to use SecurID for authentication)
399                 AC_MSG_RESULT(yes)
400                 AUTH_EXCL="$AUTH_EXCL SecurID"
401                 ;;
402 esac])
403
404 AC_ARG_WITH(fwtk, [AS_HELP_STRING([--with-fwtk[[=DIR]]], [enable FWTK AuthSRV support])],
405 [case $with_fwtk in
406     no)         ;;
407     *)          AC_DEFINE(HAVE_FWTK)
408                 AC_MSG_CHECKING(whether to use FWTK AuthSRV for authentication)
409                 AC_MSG_RESULT(yes)
410                 AUTH_EXCL="$AUTH_EXCL FWTK"
411                 ;;
412 esac])
413
414 AC_ARG_WITH(kerb5, [AS_HELP_STRING([--with-kerb5[[=DIR]]], [enable Kerberos V support])],
415 [case $with_kerb5 in
416     no)         ;;
417     *)          AC_MSG_CHECKING(whether to try Kerberos V authentication)
418                 AC_MSG_RESULT(yes)
419                 AUTH_REG="$AUTH_REG kerb5"
420                 ;;
421 esac])
422
423 AC_ARG_WITH(aixauth, [AS_HELP_STRING([--with-aixauth], [enable AIX general authentication support])],
424 [case $with_aixauth in
425     yes)        AUTH_EXCL="$AUTH_EXCL AIX_AUTH";;
426     no)         ;;
427     *)          AC_MSG_ERROR(["--with-aixauth does not take an argument."])
428                 ;;
429 esac])
430
431 AC_ARG_WITH(pam, [AS_HELP_STRING([--with-pam], [enable PAM support])],
432 [case $with_pam in
433     yes)        AUTH_EXCL="$AUTH_EXCL PAM";;
434     no)         ;;
435     *)          AC_MSG_ERROR(["--with-pam does not take an argument."])
436                 ;;
437 esac])
438
439 AC_ARG_WITH(AFS, [AS_HELP_STRING([--with-AFS], [enable AFS support])],
440 [case $with_AFS in
441     yes)        AC_DEFINE(HAVE_AFS)
442                 AC_MSG_CHECKING(whether to try AFS (kerberos) authentication)
443                 AC_MSG_RESULT(yes)
444                 AUTH_REG="$AUTH_REG AFS"
445                 ;;
446     no)         ;;
447     *)          AC_MSG_ERROR(["--with-AFS does not take an argument."])
448                 ;;
449 esac])
450
451 AC_ARG_WITH(DCE, [AS_HELP_STRING([--with-DCE], [enable DCE support])],
452 [case $with_DCE in
453     yes)        AC_DEFINE(HAVE_DCE)
454                 AC_MSG_CHECKING(whether to try DCE (kerberos) authentication)
455                 AC_MSG_RESULT(yes)
456                 AUTH_REG="$AUTH_REG DCE"
457                 ;;
458     no)         ;;
459     *)          AC_MSG_ERROR(["--with-DCE does not take an argument."])
460                 ;;
461 esac])
462
463 AC_ARG_WITH(logincap, [AS_HELP_STRING([--with-logincap], [enable BSD login class support])],
464 [case $with_logincap in
465     yes|no)     ;;
466     *)          AC_MSG_ERROR(["--with-logincap does not take an argument."])
467                 ;;
468 esac])
469
470 AC_ARG_WITH(bsdauth, [AS_HELP_STRING([--with-bsdauth], [enable BSD authentication support])],
471 [case $with_bsdauth in
472     yes)        AUTH_EXCL="$AUTH_EXCL BSD_AUTH";;
473     no)         ;;
474     *)          AC_MSG_ERROR(["--with-bsdauth does not take an argument."])
475                 ;;
476 esac])
477
478 AC_ARG_WITH(project, [AS_HELP_STRING([--with-project], [enable Solaris project support])],
479 [case $with_project in
480     yes|no)     ;;
481     no) ;;
482     *)          AC_MSG_ERROR(["--with-project does not take an argument."])
483                 ;;
484 esac])
485
486 AC_MSG_CHECKING(whether to lecture users the first time they run sudo)
487 AC_ARG_WITH(lecture, [AS_HELP_STRING([--without-lecture], [don't print lecture for first-time sudoer])],
488 [case $with_lecture in
489     yes|short|always)   lecture=once
490                 ;;
491     no|none|never)      lecture=never
492                 ;;
493     *)          AC_MSG_ERROR(["unknown argument to --with-lecture: $with_lecture"])
494                 ;;
495 esac])
496 if test "$lecture" = "once"; then
497     AC_MSG_RESULT(yes)
498 else
499     AC_DEFINE(NO_LECTURE)
500     AC_MSG_RESULT(no)
501 fi
502
503 AC_MSG_CHECKING(whether sudo should log via syslog or to a file by default)
504 AC_ARG_WITH(logging, [AS_HELP_STRING([--with-logging], [log via syslog, file, or both])],
505 [case $with_logging in
506     yes)        AC_MSG_ERROR(["must give --with-logging an argument."])
507                 ;;
508     no)         AC_MSG_ERROR(["--without-logging not supported."])
509                 ;;
510     syslog)     AC_DEFINE(LOGGING, SLOG_SYSLOG)
511                 AC_MSG_RESULT(syslog)
512                 ;;
513     file)       AC_DEFINE(LOGGING, SLOG_FILE)
514                 AC_MSG_RESULT(file)
515                 ;;
516     both)       AC_DEFINE(LOGGING, SLOG_BOTH)
517                 AC_MSG_RESULT(both)
518                 ;;
519     *)          AC_MSG_ERROR(["unknown argument to --with-logging: $with_logging"])
520                 ;;
521 esac], [AC_DEFINE(LOGGING, SLOG_SYSLOG) AC_MSG_RESULT(syslog)])
522
523 AC_ARG_WITH(logfac, [AS_HELP_STRING([--with-logfac], [syslog facility to log with (default is "auth")])],
524 [case $with_logfac in
525     yes)        AC_MSG_ERROR(["must give --with-logfac an argument."])
526                 ;;
527     no)         AC_MSG_ERROR(["--without-logfac not supported."])
528                 ;;
529     authpriv|auth|daemon|user|local0|local1|local2|local3|local4|local5|local6|local7)          logfac=$with_logfac
530                 ;;
531     *)          AC_MSG_ERROR(["$with_logfac is not a supported syslog facility."])
532                 ;;
533 esac])
534
535 AC_MSG_CHECKING(at which syslog priority to log commands)
536 AC_ARG_WITH(goodpri, [AS_HELP_STRING([--with-goodpri], [syslog priority for commands (def is "notice")])],
537 [case $with_goodpri in
538     yes)        AC_MSG_ERROR(["must give --with-goodpri an argument."])
539                 ;;
540     no)         AC_MSG_ERROR(["--without-goodpri not supported."])
541                 ;;
542     alert|crit|debug|emerg|err|info|notice|warning)
543                 goodpri=$with_goodpri
544                 ;;
545     *)          AC_MSG_ERROR(["$with_goodpri is not a supported syslog priority."])
546                 ;;
547 esac])
548 AC_DEFINE_UNQUOTED(PRI_SUCCESS, "$goodpri", [The syslog priority sudo will use for successful attempts.])
549 AC_MSG_RESULT($goodpri)
550
551 AC_MSG_CHECKING(at which syslog priority to log failures)
552 AC_ARG_WITH(badpri, [AS_HELP_STRING([--with-badpri], [syslog priority for failures (def is "alert")])],
553 [case $with_badpri in
554     yes)        AC_MSG_ERROR(["must give --with-badpri an argument."])
555                 ;;
556     no)         AC_MSG_ERROR(["--without-badpri not supported."])
557                 ;;
558     alert|crit|debug|emerg|err|info|notice|warning)
559                 badpri=$with_badpri
560                 ;;
561     *)          AC_MSG_ERROR([$with_badpri is not a supported syslog priority.])
562                 ;;
563 esac])
564 AC_DEFINE_UNQUOTED(PRI_FAILURE, "$badpri", [The syslog priority sudo will use for unsuccessful attempts/errors.])
565 AC_MSG_RESULT($badpri)
566
567 AC_ARG_WITH(logpath, [AS_HELP_STRING([--with-logpath], [path to the sudo log file])],
568 [case $with_logpath in
569     yes)        AC_MSG_ERROR(["must give --with-logpath an argument."])
570                 ;;
571     no)         AC_MSG_ERROR(["--without-logpath not supported."])
572                 ;;
573 esac])
574
575 AC_MSG_CHECKING(how long a line in the log file should be)
576 AC_ARG_WITH(loglen, [AS_HELP_STRING([--with-loglen], [maximum length of a log file line (default is 80)])],
577 [case $with_loglen in
578     yes)        AC_MSG_ERROR(["must give --with-loglen an argument."])
579                 ;;
580     no)         AC_MSG_ERROR(["--without-loglen not supported."])
581                 ;;
582     [[0-9]]*)   loglen=$with_loglen
583                 ;;
584     *)          AC_MSG_ERROR(["you must enter a number, not $with_loglen"])
585                 ;;
586 esac])
587 AC_DEFINE_UNQUOTED(MAXLOGFILELEN, $loglen, [The max number of chars per log file line (for line wrapping).])
588 AC_MSG_RESULT($loglen)
589
590 AC_MSG_CHECKING(whether sudo should ignore '.' or '' in \$PATH)
591 AC_ARG_WITH(ignore-dot, [AS_HELP_STRING([--with-ignore-dot], [ignore '.' in the PATH])],
592 [case $with_ignore_dot in
593     yes)        ignore_dot=on
594                 ;;
595     no)         ignore_dot=off
596                 ;;
597     *)          AC_MSG_ERROR(["--with-ignore-dot does not take an argument."])
598                 ;;
599 esac])
600 if test "$ignore_dot" = "on"; then
601     AC_DEFINE(IGNORE_DOT_PATH)
602     AC_MSG_RESULT(yes)
603 else
604     AC_MSG_RESULT(no)
605 fi
606
607 AC_MSG_CHECKING(whether to send mail when a user is not in sudoers)
608 AC_ARG_WITH(mail-if-no-user, [AS_HELP_STRING([--without-mail-if-no-user], [do not send mail if user not in sudoers])],
609 [case $with_mail_if_no_user in
610     yes)        mail_no_user=on
611                 ;;
612     no)         mail_no_user=off
613                 ;;
614     *)          AC_MSG_ERROR(["--with-mail-if-no-user does not take an argument."])
615                 ;;
616 esac])
617 if test "$mail_no_user" = "on"; then
618     AC_DEFINE(SEND_MAIL_WHEN_NO_USER)
619     AC_MSG_RESULT(yes)
620 else
621     AC_MSG_RESULT(no)
622 fi
623
624 AC_MSG_CHECKING(whether to send mail when user listed but not for this host)
625 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])],
626 [case $with_mail_if_no_host in
627     yes)        mail_no_host=on
628                 ;;
629     no)         mail_no_host=off
630                 ;;
631     *)          AC_MSG_ERROR(["--with-mail-if-no-host does not take an argument."])
632                 ;;
633 esac])
634 if test "$mail_no_host" = "on"; then
635     AC_DEFINE(SEND_MAIL_WHEN_NO_HOST)
636     AC_MSG_RESULT(yes)
637 else
638     AC_MSG_RESULT(no)
639 fi
640
641 AC_MSG_CHECKING(whether to send mail when a user tries a disallowed command)
642 AC_ARG_WITH(mail-if-noperms, [AS_HELP_STRING([--with-mail-if-noperms], [send mail if user not allowed to run command])],
643 [case $with_mail_if_noperms in
644     yes)        mail_noperms=on
645                 ;;
646     no)         mail_noperms=off
647                 ;;
648     *)          AC_MSG_ERROR(["--with-mail-if-noperms does not take an argument."])
649                 ;;
650 esac])
651 if test "$mail_noperms" = "on"; then
652     AC_DEFINE(SEND_MAIL_WHEN_NOT_OK)
653     AC_MSG_RESULT(yes)
654 else
655     AC_MSG_RESULT(no)
656 fi
657
658 AC_MSG_CHECKING(who should get the mail that sudo sends)
659 AC_ARG_WITH(mailto, [AS_HELP_STRING([--with-mailto], [who should get sudo mail (default is "root")])],
660 [case $with_mailto in
661     yes)        AC_MSG_ERROR(["must give --with-mailto an argument."])
662                 ;;
663     no)         AC_MSG_ERROR(["--without-mailto not supported."])
664                 ;;
665     *)          mailto=$with_mailto
666                 ;;
667 esac])
668 AC_DEFINE_UNQUOTED(MAILTO, "$mailto", [The user or email address that sudo mail is sent to.])
669 AC_MSG_RESULT([$mailto])
670
671 AC_ARG_WITH(mailsubject, [AS_HELP_STRING([--with-mailsubject], [subject of sudo mail])],
672 [case $with_mailsubject in
673     yes)        AC_MSG_ERROR(["must give --with-mailsubject an argument."])
674                 ;;
675     no)         AC_MSG_WARN([Sorry, --without-mailsubject not supported.])
676                 ;;
677     *)          mailsub="$with_mailsubject"
678                 AC_MSG_CHECKING(sudo mail subject)
679                 AC_MSG_RESULT([Using alert mail subject: $mailsub])
680                 ;;
681 esac])
682 AC_DEFINE_UNQUOTED(MAILSUBJECT, "$mailsub", [The subject of the mail sent by sudo to the MAILTO user/address.])
683
684 AC_MSG_CHECKING(for bad password prompt)
685 AC_ARG_WITH(passprompt, [AS_HELP_STRING([--with-passprompt], [default password prompt])],
686 [case $with_passprompt in
687     yes)        AC_MSG_ERROR(["must give --with-passprompt an argument."])
688                 ;;
689     no)         AC_MSG_WARN([Sorry, --without-passprompt not supported.])
690                 ;;
691     *)          passprompt="$with_passprompt"
692 esac])
693 AC_MSG_RESULT($passprompt)
694 AC_DEFINE_UNQUOTED(PASSPROMPT, "$passprompt", [The default password prompt.])
695
696 AC_MSG_CHECKING(for bad password message)
697 AC_ARG_WITH(badpass-message, [AS_HELP_STRING([--with-badpass-message], [message the user sees when the password is wrong])],
698 [case $with_badpass_message in
699     yes)        AC_MSG_ERROR(["Must give --with-badpass-message an argument."])
700                 ;;
701     no)         AC_MSG_WARN([Sorry, --without-badpass-message not supported.])
702                 ;;
703     *)          badpass_message="$with_badpass_message"
704                 ;;
705 esac])
706 AC_DEFINE_UNQUOTED(INCORRECT_PASSWORD, "$badpass_message", [The message given when a bad password is entered.])
707 AC_MSG_RESULT([$badpass_message])
708
709 AC_MSG_CHECKING(whether to expect fully qualified hosts in sudoers)
710 AC_ARG_WITH(fqdn, [AS_HELP_STRING([--with-fqdn], [expect fully qualified hosts in sudoers])],
711 [case $with_fqdn in
712     yes)        fqdn=on
713                 ;;
714     no)         fqdn=off
715                 ;;
716     *)          AC_MSG_ERROR(["--with-fqdn does not take an argument."])
717                 ;;
718 esac])
719 if test "$fqdn" = "on"; then
720     AC_DEFINE(FQDN)
721     AC_MSG_RESULT(yes)
722 else
723     AC_MSG_RESULT(no)
724 fi
725
726 AC_ARG_WITH(timedir, [AS_HELP_STRING([--with-timedir], [path to the sudo timestamp dir])],
727 [case $with_timedir in
728     yes)        AC_MSG_ERROR(["must give --with-timedir an argument."])
729                 ;;
730     no)         AC_MSG_ERROR(["--without-timedir not supported."])
731                 ;;
732 esac])
733
734 AC_ARG_WITH(iologdir, [AS_HELP_STRING([--with-iologdir=DIR], [directory to store sudo I/O log files in])],
735 [case $with_iologdir in
736     yes)    ;;
737     no)     AC_MSG_ERROR(["--without-iologdir not supported."])
738             ;;
739 esac])
740
741 AC_ARG_WITH(sendmail, [AS_HELP_STRING([--with-sendmail], [set path to sendmail])
742 AS_HELP_STRING([--without-sendmail], [do not send mail at all])],
743 [case $with_sendmail in
744     yes)        with_sendmail=""
745                 ;;
746     no)         ;;
747     *)          SUDO_DEFINE_UNQUOTED(_PATH_SUDO_SENDMAIL, "$with_sendmail")
748                 ;;
749 esac])
750
751 AC_ARG_WITH(sudoers-mode, [AS_HELP_STRING([--with-sudoers-mode], [mode of sudoers file (defaults to 0440)])],
752 [case $with_sudoers_mode in
753     yes)        AC_MSG_ERROR(["must give --with-sudoers-mode an argument."])
754                 ;;
755     no)         AC_MSG_ERROR(["--without-sudoers-mode not supported."])
756                 ;;
757     [[1-9]]*)   SUDOERS_MODE=0${with_sudoers_mode}
758                 ;;
759     0*)         SUDOERS_MODE=$with_sudoers_mode
760                 ;;
761     *)          AC_MSG_ERROR(["you must use an octal mode, not a name."])
762                 ;;
763 esac])
764
765 AC_ARG_WITH(sudoers-uid, [AS_HELP_STRING([--with-sudoers-uid], [uid that owns sudoers file (defaults to 0)])],
766 [case $with_sudoers_uid in
767     yes)        AC_MSG_ERROR(["must give --with-sudoers-uid an argument."])
768                 ;;
769     no)         AC_MSG_ERROR(["--without-sudoers-uid not supported."])
770                 ;;
771     [[0-9]]*)   SUDOERS_UID=$with_sudoers_uid
772                 ;;
773     *)          AC_MSG_ERROR(["you must use an unsigned numeric uid, not a name."])
774                 ;;
775 esac])
776
777 AC_ARG_WITH(sudoers-gid, [AS_HELP_STRING([--with-sudoers-gid], [gid that owns sudoers file (defaults to 0)])],
778 [case $with_sudoers_gid in
779     yes)        AC_MSG_ERROR(["must give --with-sudoers-gid an argument."])
780                 ;;
781     no)         AC_MSG_ERROR(["--without-sudoers-gid not supported."])
782                 ;;
783     [[0-9]]*)   SUDOERS_GID=$with_sudoers_gid
784                 ;;
785     *)          AC_MSG_ERROR(["you must use an unsigned numeric gid, not a name."])
786                 ;;
787 esac])
788
789 AC_MSG_CHECKING(for umask programs should be run with)
790 AC_ARG_WITH(umask, [AS_HELP_STRING([--with-umask], [umask with which the prog should run (default is 022)])
791 AS_HELP_STRING([--without-umask], [Preserves the umask of the user invoking sudo.])],
792 [case $with_umask in
793     yes)        AC_MSG_ERROR(["must give --with-umask an argument."])
794                 ;;
795     no)         sudo_umask=0777
796                 ;;
797     [[0-9]]*)   sudo_umask=$with_umask
798                 ;;
799     *)          AC_MSG_ERROR(["you must enter a numeric mask."])
800                 ;;
801 esac])
802 AC_DEFINE_UNQUOTED(SUDO_UMASK, $sudo_umask, [The umask that the sudo-run prog should use.])
803 if test "$sudo_umask" = "0777"; then
804     AC_MSG_RESULT(user)
805 else
806     AC_MSG_RESULT($sudo_umask)
807 fi
808
809 AC_ARG_WITH(umask-override, [AS_HELP_STRING([--with-umask-override], [Use the umask specified in sudoers even if it is less restrictive than the user's.])],
810 [case $with_umask_override in
811     yes)        AC_DEFINE(UMASK_OVERRIDE)
812                 umask_override=on
813                 ;;
814     no)         umask_override=off
815                 ;;
816     *)          AC_MSG_ERROR(["--with-umask-override does not take an argument."])
817                 ;;
818 esac])
819
820 AC_MSG_CHECKING(for default user to run commands as)
821 AC_ARG_WITH(runas-default, [AS_HELP_STRING([--with-runas-default], [User to run commands as (default is "root")])],
822 [case $with_runas_default in
823     yes)        AC_MSG_ERROR(["must give --with-runas-default an argument."])
824                 ;;
825     no)         AC_MSG_ERROR(["--without-runas-default not supported."])
826                 ;;
827     *)          runas_default="$with_runas_default"
828                 ;;
829 esac])
830 AC_DEFINE_UNQUOTED(RUNAS_DEFAULT, "$runas_default", [The user sudo should run commands as by default.])
831 AC_MSG_RESULT([$runas_default])
832
833 AC_ARG_WITH(exempt, [AS_HELP_STRING([--with-exempt=group], [no passwd needed for users in this group])],
834 [case $with_exempt in
835     yes)        AC_MSG_ERROR(["must give --with-exempt an argument."])
836                 ;;
837     no)         AC_MSG_ERROR(["--without-exempt not supported."])
838                 ;;
839     *)          AC_DEFINE_UNQUOTED(EXEMPTGROUP, "$with_exempt", [If defined, users in this group need not enter a passwd (ie "sudo").])
840                 AC_MSG_CHECKING(for group to be exempt from password)
841                 AC_MSG_RESULT([$with_exempt])
842                 ;;
843 esac])
844
845 AC_MSG_CHECKING(for editor that visudo should use)
846 AC_ARG_WITH(editor, [AS_HELP_STRING([--with-editor=path], [Default editor for visudo (defaults to vi)])],
847 [case $with_editor in
848     yes)        AC_MSG_ERROR(["must give --with-editor an argument."])
849                 ;;
850     no)         AC_MSG_ERROR(["--without-editor not supported."])
851                 ;;
852     *)          AC_DEFINE_UNQUOTED(EDITOR, "$with_editor", [A colon-separated list of pathnames to be used as the editor for visudo.])
853                 AC_MSG_RESULT([$with_editor])
854                 editor="$with_editor"
855                 ;;
856 esac], [AC_DEFINE(EDITOR, _PATH_VI) AC_MSG_RESULT(vi)])
857
858 AC_MSG_CHECKING(whether to obey EDITOR and VISUAL environment variables)
859 AC_ARG_WITH(env-editor, [AS_HELP_STRING([--with-env-editor], [Use the environment variable EDITOR for visudo])],
860 [case $with_env_editor in
861     yes)        env_editor=on
862                 ;;
863     no)         env_editor=off
864                 ;;
865     *)          AC_MSG_ERROR(["--with-env-editor does not take an argument."])
866                 ;;
867 esac])
868 if test "$env_editor" = "on"; then
869     AC_DEFINE(ENV_EDITOR)
870     AC_MSG_RESULT(yes)
871 else
872     AC_MSG_RESULT(no)
873 fi
874
875 AC_MSG_CHECKING(number of tries a user gets to enter their password)
876 AC_ARG_WITH(passwd-tries, [AS_HELP_STRING([--with-passwd-tries], [number of tries to enter password (default is 3)])],
877 [case $with_passwd_tries in
878     yes)        ;;
879     no)         AC_MSG_ERROR(["--without-editor not supported."])
880                 ;;
881     [[1-9]]*)   passwd_tries=$with_passwd_tries
882                 ;;
883     *)          AC_MSG_ERROR(["you must enter the numer of tries, > 0"])
884                 ;;
885 esac])
886 AC_DEFINE_UNQUOTED(TRIES_FOR_PASSWORD, $passwd_tries, [The number of tries a user gets to enter their password.])
887 AC_MSG_RESULT($passwd_tries)
888
889 AC_MSG_CHECKING(time in minutes after which sudo will ask for a password again)
890 AC_ARG_WITH(timeout, [AS_HELP_STRING([--with-timeout], [minutes before sudo asks for passwd again (def is 5 minutes)])],
891 [case $with_timeout in
892     yes)        ;;
893     no)         timeout=0
894                 ;;
895     [[0-9]]*)   timeout=$with_timeout
896                 ;;
897     *)          AC_MSG_ERROR(["you must enter the numer of minutes."])
898                 ;;
899 esac])
900 AC_DEFINE_UNQUOTED(TIMEOUT, $timeout, [The number of minutes before sudo asks for a password again.])
901 AC_MSG_RESULT($timeout)
902
903 AC_MSG_CHECKING(time in minutes after the password prompt will time out)
904 AC_ARG_WITH(password-timeout, [AS_HELP_STRING([--with-password-timeout], [passwd prompt timeout in minutes (default is 5 minutes)])],
905 [case $with_password_timeout in
906     yes)        ;;
907     no)         password_timeout=0
908                 ;;
909     [[0-9]]*)   password_timeout=$with_password_timeout
910                 ;;
911     *)          AC_MSG_ERROR(["you must enter the numer of minutes."])
912                 ;;
913 esac])
914 AC_DEFINE_UNQUOTED(PASSWORD_TIMEOUT, $password_timeout, [The passwd prompt timeout (in minutes).])
915 AC_MSG_RESULT($password_timeout)
916
917 AC_MSG_CHECKING(whether to use per-tty ticket files)
918 AC_ARG_WITH(tty-tickets, [AS_HELP_STRING([--with-tty-tickets], [use a different ticket file for each tty])],
919 [case $with_tty_tickets in
920     yes)        tty_tickets=on
921                 ;;
922     no)         tty_tickets=off
923                 ;;
924     *)          AC_MSG_ERROR(["--with-tty-tickets does not take an argument."])
925                 ;;
926 esac])
927 if test "$tty_tickets" = "off"; then
928     AC_DEFINE(NO_TTY_TICKETS)
929     AC_MSG_RESULT(no)
930 else
931     AC_MSG_RESULT(yes)
932 fi
933
934 AC_MSG_CHECKING(whether to include insults)
935 AC_ARG_WITH(insults, [AS_HELP_STRING([--with-insults], [insult the user for entering an incorrect password])],
936 [case $with_insults in
937     yes)        insults=on
938                 with_classic_insults=yes
939                 with_csops_insults=yes
940                 ;;
941     disabled)   insults=off
942                 with_classic_insults=yes
943                 with_csops_insults=yes
944                 ;;
945     no)         insults=off
946                 ;;
947     *)          AC_MSG_ERROR(["--with-insults does not take an argument."])
948                 ;;
949 esac])
950 if test "$insults" = "on"; then
951     AC_DEFINE(USE_INSULTS)
952     AC_MSG_RESULT(yes)
953 else
954     AC_MSG_RESULT(no)
955 fi
956
957 AC_ARG_WITH(all-insults, [AS_HELP_STRING([--with-all-insults], [include all the sudo insult sets])],
958 [case $with_all_insults in
959     yes)        with_classic_insults=yes
960                 with_csops_insults=yes
961                 with_hal_insults=yes
962                 with_goons_insults=yes
963                 ;;
964     no)         ;;
965     *)          AC_MSG_ERROR(["--with-all-insults does not take an argument."])
966                 ;;
967 esac])
968
969 AC_ARG_WITH(classic-insults, [AS_HELP_STRING([--with-classic-insults], [include the insults from the "classic" sudo])],
970 [case $with_classic_insults in
971     yes)        AC_DEFINE(CLASSIC_INSULTS)
972                 ;;
973     no)         ;;
974     *)          AC_MSG_ERROR(["--with-classic-insults does not take an argument."])
975                 ;;
976 esac])
977
978 AC_ARG_WITH(csops-insults, [AS_HELP_STRING([--with-csops-insults], [include CSOps insults])],
979 [case $with_csops_insults in
980     yes)        AC_DEFINE(CSOPS_INSULTS)
981                 ;;
982     no)         ;;
983     *)          AC_MSG_ERROR(["--with-csops-insults does not take an argument."])
984                 ;;
985 esac])
986
987 AC_ARG_WITH(hal-insults, [AS_HELP_STRING([--with-hal-insults], [include 2001-like insults])],
988 [case $with_hal_insults in
989     yes)        AC_DEFINE(HAL_INSULTS)
990                 ;;
991     no)         ;;
992     *)          AC_MSG_ERROR(["--with-hal-insults does not take an argument."])
993                 ;;
994 esac])
995
996 AC_ARG_WITH(goons-insults, [AS_HELP_STRING([--with-goons-insults], [include the insults from the "Goon Show"])],
997 [case $with_goons_insults in
998     yes)        AC_DEFINE(GOONS_INSULTS)
999                 ;;
1000     no)         ;;
1001     *)          AC_MSG_ERROR(["--with-goons-insults does not take an argument."])
1002                 ;;
1003 esac])
1004
1005 AC_ARG_WITH(nsswitch, [AS_HELP_STRING([--with-nsswitch[[=PATH]]], [path to nsswitch.conf])],
1006 [case $with_nsswitch in
1007     no)         ;;
1008     yes)        with_nsswitch="/etc/nsswitch.conf"
1009                 ;;
1010     *)          ;;
1011 esac])
1012
1013 AC_ARG_WITH(ldap, [AS_HELP_STRING([--with-ldap[[=DIR]]], [enable LDAP support])],
1014 [case $with_ldap in
1015     no)         ;;
1016     *)          AC_DEFINE(HAVE_LDAP)
1017                 AC_MSG_CHECKING(whether to use sudoers from LDAP)
1018                 AC_MSG_RESULT(yes)
1019                 ;;
1020 esac])
1021
1022 AC_ARG_WITH(ldap-conf-file, [AS_HELP_STRING([--with-ldap-conf-file], [path to LDAP configuration file])])
1023 test -n "$with_ldap_conf_file" && ldap_conf="$with_ldap_conf_file"
1024 SUDO_DEFINE_UNQUOTED(_PATH_LDAP_CONF, "$ldap_conf", [Path to the ldap.conf file])
1025
1026 AC_ARG_WITH(ldap-secret-file, [AS_HELP_STRING([--with-ldap-secret-file], [path to LDAP secret password file])])
1027 test -n "$with_ldap_secret_file" && ldap_secret="$with_ldap_secret_file"
1028 SUDO_DEFINE_UNQUOTED(_PATH_LDAP_SECRET, "$ldap_secret", [Path to the ldap.secret file])
1029
1030 AC_ARG_WITH(pc-insults, [AS_HELP_STRING([--with-pc-insults], [replace politically incorrect insults with less offensive ones])],
1031 [case $with_pc_insults in
1032     yes)        AC_DEFINE(PC_INSULTS)
1033                 ;;
1034     no)         ;;
1035     *)          AC_MSG_ERROR(["--with-pc-insults does not take an argument."])
1036                 ;;
1037 esac])
1038
1039 dnl include all insult sets on one line
1040 if test "$insults" = "on"; then
1041     AC_MSG_CHECKING(which insult sets to include)
1042     i=""
1043     test "$with_goons_insults" = "yes" && i="goons ${i}"
1044     test "$with_hal_insults" = "yes" && i="hal ${i}"
1045     test "$with_csops_insults" = "yes" && i="csops ${i}"
1046     test "$with_classic_insults" = "yes" && i="classic ${i}"
1047     AC_MSG_RESULT([$i])
1048 fi
1049
1050 AC_MSG_CHECKING(whether to override the user's path)
1051 AC_ARG_WITH(secure-path, [AS_HELP_STRING([--with-secure-path], [override the user's path with a built-in one])],
1052 [case $with_secure_path in
1053     yes)        with_secure_path="/bin:/usr/ucb:/usr/bin:/usr/sbin:/sbin:/usr/etc:/etc"
1054                 AC_DEFINE_UNQUOTED(SECURE_PATH, "$with_secure_path")
1055                 AC_MSG_RESULT([$with_secure_path])
1056                 secure_path="set to $with_secure_path"
1057                 ;;
1058     no)         AC_MSG_RESULT(no)
1059                 ;;
1060     *)          AC_DEFINE_UNQUOTED(SECURE_PATH, "$with_secure_path")
1061                 AC_MSG_RESULT([$with_secure_path])
1062                 secure_path="set to F<$with_secure_path>"
1063                 ;;
1064 esac], AC_MSG_RESULT(no))
1065
1066 AC_MSG_CHECKING(whether to get ip addresses from the network interfaces)
1067 AC_ARG_WITH(interfaces, [AS_HELP_STRING([--without-interfaces], [don't try to read the ip addr of ether interfaces])],
1068 [case $with_interfaces in
1069     yes)        AC_MSG_RESULT(yes)
1070                 ;;
1071     no)         AC_DEFINE(STUB_LOAD_INTERFACES)
1072                 AC_MSG_RESULT(no)
1073                 ;;
1074     *)          AC_MSG_ERROR(["--with-interfaces does not take an argument."])
1075                 ;;
1076 esac], AC_MSG_RESULT(yes))
1077
1078 AC_MSG_CHECKING(whether stow should be used)
1079 AC_ARG_WITH(stow, [AS_HELP_STRING([--with-stow], [properly handle GNU stow packaging])],
1080 [case $with_stow in
1081     yes)        AC_MSG_RESULT(yes)
1082                 AC_DEFINE(USE_STOW)
1083                 ;;
1084     no)         AC_MSG_RESULT(no)
1085                 ;;
1086     *)          AC_MSG_ERROR(["--with-stow does not take an argument."])
1087                 ;;
1088 esac], AC_MSG_RESULT(no))
1089
1090 AC_MSG_CHECKING(whether to use an askpass helper)
1091 AC_ARG_WITH(askpass, [AS_HELP_STRING([--with-askpass=PATH], [Fully qualified pathname of askpass helper])],
1092 [case $with_askpass in
1093     yes)        AC_MSG_ERROR(["--with-askpass takes a path as an argument."])
1094                 ;;
1095     no)         ;;
1096     *)          SUDO_DEFINE_UNQUOTED(_PATH_SUDO_ASKPASS, "$with_askpass", [The fully qualified pathname of askpass])
1097                 ;;
1098 esac], AC_MSG_RESULT(no))
1099
1100 AC_ARG_WITH(plugindir, [AS_HELP_STRING([--with-plugindir], [set directory to load plugins from])],
1101 [case $with_plugindir in
1102     no)         AC_MSG_ERROR(["illegal argument: --without-plugindir."])
1103                 ;;
1104     *)          ;;
1105 esac], [with_plugindir="$libexecdir"])
1106
1107 dnl
1108 dnl Options for --enable
1109 dnl
1110
1111 AC_MSG_CHECKING(whether to do user authentication by default)
1112 AC_ARG_ENABLE(authentication,
1113 [AS_HELP_STRING([--disable-authentication], [Do not require authentication by default])],
1114 [ case "$enableval" in
1115     yes)        AC_MSG_RESULT(yes)
1116                 ;;
1117     no)         AC_MSG_RESULT(no)
1118                 AC_DEFINE(NO_AUTHENTICATION)
1119                 ;;
1120     *)          AC_MSG_RESULT(no)
1121                 AC_MSG_WARN([Ignoring unknown argument to --enable-authentication: $enableval])
1122                 ;;
1123   esac
1124 ], AC_MSG_RESULT(yes))
1125
1126 AC_MSG_CHECKING(whether to disable running the mailer as root)
1127 AC_ARG_ENABLE(root-mailer,
1128 [AS_HELP_STRING([--disable-root-mailer], [Don't run the mailer as root, run as the user])],
1129 [ case "$enableval" in
1130     yes)        AC_MSG_RESULT(no)
1131                 ;;
1132     no)         AC_MSG_RESULT(yes)
1133                 AC_DEFINE(NO_ROOT_MAILER)
1134                 ;;
1135     *)          AC_MSG_RESULT(no)
1136                 AC_MSG_WARN([Ignoring unknown argument to --enable-root-mailer: $enableval])
1137                 ;;
1138   esac
1139 ], AC_MSG_RESULT(no))
1140
1141 AC_ARG_ENABLE(setreuid,
1142 [AS_HELP_STRING([--disable-setreuid], [Don't try to use the setreuid() function])],
1143 [ case "$enableval" in
1144     no)         SKIP_SETREUID=yes
1145                 ;;
1146     *)          ;;
1147   esac
1148 ])
1149
1150 AC_ARG_ENABLE(setresuid,
1151 [AS_HELP_STRING([--disable-setresuid], [Don't try to use the setresuid() function])],
1152 [ case "$enableval" in
1153     no)         SKIP_SETRESUID=yes
1154                 ;;
1155     *)          ;;
1156   esac
1157 ])
1158
1159 AC_MSG_CHECKING(whether to disable shadow password support)
1160 AC_ARG_ENABLE(shadow,
1161 [AS_HELP_STRING([--disable-shadow], [Never use shadow passwords])],
1162 [ case "$enableval" in
1163     yes)        AC_MSG_RESULT(no)
1164                 ;;
1165     no)         AC_MSG_RESULT(yes)
1166                 CHECKSHADOW="false"
1167                 ;;
1168     *)          AC_MSG_RESULT(no)
1169                 AC_MSG_WARN([Ignoring unknown argument to --enable-shadow: $enableval])
1170                 ;;
1171   esac
1172 ], AC_MSG_RESULT(no))
1173
1174 AC_MSG_CHECKING(whether root should be allowed to use sudo)
1175 AC_ARG_ENABLE(root-sudo,
1176 [AS_HELP_STRING([--disable-root-sudo], [Don't allow root to run sudo])],
1177 [ case "$enableval" in
1178     yes)        AC_MSG_RESULT(yes)
1179                 ;;
1180     no)         AC_DEFINE(NO_ROOT_SUDO)
1181                 AC_MSG_RESULT(no)
1182                 root_sudo=off
1183                 ;;
1184     *)          AC_MSG_ERROR(["--enable-root-sudo does not take an argument."])
1185                 ;;
1186   esac
1187 ], AC_MSG_RESULT(yes))
1188
1189 AC_MSG_CHECKING(whether to log the hostname in the log file)
1190 AC_ARG_ENABLE(log-host,
1191 [AS_HELP_STRING([--enable-log-host], [Log the hostname in the log file])],
1192 [ case "$enableval" in
1193     yes)        AC_MSG_RESULT(yes)
1194                 AC_DEFINE(HOST_IN_LOG)
1195                 ;;
1196     no)         AC_MSG_RESULT(no)
1197                 ;;
1198     *)          AC_MSG_RESULT(no)
1199                 AC_MSG_WARN([Ignoring unknown argument to --enable-log-host: $enableval])
1200                 ;;
1201   esac
1202 ], AC_MSG_RESULT(no))
1203
1204 AC_MSG_CHECKING(whether to invoke a shell if sudo is given no arguments)
1205 AC_ARG_ENABLE(noargs-shell,
1206 [AS_HELP_STRING([--enable-noargs-shell], [If sudo is given no arguments run a shell])],
1207 [ case "$enableval" in
1208     yes)        AC_MSG_RESULT(yes)
1209                 AC_DEFINE(SHELL_IF_NO_ARGS)
1210                 ;;
1211     no)         AC_MSG_RESULT(no)
1212                 ;;
1213     *)          AC_MSG_RESULT(no)
1214                 AC_MSG_WARN([Ignoring unknown argument to --enable-noargs-shell: $enableval])
1215                 ;;
1216   esac
1217 ], AC_MSG_RESULT(no))
1218
1219 AC_MSG_CHECKING(whether to set \$HOME to target user in shell mode)
1220 AC_ARG_ENABLE(shell-sets-home,
1221 [AS_HELP_STRING([--enable-shell-sets-home], [Set $HOME to target user in shell mode])],
1222 [ case "$enableval" in
1223     yes)        AC_MSG_RESULT(yes)
1224                 AC_DEFINE(SHELL_SETS_HOME)
1225                 ;;
1226     no)         AC_MSG_RESULT(no)
1227                 ;;
1228     *)          AC_MSG_RESULT(no)
1229                 AC_MSG_WARN([Ignoring unknown argument to --enable-shell-sets-home: $enableval])
1230                 ;;
1231   esac
1232 ], AC_MSG_RESULT(no))
1233
1234 AC_MSG_CHECKING(whether to disable 'command not found' messages)
1235 AC_ARG_ENABLE(path_info,
1236 [AS_HELP_STRING([--disable-path-info], [Print 'command not allowed' not 'command not found'])],
1237 [ case "$enableval" in
1238     yes)        AC_MSG_RESULT(no)
1239                 ;;
1240     no)         AC_MSG_RESULT(yes)
1241                 AC_DEFINE(DONT_LEAK_PATH_INFO)
1242                 path_info=off
1243                 ;;
1244     *)          AC_MSG_RESULT(no)
1245                 AC_MSG_WARN([Ignoring unknown argument to --enable-path-info: $enableval])
1246                 ;;
1247   esac
1248 ], AC_MSG_RESULT(no))
1249
1250 AC_MSG_CHECKING(whether to enable environment debugging)
1251 AC_ARG_ENABLE(env_debug,
1252 [AS_HELP_STRING([--enable-env-debug], [Whether to enable environment debugging.])],
1253 [ case "$enableval" in
1254     yes)        AC_MSG_RESULT(yes)
1255                 AC_DEFINE(ENV_DEBUG)
1256                 ;;
1257     no)         AC_MSG_RESULT(no)
1258                 ;;
1259     *)          AC_MSG_RESULT(no)
1260                 AC_MSG_WARN([Ignoring unknown argument to --enable-env-debug: $enableval])
1261                 ;;
1262   esac
1263 ], AC_MSG_RESULT(no))
1264
1265 AC_ARG_ENABLE(zlib,
1266 [AS_HELP_STRING([--enable-zlib[[=PATH]]], [Whether to enable or disable zlib])],
1267 [], [enable_zlib=yes])
1268
1269 AC_MSG_CHECKING(whether to enable environment resetting by default)
1270 AC_ARG_ENABLE(env_reset,
1271 [AS_HELP_STRING([--enable-env-reset], [Whether to enable environment resetting by default.])],
1272 [ case "$enableval" in
1273     yes)        env_reset=on
1274                 ;;
1275     no)         env_reset=off
1276                 ;;
1277     *)          env_reset=on
1278                 AC_MSG_WARN([Ignoring unknown argument to --enable-env-reset: $enableval])
1279                 ;;
1280   esac
1281 ])
1282 if test "$env_reset" = "on"; then
1283     AC_MSG_RESULT(yes)
1284     AC_DEFINE(ENV_RESET, 1)
1285 else
1286     AC_MSG_RESULT(no)
1287     AC_DEFINE(ENV_RESET, 0)
1288 fi
1289
1290 AC_ARG_ENABLE(warnings,
1291 [AS_HELP_STRING([--enable-warnings], [Whether to enable compiler warnings])],
1292 [ case "$enableval" in
1293     yes)    ;;
1294     no)     ;;
1295     *)      AC_MSG_WARN([Ignoring unknown argument to --enable-warnings: $enableval])
1296             ;;
1297   esac
1298 ])
1299
1300 AC_ARG_ENABLE(werror,
1301 [AS_HELP_STRING([--enable-werror], [Whether to enable the -Werror compiler option])],
1302 [ case "$enableval" in
1303     yes)    ;;
1304     no)     ;;
1305     *)      AC_MSG_WARN([Ignoring unknown argument to --enable-werror: $enableval])
1306             ;;
1307   esac
1308 ])
1309
1310 AC_ARG_ENABLE(admin-flag,
1311 [AS_HELP_STRING([--enable-admin-flag], [Whether to create a Ubuntu-style admin flag file])],
1312 [ case "$enableval" in
1313     yes)    AC_DEFINE(USE_ADMIN_FLAG)
1314             ;;
1315     no)     ;;
1316     *)      AC_MSG_WARN([Ignoring unknown argument to --enable-admin-flag: $enableval])
1317             ;;
1318   esac
1319 ])
1320
1321 AC_ARG_ENABLE(nls,
1322 [AS_HELP_STRING([--disable-nls], [Disable natural language support using gettext])],
1323 [], [enable_nls=yes])
1324
1325 AC_ARG_WITH(selinux, [AS_HELP_STRING([--with-selinux], [enable SELinux support])],
1326 [case $with_selinux in
1327     yes)        SELINUX_USAGE="[[-r role]] [[-t type]] "
1328                 AC_DEFINE(HAVE_SELINUX)
1329                 SUDO_LIBS="${SUDO_LIBS} -lselinux"
1330                 SUDO_OBJS="${SUDO_OBJS} selinux.o"
1331                 PROGS="${PROGS} sesh"
1332                 SEMAN=1
1333                 AC_CHECK_LIB([selinux], [setkeycreatecon],
1334                     [AC_DEFINE(HAVE_SETKEYCREATECON)])
1335                 ;;
1336     no)         ;;
1337     *)          AC_MSG_ERROR(["--with-selinux does not take an argument."])
1338                 ;;
1339 esac])
1340
1341 dnl
1342 dnl gss_krb5_ccache_name() may not work on Heimdal so we don't use it by default
1343 dnl
1344 AC_ARG_ENABLE(gss_krb5_ccache_name,
1345 [AS_HELP_STRING([--enable-gss-krb5-ccache-name], [Use GSS-API to set the Kerberos V cred cache name])],
1346 [check_gss_krb5_ccache_name=$enableval], [check_gss_krb5_ccache_name=no])
1347
1348 dnl
1349 dnl C compiler checks
1350 dnl
1351 AC_SEARCH_LIBS([strerror], [cposix])
1352 AC_PROG_CPP
1353 AC_CHECK_TOOL(AR, ar, false)
1354 AC_CHECK_TOOL(RANLIB, ranlib, :)
1355 if test X"$AR" = X"false"; then
1356     AC_MSG_ERROR([the "ar" utility is required to build sudo])
1357 fi
1358
1359 if test "x$ac_cv_prog_cc_c89" = "xno"; then
1360     AC_MSG_ERROR([Sudo version $PACKAGE_VERSION requires an ANSI C compiler to build.])
1361 fi
1362
1363 dnl
1364 dnl If the user specified --disable-static, override them or we'll
1365 dnl be unable to build the executables in the sudoers plugin dir.
1366 dnl
1367 if test "$enable_static" = "no"; then
1368     AC_MSG_WARN([Ignoring --disable-static, sudo does not install static libs])
1369     enable_static=yes
1370 fi
1371
1372 dnl
1373 dnl Libtool setup, we require libtool 2.2.6b or higher
1374 dnl
1375 AC_CANONICAL_HOST
1376 AC_CONFIG_MACRO_DIR([m4])
1377 LT_PREREQ([2.2.6b])
1378 LT_INIT([dlopen])
1379
1380 dnl
1381 dnl Defer with_noexec until after libtool magic runs
1382 dnl
1383 if test "$enable_shared" = "no"; then
1384     with_noexec=no
1385     enable_dlopen=no
1386     lt_cv_dlopen=none
1387     lt_cv_dlopen_libs=
1388     ac_cv_func_dlopen=no
1389 else
1390     eval _shrext="$shrext_cmds"
1391     # Darwin uses .dylib for libraries but .so for modules
1392     if test X"$_shrext" = X".dylib"; then
1393         SOEXT=".so"
1394     else
1395         SOEXT="$_shrext"
1396     fi
1397 fi
1398 AC_MSG_CHECKING(path to sudo_noexec.so)
1399 AC_ARG_WITH(noexec, [AS_HELP_STRING([--with-noexec[=PATH]], [fully qualified pathname of sudo_noexec.so])],
1400 [case $with_noexec in
1401     yes)        with_noexec="$libexecdir/sudo_noexec$_shrext"
1402                 ;;
1403     no)         ;;
1404     *)          ;;
1405 esac], [with_noexec="$libexecdir/sudo_noexec$_shrext"])
1406 AC_MSG_RESULT($with_noexec)
1407 NOEXECFILE="sudo_noexec$_shrext"
1408 NOEXECDIR="`echo $with_noexec|sed 's:^\(.*\)/[[^/]]*:\1:'`"
1409
1410 dnl
1411 dnl Find programs we use
1412 dnl
1413 AC_CHECK_PROG(UNAMEPROG, [uname], [uname])
1414 AC_CHECK_PROG(TRPROG, [tr], [tr])
1415 AC_CHECK_PROGS(NROFFPROG, [nroff mandoc])
1416 if test -n "$NROFFPROG"; then
1417     AC_CACHE_CHECK([whether $NROFFPROG supports the -c option],
1418         [sudo_cv_var_nroff_opt_c],
1419         [if $NROFFPROG -c </dev/null >/dev/null 2>&1; then
1420             sudo_cv_var_nroff_opt_c=yes
1421         else
1422             sudo_cv_var_nroff_opt_c=no
1423         fi]
1424     )
1425     if test "$sudo_cv_var_nroff_opt_c" = "yes"; then
1426         NROFFPROG="$NROFFPROG -c"
1427     fi
1428     AC_CACHE_CHECK([whether $NROFFPROG supports the -Tascii option],
1429         [sudo_cv_var_nroff_opt_Tascii],
1430         [if $NROFFPROG -Tascii </dev/null >/dev/null 2>&1; then
1431             sudo_cv_var_nroff_opt_Tascii=yes
1432         else
1433             sudo_cv_var_nroff_opt_Tascii=no
1434         fi]
1435     if test "$sudo_cv_var_nroff_opt_Tascii" = "yes"; then
1436         NROFFPROG="$NROFFPROG -Tascii"
1437     fi
1438     )
1439 else
1440     MANTYPE="cat"
1441     mansrcdir='$(srcdir)'
1442 fi
1443
1444 dnl
1445 dnl What kind of beastie are we being run on?
1446 dnl Barf if config.cache was generated on another host.
1447 dnl
1448 if test -n "$sudo_cv_prev_host"; then
1449     if test "$sudo_cv_prev_host" != "$host"; then
1450         AC_MSG_ERROR([config.cache was created on a different host; remove it and re-run configure.])
1451     else
1452         AC_MSG_CHECKING(previous host type)
1453         AC_CACHE_VAL(sudo_cv_prev_host, sudo_cv_prev_host="$host")
1454         AC_MSG_RESULT([$sudo_cv_prev_host])
1455     fi
1456 else
1457     # this will produce no output since there is no cached value
1458     AC_CACHE_VAL(sudo_cv_prev_host, sudo_cv_prev_host="$host")
1459 fi
1460
1461 dnl
1462 dnl We want to be able to differentiate between different rev's
1463 dnl
1464 if test -n "$host_os"; then
1465     OS=`echo $host_os | sed 's/[[0-9]].*//'`
1466     OSREV=`echo $host_os | sed 's/^[[^0-9\.]]*\([[0-9\.]]*\).*$/\1/'`
1467     OSMAJOR=`echo $OSREV | sed 's/\..*$//'`
1468 else
1469     OS="unknown"
1470     OSREV=0
1471     OSMAJOR=0
1472 fi
1473
1474 case "$host" in
1475     *-*-sunos4*)
1476                 # LD_PRELOAD is space-delimited
1477                 RTLD_PRELOAD_DELIM=" "
1478
1479                 # getcwd(3) opens a pipe to getpwd(1)!?!
1480                 BROKEN_GETCWD=1
1481
1482                 # system headers lack prototypes but gcc helps...
1483                 if test -n "$GCC"; then
1484                     OSDEFS="${OSDEFS} -D__USE_FIXED_PROTOTYPES__"
1485                 fi
1486
1487                 shadow_funcs="getpwanam issecure"
1488                 ;;
1489     *-*-solaris2*)
1490                 # LD_PRELOAD is space-delimited
1491                 RTLD_PRELOAD_DELIM=" "
1492
1493                 # To get the crypt(3) prototype (so we pass -Wall)
1494                 OSDEFS="${OSDEFS} -D__EXTENSIONS__"
1495                 # AFS support needs -lucb
1496                 if test "$with_AFS" = "yes"; then
1497                     AFS_LIBS="-lc -lucb"
1498                 fi
1499                 : ${mansectsu='1m'}
1500                 : ${mansectform='4'}
1501                 : ${with_rpath='yes'}
1502                 test -z "$with_pam" && AUTH_EXCL_DEF="PAM"
1503                 AC_CHECK_FUNCS(priv_set)
1504                 ;;
1505     *-*-aix*)
1506                 # To get all prototypes (so we pass -Wall)
1507                 OSDEFS="${OSDEFS} -D_ALL_SOURCE -D_LINUX_SOURCE_COMPAT"
1508                 SUDOERS_LDFLAGS="${SUDOERS_LDFLAGS} -Wl,-bI:\$(srcdir)/aixcrypt.exp"
1509                 if test X"$with_blibpath" != X"no"; then
1510                     AC_MSG_CHECKING([if linker accepts -Wl,-blibpath])
1511                     O_LDFLAGS="$LDFLAGS"
1512                     LDFLAGS="$O_LDFLAGS -Wl,-blibpath:/usr/lib:/lib"
1513                     AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])], [
1514                         if test -n "$with_blibpath" -a "$with_blibpath" != "yes"; then
1515                             blibpath="$with_blibpath"
1516                         elif test -n "$GCC"; then
1517                             blibpath="/usr/lib:/lib:/usr/local/lib"
1518                         else
1519                             blibpath="/usr/lib:/lib"
1520                         fi
1521                         AC_MSG_RESULT(yes)
1522                     ], [AC_MSG_RESULT(no)])
1523                 fi
1524                 LDFLAGS="$O_LDFLAGS"
1525
1526                 # On AIX 6 and higher default to PAM, else default to LAM
1527                 if test $OSMAJOR -ge 6; then
1528                     if test X"$with_pam" = X""; then
1529                         AUTH_EXCL_DEF="PAM"
1530                     fi
1531                 else
1532                     if test X"$with_aixauth" = X""; then
1533                         AC_CHECK_FUNCS(authenticate, [AUTH_EXCL_DEF="AIX_AUTH"])
1534                     fi
1535                 fi
1536
1537                 # AIX analog of nsswitch.conf, enabled by default
1538                 AC_ARG_WITH(netsvc, [AS_HELP_STRING([--with-netsvc[[=PATH]]], [path to netsvc.conf])],
1539                 [case $with_netsvc in
1540                     no)         ;;
1541                     yes)        with_netsvc="/etc/netsvc.conf"
1542                                 ;;
1543                     *)          ;;
1544                 esac])
1545                 if test -z "$with_nsswitch" -a -z "$with_netsvc"; then
1546                     with_netsvc="/etc/netsvc.conf"
1547                 fi
1548
1549                 # For implementing getgrouplist()
1550                 AC_CHECK_FUNCS(getgrset)
1551
1552                 # LDR_PRELOAD is only supported in AIX 5.3 and later
1553                 if test $OSMAJOR -lt 5; then
1554                     with_noexec=no
1555                 else
1556                     RTLD_PRELOAD_VAR="LDR_PRELOAD"
1557                 fi
1558
1559                 # AIX-specific functions
1560                 AC_CHECK_FUNCS(getuserattr setauthdb)
1561                 COMMON_OBJS="$COMMON_OBJS aix.lo"
1562                 ;;
1563     *-*-hiuxmpp*)
1564                 : ${mansectsu='1m'}
1565                 : ${mansectform='4'}
1566                 ;;
1567     *-*-hpux*)
1568                 # AFS support needs -lBSD
1569                 if test "$with_AFS" = "yes"; then
1570                     AFS_LIBS="-lc -lBSD"
1571                 fi
1572                 : ${mansectsu='1m'}
1573                 : ${mansectform='4'}
1574
1575                 # The HP bundled compiler cannot generate shared libs
1576                 if test -z "$GCC"; then
1577                     AC_CACHE_CHECK([for HP bundled C compiler],
1578                         [sudo_cv_var_hpccbundled],
1579                         [if $CC -V 2>&1 | grep '^(Bundled)' >/dev/null 2>&1; then
1580                             sudo_cv_var_hpccbundled=yes
1581                         else
1582                             sudo_cv_var_hpccbundled=no
1583                         fi]
1584                     )
1585                     if test "$sudo_cv_var_hpccbundled" = "yes"; then
1586                         AC_MSG_ERROR([The HP bundled C compiler is unable to build Sudo, you must use gcc or the HP ANSI C compiler instead.])
1587                     fi
1588                 fi
1589
1590                 # Build PA-RISC1.1 objects for better portability
1591                 case "$host_cpu" in
1592                     hppa[[2-9]]*)
1593                         _CFLAGS="$CFLAGS"
1594                         if test -n "$GCC"; then
1595                             portable_flag="-march=1.1"
1596                         else
1597                             portable_flag="+DAportable"
1598                         fi
1599                         CFLAGS="$CFLAGS $portable_flag"
1600                         AC_CACHE_CHECK([whether $CC understands $portable_flag],
1601                             [sudo_cv_var_daportable],
1602                             [AC_LINK_IFELSE(
1603                                 [AC_LANG_PROGRAM([[]], [[]])],
1604                                     [sudo_cv_var_daportable=yes],
1605                                     [sudo_cv_var_daportable=no]
1606                                 )
1607                             ]
1608                         )
1609                         if test X"$sudo_cv_var_daportable" != X"yes"; then
1610                             CFLAGS="$_CFLAGS"
1611                         fi
1612                         ;;
1613                 esac
1614
1615                 case "$host" in
1616                         *-*-hpux[[1-8]].*)
1617                             AC_DEFINE(BROKEN_SYSLOG)
1618                         ;;
1619                         *-*-hpux9.*)
1620                             AC_DEFINE(BROKEN_SYSLOG)
1621
1622                             shadow_funcs="getspwuid"
1623
1624                             # DCE support (requires ANSI C compiler)
1625                             if test "$with_DCE" = "yes"; then
1626                                 # order of libs in 9.X is important. -lc_r must be last
1627                                 SUDOERS_LIBS="${SUDOERS_LIBS} -ldce -lM -lc_r"
1628                                 LIBS="${LIBS} -ldce -lM -lc_r"
1629                                 CPPFLAGS="${CPPFLAGS} -D_REENTRANT -I/usr/include/reentrant"
1630                             fi
1631                         ;;
1632                         *-*-hpux10.*)
1633                             shadow_funcs="getprpwnam iscomsec"
1634                             shadow_libs="-lsec"
1635                             # HP-UX 10.20 libc has an incompatible getline
1636                             ac_cv_func_getline="no"
1637                         ;;
1638                         *)
1639                             shadow_funcs="getspnam iscomsec"
1640                             shadow_libs="-lsec"
1641                             test -z "$with_pam" && AUTH_EXCL_DEF="PAM"
1642                         ;;
1643                 esac
1644                 ;;
1645     *-dec-osf*)
1646                 # ignore envariables wrt dynamic lib path
1647                 SUDOERS_LDFLAGS="${SUDOERS_LDFLAGS} -Wl,-no_library_replacement"
1648
1649                 : ${CHECKSIA='true'}
1650                 AC_MSG_CHECKING(whether to disable sia support on Digital UNIX)
1651                 AC_ARG_ENABLE(sia,
1652                 [AS_HELP_STRING([--disable-sia], [Disable SIA on Digital UNIX])],
1653                 [ case "$enableval" in
1654                     yes)        AC_MSG_RESULT(no)
1655                                 CHECKSIA=true
1656                                 ;;
1657                     no)         AC_MSG_RESULT(yes)
1658                                 CHECKSIA=false
1659                                 ;;
1660                     *)          AC_MSG_RESULT(no)
1661                                 AC_MSG_WARN([Ignoring unknown argument to --enable-sia: $enableval])
1662                                 ;;
1663                   esac
1664                 ], AC_MSG_RESULT(no))
1665
1666                 shadow_funcs="getprpwnam dispcrypt"
1667                 # OSF/1 4.x and higher need -ldb too
1668                 if test $OSMAJOR -lt 4; then
1669                     shadow_libs="-lsecurity -laud -lm"
1670                 else
1671                     shadow_libs="-lsecurity -ldb -laud -lm"
1672                 fi
1673
1674                 # use SIA by default, if we have it
1675                 test "$CHECKSIA" = "true" && AUTH_EXCL_DEF="SIA"
1676
1677                 #
1678                 # Some versions of Digital Unix ship with a broken
1679                 # copy of prot.h, which we need for shadow passwords.
1680                 # XXX - make should remove this as part of distclean
1681                 #
1682                 AC_MSG_CHECKING([for broken prot.h])
1683                 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1684 #include <sys/types.h>
1685 #include <sys/security.h>
1686 #include <prot.h>
1687                 ]], [[exit(0);]])], [AC_MSG_RESULT(no)], [AC_MSG_RESULT([yes, fixing locally])
1688                 sed 's:<acl.h>:<sys/acl.h>:g' < /usr/include/prot.h > prot.h
1689                 ])
1690                 # ":DEFAULT" must be appended to _RLD_LIST
1691                 RTLD_PRELOAD_VAR="_RLD_LIST"
1692                 RTLD_PRELOAD_DEFAULT="DEFAULT"
1693                 : ${mansectsu='8'}
1694                 : ${mansectform='4'}
1695                 ;;
1696     *-*-irix*)
1697                 OSDEFS="${OSDEFS} -D_BSD_TYPES"
1698                 if test -z "$NROFFPROG"; then
1699                     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)'
1700                     if test "$prefix" = "/usr/local" -a "$mandir" = '${datarootdir}/man'; then
1701                         if test -d /usr/share/catman/local; then
1702                             mandir="/usr/share/catman/local"
1703                         else
1704                             mandir="/usr/catman/local"
1705                         fi
1706                     fi
1707                 else
1708                     if test "$prefix" = "/usr/local" -a "$mandir" = '${datarootdir}/man'; then
1709                         if test -d "/usr/share/man/local"; then
1710                             mandir="/usr/share/man/local"
1711                         else
1712                             mandir="/usr/man/local"
1713                         fi
1714                     fi
1715                 fi
1716                 # IRIX <= 4 needs -lsun
1717                 if test "$OSMAJOR" -le 4; then
1718                     AC_CHECK_LIB(sun, getpwnam, [LIBS="${LIBS} -lsun"])
1719                 fi
1720                 # ":DEFAULT" must be appended to _RLD_LIST
1721                 RTLD_PRELOAD_VAR="_RLD_LIST"
1722                 RTLD_PRELOAD_DEFAULT="DEFAULT"
1723                 : ${mansectsu='1m'}
1724                 : ${mansectform='4'}
1725                 ;;
1726     *-*-linux*|*-*-k*bsd*-gnu)
1727                 OSDEFS="${OSDEFS} -D_GNU_SOURCE"
1728                 # Some Linux versions need to link with -lshadow
1729                 shadow_funcs="getspnam"
1730                 shadow_libs_optional="-lshadow"
1731                 test -z "$with_pam" && AUTH_EXCL_DEF="PAM"
1732                 ;;
1733     *-convex-bsd*)
1734                 OSDEFS="${OSDEFS} -D_CONVEX_SOURCE"
1735                 if test -z "$GCC"; then
1736                     CFLAGS="${CFLAGS} -D__STDC__"
1737                 fi
1738
1739                 shadow_defs="-D_AUDIT -D_ACL -DSecureWare"
1740                 shadow_funcs="getprpwnam"
1741                 shadow_libs="-lprot"
1742                 ;;
1743     *-*-ultrix*)
1744                 OS="ultrix"
1745                 shadow_funcs="getauthuid"
1746                 shadow_libs="-lauth"
1747                 ;;
1748     *-*-riscos*)
1749                 LIBS="${LIBS} -lsun -lbsd"
1750                 CPPFLAGS="${CPPFLAGS} -I/usr/include -I/usr/include/bsd"
1751                 OSDEFS="${OSDEFS} -D_MIPS"
1752                 : ${mansectsu='1m'}
1753                 : ${mansectform='4'}
1754                 ;;
1755     *-*-isc*)
1756                 OSDEFS="${OSDEFS} -D_ISC"
1757                 LIB_CRYPT=1
1758                 SUDOERS_LIBS="${SUDOERS_LIBS} -lcrypt"
1759
1760                 shadow_funcs="getspnam"
1761                 shadow_libs="-lsec"
1762
1763                 : ${mansectsu='1m'}
1764                 : ${mansectform='4'}
1765                 ;;
1766     *-*-sco*|*-sco-*)
1767                 shadow_funcs="getprpwnam"
1768                 shadow_libs="-lprot -lx"
1769                 : ${mansectsu='1m'}
1770                 : ${mansectform='4'}
1771                 ;;
1772     m88k-motorola-sysv*)
1773                 # motorolla's cc (a variant of gcc) does -O but not -O2
1774                 CFLAGS=`echo $CFLAGS | sed 's/-O2/-O/g'`
1775                 : ${mansectsu='1m'}
1776                 : ${mansectform='4'}
1777                 ;;
1778     *-sequent-sysv*)
1779                 shadow_funcs="getspnam"
1780                 shadow_libs="-lsec"
1781                 : ${mansectsu='1m'}
1782                 : ${mansectform='4'}
1783                 : ${with_rpath='yes'}
1784                 ;;
1785     *-ncr-sysv4*|*-ncr-sysvr4*)
1786                 AC_CHECK_LIB(c89, strcasecmp, [LIBS="${LIBS} -lc89"])
1787                 : ${mansectsu='1m'}
1788                 : ${mansectform='4'}
1789                 : ${with_rpath='yes'}
1790                 ;;
1791     *-ccur-sysv4*|*-ccur-sysvr4*)
1792                 LIBS="${LIBS} -lgen"
1793                 : ${mansectsu='1m'}
1794                 : ${mansectform='4'}
1795                 : ${with_rpath='yes'}
1796                 ;;
1797     *-*-bsdi*)
1798                 SKIP_SETREUID=yes
1799                 # Check for newer BSD auth API
1800                 if test -z "$with_bsdauth"; then
1801                     AC_CHECK_FUNCS(auth_challenge, [AUTH_EXCL_DEF="BSD_AUTH"])
1802                 fi
1803                 ;;
1804     *-*-freebsd*)
1805                 # FreeBSD has a real setreuid(2) starting with 2.1 and
1806                 # backported to 2.0.5.  We just take 2.1 and above...
1807                 case "$OSREV" in
1808                 0.*|1.*|2.0*)
1809                     SKIP_SETREUID=yes
1810                     ;;
1811                 esac
1812                 OSDEFS="${OSDEFS} -D_BSD_SOURCE"
1813                 if test "${with_skey-'no'}" = "yes"; then
1814                      SUDOERS_LIBS="${SUDOERS_LIBS} -lmd"
1815                 fi
1816                 CHECKSHADOW="false"
1817                 test -z "$with_pam" && AUTH_EXCL_DEF="PAM"
1818                 : ${with_logincap='maybe'}
1819                 ;;
1820     *-*-*openbsd*)
1821                 # OpenBSD has a real setreuid(2) starting with 3.3 but
1822                 # we will use setresuid(2) instead.
1823                 SKIP_SETREUID=yes
1824                 OSDEFS="${OSDEFS} -D_BSD_SOURCE"
1825                 CHECKSHADOW="false"
1826                 # OpenBSD >= 3.0 supports BSD auth
1827                 if test -z "$with_bsdauth"; then
1828                     if test "$OSMAJOR" -ge 3; then
1829                         AUTH_EXCL_DEF="BSD_AUTH"
1830                     fi
1831                 fi
1832                 : ${with_logincap='maybe'}
1833                 ;;
1834     *-*-*netbsd*)
1835                 # NetBSD has a real setreuid(2) starting with 1.3.2
1836                 case "$OSREV" in
1837                 0.9*|1.[[012]]*|1.3|1.3.1)
1838                     SKIP_SETREUID=yes
1839                     ;;
1840                 esac
1841                 CHECKSHADOW="false"
1842                 test -z "$with_pam" && AUTH_EXCL_DEF="PAM"
1843                 : ${with_logincap='maybe'}
1844                 ;;
1845     *-*-dragonfly*)
1846                 OSDEFS="${OSDEFS} -D_BSD_SOURCE"
1847                 if test "${with_skey-'no'}" = "yes"; then
1848                      SUDOERS_LIBS="${SUDOERS_LIBS} -lmd"
1849                 fi
1850                 CHECKSHADOW="false"
1851                 test -z "$with_pam" && AUTH_EXCL_DEF="PAM"
1852                 : ${with_logincap='yes'}
1853                 ;;
1854     *-*-*bsd*)
1855                 CHECKSHADOW="false"
1856                 ;;
1857     *-*-darwin*)
1858                 # Darwin has a real setreuid(2) starting with 9.0
1859                 if test $OSMAJOR -lt 9; then
1860                     SKIP_SETREUID=yes
1861                 fi
1862                 CHECKSHADOW="false"
1863                 test -z "$with_pam" && AUTH_EXCL_DEF="PAM"
1864                 : ${with_logincap='yes'}
1865                 RTLD_PRELOAD_VAR="DYLD_INSERT_LIBRARIES"
1866                 RTLD_PRELOAD_ENABLE_VAR="DYLD_FORCE_FLAT_NAMESPACE"
1867                 ;;
1868     *-*-nextstep*)
1869                 # lockf() on is broken on the NeXT -- use flock instead
1870                 ac_cv_func_lockf=no
1871                 ac_cv_func_flock=yes
1872                 RTLD_PRELOAD_VAR="DYLD_INSERT_LIBRARIES"
1873                 RTLD_PRELOAD_ENABLE_VAR="DYLD_FORCE_FLAT_NAMESPACE"
1874                 ;;
1875     *-*-*sysv4*)
1876                 : ${mansectsu='1m'}
1877                 : ${mansectform='4'}
1878                 : ${with_rpath='yes'}
1879                 ;;
1880     *-*-sysv*)
1881                 : ${mansectsu='1m'}
1882                 : ${mansectform='4'}
1883                 ;;
1884     *-gnu*)
1885                 OSDEFS="${OSDEFS} -D_GNU_SOURCE"
1886                 ;;
1887 esac
1888
1889 dnl
1890 dnl Library preloading to support NOEXEC
1891 dnl
1892 if test -n "$with_noexec"; then
1893     SUDO_DEFINE_UNQUOTED(RTLD_PRELOAD_VAR, "$RTLD_PRELOAD_VAR")
1894     SUDO_DEFINE_UNQUOTED(RTLD_PRELOAD_DELIM, "$RTLD_PRELOAD_DELIM")
1895     if test -n "$RTLD_PRELOAD_DEFAULT"; then
1896         SUDO_DEFINE_UNQUOTED(RTLD_PRELOAD_DEFAULT, "$RTLD_PRELOAD_DEFAULT")
1897     fi
1898     if test -n "$RTLD_PRELOAD_ENABLE_VAR"; then
1899         SUDO_DEFINE_UNQUOTED(RTLD_PRELOAD_ENABLE_VAR, "$RTLD_PRELOAD_ENABLE_VAR")
1900     fi
1901 fi
1902
1903 dnl
1904 dnl Check for mixing mutually exclusive and regular auth methods
1905 dnl
1906 AUTH_REG=${AUTH_REG# }
1907 AUTH_EXCL=${AUTH_EXCL# }
1908 if test -n "$AUTH_EXCL"; then
1909     set -- $AUTH_EXCL
1910     if test $# != 1; then
1911         AC_MSG_ERROR([More than one mutually exclusive authentication method specified: $AUTH_EXCL])
1912     fi
1913     if test -n "$AUTH_REG"; then
1914         AC_MSG_ERROR([Cannot mix mutually exclusive ($AUTH_EXCL) and regular ($AUTH_REG) authentication methods])
1915     fi
1916 fi
1917 dnl
1918 dnl Only one of S/Key and OPIE may be specified
1919 dnl
1920 if test X"${with_skey}${with_opie}" = X"yesyes"; then
1921     AC_MSG_ERROR(["cannot use both S/Key and OPIE"])
1922 fi
1923
1924 dnl
1925 dnl Use BSD-style man sections by default
1926 dnl
1927 : ${mansectsu='8'}
1928 : ${mansectform='5'}
1929
1930 dnl
1931 dnl Add in any libpaths or libraries specified via configure
1932 dnl
1933 if test -n "$with_libpath"; then
1934     for i in ${with_libpath}; do
1935         SUDO_APPEND_LIBPATH(LDFLAGS, [$i])
1936     done
1937 fi
1938 if test -n "$with_libraries"; then
1939     for i in ${with_libraries}; do
1940         case $i in
1941             -l*)        ;;
1942             *.a)        ;;
1943             *.o)        ;;
1944             *)  i="-l${i}";;
1945         esac
1946         LIBS="${LIBS} ${i}"
1947     done
1948 fi
1949
1950 dnl
1951 dnl C compiler checks (to be done after os checks)
1952 dnl
1953 AC_PROG_GCC_TRADITIONAL
1954 AC_C_CONST
1955 AC_C_VOLATILE
1956 # Check for variadic macro support in cpp
1957 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
1958 AC_INCLUDES_DEFAULT
1959 #if defined(__GNUC__) && __GNUC__ == 2
1960 # define sudo_fprintf(fp, fmt...) fprintf((fp), (fmt))
1961 #else
1962 # define sudo_fprintf(fp, ...) fprintf((fp), __VA_ARGS__)
1963 #endif
1964 ], [sudo_fprintf(stderr, "a %s", "test");])], [], [AC_MSG_ERROR([Your C compiler doesn't support variadic macros, try building with gcc instead])])
1965 if test X"$with_gnu_ld" != "yes" -a -n "$GCC"; then
1966     _CFLAGS="$CFLAGS"
1967     CFLAGS="$CFLAGS -static-libgcc"
1968     AC_CACHE_CHECK([whether $CC understands -static-libgcc],
1969         [sudo_cv_var_gcc_static_libgcc],
1970         [AC_LINK_IFELSE(
1971             [AC_LANG_PROGRAM([[]], [[]])],
1972                 [sudo_cv_var_gcc_static_libgcc=yes],
1973                 [sudo_cv_var_gcc_static_libgcc=no]
1974             )
1975         ]
1976     )
1977     CFLAGS="$_CFLAGS"
1978     if test "$sudo_cv_var_gcc_static_libgcc" = "yes"; then
1979         LTLDFLAGS="$LTLDFLAGS -Wc,-static-libgcc"
1980     fi
1981 fi
1982 dnl
1983 dnl Program checks
1984 dnl
1985 AC_PROG_YACC
1986 AC_PATH_PROG([FLEX], [flex], [flex])
1987 SUDO_PROG_MV
1988 SUDO_PROG_BSHELL
1989 if test -z "$with_sendmail"; then
1990     SUDO_PROG_SENDMAIL
1991 fi
1992 SUDO_PROG_VI
1993 dnl
1994 dnl Check for authpriv support in syslog
1995 dnl
1996 AC_MSG_CHECKING(which syslog facility sudo should log with)
1997 if test X"$with_logfac" = X""; then
1998     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <syslog.h>]], [[int i = LOG_AUTHPRIV; (void)i;]])], [logfac=authpriv])
1999 fi
2000 AC_DEFINE_UNQUOTED(LOGFAC, "$logfac", [The syslog facility sudo will use.])
2001 AC_MSG_RESULT($logfac)
2002 dnl
2003 dnl Header file checks
2004 dnl
2005 AC_HEADER_STDC
2006 AC_HEADER_DIRENT
2007 AC_HEADER_TIME
2008 AC_HEADER_STDBOOL
2009 AC_HEADER_MAJOR
2010 AC_CHECK_HEADERS(malloc.h netgroup.h paths.h spawn.h utime.h utmpx.h sys/sockio.h sys/bsdtypes.h sys/select.h sys/stropts.h sys/sysmacros.h)
2011 AC_CHECK_HEADERS([procfs.h] [sys/procfs.h], [AC_CHECK_MEMBERS(struct psinfo.pr_ttydev, [AC_CHECK_FUNCS(_ttyname_dev)], [], [AC_INCLUDES_DEFAULT
2012 #ifdef HAVE_PROCFS_H
2013 #include <procfs.h>
2014 #endif
2015 #ifdef HAVE_SYS_PROCFS_H
2016 #include <sys/procfs.h>
2017 #endif
2018 ])]
2019 break)
2020 dnl
2021 dnl Check for large file support.  HP-UX 11.23 has a broken sys/type.h
2022 dnl when large files support is enabled so work around it.
2023 dnl
2024 AC_SYS_LARGEFILE
2025 case "$host" in
2026     *-*-hpux11.*)
2027         AC_CACHE_CHECK([whether sys/types.h needs _XOPEN_SOURCE_EXTENDED], [sudo_cv_xopen_source_extended],
2028         [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
2029         #include <sys/socket.h>], [])], [sudo_cv_xopen_source_extended=no], [
2030             AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#define _XOPEN_SOURCE_EXTENDED
2031             AC_INCLUDES_DEFAULT
2032             #include <sys/socket.h>], [])], [sudo_cv_xopen_source_extended=yes],
2033             [sudo_cv_xopen_source_extended=error])
2034         ])])
2035         if test "$sudo_cv_xopen_source_extended" = "yes"; then
2036             OSDEFS="${OSDEFS} -D_XOPEN_SOURCE_EXTENDED"
2037             SUDO_DEFINE(_XOPEN_SOURCE_EXTENDED)
2038         fi
2039         ;;
2040 esac
2041 AC_SYS_POSIX_TERMIOS
2042 if test "$ac_cv_sys_posix_termios" != "yes"; then
2043     AC_MSG_ERROR([Must have POSIX termios to build sudo])
2044 fi
2045 SUDO_MAILDIR
2046 if test ${with_logincap-'no'} != "no"; then
2047     AC_CHECK_HEADERS(login_cap.h, [LOGINCAP_USAGE='[[-c class|-]] '; LCMAN=1
2048         case "$OS" in
2049             freebsd|netbsd)
2050                 SUDO_LIBS="${SUDO_LIBS} -lutil"
2051                 SUDOERS_LIBS="${SUDOERS_LIBS} -lutil"
2052                 ;;
2053         esac
2054     ])
2055 fi
2056 if test ${with_project-'no'} != "no"; then
2057     AC_CHECK_HEADER(project.h, [
2058         AC_CHECK_LIB(project, setproject, [
2059             AC_DEFINE(HAVE_PROJECT_H)
2060             SUDO_LIBS="${SUDO_LIBS} -lproject"
2061         ])
2062     ], [])
2063 fi
2064 dnl
2065 dnl typedef checks
2066 dnl
2067 AC_TYPE_MODE_T
2068 AC_TYPE_UID_T
2069 AC_CHECK_TYPE([__signed char], [], [AC_CHECK_TYPE([signed char], [AC_DEFINE(__signed, signed)], [AC_DEFINE(__signed, [])])])
2070 AC_CHECK_TYPE([sig_atomic_t], [], [AC_DEFINE(sig_atomic_t, int)], [#include <sys/types.h>
2071 #include <signal.h>])
2072 AC_CHECK_TYPES([sigaction_t], [], [], [#include <sys/types.h>
2073 #include <signal.h>])
2074 AC_CHECK_TYPES([struct timespec], [], [], [#include <sys/types.h>
2075 #if TIME_WITH_SYS_TIME
2076 # include <sys/time.h>
2077 #endif
2078 #include <time.h>])
2079 AC_CHECK_TYPES([struct in6_addr], [], [], [#include <sys/types.h>
2080 #include <netinet/in.h>])
2081 AC_TYPE_LONG_LONG_INT
2082 AC_CHECK_SIZEOF([long int])
2083 AC_CHECK_TYPE(size_t, unsigned int)
2084 AC_CHECK_TYPE(ssize_t, int)
2085 AC_CHECK_TYPE(dev_t, int)
2086 AC_CHECK_TYPE(ino_t, unsigned int)
2087 AC_CHECK_TYPE(socklen_t, [], [AC_DEFINE(socklen_t, unsigned int)], [
2088 AC_INCLUDES_DEFAULT
2089 #include <sys/socket.h>])
2090 SUDO_UID_T_LEN
2091 SUDO_SOCK_SA_LEN
2092 dnl
2093 dnl Check for utmp/utmpx struct members.
2094 dnl We need to include OSDEFS for glibc which only has __e_termination
2095 dnl visible when _GNU_SOURCE is *not* defined.
2096 dnl
2097 _CFLAGS="$CFLAGS"
2098 CFLAGS="$CFLAGS $OSDEFS"
2099 if test $ac_cv_header_utmpx_h = "yes"; then
2100     AC_CHECK_MEMBERS([struct utmpx.ut_id, struct utmpx.ut_pid, struct utmpx.ut_tv, struct utmpx.ut_type], [], [], [
2101         #include <sys/types.h>
2102         #include <utmpx.h>
2103     ])
2104     dnl
2105     dnl Check for ut_exit.__e_termination first, then ut_exit.e_termination
2106     dnl
2107     AC_CHECK_MEMBERS([struct utmpx.ut_exit.__e_termination], [AC_DEFINE(HAVE_STRUCT_UTMPX_UT_EXIT)], [
2108         AC_CHECK_MEMBERS([struct utmpx.ut_exit.e_termination], [AC_DEFINE(HAVE_STRUCT_UTMPX_UT_EXIT)], [], [
2109             #include <sys/types.h>
2110             #include <utmpx.h>
2111         ])
2112     ], [
2113         #include <sys/types.h>
2114         #include <utmpx.h>
2115     ])
2116 else
2117     AC_CHECK_MEMBERS([struct utmp.ut_id, struct utmp.ut_pid, struct utmp.ut_tv, struct utmp.ut_type, struct utmp.ut_user], [], [], [
2118         #include <sys/types.h>
2119         #include <utmp.h>
2120     ])
2121     dnl
2122     dnl Check for ut_exit.__e_termination first, then ut_exit.e_termination
2123     dnl
2124     AC_CHECK_MEMBERS([struct utmp.ut_exit.__e_termination], [AC_DEFINE(HAVE_STRUCT_UTMP_UT_EXIT)], [
2125         AC_CHECK_MEMBERS([struct utmp.ut_exit.e_termination], [AC_DEFINE(HAVE_STRUCT_UTMP_UT_EXIT)], [], [
2126             #include <sys/types.h>
2127             #include <utmp.h>
2128         ])
2129     ], [
2130         #include <sys/types.h>
2131         #include <utmp.h>
2132     ])
2133 fi
2134 CFLAGS="$_CFLAGS"
2135
2136 dnl
2137 dnl Function checks
2138 dnl
2139 AC_FUNC_GETGROUPS
2140 AC_CHECK_FUNCS(glob strrchr sysconf tzset strftime setenv \
2141                regcomp setlocale nl_langinfo mbr_check_membership \
2142                setrlimit64)
2143 AC_REPLACE_FUNCS(getgrouplist)
2144 AC_CHECK_FUNCS(getline, [], [
2145     AC_LIBOBJ(getline)
2146     AC_CHECK_FUNCS(fgetln)
2147 ])
2148 dnl
2149 dnl If libc supports _FORTIFY_SOURCE check functions, use it.
2150 dnl
2151 O_CPPFLAGS="$CPPFLAGS"
2152 CPPFLAGS="$CPPFLAGS -D_FORTIFY_SOURCE=2"
2153 AC_CHECK_FUNC(__sprintf_chk, [
2154     AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[char buf[4]; (void)sprintf(buf, "%s", "foo");]])], [OSDEFS="${OSDEFS} -D_FORTIFY_SOURCE=2"], [])
2155 ], [])
2156 CPPFLAGS="$O_CPPFLAGS"
2157
2158 utmp_style=LEGACY
2159 AC_CHECK_FUNCS(getutxid getutid, [utmp_style=POSIX; break])
2160 if test "$utmp_style" = "LEGACY"; then
2161     AC_CHECK_FUNCS(getttyent ttyslot, [break])
2162 fi
2163
2164 AC_CHECK_FUNCS(sysctl, [AC_CHECK_MEMBERS([struct kinfo_proc.ki_tdev], [],
2165     [
2166         AC_CHECK_MEMBERS([struct kinfo_proc2.p_tdev], [], [
2167             AC_CHECK_MEMBERS([struct kinfo_proc.p_tdev], [], [
2168                 AC_CHECK_MEMBERS([struct kinfo_proc.kp_eproc.e_tdev], [], [], [
2169                     #include <sys/param.h>
2170                     #include <sys/sysctl.h>
2171                 ])
2172             ], [
2173                 #include <sys/param.h>
2174                 #include <sys/sysctl.h>
2175             ])
2176         ],
2177         [
2178             #include <sys/param.h>
2179             #include <sys/sysctl.h>
2180         ])
2181     ],
2182     [
2183         #include <sys/param.h>
2184         #include <sys/sysctl.h>
2185         #include <sys/user.h>
2186     ])
2187 ])
2188
2189 AC_CHECK_FUNCS(openpty, [AC_CHECK_HEADERS(libutil.h util.h pty.h, [break])], [
2190     AC_CHECK_LIB(util, openpty, [
2191         AC_CHECK_HEADERS(libutil.h util.h pty.h, [break])
2192         case "$SUDO_LIBS" in
2193             *-lutil*) ;;
2194             *) SUDO_LIBS="${SUDO_LIBS} -lutil";;
2195         esac
2196         AC_DEFINE(HAVE_OPENPTY)
2197     ], [
2198         AC_CHECK_FUNCS(_getpty, [], [
2199             AC_CHECK_FUNCS(grantpt, [
2200                 AC_CHECK_FUNCS(posix_openpt)
2201             ], [
2202                 AC_CHECK_FUNCS(revoke)
2203             ])
2204         ])
2205     ])
2206 ])
2207 AC_CHECK_FUNCS(unsetenv, [SUDO_FUNC_UNSETENV_VOID], [])
2208 SUDO_FUNC_PUTENV_CONST
2209 if test -z "$SKIP_SETRESUID"; then
2210     AC_CHECK_FUNCS(setresuid, [
2211         SKIP_SETREUID=yes
2212         AC_CHECK_FUNCS(getresuid)
2213     ])
2214 fi
2215 if test -z "$SKIP_SETREUID"; then
2216     AC_CHECK_FUNCS(setreuid, [SKIP_SETEUID=yes])
2217 fi
2218 if test -z "$SKIP_SETEUID"; then
2219     AC_CHECK_FUNCS(seteuid)
2220 fi
2221 if test X"$with_interfaces" != X"no"; then
2222     AC_CHECK_FUNCS(getifaddrs, [AC_CHECK_FUNCS(freeifaddrs)])
2223 fi
2224 if test -z "$BROKEN_GETCWD"; then
2225     AC_REPLACE_FUNCS(getcwd)
2226 fi
2227 AC_CHECK_FUNCS(lockf flock, [break])
2228 AC_CHECK_FUNCS(innetgr _innetgr, [AC_CHECK_FUNCS(getdomainname) [break]])
2229 AC_CHECK_FUNCS(utimes, [AC_CHECK_FUNCS(futimes futimesat, [break])], [AC_CHECK_FUNCS(futime) AC_LIBOBJ(utimes)])
2230 AC_CHECK_FUNCS(killpg, [], [AC_LIBOBJ(killpg)])
2231 SUDO_FUNC_FNMATCH([AC_DEFINE(HAVE_FNMATCH)], [AC_LIBOBJ(fnmatch)
2232     COMPAT_TEST_PROGS="${COMPAT_TEST_PROGS}${COMPAT_TEST_PROGS+ }fnm_test"
2233 ])
2234 SUDO_FUNC_ISBLANK
2235 AC_REPLACE_FUNCS(memrchr pw_dup strlcpy strlcat)
2236 AC_CHECK_FUNCS(nanosleep, [], [
2237     # On Solaris, nanosleep is in librt
2238     AC_CHECK_LIB(rt, nanosleep, [REPLAY_LIBS="${REPLAY_LIBS} -lrt"], [AC_LIBOBJ(nanosleep)])
2239 ])
2240 AC_CHECK_FUNCS(closefrom, [], [AC_LIBOBJ(closefrom)
2241     AC_CHECK_DECL(F_CLOSEM, AC_DEFINE(HAVE_FCNTL_CLOSEM), [],
2242         [ #include <limits.h>
2243           #include <fcntl.h> ])
2244 ])
2245 AC_CHECK_FUNCS(mkstemps mkdtemp, [], [
2246     AC_CHECK_FUNCS(random lrand48, [break])
2247     AC_LIBOBJ(mktemp)
2248 ])
2249 AC_CHECK_FUNCS(snprintf vsnprintf asprintf vasprintf, , [NEED_SNPRINTF=1])
2250 if test X"$ac_cv_type_struct_timespec" != X"no"; then
2251     AC_CHECK_MEMBER([struct stat.st_mtim], [AC_DEFINE(HAVE_ST_MTIM)]
2252         [AC_CHECK_MEMBER([struct stat.st_mtim.st__tim], AC_DEFINE(HAVE_ST__TIM))],
2253         [AC_CHECK_MEMBER([struct stat.st_mtimespec], AC_DEFINE([HAVE_ST_MTIMESPEC]))])
2254 fi
2255 dnl
2256 dnl Check for the dirfd function/macro.  If not found, look for dd_fd in DIR.
2257 dnl
2258 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
2259 #include <$ac_header_dirent>]], [[DIR *d; (void)dirfd(d);]])], [AC_DEFINE(HAVE_DIRFD)], [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
2260 #include <$ac_header_dirent>]], [[DIR d; memset(&d, 0, sizeof(d)); return(d.dd_fd);]])], [AC_DEFINE(HAVE_DD_FD)], [])])
2261 AC_CHECK_MEMBERS([struct dirent.d_type], [], [], [
2262 AC_INCLUDES_DEFAULT
2263 #include <$ac_header_dirent>
2264 ])
2265 dnl
2266 dnl If NEED_SNPRINTF is set, add snprintf.c to LIBOBJS
2267 dnl (it contains snprintf, vsnprintf, asprintf, and vasprintf)
2268 dnl
2269 if test -n "$NEED_SNPRINTF"; then
2270     AC_LIBOBJ(snprintf)
2271 fi
2272 dnl
2273 dnl If socket(2) not in libc, check -lsocket and -linet
2274 dnl May need to link with *both* -lnsl and -lsocket due to unresolved symbols
2275 dnl
2276 AC_CHECK_FUNC(socket, [], [
2277     for libs in "-lsocket" "-linet" "-lsocket -lnsl"; do
2278         _libs=
2279         for lib in $libs; do
2280             case "$NET_LIBS" in
2281                 *"$lib"*)   ;;
2282                 *)          _libs="$_libs $lib";;
2283             esac
2284         done
2285         libs="${_libs# }"
2286         test -z "$libs" && continue
2287         lib="`echo \"$libs\"|sed -e 's/^-l//' -e 's/ .*$//'`"
2288         extralibs="`echo \"$libs\"|sed 's/^-l[[^ ]]*//'`"
2289         SUDO_CHECK_LIB($lib, socket, [NET_LIBS="${NET_LIBS} $libs"; LIBS="${LIBS} $libs"; break], [], [$extralibs])
2290     done
2291 ])
2292 dnl
2293 dnl If inet_addr(3) not in libc, check -lnsl and -linet
2294 dnl May need to link with *both* -lnsl and -lsocket due to unresolved symbols
2295 dnl
2296 AC_CHECK_FUNC(inet_addr, [], [
2297     AC_CHECK_FUNC(__inet_addr, [], [
2298         for libs in "-lsocket" "-linet" "-lsocket -lnsl"; do
2299             _libs=
2300             for lib in $libs; do
2301                 case "$NET_LIBS" in
2302                     *"$lib"*)   ;;
2303                     *)          _libs="$_libs $lib";;
2304                 esac
2305             done
2306             libs="${_libs# }"
2307             test -z "$libs" && continue
2308             lib="`echo \"$libs\"|sed -e 's/^-l//' -e 's/ .*$//'`"
2309             extralibs="`echo \"$libs\"|sed 's/^-l[[^ ]]*//'`"
2310             SUDO_CHECK_LIB($lib, inet_addr, [NET_LIBS="${NET_LIBS} $libs"; LIBS="${LIBS} $libs"; break], [], [$extralibs])
2311         done
2312     ])
2313 ])
2314 dnl
2315 dnl If syslog(3) not in libc, check -lsocket, -lnsl and -linet
2316 dnl
2317 AC_CHECK_FUNC(syslog, [], [
2318     for libs in "-lsocket" "-linet" "-lsocket -lnsl"; do
2319         _libs=
2320         for lib in $libs; do
2321             case "$NET_LIBS" in
2322                 *"$lib"*)   ;;
2323                 *)          _libs="$_libs $lib";;
2324             esac
2325         done
2326         libs="${_libs# }"
2327         test -z "$libs" && continue
2328         lib="`echo \"$libs\"|sed -e 's/^-l//' -e 's/ .*$//'`"
2329         extralibs="`echo \"$libs\"|sed 's/^-l[[^ ]]*//'`"
2330         SUDO_CHECK_LIB($lib, syslog, [NET_LIBS="${NET_LIBS} $libs"; LIBS="${LIBS} $libs"; break], [], [$extralibs])
2331     done
2332 ])
2333 dnl
2334 dnl If getaddrinfo(3) not in libc, check -lsocket and -linet
2335 dnl May need to link with *both* -lnsl and -lsocket due to unresolved symbols.
2336 dnl
2337 AC_CHECK_FUNCS(getaddrinfo, [], [
2338     found=no
2339     for libs in "-lsocket" "-linet" "-lsocket -lnsl"; do
2340         _libs=
2341         for lib in $libs; do
2342             case "$NET_LIBS" in
2343                 *"$lib"*)   ;;
2344                 *)          _libs="$_libs $lib";;
2345             esac
2346         done
2347         libs="${_libs# }"
2348         test -z "$libs" && continue
2349         lib="`echo \"$libs\"|sed -e 's/^-l//' -e 's/ .*$//'`"
2350         extralibs="`echo \"$libs\"|sed 's/^-l[[^ ]]*//'`"
2351         SUDO_CHECK_LIB($lib, getaddrinfo, [NET_LIBS="${NET_LIBS} $libs"; LIBS="${LIBS} $libs"; found=yes; break], [], [$extralibs])
2352     done
2353     if test X"$found" != X"no"; then
2354         AC_DEFINE(HAVE_GETADDRINFO)
2355     fi
2356 ])
2357 dnl
2358 dnl Check for getprogname() or __progname
2359 dnl
2360 AC_CHECK_FUNCS(getprogname, , [
2361     AC_MSG_CHECKING([for __progname])
2362     AC_CACHE_VAL(sudo_cv___progname, [
2363     AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[extern char *__progname; (void)puts(__progname);]])], [sudo_cv___progname=yes], [sudo_cv___progname=no])])
2364     if test "$sudo_cv___progname" = "yes"; then
2365         AC_DEFINE(HAVE___PROGNAME)
2366     else
2367         AC_LIBOBJ(getprogname)
2368     fi
2369     AC_MSG_RESULT($sudo_cv___progname)
2370 ])
2371 dnl
2372 dnl Check for __func__ or __FUNCTION__
2373 dnl
2374 AC_MSG_CHECKING([for __func__])
2375 AC_CACHE_VAL(sudo_cv___func__, [
2376 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[(void)puts(__func__);]])], [sudo_cv___func__=yes], [sudo_cv___func__=no])])
2377 AC_MSG_RESULT($sudo_cv___func__)
2378 if test "$sudo_cv___func__" = "yes"; then
2379     AC_DEFINE(HAVE___FUNC__)
2380 elif test -n "$GCC"; then
2381     AC_MSG_CHECKING([for __FUNCTION__])
2382     AC_CACHE_VAL(sudo_cv___FUNCTION__, [
2383     AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[(void)puts(__FUNCTION__);]])], [sudo_cv___FUNCTION__=yes], [sudo_cv___FUNCTION__=no])])
2384     AC_MSG_RESULT($sudo_cv___FUNCTION__)
2385     if test "$sudo_cv___FUNCTION__" = "yes"; then
2386         AC_DEFINE(HAVE___FUNC__)
2387         AC_DEFINE(__func__, __FUNCTION__, [Define to __FUNCTION__ if your compiler support __FUNCTION__ but not __func__])
2388     fi
2389 fi
2390
2391 # gettext() and friends may be located in libc (Linux and Solaris)
2392 # or in libintl.  However, it is possible to have libintl installed
2393 # even when gettext() is present in libc.  In the case of GNU libintl,
2394 # gettext() will be defined to gettext_libintl in libintl.h.
2395 # Since gcc prefers /usr/local/include to /usr/include, we need to
2396 # make sure we use the gettext() that matches the include file.
2397 if test "$enable_nls" != "no"; then
2398     if test "$enable_nls" != "yes"; then
2399         CPPFLAGS="${CPPFLAGS} -I${enable_nls}/include"
2400         SUDO_APPEND_LIBPATH(LDFLAGS, [$enable_nls/lib])
2401     fi
2402     OLIBS="$LIBS"
2403     for l in "libc" "-lintl" "-lintl -liconv"; do
2404         if test "$l" = "libc"; then
2405             # If user specified a dir for libintl ignore libc
2406             if test "$enable_nls" != "yes"; then
2407                 continue
2408             fi
2409             gettext_name=sudo_cv_gettext
2410             AC_MSG_CHECKING([for gettext])
2411         else
2412             LIBS="$OLIBS $l"
2413             gettext_name=sudo_cv_gettext"`echo $l|sed -e 's/ //g' -e 's/-/_/g'`"
2414             AC_MSG_CHECKING([for gettext in $l])
2415         fi
2416         AC_CACHE_VAL($gettext_name, [
2417                 AC_LINK_IFELSE(
2418                     [
2419                         AC_LANG_PROGRAM([[#include <libintl.h>]], [(void)gettext((char *)0);])
2420                     ], [eval $gettext_name=yes], [eval $gettext_name=no]
2421                 )
2422         ])
2423         eval gettext_result="\$$gettext_name"
2424         AC_MSG_RESULT($gettext_result)
2425         test "$gettext_result" = "yes" && break
2426     done
2427     LIBS="$OLIBS"
2428
2429     if test "$sudo_cv_gettext" = "yes"; then
2430         AC_DEFINE(HAVE_LIBINTL_H)
2431         SUDO_NLS=enabled
2432     elif test "$sudo_cv_gettext_lintl" = "yes"; then
2433         AC_DEFINE(HAVE_LIBINTL_H)
2434         SUDO_NLS=enabled
2435         LIBINTL="-lintl"
2436     elif test "$sudo_cv_gettext_lintl_liconv" = "yes"; then
2437         AC_DEFINE(HAVE_LIBINTL_H)
2438         SUDO_NLS=enabled
2439         LIBINTL="-lintl -liconv"
2440     fi
2441 fi
2442
2443 dnl
2444 dnl Deferred zlib option processing.
2445 dnl By default we use the system zlib if it is present.
2446 dnl If a directory was specified for zlib (or we are use sudo's version),
2447 dnl prepend the include dir to make sure we get the right zlib header.
2448 dnl
2449 case "$enable_zlib" in
2450     yes)
2451         AC_CHECK_LIB(z, gzdopen, [
2452             AC_CHECK_HEADERS(zlib.h, [ZLIB="-lz"], [enable_zlib=builtin])
2453         ])
2454         ;;
2455     no)
2456         ;;
2457     system)
2458         AC_DEFINE(HAVE_ZLIB_H)
2459         ZLIB="-lz"
2460         ;;
2461     builtin)
2462         # handled below
2463         ;;
2464     *)
2465         AC_DEFINE(HAVE_ZLIB_H)
2466         CPPFLAGS="-I${enable_zlib}/include ${CPPFLAGS}"
2467         SUDO_APPEND_LIBPATH(ZLIB, [$enable_zlib/lib])
2468         ZLIB="${ZLIB} -lz"
2469         ;;
2470 esac
2471 if test X"$enable_zlib" = X"builtin"; then
2472     AC_DEFINE(HAVE_ZLIB_H)
2473     CPPFLAGS='-I$(top_builddir)/zlib -I$(top_srcdir)/zlib '"${CPPFLAGS}"
2474     ZLIB="${ZLIB}"' $(top_builddir)/zlib/libz.la'
2475     ZLIB_SRC=zlib
2476     AC_CONFIG_HEADER([zlib/zconf.h])
2477     AC_CONFIG_FILES([zlib/Makefile])
2478 fi
2479
2480 dnl
2481 dnl Check for errno declaration in errno.h
2482 dnl
2483 AC_CHECK_DECLS([errno], [], [], [
2484 AC_INCLUDES_DEFAULT
2485 #include <errno.h>
2486 ])
2487
2488 dnl
2489 dnl Check for h_errno declaration in netdb.h
2490 dnl
2491 AC_CHECK_DECLS([h_errno], [], [], [
2492 AC_INCLUDES_DEFAULT
2493 #include <netdb.h>
2494 ])
2495
2496 dnl
2497 dnl Check for strsignal() or sys_siglist
2498 dnl
2499 AC_CHECK_FUNCS(strsignal, [], [
2500     AC_LIBOBJ(strsignal)
2501     HAVE_SIGLIST="false"
2502     AC_CHECK_DECLS([sys_siglist, _sys_siglist, __sys_siglist], [
2503         HAVE_SIGLIST="true"
2504         break
2505     ], [ ], [
2506 AC_INCLUDES_DEFAULT
2507 #include <signal.h>
2508     ])
2509     if test "$HAVE_SIGLIST" != "true"; then
2510         AC_LIBOBJ(siglist)
2511     fi
2512 ])
2513
2514 dnl
2515 dnl nsswitch.conf and its equivalents
2516 dnl
2517 if test ${with_netsvc-"no"} != "no"; then
2518     SUDO_DEFINE_UNQUOTED(_PATH_NETSVC_CONF, "${with_netsvc-/etc/netsvc.conf}")
2519     netsvc_conf=${with_netsvc-/etc/netsvc.conf}
2520 elif test ${with_nsswitch-"yes"} != "no"; then
2521     SUDO_DEFINE_UNQUOTED(_PATH_NSSWITCH_CONF, "${with_nsswitch-/etc/nsswitch.conf}")
2522     nsswitch_conf=${with_nsswitch-/etc/nsswitch.conf}
2523 fi
2524
2525 dnl
2526 dnl Mutually exclusive auth checks come first, followed by
2527 dnl non-exclusive ones.  Note: passwd must be last of all!
2528 dnl
2529
2530 dnl
2531 dnl Convert default authentication methods to with_* if
2532 dnl no explicit authentication scheme was specified.
2533 dnl
2534 if test -z "${AUTH_EXCL}${AUTH_REG}" -a -n "$AUTH_EXCL_DEF"; then
2535     for auth in $AUTH_EXCL_DEF; do
2536         case $auth in
2537             AIX_AUTH)   with_aixauth=maybe;;
2538             BSD_AUTH)   with_bsdauth=maybe;;
2539             PAM)        with_pam=maybe;;
2540             SIA)        CHECKSIA=true;;
2541         esac
2542     done
2543 fi
2544
2545 dnl
2546 dnl PAM support.  Systems that use PAM by default set with_pam=default
2547 dnl and we do the actual tests here.
2548 dnl
2549 if test ${with_pam-"no"} != "no"; then
2550     #
2551     # Check for pam_start() in libpam first, then for pam_appl.h.
2552     #
2553     found_pam_lib=no
2554     AC_CHECK_LIB(pam, pam_start, [found_pam_lib=yes], [], [$lt_cv_dlopen_libs])
2555     #
2556     # Some PAM implementations (MacOS X for example) put the PAM headers
2557     # in /usr/include/pam instead of /usr/include/security...
2558     #
2559     found_pam_hdrs=no
2560     AC_CHECK_HEADERS([security/pam_appl.h] [pam/pam_appl.h], [found_pam_hdrs=yes; break])
2561     if test "$found_pam_lib" = "yes" -a "$found_pam_hdrs" = "yes"; then
2562         # Found both PAM libs and headers
2563         with_pam=yes
2564     elif test "$with_pam" = "yes"; then
2565         if test "$found_pam_lib" = "no"; then
2566             AC_MSG_ERROR(["--with-pam specified but unable to locate PAM development library."])
2567         fi
2568         if test "$found_pam_hdrs" = "no"; then
2569             AC_MSG_ERROR(["--with-pam specified but unable to locate PAM development headers."])
2570         fi
2571     elif test "$found_pam_lib" != "$found_pam_hdrs"; then
2572         if test "$found_pam_lib" = "no"; then
2573             AC_MSG_ERROR(["found PAM headers but no PAM development library; specify --without-pam to build without PAM"])
2574         fi
2575         if test "$found_pam_hdrs" = "no"; then
2576             AC_MSG_ERROR(["found PAM library but no PAM development headers; specify --without-pam to build without PAM"])
2577         fi
2578     fi
2579
2580     if test "$with_pam" = "yes"; then
2581         # Older PAM implementations lack pam_getenvlist
2582         OLIBS="$LIBS"
2583         LIBS="$LIBS -lpam $lt_cv_dlopen_libs"
2584         AC_CHECK_FUNCS(pam_getenvlist)
2585         LIBS="$OLIBS"
2586
2587         # We already link with -ldl if needed (see LIBDL below)
2588         SUDOERS_LIBS="${SUDOERS_LIBS} -lpam"
2589         AC_DEFINE(HAVE_PAM)
2590         AUTH_OBJS="$AUTH_OBJS pam.lo";
2591         AUTH_EXCL=PAM
2592
2593         AC_ARG_WITH(pam-login, [AS_HELP_STRING([--with-pam-login], [enable specific PAM session for sudo -i])],
2594         [case $with_pam_login in
2595             yes)        AC_DEFINE([HAVE_PAM_LOGIN])
2596                         AC_MSG_CHECKING(whether to use PAM login)
2597                         AC_MSG_RESULT(yes)
2598                         ;;
2599             no)         ;;
2600             *)          AC_MSG_ERROR(["--with-pam-login does not take an argument."])
2601                         ;;
2602         esac])
2603
2604         AC_MSG_CHECKING(whether to use PAM session support)
2605         AC_ARG_ENABLE(pam_session,
2606         [AS_HELP_STRING([--disable-pam-session], [Disable PAM session support])],
2607             [ case "$enableval" in
2608                 yes)    AC_MSG_RESULT(yes)
2609                         ;;
2610                 no)             AC_MSG_RESULT(no)
2611                             AC_DEFINE(NO_PAM_SESSION)
2612                             ;;
2613                 *)              AC_MSG_RESULT(no)
2614                             AC_MSG_WARN([Ignoring unknown argument to --enable-pam-session: $enableval])
2615                             ;;
2616             esac], AC_MSG_RESULT(yes))
2617     fi
2618 fi
2619
2620 dnl
2621 dnl AIX general authentication
2622 dnl If set to "maybe" only enable if no other exclusive method in use.
2623 dnl
2624 if test ${with_aixauth-'no'} != "no"; then
2625     if test X"$with_aixauth" != X"maybe" -o X"$AUTH_EXCL" = X""; then
2626         AC_MSG_NOTICE([using AIX general authentication])
2627         AC_DEFINE(HAVE_AIXAUTH)
2628         AUTH_OBJS="$AUTH_OBJS aix_auth.lo";
2629         SUDOERS_LIBS="${SUDOERS_LIBS} -ls"
2630         AUTH_EXCL=AIX_AUTH
2631     fi
2632 fi
2633
2634 dnl
2635 dnl BSD authentication
2636 dnl If set to "maybe" only enable if no other exclusive method in use.
2637 dnl
2638 if test ${with_bsdauth-'no'} != "no"; then
2639     AC_CHECK_HEADER(bsd_auth.h, AC_DEFINE(HAVE_BSD_AUTH_H)
2640         [AUTH_OBJS="$AUTH_OBJS bsdauth.lo"]
2641         [BSDAUTH_USAGE='[[-a auth_type]] ']
2642         [AUTH_EXCL=BSD_AUTH; BAMAN=1],
2643         [AC_MSG_ERROR([BSD authentication was specified but bsd_auth.h could not be found])])
2644 fi
2645
2646 dnl
2647 dnl SIA authentication for Tru64 Unix
2648 dnl
2649 if test ${CHECKSIA-'false'} = "true"; then
2650     AC_CHECK_FUNCS(sia_ses_init, [found=true], [found=false])
2651     if test "$found" = "true"; then
2652         AUTH_EXCL=SIA
2653         AUTH_OBJS="$AUTH_OBJS sia.lo"
2654     fi
2655 fi
2656
2657 dnl
2658 dnl extra FWTK libs + includes
2659 dnl
2660 if test ${with_fwtk-'no'} != "no"; then
2661     if test "$with_fwtk" != "yes"; then
2662         SUDO_APPEND_LIBPATH(SUDOERS_LDFLAGS, [${with_fwtk}])
2663         CPPFLAGS="${CPPFLAGS} -I${with_fwtk}"
2664         with_fwtk=yes
2665     fi
2666     SUDOERS_LIBS="${SUDOERS_LIBS} -lauth -lfwall"
2667     AUTH_OBJS="$AUTH_OBJS fwtk.lo"
2668 fi
2669
2670 dnl
2671 dnl extra SecurID lib + includes
2672 dnl
2673 if test ${with_SecurID-'no'} != "no"; then
2674     if test "$with_SecurID" != "yes"; then
2675         :
2676     elif test -d /usr/ace/examples; then
2677         with_SecurID=/usr/ace/examples
2678     else
2679         with_SecurID=/usr/ace
2680     fi
2681     CPPFLAGS="${CPPFLAGS} -I${with_SecurID}"
2682     SUDO_APPEND_LIBPATH(LDFLAGS, [${with_SecurID}])
2683     SUDOERS_LIBS="${SUDOERS_LIBS} -laceclnt -lpthread"
2684     AUTH_OBJS="$AUTH_OBJS securid5.lo";
2685 fi
2686
2687 dnl
2688 dnl Non-mutually exclusive auth checks come next.
2689 dnl Note: passwd must be last of all!
2690 dnl
2691
2692 dnl
2693 dnl Convert default authentication methods to with_* if
2694 dnl no explicit authentication scheme was specified.
2695 dnl
2696 if test -z "${AUTH_EXCL}" -a -n "$AUTH_DEF"; then
2697     for auth in $AUTH_DEF; do
2698         case $auth in
2699             passwd)     : ${with_passwd='maybe'};;
2700         esac
2701     done
2702 fi
2703
2704 dnl
2705 dnl Kerberos V
2706 dnl There is an easy way and a hard way...
2707 dnl
2708 if test ${with_kerb5-'no'} != "no"; then
2709     AC_CHECK_PROG(KRB5CONFIG, krb5-config, yes, "")
2710     if test -n "$KRB5CONFIG"; then
2711         AC_DEFINE(HAVE_KERB5)
2712         AUTH_OBJS="$AUTH_OBJS kerb5.lo"
2713         CPPFLAGS="$CPPFLAGS `krb5-config --cflags`"
2714         SUDOERS_LIBS="$SUDOERS_LIBS `krb5-config --libs`"
2715         dnl
2716         dnl Try to determine whether we have Heimdal or MIT Kerberos
2717         dnl
2718         AC_MSG_CHECKING(whether we are using Heimdal)
2719         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <krb5.h>]], [[const char *tmp = heimdal_version;]])], [
2720                 AC_MSG_RESULT(yes)
2721                 AC_DEFINE(HAVE_HEIMDAL)
2722             ], [
2723                 AC_MSG_RESULT(no)
2724             ]
2725         )
2726     else
2727         AC_DEFINE(HAVE_KERB5)
2728         dnl
2729         dnl Use the specified directory, if any, else search for correct inc dir
2730         dnl
2731         if test "$with_kerb5" = "yes"; then
2732             found=no
2733             O_CPPFLAGS="$CPPFLAGS"
2734             for dir in "" "kerberosV/" "krb5/" "kerberos5/" "kerberosv5/"; do
2735                 CPPFLAGS="$O_CPPFLAGS -I/usr/include/${dir}"
2736                 AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[#include <krb5.h>]])], [found=yes; break])
2737             done
2738             if test X"$found" = X"no"; then
2739                 CPPFLAGS="$O_CPPFLAGS"
2740                 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])
2741             fi
2742         else
2743             dnl XXX - try to include krb5.h here too
2744             SUDO_APPEND_LIBPATH(SUDOERS_LDFLAGS, [${with_kerb5}/lib])
2745             CPPFLAGS="$CPPFLAGS -I${with_kerb5}/include"
2746         fi
2747
2748         dnl
2749         dnl Try to determine whether we have Heimdal or MIT Kerberos
2750         dnl
2751         AC_MSG_CHECKING(whether we are using Heimdal)
2752         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <krb5.h>]], [[const char *tmp = heimdal_version;]])], [
2753                 AC_MSG_RESULT(yes)
2754                 AC_DEFINE(HAVE_HEIMDAL)
2755                 # XXX - need to check whether -lcrypo is needed!
2756                 SUDOERS_LIBS="${SUDOERS_LIBS} -lkrb5 -lcrypto -ldes -lcom_err -lasn1"
2757                 AC_CHECK_LIB(roken, main, [SUDOERS_LIBS="${SUDOERS_LIBS} -lroken"])
2758             ], [
2759                 AC_MSG_RESULT(no)
2760                 SUDOERS_LIBS="${SUDOERS_LIBS} -lkrb5 -lk5crypto -lcom_err"
2761                 AC_CHECK_LIB(krb5support, main, [SUDOERS_LIBS="${SUDOERS_LIBS} -lkrb5support"])
2762         ])
2763         AUTH_OBJS="$AUTH_OBJS kerb5.lo"
2764     fi
2765     _LIBS="$LIBS"
2766     LIBS="${LIBS} ${SUDOERS_LIBS}"
2767     AC_CHECK_FUNCS(krb5_verify_user krb5_init_secure_context)
2768     AC_CHECK_FUNCS(krb5_get_init_creds_opt_alloc, [
2769         AC_CACHE_CHECK([whether krb5_get_init_creds_opt_free takes a context],
2770             sudo_cv_krb5_get_init_creds_opt_free_two_args, [
2771                 AC_COMPILE_IFELSE(
2772                     [AC_LANG_PROGRAM(
2773                         [[#include <krb5.h>]],
2774                         [[krb5_get_init_creds_opt_free(NULL, NULL);]]
2775                     )],
2776                     [sudo_cv_krb5_get_init_creds_opt_free_two_args=yes],
2777                     [sudo_cv_krb5_get_init_creds_opt_free_two_args=no]
2778                 )
2779             ]
2780         )
2781     ])
2782     if test X"$sudo_cv_krb5_get_init_creds_opt_free_two_args" = X"yes"; then
2783         AC_DEFINE(HAVE_KRB5_GET_INIT_CREDS_OPT_FREE_TWO_ARGS)
2784     fi
2785     LIBS="$_LIBS"
2786     AC_MSG_CHECKING(whether to use an instance name for Kerberos V)
2787     AC_ARG_ENABLE(kerb5-instance,
2788     [AS_HELP_STRING([--enable-kerb5-instance], [instance string to append to the username (separated by a slash)])],
2789         [ case "$enableval" in
2790             yes)        AC_MSG_ERROR(["must give --enable-kerb5-instance an argument."])
2791                         ;;
2792             no)         AC_MSG_RESULT(no)
2793                         ;;
2794             *)          SUDO_DEFINE_UNQUOTED(SUDO_KRB5_INSTANCE, "$enableval")
2795                         AC_MSG_RESULT([$enableval])
2796                         ;;
2797         esac], AC_MSG_RESULT(no))
2798 fi
2799
2800 dnl
2801 dnl extra AFS libs and includes
2802 dnl
2803 if test ${with_AFS-'no'} = "yes"; then
2804
2805     # looks like the "standard" place for AFS libs is /usr/afsws/lib
2806     AFSLIBDIRS="/usr/lib/afs /usr/afsws/lib /usr/afsws/lib/afs"
2807     for i in $AFSLIBDIRS; do
2808         if test -d ${i}; then
2809             SUDO_APPEND_LIBPATH(SUDOERS_LDFLAGS, [$i])
2810             FOUND_AFSLIBDIR=true
2811         fi
2812     done
2813     if test -z "$FOUND_AFSLIBDIR"; then
2814         AC_MSG_WARN([Unable to locate AFS libraries, you will have to edit the Makefile and add -L/path/to/afs/libs to SUDOERS_LDFLAGS or rerun configure with the --with-libpath options.])
2815     fi
2816
2817     # Order is important here.  Note that we build AFS_LIBS from right to left
2818     # since AFS_LIBS may be initialized with BSD compat libs that must go last
2819     AFS_LIBS="-laudit ${AFS_LIBS}"
2820     for i in $AFSLIBDIRS; do
2821         if test -f ${i}/util.a; then
2822             AFS_LIBS="${i}/util.a ${AFS_LIBS}"
2823             FOUND_UTIL_A=true
2824             break;
2825         fi
2826     done
2827     if test -z "$FOUND_UTIL_A"; then
2828         AFS_LIBS="-lutil ${AFS_LIBS}"
2829     fi
2830     AFS_LIBS="-lkauth -lprot -lubik -lauth -lrxkad -lsys -ldes -lrx -llwp -lcom_err ${AFS_LIBS}"
2831
2832     # AFS includes may live in /usr/include on some machines...
2833     for i in /usr/afsws/include; do
2834         if test -d ${i}; then
2835             CPPFLAGS="${CPPFLAGS} -I${i}"
2836             FOUND_AFSINCDIR=true
2837         fi
2838     done
2839
2840     if test -z "$FOUND_AFSLIBDIR"; then
2841         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.])
2842     fi
2843
2844     AUTH_OBJS="$AUTH_OBJS afs.lo"
2845 fi
2846
2847 dnl
2848 dnl extra DCE obj + lib
2849 dnl Order of libs in HP-UX 10.x is important, -ldce must be last.
2850 dnl
2851 if test ${with_DCE-'no'} = "yes"; then
2852     DCE_OBJS="${DCE_OBJS} dce_pwent.o"
2853     SUDOERS_LIBS="${SUDOERS_LIBS} -ldce"
2854     AUTH_OBJS="$AUTH_OBJS dce.lo"
2855 fi
2856
2857 dnl
2858 dnl extra S/Key lib and includes
2859 dnl
2860 if test "${with_skey-'no'}" = "yes"; then
2861     O_LDFLAGS="$LDFLAGS"
2862     if test "$with_skey" != "yes"; then
2863         CPPFLAGS="${CPPFLAGS} -I${with_skey}/include"
2864         SUDO_APPEND_LIBPATH(LDFLAGS, [${with_skey}/lib])
2865         SUDO_APPEND_LIBPATH(SUDOERS_LDFLAGS, [${with_skey}/lib])
2866         AC_CHECK_HEADER([skey.h], [found=yes], [found=no], [#include <stdio.h>])
2867     else
2868         found=no
2869         O_CPPFLAGS="$CPPFLAGS"
2870         for dir in "" "/usr/local" "/usr/contrib"; do
2871             test -n "$dir" && CPPFLAGS="$O_CPPFLAGS -I${dir}/include"
2872             AC_CHECK_HEADER([skey.h], [found=yes; break], [],
2873                 [#include <stdio.h>]) 
2874         done
2875         if test "$found" = "no" -o -z "$dir"; then
2876             CPPFLAGS="$O_CPPFLAGS"
2877         else
2878             SUDO_APPEND_LIBPATH(LDFLAGS, [${dir}/lib])
2879             SUDO_APPEND_LIBPATH(SUDOERS_LDFLAGS, [${dir}/lib])
2880         fi
2881         if test "$found" = "no"; then
2882             AC_MSG_WARN([Unable to locate skey.h, you will have to edit the Makefile and add -I/path/to/skey/includes to CPPFLAGS])
2883         fi
2884     fi
2885     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 SUDOERS_LDFLAGS])])
2886     AC_CHECK_LIB(skey, skeyaccess, AC_DEFINE(HAVE_SKEYACCESS))
2887
2888     AC_MSG_CHECKING([for RFC1938-compliant skeychallenge])
2889     AC_COMPILE_IFELSE(
2890         [AC_LANG_PROGRAM(
2891             [[#include <stdio.h>
2892             #include <skey.h>]],
2893             [[skeychallenge(NULL, NULL, NULL, 0);]]
2894         )], [
2895             AC_DEFINE(HAVE_RFC1938_SKEYCHALLENGE)
2896             AC_MSG_RESULT([yes])
2897         ], [
2898             AC_MSG_RESULT([no])
2899         ]
2900     )
2901
2902     LDFLAGS="$O_LDFLAGS"
2903     SUDOERS_LIBS="${SUDOERS_LIBS} -lskey"
2904     AUTH_OBJS="$AUTH_OBJS rfc1938.lo"
2905 fi
2906
2907 dnl
2908 dnl extra OPIE lib and includes
2909 dnl
2910 if test "${with_opie-'no'}" = "yes"; then
2911     O_LDFLAGS="$LDFLAGS"
2912     if test "$with_opie" != "yes"; then
2913         CPPFLAGS="${CPPFLAGS} -I${with_opie}/include"
2914         SUDO_APPEND_LIBPATH(LDFLAGS, [${with_opie}/lib])
2915         SUDO_APPEND_LIBPATH(SUDOERS_LDFLAGS, [${with_opie}/lib])
2916         AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[#include <opie.h>]])], [found=yes], [found=no])
2917     else
2918         found=no
2919         O_CPPFLAGS="$CPPFLAGS"
2920         for dir in "" "/usr/local" "/usr/contrib"; do
2921             test -n "$dir" && CPPFLAGS="$O_CPPFLAGS -I${dir}/include"
2922             AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[#include <opie.h>]])], [found=yes; break])
2923         done
2924         if test "$found" = "no" -o -z "$dir"; then
2925             CPPFLAGS="$O_CPPFLAGS"
2926         else
2927             SUDO_APPEND_LIBPATH(LDFLAGS, [${dir}/lib])
2928             SUDO_APPEND_LIBPATH(SUDOERS_LDFLAGS, [${dir}/lib])
2929         fi
2930         if test "$found" = "no"; then
2931             AC_MSG_WARN([Unable to locate opie.h, you will have to edit the Makefile and add -I/path/to/opie/includes to CPPFLAGS])
2932         fi
2933     fi
2934     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 SUDOERS_LDFLAGS])])
2935     LDFLAGS="$O_LDFLAGS"
2936     SUDOERS_LIBS="${SUDOERS_LIBS} -lopie"
2937     AUTH_OBJS="$AUTH_OBJS rfc1938.lo"
2938 fi
2939
2940 dnl
2941 dnl Check for shadow password routines if we have not already done so.
2942 dnl If there is a specific list of functions to check we do that first.
2943 dnl Otherwise, we check for SVR4-style and then SecureWare-style.
2944 dnl
2945 if test ${with_passwd-'no'} != "no"; then
2946     dnl
2947     dnl if crypt(3) not in libc, look elsewhere
2948     dnl
2949     if test -z "$LIB_CRYPT"; then
2950         _LIBS="$LIBS"
2951         AC_SEARCH_LIBS([crypt], [crypt crypt_d ufc], [test -n "$ac_lib" && SUDOERS_LIBS="${SUDOERS_LIBS} $ac_res"])
2952         LIBS="$_LIBS"
2953     fi
2954
2955     if test "$CHECKSHADOW" = "true" -a -n "$shadow_funcs"; then
2956         _LIBS="$LIBS"
2957         LIBS="$LIBS $shadow_libs"
2958         found=no
2959         AC_CHECK_FUNCS($shadow_funcs, [found=yes])
2960         if test "$found" = "yes"; then
2961             SUDOERS_LIBS="$SUDOERS_LIBS $shadow_libs"
2962         elif test -n "$shadow_libs_optional"; then
2963             LIBS="$LIBS $shadow_libs_optional"
2964             AC_CHECK_FUNCS($shadow_funcs, [found=yes])
2965             if test "$found" = "yes"; then
2966                 SUDOERS_LIBS="$SUDOERS_LIBS $shadow_libs $shadow_libs_optional"
2967             fi
2968         fi
2969         if test "$found" = "yes"; then
2970             case "$shadow_funcs" in
2971                 *getprpwnam*) SECUREWARE=1;;
2972             esac
2973             test -n "$shadow_defs" && OSDEFS="${OSDEFS} $shadow_defs"
2974         else
2975             LIBS="$_LIBS"
2976         fi
2977         CHECKSHADOW=false
2978     fi
2979     if test "$CHECKSHADOW" = "true"; then
2980         AC_SEARCH_LIBS([getspnam], [gen], [AC_DEFINE(HAVE_GETSPNAM)] [CHECKSHADOW=false; test -n "$ac_lib" && SUDOERS_LIBS="${SUDOERS_LIBS} $ac_res"])
2981     fi
2982     if test "$CHECKSHADOW" = "true"; then
2983         AC_SEARCH_LIBS([getprpwnam], [sec security prot], [AC_DEFINE(HAVE_GETPRPWNAM)] [CHECKSHADOW=false; SECUREWARE=1; test -n "$ac_lib" && SUDOERS_LIBS="${SUDOERS_LIBS} $ac_res"])
2984     fi
2985     if test -n "$SECUREWARE"; then
2986         AC_CHECK_FUNCS(bigcrypt set_auth_parameters initprivs)
2987         AUTH_OBJS="$AUTH_OBJS secureware.lo"
2988     fi
2989 fi
2990
2991 dnl
2992 dnl extra lib and .o file for LDAP support
2993 dnl
2994 if test ${with_ldap-'no'} != "no"; then
2995     _LDFLAGS="$LDFLAGS"
2996     if test "$with_ldap" != "yes"; then
2997         SUDO_APPEND_LIBPATH(SUDOERS_LDFLAGS, [${with_ldap}/lib])
2998         SUDO_APPEND_LIBPATH(LDFLAGS, [${with_ldap}/lib])
2999         CPPFLAGS="${CPPFLAGS} -I${with_ldap}/include"
3000         with_ldap=yes
3001     fi
3002     SUDOERS_OBJS="${SUDOERS_OBJS} ldap.lo"
3003     LDAP=""
3004
3005     AC_MSG_CHECKING([for LDAP libraries])
3006     LDAP_LIBS=""
3007     _LIBS="$LIBS"
3008     found=no
3009     for l in -lldap -llber '-lssl -lcrypto'; do
3010         LIBS="${LIBS} $l"
3011         LDAP_LIBS="${LDAP_LIBS} $l"
3012         AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
3013         #include <lber.h>
3014         #include <ldap.h>]], [[(void)ldap_init(0, 0)]])], [found=yes; break])
3015     done
3016     if test "$found" = "no"; then
3017         LDAP_LIBS=""
3018         LIBS="$_LIBS"
3019         for l in -libmldap -lidsldif; do
3020             LIBS="${LIBS} $l"
3021             LDAP_LIBS="${LDAP_LIBS} $l"
3022             AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
3023             #include <lber.h>
3024             #include <ldap.h>]], [[(void)ldap_init(0, 0)]])], [found=yes; break])
3025         done
3026     fi
3027     dnl if nothing linked just try with -lldap
3028     if test "$found" = "no"; then
3029         LIBS="${_LIBS} -lldap"
3030         LDAP_LIBS="-lldap"
3031         AC_MSG_RESULT([not found, using -lldap])
3032     else
3033         AC_MSG_RESULT([$LDAP_LIBS])
3034     fi
3035     dnl check if we need to link with -llber for ber_set_option
3036     OLIBS="$LIBS"
3037     AC_SEARCH_LIBS([ber_set_option], [lber], [found=yes], [found=no])
3038     if test X"$found" = X"yes" -a X"$LIBS" != X"$OLIBS"; then
3039         LDAP_LIBS="$LDAP_LIBS -llber"
3040     fi
3041     dnl check if ldap.h includes lber.h for us
3042     AC_MSG_CHECKING([whether lber.h is needed])
3043     AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
3044     #include <ldap.h>]], [[(void)ldap_init(0, 0)]])], [AC_MSG_RESULT([no])], [
3045     AC_MSG_RESULT([yes])
3046     AC_DEFINE(HAVE_LBER_H)])
3047
3048     AC_CHECK_HEADERS([sasl/sasl.h] [sasl.h], [AC_CHECK_FUNCS(ldap_sasl_interactive_bind_s)], [break])
3049     AC_CHECK_HEADERS([ldap_ssl.h] [mps/ldap_ssl.h], [break], [], [#include <ldap.h>])
3050     AC_CHECK_FUNCS(ldap_initialize ldap_start_tls_s ldapssl_init ldapssl_set_strength ldap_unbind_ext_s ldap_str2dn ldap_create ldap_sasl_bind_s ldap_ssl_client_init ldap_start_tls_s_np)
3051     AC_CHECK_FUNCS(ldap_search_ext_s ldap_search_st, [break])
3052
3053     if test X"$check_gss_krb5_ccache_name" = X"yes"; then
3054         AC_CHECK_LIB(gssapi, gss_krb5_ccache_name,
3055             AC_DEFINE(HAVE_GSS_KRB5_CCACHE_NAME)
3056             [LDAP_LIBS="${LDAP_LIBS} -lgssapi"],
3057             AC_CHECK_LIB(gssapi_krb5, gss_krb5_ccache_name,
3058                 AC_DEFINE(HAVE_GSS_KRB5_CCACHE_NAME)
3059                 [LDAP_LIBS="${LDAP_LIBS} -lgssapi_krb5"])
3060         )
3061
3062         # gssapi headers may be separate or part of Kerberos V
3063         found=no
3064         O_CPPFLAGS="$CPPFLAGS"
3065         for dir in "" "kerberosV" "krb5" "kerberos5" "kerberosv5"; do
3066             test X"$dir" != X"" && CPPFLAGS="$O_CPPFLAGS -I/usr/include/${dir}"
3067             AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[#include <gssapi/gssapi.h>]])], [found="gssapi/gssapi.h"; break], [AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[#include <gssapi.h>]])], [found="gssapi.h"; break])])
3068         done
3069         if test X"$found" != X"no"; then
3070             AC_CHECK_HEADERS([$found])
3071             if test X"$found" = X"gssapi/gssapi.h"; then
3072                 AC_CHECK_HEADERS([gssapi/gssapi_krb5.h])
3073             fi
3074         else
3075             CPPFLAGS="$O_CPPFLAGS"
3076             AC_MSG_WARN([Unable to locate gssapi.h, you will have to edit the Makefile and add -I/path/to/gssapi/includes to CPPFLAGS])
3077         fi
3078     fi
3079
3080     SUDOERS_LIBS="${SUDOERS_LIBS} ${LDAP_LIBS}"
3081     LIBS="$_LIBS"
3082     LDFLAGS="$_LDFLAGS"
3083 fi
3084
3085 #
3086 # How to do dynamic object loading.
3087 # We support dlopen() and sh_load(), else fall back to static loading.
3088 #
3089 case "$lt_cv_dlopen" in
3090     dlopen)
3091         AC_DEFINE(HAVE_DLOPEN)
3092         SUDOERS_OBJS="$SUDOERS_OBJS plugin_error.lo"
3093         LT_STATIC="--tag=disable-static"
3094         ;;
3095     shl_load)
3096         AC_DEFINE(HAVE_SHL_LOAD)
3097         SUDOERS_OBJS="$SUDOERS_OBJS plugin_error.lo"
3098         LT_STATIC="--tag=disable-static"
3099         AC_LIBOBJ(dlopen)
3100         ;;
3101     *)
3102         if test X"${ac_cv_func_dlopen}" = X"yes"; then
3103             AC_MSG_ERROR(["dlopen present but libtool doesn't appear to support your platform."])
3104         fi
3105         # Preload sudoers module symbols
3106         SUDO_OBJS="${SUDO_OBJS} preload.o"
3107         SUDO_LIBS="${SUDO_LIBS} \$(top_builddir)/plugins/sudoers/sudoers.la"
3108         LT_STATIC=""
3109         AC_LIBOBJ(dlopen)
3110         ;;
3111 esac
3112
3113 #
3114 # Add library needed for dynamic loading, if any.
3115 #
3116 LIBDL="$lt_cv_dlopen_libs"
3117 if test X"$LIBDL" != X""; then
3118     SUDO_LIBS="${SUDO_LIBS} $LIBDL"
3119     SUDOERS_LIBS="${SUDOERS_LIBS} $LIBDL"
3120 fi
3121
3122 # On HP-UX, you cannot dlopen() a shared object that uses pthreads
3123 # unless the main program is linked against -lpthread.  Since we
3124 # have no knowledge what libraries a plugin may depend on, we always
3125 # link against -lpthread on HP-UX if it is available.
3126 # This check should go after all other libraries tests.
3127 case "$host" in
3128     *-*-hpux*)
3129         AC_CHECK_LIB(pthread, main, [SUDO_LIBS="${SUDO_LIBS} -lpthread"])
3130         ;;
3131 esac
3132
3133 dnl
3134 dnl Add $blibpath to SUDOERS_LDFLAGS if specified by the user or if we
3135 dnl added -L dirpaths to SUDOERS_LDFLAGS.
3136 dnl
3137 if test -n "$blibpath"; then
3138     if test -n "$blibpath_add"; then
3139         SUDOERS_LDFLAGS="$SUDOERS_LDFLAGS -Wl,-blibpath:${blibpath}${blibpath_add}"
3140     elif test -n "$with_blibpath" -a "$with_blibpath" != "yes"; then
3141         SUDOERS_LDFLAGS="$SUDOERS_LDFLAGS -Wl,-blibpath:${blibpath}"
3142     fi
3143 fi
3144
3145 dnl
3146 dnl Check for log file, timestamp and iolog locations
3147 dnl
3148 if test "$utmp_style" = "LEGACY"; then
3149     SUDO_PATH_UTMP
3150 fi
3151 SUDO_LOGFILE
3152 SUDO_TIMEDIR
3153 SUDO_IO_LOGDIR
3154
3155 dnl
3156 dnl Use passwd auth module?
3157 dnl
3158 case "$with_passwd" in
3159 yes|maybe)
3160     AUTH_OBJS="$AUTH_OBJS getspwuid.lo passwd.lo"
3161     ;;
3162 *)
3163     AC_DEFINE(WITHOUT_PASSWD)
3164     if test -z "$AUTH_OBJS"; then
3165         AC_MSG_ERROR([no authentication methods defined.])
3166     fi
3167     ;;
3168 esac
3169 AUTH_OBJS=${AUTH_OBJS# }
3170 _AUTH=`echo "$AUTH_OBJS" | sed -e 's/\.lo//g' -e 's/getspwuid *//'`
3171 AC_MSG_NOTICE([using the following authentication methods: $_AUTH])
3172
3173 dnl
3174 dnl LIBS may contain duplicates from SUDO_LIBS, SUDOERS_LIBS, or NET_LIBS
3175 dnl
3176 if test -n "$LIBS"; then
3177     L="$LIBS"
3178     LIBS=
3179     for l in ${L}; do
3180         dupe=0
3181         for sl in ${SUDO_LIBS} ${SUDOERS_LIBS} ${NET_LIBS}; do
3182             test $l = $sl && dupe=1
3183         done
3184         test $dupe = 0 && LIBS="${LIBS} $l"
3185     done
3186 fi
3187
3188 dnl
3189 dnl We add -Wall and -Werror after all tests so they don't cause failures
3190 dnl
3191 if test -n "$GCC"; then
3192     if test X"$enable_warnings" = X"yes" -o X"$with_devel" = X"yes"; then
3193         CFLAGS="${CFLAGS} -Wall"
3194     fi
3195     if test X"$enable_werror" = X"yes"; then
3196         CFLAGS="${CFLAGS} -Werror"
3197     fi
3198 fi
3199
3200 dnl
3201 dnl Set exec_prefix
3202 dnl
3203 test "$exec_prefix" = "NONE" && exec_prefix='$(prefix)'
3204
3205 dnl
3206 dnl Defer setting _PATH_SUDO_NOEXEC until after exec_prefix is set
3207 dnl XXX - this is gross!
3208 dnl
3209 if test X"$with_noexec" != X"no" -o X"$with_selinux" != X"no"; then
3210     oexec_prefix="$exec_prefix"
3211     if test "$exec_prefix" = '$(prefix)'; then
3212         if test "$prefix" = "NONE"; then
3213             exec_prefix="$ac_default_prefix"
3214         else
3215             exec_prefix="$prefix"
3216         fi
3217     fi
3218     if test X"$with_noexec" != X"no"; then
3219         PROGS="${PROGS} libsudo_noexec.la"
3220         INSTALL_NOEXEC="install-noexec"
3221
3222         noexec_file="$with_noexec"
3223         _noexec_file=
3224         while test X"$noexec_file" != X"$_noexec_file"; do
3225             _noexec_file="$noexec_file"
3226             eval noexec_file="$_noexec_file"
3227         done
3228         SUDO_DEFINE_UNQUOTED(_PATH_SUDO_NOEXEC, "$noexec_file", [The fully qualified pathname of sudo_noexec.so])
3229     fi
3230     if test X"$with_selinux" != X"no"; then
3231         sesh_file="$libexecdir/sesh"
3232         _sesh_file=
3233         while test X"$sesh_file" != X"$_sesh_file"; do
3234             _sesh_file="$sesh_file"
3235             eval sesh_file="$_sesh_file"
3236         done
3237         SUDO_DEFINE_UNQUOTED(_PATH_SUDO_SESH, "$sesh_file", [The fully qualified pathname of sesh])
3238     fi
3239     PLUGINDIR="$with_plugindir"
3240     _PLUGINDIR=
3241     while test X"$PLUGINDIR" != X"$_PLUGINDIR"; do
3242         _PLUGINDIR="$PLUGINDIR"
3243         eval PLUGINDIR="$_PLUGINDIR"
3244     done
3245     SUDO_DEFINE_UNQUOTED(_PATH_SUDO_PLUGIN_DIR, "$PLUGINDIR/")
3246     SUDO_DEFINE_UNQUOTED(SUDOERS_PLUGIN, "sudoers${SOEXT}")
3247     exec_prefix="$oexec_prefix"
3248 fi
3249
3250 dnl
3251 dnl Override default configure dirs for the Makefile
3252 dnl
3253 if test X"$prefix" = X"NONE"; then
3254     test "$mandir" = '${datarootdir}/man' && mandir='$(prefix)/man'
3255 else
3256     test "$mandir" = '${datarootdir}/man' && mandir='$(datarootdir)/man'
3257 fi
3258 test "$bindir" = '${exec_prefix}/bin' && bindir='$(exec_prefix)/bin'
3259 test "$sbindir" = '${exec_prefix}/sbin' && sbindir='$(exec_prefix)/sbin'
3260 test "$libexecdir" = '${exec_prefix}/libexec' && libexecdir='$(exec_prefix)/libexec'
3261 test "$includedir" = '${prefix}/include' && includedir='$(prefix)/include'
3262 test "$datarootdir" = '${prefix}/share' && datarootdir='$(prefix)/share'
3263 test "$docdir" = '${datarootdir}/doc/${PACKAGE_TARNAME}' && docdir='$(datarootdir)/doc/$(PACKAGE_TARNAME)'
3264 test "$sysconfdir" = '${prefix}/etc' -a X"$with_stow" != X"yes" && sysconfdir='/etc'
3265
3266 dnl
3267 dnl Substitute into the Makefile and man pages
3268 dnl
3269 dnl AC_CONFIG_FILES([doc/sudo.man doc/visudo.man doc/sudoers.man doc/sudoers.ldap.man doc/sudoreplay.man src/Makefile src/sudo_usage.h])
3270 AC_CONFIG_FILES([Makefile common/Makefile compat/Makefile doc/Makefile include/Makefile src/sudo_usage.h src/Makefile plugins/sample/Makefile plugins/sample_group/Makefile plugins/system_group/Makefile plugins/sudoers/Makefile plugins/sudoers/sudoers])
3271 AC_OUTPUT
3272
3273 dnl
3274 dnl Spew any text the user needs to know about
3275 dnl
3276 if test "$with_pam" = "yes"; then
3277     case $host in
3278         *-*-hpux*)
3279             if test -f /usr/lib/security/libpam_hpsec.so.1; then
3280                 AC_MSG_NOTICE([You may wish to add the following line to /etc/pam.conf])
3281                 AC_MSG_NOTICE([sudo session required libpam_hpsec.so.1 bypass_umask bypass_last_login])
3282             fi
3283             ;;
3284         *-*-linux*)
3285             AC_MSG_NOTICE([You will need to customize sample.pam and install it as /etc/pam.d/sudo])
3286             ;;
3287     esac
3288 fi
3289
3290 dnl
3291 dnl Autoheader templates
3292 dnl
3293 AH_TEMPLATE(BROKEN_SYSLOG, [Define to 1 if the `syslog' function returns a non-zero int to denote failure.])
3294 AH_TEMPLATE(CLASSIC_INSULTS, [Define to 1 if you want the insults from the "classic" version sudo.])
3295 AH_TEMPLATE(CSOPS_INSULTS, [Define to 1 if you want insults culled from the twisted minds of CSOps.])
3296 AH_TEMPLATE(SUDOERS_PLUGIN, [The name of the sudoers plugin, including extension.])
3297 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.])
3298 AH_TEMPLATE(ENV_DEBUG, [Define to 1 to enable environment function debugging.])
3299 AH_TEMPLATE(ENV_EDITOR, [Define to 1 if you want visudo to honor the EDITOR and VISUAL env variables.])
3300 AH_TEMPLATE(FQDN, [Define to 1 if you want to require fully qualified hosts in sudoers.])
3301 AH_TEMPLATE(ENV_RESET, [Define to 1 to enable environment resetting by default.])
3302 AH_TEMPLATE(GOONS_INSULTS, [Define to 1 if you want insults from the "Goon Show".])
3303 AH_TEMPLATE(HAL_INSULTS, [Define to 1 if you want 2001-like insults.])
3304 AH_TEMPLATE(HAVE_AFS, [Define to 1 if you use AFS.])
3305 AH_TEMPLATE(HAVE_AIXAUTH, [Define to 1 if you use AIX general authentication.])
3306 AH_TEMPLATE(HAVE_BSD_AUTH_H, [Define to 1 if you use BSD authentication.])
3307 AH_TEMPLATE(HAVE_BSM_AUDIT, [Define to 1 to enable BSM audit support.])
3308 AH_TEMPLATE(HAVE_DCE, [Define to 1 if you use OSF DCE.])
3309 AH_TEMPLATE(HAVE_DD_FD, [Define to 1 if your `DIR' contains dd_fd.])
3310 AH_TEMPLATE(HAVE_DIRFD, [Define to 1 if you have the `dirfd' function or macro.])
3311 AH_TEMPLATE(HAVE_DISPCRYPT, [Define to 1 if you have the `dispcrypt' function.])
3312 AH_TEMPLATE(HAVE_DLOPEN, [Define to 1 if you have the `dlopen' function.])
3313 AH_TEMPLATE(HAVE_FCNTL_CLOSEM, [Define to 1 if your system has the F_CLOSEM fcntl.])
3314 AH_TEMPLATE(HAVE_FNMATCH, [Define to 1 if you have the `fnmatch' function.])
3315 AH_TEMPLATE(HAVE_FWTK, [Define to 1 if you use the FWTK authsrv daemon.])
3316 AH_TEMPLATE(HAVE_GETAUTHUID, [Define to 1 if you have the `getauthuid' function. (ULTRIX 4.x  shadow passwords)])
3317 AH_TEMPLATE(HAVE_GETPRPWNAM, [Define to 1 if you have the `getprpwnam' function.  (SecureWare-style shadow passwords)])
3318 AH_TEMPLATE(HAVE_GETPWANAM, [Define to 1 if you have the `getpwanam' function. (SunOS 4.x shadow passwords)])
3319 AH_TEMPLATE(HAVE_GETSPNAM, [Define to 1 if you have the `getspnam' function (SVR4-style shadow passwords)])
3320 AH_TEMPLATE(HAVE_GETSPWUID, [Define to 1 if you have the `getspwuid' function. (HP-UX <= 9.X shadow passwords)])
3321 AH_TEMPLATE(HAVE_GSS_KRB5_CCACHE_NAME, [Define to 1 if you have the `gss_krb5_ccache_name' function.])
3322 AH_TEMPLATE(HAVE_HEIMDAL, [Define to 1 if your Kerberos is Heimdal.])
3323 AH_TEMPLATE(HAVE_ISCOMSEC, [Define to 1 if you have the `iscomsec' function. (HP-UX >= 10.x check for shadow enabled)])
3324 AH_TEMPLATE(HAVE_ISSECURE, [Define to 1 if you have the `issecure' function. (SunOS 4.x check for shadow enabled)])
3325 AH_TEMPLATE(HAVE_KERB5, [Define to 1 if you use Kerberos V.])
3326 AH_TEMPLATE(HAVE_KRB5_GET_INIT_CREDS_OPT_ALLOC, [Define to 1 if you have the `krb5_get_init_creds_opt_alloc' function.])
3327 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.])
3328 AH_TEMPLATE(HAVE_KRB5_INIT_SECURE_CONTEXT, [Define to 1 if you have the `krb5_init_secure_context' function.])
3329 AH_TEMPLATE(HAVE_KRB5_VERIFY_USER, [Define to 1 if you have the `krb5_verify_user' function.])
3330 AH_TEMPLATE(HAVE_LBER_H, [Define to 1 if your LDAP needs <lber.h>. (OpenLDAP does not)])
3331 AH_TEMPLATE(HAVE_LDAP, [Define to 1 if you use LDAP for sudoers.])
3332 AH_TEMPLATE(HAVE_LIBINTL_H, [Define to 1 if you have the <libintl.h> header file.])
3333 AH_TEMPLATE(HAVE_LINUX_AUDIT, [Define to 1 to enable Linux audit support.])
3334 AH_TEMPLATE(HAVE_OPIE, [Define to 1 if you use NRL OPIE.])
3335 AH_TEMPLATE(HAVE_PAM, [Define to 1 if you use PAM authentication.])
3336 AH_TEMPLATE(HAVE_PAM_LOGIN, [Define to 1 if you use a specific PAM session for sudo -i.])
3337 AH_TEMPLATE(HAVE_PROJECT_H, [Define to 1 if you have the <project.h> header file.])
3338 AH_TEMPLATE(HAVE_SECURID, [Define to 1 if you use SecurID for authentication.])
3339 AH_TEMPLATE(HAVE_SELINUX, [Define to 1 to enable SELinux RBAC support.])
3340 AH_TEMPLATE(HAVE_SETKEYCREATECON, [Define to 1 if you have the `setkeycreatecon' function.])
3341 AH_TEMPLATE(HAVE_SHL_LOAD, [Define to 1 if you have the `shl_load' function.])
3342 AH_TEMPLATE(HAVE_SKEY, [Define to 1 if you use S/Key.])
3343 AH_TEMPLATE(HAVE_SKEYACCESS, [Define to 1 if your S/Key library has skeyaccess().])
3344 AH_TEMPLATE(HAVE_RFC1938_SKEYCHALLENGE, [Define to 1 if the skeychallenge() function is RFC1938-compliant and takes 4 arguments])
3345 AH_TEMPLATE(HAVE_ST__TIM, [Define to 1 if your struct stat uses an st__tim union])
3346 AH_TEMPLATE(HAVE_ST_MTIM, [Define to 1 if your struct stat has an st_mtim member])
3347 AH_TEMPLATE(HAVE_ST_MTIMESPEC, [Define to 1 if your struct stat has an st_mtimespec member])
3348 AH_TEMPLATE(HAVE___PROGNAME, [Define to 1 if your crt0.o defines the __progname symbol for you.])
3349 AH_TEMPLATE(HOST_IN_LOG, [Define to 1 if you want the hostname to be entered into the log file.])
3350 AH_TEMPLATE(IGNORE_DOT_PATH, [Define to 1 if you want to ignore '.' and empty PATH elements])
3351 AH_TEMPLATE(LOGGING, [Define to SLOG_SYSLOG, SLOG_FILE, or SLOG_BOTH.])
3352 AH_TEMPLATE(LONG_OTP_PROMPT, [Define to 1 if you want a two line OTP (S/Key or OPIE) prompt.])
3353 AH_TEMPLATE(NO_AUTHENTICATION, [Define to 1 if you don't want sudo to prompt for a password by default.])
3354 AH_TEMPLATE(NO_LECTURE, [Define to 1 if you don't want users to get the lecture the first they user sudo.])
3355 AH_TEMPLATE(NO_PAM_SESSION, [Define to 1 if you don't want to use sudo's PAM session support])
3356 AH_TEMPLATE(NO_ROOT_MAILER, [Define to avoid runing the mailer as root.])
3357 AH_TEMPLATE(NO_ROOT_SUDO, [Define to 1 if root should not be allowed to use sudo.])
3358 AH_TEMPLATE(NO_TTY_TICKETS, [Define to 1 if you want a single ticket file instead of per-tty files.])
3359 AH_TEMPLATE(PC_INSULTS, [Define to 1 to replace politically incorrect insults with less offensive ones.])
3360 AH_TEMPLATE(SECURE_PATH, [Define to 1 to override the user's path with a built-in one.])
3361 AH_TEMPLATE(SEND_MAIL_WHEN_NOT_OK, [Define to 1 to send mail when the user is not allowed to run a command.])
3362 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.])
3363 AH_TEMPLATE(SEND_MAIL_WHEN_NO_USER, [Define to 1 to send mail when the user is not in the sudoers file.])
3364 AH_TEMPLATE(SHELL_IF_NO_ARGS, [Define to 1 if you want sudo to start a shell if given no arguments.])
3365 AH_TEMPLATE(SHELL_SETS_HOME, [Define to 1 if you want sudo to set $HOME in shell mode.])
3366 AH_TEMPLATE(STUB_LOAD_INTERFACES, [Define to 1 if the code in interfaces.c does not compile for you.])
3367 AH_TEMPLATE(UMASK_OVERRIDE, [Define to 1 to use the umask specified in sudoers even when it is less restrictive than the invoking user's.])
3368 AH_TEMPLATE(USE_ADMIN_FLAG, [Define to 1 if you want to create ~/.sudo_as_admin_successful if the user is in the admin group the first time they run sudo.])
3369 AH_TEMPLATE(USE_INSULTS, [Define to 1 if you want to insult the user for entering an incorrect password.])
3370 AH_TEMPLATE(USE_STOW, [Define to 1 if you use GNU stow packaging.])
3371 AH_TEMPLATE(WITHOUT_PASSWD, [Define to avoid using the passwd/shadow file for authentication.])
3372 AH_TEMPLATE(sig_atomic_t, [Define to `int' if <signal.h> does not define.])
3373 AH_TEMPLATE(__signed, [Define to `signed' or nothing if compiler does not support a signed type qualifier.])
3374 AH_TEMPLATE(socklen_t, [Define to `unsigned int' if <sys/socket.h> doesn't define.])
3375 AH_TEMPLATE(HAVE_STRUCT_UTMP_UT_EXIT, [Define to 1 if `ut_exit' is a member of `struct utmp'.])
3376 AH_TEMPLATE(HAVE_STRUCT_UTMPX_UT_EXIT, [Define to 1 if `ut_exit' is a member of `struct utmpx'.])
3377 AH_TEMPLATE(HAVE___FUNC__, [Define to 1 if the compiler supports the C99 __func__ variable.])
3378 AH_TEMPLATE(SUDO_KRB5_INSTANCE, [An instance string to append to the username (separated by a slash) for Kerberos V authentication])
3379 AH_TEMPLATE(RTLD_PRELOAD_VAR, [The environment variable that controls preloading of dynamic objects.])
3380 AH_TEMPLATE(RTLD_PRELOAD_ENABLE_VAR, [An extra environment variable that is required to enable preloading (if any).])
3381 AH_TEMPLATE(RTLD_PRELOAD_DELIM, [The delimiter to use when defining multiple preloaded objects.])
3382 AH_TEMPLATE(RTLD_PRELOAD_DEFAULT, [The default value of preloaded objects (if any).])
3383
3384 dnl
3385 dnl Bits to copy verbatim into config.h.in
3386 dnl
3387 AH_TOP([#ifndef _SUDO_CONFIG_H
3388 #define _SUDO_CONFIG_H])
3389
3390 AH_BOTTOM([/*
3391  * Macros to convert ctime and mtime into timevals.
3392  */
3393 #define timespec2timeval(_ts, _tv) do {                                 \
3394     (_tv)->tv_sec = (_ts)->tv_sec;                                      \
3395     (_tv)->tv_usec = (_ts)->tv_nsec / 1000;                             \
3396 } while (0)
3397
3398 #ifdef HAVE_ST_MTIM
3399 # ifdef HAVE_ST__TIM
3400 #  define ctim_get(_x, _y)      timespec2timeval(&(_x)->st_ctim.st__tim, (_y))
3401 #  define mtim_get(_x, _y)      timespec2timeval(&(_x)->st_mtim.st__tim, (_y))
3402 # else
3403 #  define ctim_get(_x, _y)      timespec2timeval(&(_x)->st_ctim, (_y))
3404 #  define mtim_get(_x, _y)      timespec2timeval(&(_x)->st_mtim, (_y))
3405 # endif
3406 #else
3407 # ifdef HAVE_ST_MTIMESPEC
3408 #  define ctim_get(_x, _y)      timespec2timeval(&(_x)->st_ctimespec, (_y))
3409 #  define mtim_get(_x, _y)      timespec2timeval(&(_x)->st_mtimespec, (_y))
3410 # else
3411 #  define ctim_get(_x, _y)      do { (_y)->tv_sec = (_x)->st_ctime; (_y)->tv_usec = 0; } while (0)
3412 #  define mtim_get(_x, _y)      do { (_y)->tv_sec = (_x)->st_mtime; (_y)->tv_usec = 0; } while (0)
3413 # endif /* HAVE_ST_MTIMESPEC */
3414 #endif /* HAVE_ST_MTIM */
3415
3416 #ifdef __GNUC__
3417 # define ignore_result(x) do {                                                 \
3418     __typeof__(x) y = (x);                                                     \
3419     (void)y;                                                                   \
3420 } while(0)
3421 #else
3422 # define ignore_result(x)       (void)(x)
3423 #endif
3424
3425 /* GNU stow needs /etc/sudoers to be a symlink. */
3426 #ifdef USE_STOW
3427 # define stat_sudoers   stat
3428 #else
3429 # define stat_sudoers   lstat
3430 #endif
3431
3432 /* Macros to set/clear/test flags. */
3433 #undef SET
3434 #define SET(t, f)       ((t) |= (f))
3435 #undef CLR
3436 #define CLR(t, f)       ((t) &= ~(f))
3437 #undef ISSET
3438 #define ISSET(t, f)     ((t) & (f))
3439
3440 /* ANSI-style OS defs for HP-UX and ConvexOS. */
3441 #if defined(hpux) && !defined(__hpux)
3442 # define __hpux         1
3443 #endif /* hpux */
3444
3445 #if defined(convex) && !defined(__convex__)
3446 # define __convex__     1
3447 #endif /* convex */
3448
3449 /* BSD compatibility on some SVR4 systems. */
3450 #ifdef __svr4__
3451 # define BSD_COMP
3452 #endif /* __svr4__ */
3453
3454 #endif /* _SUDO_CONFIG_H */])