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