1dnl Local m4 macros for autoconf (used by sudo)
2dnl
3dnl SPDX-License-Identifier: ISC
4dnl
5dnl Copyright (c) 1994-1996, 1998-2005, 2007-2015
6dnl	Todd C. Miller <Todd.Miller@sudo.ws>
7dnl
8dnl Permission to use, copy, modify, and distribute this software for any
9dnl purpose with or without fee is hereby granted, provided that the above
10dnl copyright notice and this permission notice appear in all copies.
11dnl
12dnl THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13dnl WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14dnl MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15dnl ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16dnl WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17dnl ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18dnl OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19dnl
20dnl XXX - should cache values in all cases!!!
21dnl
22dnl checks for programs
23
24dnl
25dnl check for sendmail in well-known locations
26dnl
27AC_ARG_VAR([SENDMAILPROG], [The fully-qualified path to the sendmail program to use.])
28AC_DEFUN([SUDO_PROG_SENDMAIL], [
29    AC_PATH_PROG([SENDMAILPROG], [sendmail], [], [/usr/sbin$PATH_SEPARATOR/usr/lib$PATH_SEPARATOR/usr/etc$PATH_SEPARATOR/usr/ucblib$PATH_SEPARATOR/usr/local/lib$PATH_SEPARATOR/usr/local/bin])
30    test -n "${ac_cv_path_SENDMAILPROG}" && SUDO_DEFINE_UNQUOTED(_PATH_SUDO_SENDMAIL, "${ac_cv_path_SENDMAILPROG}")
31])dnl
32
33dnl
34dnl check for vi in well-known locations
35dnl
36AC_ARG_VAR([VIPROG], [The fully-qualified path to the vi program to use.])
37AC_DEFUN([SUDO_PROG_VI], [
38    AC_PATH_PROG([VIPROG], [vi], [], [/usr/bin$PATH_SEPARATOR/bin$PATH_SEPARATOR/usr/ucb$PATH_SEPARATOR/usr/bsd$PATH_SEPARATOR/usr/local/bin])
39    test -n "${ac_cv_path_VIPROG}" && SUDO_DEFINE_UNQUOTED(_PATH_VI, "${ac_cv_path_VIPROG}")
40])dnl
41
42dnl
43dnl check for mv in well-known locations
44dnl
45AC_ARG_VAR([MVPROG], [The fully-qualified path to the mv program to use.])
46AC_DEFUN([SUDO_PROG_MV], [
47    AC_PATH_PROG([MVPROG], [mv], [], [/usr/bin$PATH_SEPARATOR/bin$PATH_SEPARATOR/usr/ucb$PATH_SEPARATOR/usr/local/bin])
48    test -n "${ac_cv_path_MVPROG}" && SUDO_DEFINE_UNQUOTED(_PATH_MV, "${ac_cv_path_MVPROG}")
49])dnl
50
51dnl
52dnl check for bourne shell in well-known locations
53dnl
54AC_ARG_VAR([BSHELLPROG], [The fully-qualified path to the Bourne shell to use.])
55AC_DEFUN([SUDO_PROG_BSHELL], [
56    AC_PATH_PROG([BSHELLPROG], [sh], [/usr/bin$PATH_SEPARATOR/bin$PATH_SEPARATOR/usr/sbin$PATH_SEPARATOR/sbin])
57    test -n "${ac_cv_path_BSHELLPROG}" && SUDO_DEFINE_UNQUOTED(_PATH_BSHELL, "${ac_cv_path_BSHELLPROG}")
58])dnl
59
60dnl
61dnl check for utmp file
62dnl
63AC_DEFUN([SUDO_PATH_UTMP], [AC_MSG_CHECKING([for utmp file path])
64found=no
65for p in "/var/run/utmp" "/var/adm/utmp" "/etc/utmp"; do
66    if test -r "$p"; then
67	found=yes
68	AC_MSG_RESULT([$p])
69	SUDO_DEFINE_UNQUOTED(_PATH_UTMP, "$p")
70	break
71    fi
72done
73if test X"$found" != X"yes"; then
74    AC_MSG_RESULT([not found])
75fi
76])dnl
77
78dnl
79dnl Where the log file goes, use /var/log if it exists, else /{var,usr}/adm
80dnl
81AC_DEFUN([SUDO_LOGFILE], [AC_MSG_CHECKING(for log file location)
82    if test "${with_logpath-yes}" != "yes"; then
83	logpath="$with_logpath"
84    else
85	# Default value of logpath set in configure.ac
86	for d in /var/log /var/adm /usr/adm; do
87	    if test -d "$d"; then
88		logpath="$d/sudo.log"
89		break
90	    fi
91	done
92    fi
93    AC_MSG_RESULT($logpath)
94    SUDO_DEFINE_UNQUOTED(_PATH_SUDO_LOGFILE, "$logpath")
95])dnl
96
97dnl
98dnl Detect time zone file directory, if any.
99dnl
100AC_DEFUN([SUDO_TZDIR], [AC_MSG_CHECKING(time zone data directory)
101tzdir="$with_tzdir"
102if test -z "$tzdir"; then
103    tzdir=no
104    for d in /usr/share /usr/share/lib /usr/lib /etc; do
105	if test -d "$d/zoneinfo"; then
106	    tzdir="$d/zoneinfo"
107	    break
108	fi
109    done
110fi
111AC_MSG_RESULT([$tzdir])
112if test "${tzdir}" != "no"; then
113    SUDO_DEFINE_UNQUOTED(_PATH_ZONEINFO, "$tzdir")
114fi
115])dnl
116
117dnl
118dnl Parent directory for time stamp dir.
119dnl
120AC_DEFUN([SUDO_RUNDIR], [AC_MSG_CHECKING(for sudo run dir location)
121if test -n "$with_rundir"; then
122    rundir="$with_rundir"
123elif test -n "$runstatedir" && test "$runstatedir" != '${localstatedir}/run'; then
124    rundir="$runstatedir/sudo"
125else
126    # No --with-rundir or --runstatedir specified
127    for d in /run /var/run /var/db /var/lib /var/adm /usr/adm; do
128	if test -d "$d"; then
129	    rundir="$d/sudo"
130	    break
131	fi
132    done
133fi
134AC_MSG_RESULT([$rundir])
135SUDO_DEFINE_UNQUOTED(_PATH_SUDO_TIMEDIR, "$rundir/ts")
136SUDO_DEFINE_UNQUOTED(_PATH_SUDO_LOGSRVD_PID, "$rundir/sudo_logsrvd.pid")
137])dnl
138
139dnl
140dnl Parent directory for the lecture status dir.
141dnl
142AC_DEFUN([SUDO_VARDIR], [AC_MSG_CHECKING(for sudo var dir location)
143vardir="$with_vardir"
144if test -z "$vardir"; then
145    for d in /var/db /var/lib /var/adm /usr/adm; do
146	if test -d "$d"; then
147	    vardir="$d/sudo"
148	    break
149	fi
150    done
151fi
152AC_MSG_RESULT([$vardir])
153SUDO_DEFINE_UNQUOTED(_PATH_SUDO_LECTURE_DIR, "$vardir/lectured")
154])dnl
155
156dnl
157dnl Where the sudo_logsrvd relay temporary log files go, use
158dnl /var/log/sudo_logsrvd if /var/log exists, else
159dnl /{var,usr}/adm/sudo_logsrvd
160dnl
161AC_DEFUN([SUDO_RELAY_DIR], [
162    AC_MSG_CHECKING(for sudo_logsrvd relay dir location)
163    if test "${with_relaydir-yes}" != "yes"; then
164	relay_dir="$with_relaydir"
165    else
166	# Default value of relay_dir set in configure.ac
167	for d in /var/log /var/adm /usr/adm; do
168	    if test -d "$d"; then
169		relay_dir="$d/sudo_logsrvd"
170		break
171	    fi
172	done
173    fi
174    if test "${with_relaydir}" != "no"; then
175	SUDO_DEFINE_UNQUOTED(_PATH_SUDO_RELAY_DIR, "$relay_dir")
176    fi
177    AC_MSG_RESULT($relay_dir)
178])dnl
179
180dnl
181dnl Where the I/O log files go, use /var/log/sudo-io if
182dnl /var/log exists, else /{var,usr}/adm/sudo-io
183dnl
184AC_DEFUN([SUDO_IO_LOGDIR], [
185    AC_MSG_CHECKING(for I/O log dir location)
186    if test "${with_iologdir-yes}" != "yes"; then
187	iolog_dir="$with_iologdir"
188    else
189	# Default value of iolog_dir set in configure.ac
190	for d in /var/log /var/adm /usr/adm; do
191	    if test -d "$d"; then
192		iolog_dir="$d/sudo-io"
193		break
194	    fi
195	done
196    fi
197    if test "${with_iologdir}" != "no"; then
198	SUDO_DEFINE_UNQUOTED(_PATH_SUDO_IO_LOGDIR, "$iolog_dir")
199    fi
200    AC_MSG_RESULT($iolog_dir)
201])dnl
202
203dnl
204dnl Where the log files go, use /var/log if it exists, else /{var,usr}/adm
205dnl
206AC_DEFUN([SUDO_LOGDIR], [
207    AC_MSG_CHECKING(for log dir location)
208    if test "${with_logdir-yes}" != "yes"; then
209	log_dir="$with_logdir"
210    else
211	# Default value of log_dir set in configure.ac
212	for d in /var/log /var/adm /usr/adm; do
213	    if test -d "$d"; then
214		log_dir="$d"
215		break
216	    fi
217	done
218    fi
219    if test "${with_logdir}" != "no"; then
220	SUDO_DEFINE_UNQUOTED(_PATH_SUDO_LOGDIR, "$log_dir")
221    fi
222    AC_MSG_RESULT($log_dir)
223])dnl
224
225dnl
226dnl check for working fnmatch(3)
227dnl
228AC_DEFUN([SUDO_FUNC_FNMATCH], [
229    AC_CACHE_CHECK([for working fnmatch with FNM_CASEFOLD],
230    sudo_cv_func_fnmatch, [
231	AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <fnmatch.h>
232int main() { return(fnmatch("/*/bin/echo *", "/usr/bin/echo just a test", FNM_CASEFOLD)); }]])], [sudo_cv_func_fnmatch=yes], [sudo_cv_func_fnmatch=no], [sudo_cv_func_fnmatch=no])
233    ])
234    AS_IF([test $sudo_cv_func_fnmatch = yes], [$1], [$2])
235])
236
237dnl
238dnl Attempt to check for working PIE support.
239dnl This is a bit of a hack but on Solaris 10 with GNU ld and GNU as
240dnl we can end up with strange values from malloc().
241dnl A better check would be to verify that ASLR works with PIE.
242dnl
243AC_DEFUN([SUDO_WORKING_PIE], [
244    AC_CACHE_CHECK([for working PIE support], sudo_cv_working_pie, [
245	AC_RUN_IFELSE([AC_LANG_SOURCE([AC_INCLUDES_DEFAULT
246int main() { char *p = malloc(1024); if (p == NULL) return 1; memset(p, 0, 1024); return 0; }])], [sudo_cv_working_pie=yes], [sudo_cv_working_pie=no], [sudo_cv_working_pie=no])
247    ])
248    AS_IF([test $sudo_cv_working_pie = yes], [$1], [$2])
249])
250
251dnl
252dnl check for isblank(3)
253dnl
254AC_DEFUN([SUDO_FUNC_ISBLANK],
255  [AC_CACHE_CHECK([for isblank], [sudo_cv_func_isblank],
256    [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <ctype.h>]], [[return (isblank('a'));]])],
257    [sudo_cv_func_isblank=yes], [sudo_cv_func_isblank=no])])
258] [
259  if test "$sudo_cv_func_isblank" = "yes"; then
260    AC_DEFINE(HAVE_ISBLANK, 1, [Define if you have isblank(3).])
261  else
262    AC_LIBOBJ(isblank)
263    SUDO_APPEND_COMPAT_EXP(isblank)
264  fi
265])
266
267AC_DEFUN([SUDO_CHECK_LIB], [
268    _sudo_check_lib_extras=`echo "$5"|sed -e 's/[ 	]*//g' -e 's/-l/_/g'`
269    AC_MSG_CHECKING([for $2 in -l$1${5+ }$5])
270    AC_CACHE_VAL([sudo_cv_lib_$1''_$2$_sudo_check_lib_extras], [
271	SUDO_CHECK_LIB_OLIBS="$LIBS"
272	LIBS="$LIBS -l$1${5+ }$5"
273	AC_LINK_IFELSE(
274	    [AC_LANG_CALL([], [$2])],
275	    [eval sudo_cv_lib_$1''_$2$_sudo_check_lib_extras=yes],
276	    [eval sudo_cv_lib_$1''_$2$_sudo_check_lib_extras=no]
277	)
278	LIBS="$SUDO_CHECK_LIB_OLIBS"
279    ])
280    if eval test \$sudo_cv_lib_$1''_$2$_sudo_check_lib_extras = "yes"; then
281	AC_MSG_RESULT([yes])
282	$3
283    else
284	AC_MSG_RESULT([no])
285	$4
286    fi
287])
288
289dnl
290dnl check unsetenv() return value
291dnl
292AC_DEFUN([SUDO_FUNC_UNSETENV_VOID],
293  [AC_CACHE_CHECK([whether unsetenv returns void], [sudo_cv_func_unsetenv_void],
294    [AC_RUN_IFELSE([AC_LANG_PROGRAM(
295      [AC_INCLUDES_DEFAULT
296        int unsetenv();
297      ], [
298        [return unsetenv("FOO") != 0;]
299      ])
300    ],
301    [sudo_cv_func_unsetenv_void=no],
302    [sudo_cv_func_unsetenv_void=yes],
303    [sudo_cv_func_unsetenv_void=no])])
304    if test $sudo_cv_func_unsetenv_void = yes; then
305      AC_DEFINE(UNSETENV_VOID, 1,
306        [Define to 1 if the `unsetenv' function returns void instead of `int'.])
307    fi
308  ])
309
310dnl
311dnl check putenv() argument for const
312dnl
313AC_DEFUN([SUDO_FUNC_PUTENV_CONST],
314[AC_CACHE_CHECK([whether putenv takes a const argument],
315sudo_cv_func_putenv_const,
316[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
317int putenv(const char *string) {return 0;}], [])],
318    [sudo_cv_func_putenv_const=yes],
319    [sudo_cv_func_putenv_const=no])
320  ])
321  if test $sudo_cv_func_putenv_const = yes; then
322    AC_DEFINE(PUTENV_CONST, const, [Define to const if the `putenv' takes a const argument.])
323  else
324    AC_DEFINE(PUTENV_CONST, [])
325  fi
326])
327
328dnl
329dnl check whether au_close() takes 3 or 4 arguments
330dnl
331AC_DEFUN([SUDO_FUNC_AU_CLOSE_SOLARIS11],
332[AC_CACHE_CHECK([whether au_close() takes 4 arguments],
333sudo_cv_func_au_close_solaris11,
334[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
335#include <bsm/audit.h>
336#include <bsm/libbsm.h>
337#include <bsm/audit_uevents.h>
338
339int au_close(int d, int keep, au_event_t event, au_emod_t emod) {return 0;}], [])],
340    [sudo_cv_func_au_close_solaris11=yes],
341    [sudo_cv_func_au_close_solaris11=no])
342  ])
343  if test $sudo_cv_func_au_close_solaris11 = yes; then
344    AC_DEFINE(HAVE_AU_CLOSE_SOLARIS11, 1, [Define to 1 if the `au_close' functions takes 4 arguments like Solaris 11.])
345  fi
346])
347
348dnl
349dnl Check if the data argument for the sha2 functions is void * or u_char *
350dnl
351AC_DEFUN([SUDO_FUNC_SHA2_VOID_PTR],
352[AC_CACHE_CHECK([whether the data argument of SHA224Update() is void *],
353sudo_cv_func_sha2_void_ptr,
354[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
355#include <sha2.h>
356void SHA224Update(SHA2_CTX *context, const void *data, size_t len) {return;}], [])],
357    [sudo_cv_func_sha2_void_ptr=yes],
358    [sudo_cv_func_sha2_void_ptr=no])
359  ])
360  if test $sudo_cv_func_sha2_void_ptr = yes; then
361    AC_DEFINE(SHA2_VOID_PTR, 1,
362      [Define to 1 if the sha2 functions use `const void *' instead of `const unsigned char'.])
363  fi
364])
365
366dnl
367dnl check for sa_len field in struct sockaddr
368dnl
369AC_DEFUN([SUDO_SOCK_SA_LEN], [
370    AC_CHECK_MEMBER([struct sockaddr.sa_len],
371	[AC_DEFINE(HAVE_STRUCT_SOCKADDR_SA_LEN, 1, [Define if your struct sockaddr has an sa_len field.])],
372	[], [
373#	  include <sys/types.h>
374#	  include <sys/socket.h>]
375    )]
376)
377
378dnl
379dnl check for sin_len field in struct sockaddr_in
380dnl
381AC_DEFUN([SUDO_SOCK_SIN_LEN], [
382    AC_CHECK_MEMBER([struct sockaddr_in.sin_len],
383	[AC_DEFINE(HAVE_STRUCT_SOCKADDR_IN_SIN_LEN, 1, [Define if your struct sockaddr_in has a sin_len field.])],
384	[], [
385#	  include <sys/types.h>
386#	  include <sys/socket.h>]
387    )]
388)
389
390dnl
391dnl check for max length of uid_t in string representation.
392dnl we can't really trust UID_MAX or MAXUID since they may exist
393dnl only for backward compatibility.
394dnl
395AC_DEFUN([SUDO_UID_T_LEN],
396[AC_REQUIRE([AC_TYPE_UID_T])
397AC_CACHE_CHECK([max length of uid_t], sudo_cv_uid_t_len, [
398rm -f conftestdata
399AC_RUN_IFELSE([AC_LANG_SOURCE([[
400#include <stdio.h>
401#include <string.h>
402#include <pwd.h>
403#include <limits.h>
404#include <sys/types.h>
405int main() {
406  FILE *f;
407  char b[1024];
408  uid_t u = (uid_t) -1;
409
410  if ((f = fopen("conftestdata", "w")) == NULL)
411    return(1);
412
413  (void) sprintf(b, "%lu", (unsigned long) u);
414  (void) fprintf(f, "%d\n", (int)strlen(b));
415  (void) fclose(f);
416  return(0);
417}]])], [sudo_cv_uid_t_len=`cat conftestdata`], [sudo_cv_uid_t_len=10], [sudo_cv_uid_t_len=10])
418])
419rm -f conftestdata
420AC_DEFINE_UNQUOTED(MAX_UID_T_LEN, $sudo_cv_uid_t_len, [Define to the max length of a uid_t in string context (excluding the NUL).])
421])
422
423dnl
424dnl There are three different utmp variants we need to check for.
425dnl SUDO_CHECK_UTMP_MEMBERS(utmp_type)
426dnl
427AC_DEFUN([SUDO_CHECK_UTMP_MEMBERS], [
428    dnl
429    dnl Check for utmp/utmpx/utmps struct members.
430    dnl
431    AC_CHECK_MEMBER([struct $1.ut_id], [
432	AC_DEFINE(HAVE_STRUCT_UTMP_UT_ID, 1, [Define to 1 if `ut_id' is a member of `struct utmp'.])
433    ], [], [
434#	include <sys/types.h>
435#	include <$1.h>
436    ])
437    AC_CHECK_MEMBER([struct $1.ut_pid], [
438	AC_DEFINE(HAVE_STRUCT_UTMP_UT_PID, 1, [Define to 1 if `ut_pid' is a member of `struct utmp'.])
439    ], [], [
440#	include <sys/types.h>
441#	include <$1.h>
442    ])
443    AC_CHECK_MEMBER([struct $1.ut_tv], [
444	AC_DEFINE(HAVE_STRUCT_UTMP_UT_TV, 1, [Define to 1 if `ut_tv' is a member of `struct utmp'.])
445    ], [], [
446#	include <sys/types.h>
447#	include <$1.h>
448    ])
449    AC_CHECK_MEMBER([struct $1.ut_type], [
450	AC_DEFINE(HAVE_STRUCT_UTMP_UT_TYPE, 1, [Define to 1 if `ut_type' is a member of `struct utmp'.])
451    ], [], [
452#	include <sys/types.h>
453#	include <$1.h>
454    ])
455    dnl
456    dnl Older struct utmp has ut_name instead of ut_user
457    dnl
458    if test "$1" = "utmp"; then
459	AC_CHECK_MEMBERS([struct utmp.ut_user], [], [], [
460#	include <sys/types.h>
461#	include <$1.h>
462	])
463    fi
464    dnl
465    dnl Check for ut_exit.__e_termination first, then ut_exit.e_termination
466    dnl We need to have already defined _GNU_SOURCE on glibc which only has
467    dnl __e_termination visible when _GNU_SOURCE is *not* defined.
468    dnl
469    AC_CHECK_MEMBER([struct $1.ut_exit.__e_termination], [
470	AC_DEFINE(HAVE_STRUCT_UTMP_UT_EXIT, 1, [Define to 1 if `ut_exit' is a member of `struct utmp'.])
471	AC_DEFINE(HAVE_STRUCT_UTMP_UT_EXIT___E_TERMINATION, 1, [Define to 1 if `ut_exit.__e_termination' is a member of `struct utmp'.])
472    ], [
473	AC_CHECK_MEMBER([struct $1.ut_exit.e_termination], [
474	    AC_DEFINE(HAVE_STRUCT_UTMP_UT_EXIT, 1, [Define to 1 if `ut_exit' is a member of `struct utmp'.])
475	    AC_DEFINE(HAVE_STRUCT_UTMP_UT_EXIT_E_TERMINATION, 1, [Define to 1 if `ut_exit.e_termination' is a member of `struct utmp'.])
476	], [], [
477#	    include <sys/types.h>
478#	    include <$1.h>
479	])
480    ], [
481#	include <sys/types.h>
482#	include <$1.h>
483    ])
484])
485
486dnl
487dnl Append a libpath to an LDFLAGS style variable if not already present.
488dnl Also appends to the _R version unless rpath is disabled.
489dnl
490AC_DEFUN([SUDO_APPEND_LIBPATH], [
491    AX_APPEND_FLAG([-L$2], [$1])
492    if test X"$enable_rpath" = X"yes"; then
493	AX_APPEND_FLAG([-R$2], [$1_R])
494    fi
495])
496
497dnl
498dnl Append one or more symbols to COMPAT_EXP
499dnl
500AC_DEFUN([SUDO_APPEND_COMPAT_EXP], [
501    for _sym in $1; do
502	COMPAT_EXP="${COMPAT_EXP}${_sym}
503"
504    done
505])
506
507dnl
508dnl
509dnl Append one or more symbols to INTERCEPT_EXP
510dnl
511AC_DEFUN([SUDO_APPEND_INTERCEPT_EXP], [
512    for _sym in $1; do
513	INTERCEPT_EXP="${INTERCEPT_EXP}${_sym}
514"
515    done
516])
517
518dnl
519dnl Determine the mail spool location
520dnl NOTE: must be run *after* check for paths.h
521dnl
522AC_DEFUN([SUDO_MAILDIR], [
523maildir=no
524if test X"$ac_cv_header_paths_h" = X"yes"; then
525AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
526#include <paths.h>],
527[char *p = _PATH_MAILDIR;])], [maildir=yes], [])
528fi
529if test $maildir = no; then
530    # Solaris has maillock.h which defines MAILDIR
531    AC_CHECK_HEADERS(maillock.h, [
532	SUDO_DEFINE(_PATH_MAILDIR, MAILDIR)
533	maildir=yes
534    ])
535    if test $maildir = no; then
536	for d in /var/mail /var/spool/mail /usr/spool/mail; do
537	    if test -d "$d"; then
538		maildir=yes
539		SUDO_DEFINE_UNQUOTED(_PATH_MAILDIR, "$d")
540		break
541	    fi
542	done
543	if test $maildir = no; then
544	    # unable to find mail dir, hope for the best
545	    SUDO_DEFINE_UNQUOTED(_PATH_MAILDIR, "/var/mail")
546	fi
547    fi
548fi
549])
550
551dnl
552dnl private versions of AC_DEFINE and AC_DEFINE_UNQUOTED that don't support
553dnl tracing that we use to define paths for pathnames.h so autoheader doesn't
554dnl put them in config.h.in.  An awful hack.
555dnl
556m4_define([SUDO_DEFINE],
557[cat >>confdefs.h <<\EOF
558[@%:@define] $1 m4_if($#, 2, [$2], $#, 3, [$2], 1)
559EOF
560])
561
562m4_define([SUDO_DEFINE_UNQUOTED],
563[cat >>confdefs.h <<EOF
564[@%:@define] $1 m4_if($#, 2, [$2], $#, 3, [$2], 1)
565EOF
566])
567