]> git.ipfire.org Git - thirdparty/shadow.git/blame - configure.ac
src/sulogin.c: Invert logic to reduce indentation
[thirdparty/shadow.git] / configure.ac
CommitLineData
45c6603c 1dnl Process this file with autoconf to produce a configure script.
43a917cc 2AC_PREREQ([2.69])
32f641b2 3m4_define([libsubid_abi_major], 4)
43a917cc
SH
4m4_define([libsubid_abi_minor], 0)
5m4_define([libsubid_abi_micro], 0)
6m4_define([libsubid_abi], [libsubid_abi_major.libsubid_abi_minor.libsubid_abi_micro])
ba43b49a 7AC_INIT([shadow], [4.15.0], [pkg-shadow-devel@lists.alioth.debian.org], [],
84f0ae00 8 [https://github.com/shadow-maint/shadow])
d1ad64b4 9AM_INIT_AUTOMAKE([1.11 foreign dist-xz subdir-objects])
43a917cc 10AC_CONFIG_MACRO_DIRS([m4])
6e91297f 11AM_SILENT_RULES([yes])
effd479b 12AC_CONFIG_HEADERS([config.h])
45c6603c 13
43a917cc
SH
14AC_SUBST([LIBSUBID_ABI_MAJOR], [libsubid_abi_major])
15AC_SUBST([LIBSUBID_ABI_MINOR], [libsubid_abi_minor])
16AC_SUBST([LIBSUBID_ABI_MICRO], [libsubid_abi_micro])
17AC_SUBST([LIBSUBID_ABI], [libsubid_abi])
18
45c6603c 19dnl Some hacks...
20test "$prefix" = "NONE" && prefix="/usr"
21test "$prefix" = "/usr" && exec_prefix=""
45c6603c 22
48ceff86 23AC_USE_SYSTEM_EXTENSIONS
8e167d28 24
caad9b98
CG
25AC_ENABLE_STATIC
26AC_ENABLE_SHARED
3bc49967 27
effd479b 28AM_MAINTAINER_MODE
29
45c6603c 30dnl Checks for programs.
31AC_PROG_CC
45c6603c 32AC_PROG_LN_S
45c6603c 33AC_PROG_YACC
48ceff86 34LT_INIT
0f4e59fd 35LT_LIB_DLLOAD
45c6603c 36
37dnl Checks for libraries.
38
39dnl Checks for header files.
85d2688d 40AC_CHECK_HEADERS(crypt.h utmp.h \
eecd021c 41 termio.h sgtty.h sys/ioctl.h paths.h \
9d695340 42 sys/capability.h sys/random.h \
48391fb8 43 gshadow.h lastlog.h rpc/key_prot.h acl/libacl.h \
c82ed0c1 44 attr/libattr.h attr/error_context.h)
3bc49967 45
db0dddc6 46dnl shadow now uses the libc's shadow implementation
47AC_CHECK_HEADER([shadow.h],,[AC_MSG_ERROR([You need a libc with shadow.h])])
48
a082a397 49AC_CHECK_FUNCS(arc4random_buf futimes \
eefaf55b 50 getentropy getrandom getspnam getusershell \
c1fd94d7 51 initgroups lckpwdf lutimes \
64bcb54f 52 setgroups updwtmpx innetgr \
cbc363f6 53 getspnam_r \
e28deeb8 54 rpmatch \
709e6b44 55 memset_explicit explicit_bzero stpecpy stpeprintf)
0ee095ab 56AC_SYS_LARGEFILE
45c6603c 57
58dnl Checks for typedefs, structures, and compiler characteristics.
45c6603c 59
64bcb54f
AC
60AC_CHECK_MEMBERS([struct utmpx.ut_name,
61 struct utmpx.ut_host,
62 struct utmpx.ut_syslen,
63 struct utmpx.ut_addr,
64 struct utmpx.ut_addr_v6,
65 struct utmpx.ut_time,
66 struct utmpx.ut_xtime],,,[[#include <utmpx.h>]])
45c6603c 67
45c6603c 68dnl Checks for library functions.
69AC_TYPE_GETGROUPS
45c6603c 70AC_FUNC_UTIME_NULL
06f4acee 71AC_REPLACE_FUNCS(putgrent putpwent putspent)
45c6603c 72AC_REPLACE_FUNCS(sgetgrent sgetpwent sgetspent)
45c6603c 73
74AC_CHECK_FUNC(setpgrp)
3d921155
CL
75AC_CHECK_FUNC(secure_getenv, [AC_DEFINE(HAS_SECURE_GETENV,
76 1,
77 [Defined to 1 if you have the declaration of 'secure_getenv'])])
45c6603c 78
79if test "$ac_cv_header_shadow_h" = "yes"; then
b48129fc 80 AC_CACHE_CHECK(for working shadow group support,
81 ac_cv_libc_shadowgrp,
82 AC_RUN_IFELSE([AC_LANG_SOURCE([
83 #include <shadow.h>
a281f241
FW
84 #ifdef HAVE_GSHADOW_H
85 #include <gshadow.h>
86 #endif
87 int
b48129fc 88 main()
89 {
90 struct sgrp *sg = sgetsgent("test:x::");
91 /* NYS libc on Red Hat 3.0.3 has broken shadow group support */
92 return !sg || !sg->sg_adm || !sg->sg_mem;
93 }]
94 )],
95 [ac_cv_libc_shadowgrp=yes],
96 [ac_cv_libc_shadowgrp=no],
97 [ac_cv_libc_shadowgrp=no]
98 )
effd479b 99 )
45c6603c 100
b48129fc 101 if test "$ac_cv_libc_shadowgrp" = "yes"; then
102 AC_DEFINE(HAVE_SHADOWGRP, 1, [Have working shadow group support in libc])
103 fi
45c6603c 104fi
105
b0e078d9 106AC_CACHE_CHECK([location of shared mail directory], shadow_cv_maildir,
164b5570 107[for shadow_cv_maildir in /var/mail /var/spool/mail /usr/spool/mail /usr/mail none; do
108 if test -d $shadow_cv_maildir; then
45c6603c 109 break
110 fi
b0e078d9 111done])
164b5570 112if test $shadow_cv_maildir != none; then
b48129fc 113 AC_DEFINE_UNQUOTED(MAIL_SPOOL_DIR, "$shadow_cv_maildir",
114 [Location of system mail spool directory.])
164b5570 115fi
b0e078d9 116
117AC_CACHE_CHECK([location of user mail file], shadow_cv_mailfile,
164b5570 118[for shadow_cv_mailfile in Mailbox mailbox Mail mail .mail none; do
b0e078d9 119 if test -f $HOME/$shadow_cv_mailfile; then
45c6603c 120 break
121 fi
b0e078d9 122done])
164b5570 123if test $shadow_cv_mailfile != none; then
b48129fc 124 AC_DEFINE_UNQUOTED(MAIL_SPOOL_FILE, "$shadow_cv_mailfile",
125 [Name of user's mail spool file if stored in user's home directory.])
164b5570 126fi
b0e078d9 127
128AC_CACHE_CHECK([location of utmp], shadow_cv_utmpdir,
8e167d28 129[for shadow_cv_utmpdir in /var/run /var/adm /usr/adm /etc none; do
b0e078d9 130 if test -f $shadow_cv_utmpdir/utmp; then
45c6603c 131 break
132 fi
b0e078d9 133done])
134if test "$shadow_cv_utmpdir" = "none"; then
135 AC_MSG_WARN(utmp file not found)
136fi
b48129fc 137AC_DEFINE_UNQUOTED(_UTMP_FILE, "$shadow_cv_utmpdir/utmp",
138 [Path for utmp file.])
45c6603c 139
b0e078d9 140AC_CACHE_CHECK([location of faillog/lastlog/wtmp], shadow_cv_logdir,
141[for shadow_cv_logdir in /var/log /var/adm /usr/adm /etc; do
24178ad6 142 if test -d $shadow_cv_logdir; then
45c6603c 143 break
144 fi
b0e078d9 145done])
b48129fc 146AC_DEFINE_UNQUOTED(_WTMP_FILE, "$shadow_cv_logdir/wtmp",
147 [Path for wtmp file.])
148AC_DEFINE_UNQUOTED(LASTLOG_FILE, "$shadow_cv_logdir/lastlog",
149 [Path for lastlog file.])
150AC_DEFINE_UNQUOTED(FAILLOG_FILE, "$shadow_cv_logdir/faillog",
151 [Path for faillog file.])
b0e078d9 152
153AC_CACHE_CHECK([location of the passwd program], shadow_cv_passwd_dir,
154[if test -f /usr/bin/passwd; then
155 shadow_cv_passwd_dir=/usr/bin
45c6603c 156else
b0e078d9 157 shadow_cv_passwd_dir=/bin
158fi])
b48129fc 159AC_DEFINE_UNQUOTED(PASSWD_PROGRAM, "$shadow_cv_passwd_dir/passwd",
160 [Path to passwd program.])
45c6603c 161
162dnl XXX - quick hack, should disappear before anyone notices :).
428a2078 163dnl XXX - I just read the above message :).
561ba96e
MF
164if test "$ac_cv_func_ruserok" = "yes"; then
165 AC_DEFINE(RLOGIN, 1, [Define if login should support the -r flag for rlogind.])
166 AC_DEFINE(RUSEROK, 0, [Define to the ruserok() "success" return value (0 or 1).])
167fi
45c6603c 168
1de90a59 169AC_ARG_ENABLE(shadowgrp,
48ceff86 170 [AS_HELP_STRING([--enable-shadowgrp], [enable shadow group support @<:@default=yes@:>@])],
1de90a59 171 [case "${enableval}" in
172 yes) enable_shadowgrp="yes" ;;
173 no) enable_shadowgrp="no" ;;
174 *) AC_MSG_ERROR(bad value ${enableval} for --enable-shadowgrp) ;;
175 esac],
e89f3546 176 [enable_shadowgrp="yes"]
1de90a59 177)
45c6603c 178
8451bed8 179AC_ARG_ENABLE(man,
48ceff86 180 [AS_HELP_STRING([--enable-man],
8451bed8 181 [regenerate roff man pages from Docbook @<:@default=no@:>@])],
8098f639 182 [enable_man="${enableval}"],
13b74243 183 [enable_man="no"]
8451bed8 184)
185
f8aef607 186AC_ARG_ENABLE(account-tools-setuid,
48ceff86 187 [AS_HELP_STRING([--enable-account-tools-setuid],
726abe8a 188 [Install the user and group management tools setuid and authenticate the callers. This requires --with-libpam.])],
f8aef607 189 [case "${enableval}" in
190 yes) enable_acct_tools_setuid="yes" ;;
191 no) enable_acct_tools_setuid="no" ;;
192 *) AC_MSG_ERROR(bad value ${enableval} for --enable-account-tools-setuid)
193 ;;
194 esac],
66b7bc0d 195 [enable_acct_tools_setuid="no"]
f8aef607 196)
197
d611d54e 198AC_ARG_ENABLE(subordinate-ids,
48ceff86 199 [AS_HELP_STRING([--enable-subordinate-ids],
d611d54e
NF
200 [support subordinate ids @<:@default=yes@:>@])],
201 [enable_subids="${enableval}"],
1a8d3862 202 [enable_subids="maybe"]
d611d54e
NF
203)
204
1bdcfa8d
IP
205AC_ARG_ENABLE(lastlog,
206 [AS_HELP_STRING([--enable-lastlog],
207 [enable lastlog @<:@default=no@:>@])],
208 [enable_lastlog="${enableval}"],
209 [enable_lastlog="no"]
210)
211
fb35ad15
IP
212AC_ARG_ENABLE(logind,
213 [AS_HELP_STRING([--enable-logind],
214 [enable logind @<:@default=yes@:>@])],
215 [enable_logind="${enableval}"],
216 [enable_logind="yes"]
217)
218
b52ce71c 219AC_ARG_WITH(audit,
48ceff86 220 [AS_HELP_STRING([--with-audit], [use auditing support @<:@default=yes if found@:>@])],
70bf7cca 221 [with_audit=$withval], [with_audit=maybe])
8451bed8 222AC_ARG_WITH(libpam,
48ceff86 223 [AS_HELP_STRING([--with-libpam], [use libpam for PAM support @<:@default=yes if found@:>@])],
8e82ae23 224 [with_libpam=$withval], [with_libpam=maybe])
50b23584 225AC_ARG_WITH(btrfs,
48ceff86 226 [AS_HELP_STRING([--with-btrfs], [add BtrFS support @<:@default=yes if found@:>@])],
816220f9 227 [with_btrfs=$withval], [with_btrfs=maybe])
8451bed8 228AC_ARG_WITH(selinux,
48ceff86 229 [AS_HELP_STRING([--with-selinux], [use SELinux support @<:@default=yes if found@:>@])],
8e82ae23 230 [with_selinux=$withval], [with_selinux=maybe])
902aad57 231AC_ARG_WITH(acl,
48ceff86 232 [AS_HELP_STRING([--with-acl], [use ACL support @<:@default=yes if found@:>@])],
47733f1a 233 [with_acl=$withval], [with_acl=maybe])
234AC_ARG_WITH(attr,
48ceff86 235 [AS_HELP_STRING([--with-attr], [use Extended Attribute support @<:@default=yes if found@:>@])],
902aad57 236 [with_attr=$withval], [with_attr=maybe])
8451bed8 237AC_ARG_WITH(skey,
48ceff86 238 [AS_HELP_STRING([--with-skey], [use S/Key support @<:@default=no@:>@])],
8451bed8 239 [with_skey=$withval], [with_skey=no])
c5c94a1d 240AC_ARG_WITH(tcb,
48ceff86 241 [AS_HELP_STRING([--with-tcb], [use tcb support (incomplete) @<:@default=yes if found@:>@])],
c5c94a1d 242 [with_tcb=$withval], [with_tcb=maybe])
4d606cc6 243AC_ARG_WITH(sha-crypt,
48ceff86 244 [AS_HELP_STRING([--with-sha-crypt], [allow the SHA256 and SHA512 password encryption algorithms @<:@default=yes@:>@])],
4d606cc6 245 [with_sha_crypt=$withval], [with_sha_crypt=yes])
2958bd05 246AC_ARG_WITH(bcrypt,
48ceff86 247 [AS_HELP_STRING([--with-bcrypt], [allow the bcrypt password encryption algorithm @<:@default=no@:>@])],
2958bd05 248 [with_bcrypt=$withval], [with_bcrypt=no])
5cd04d03 249AC_ARG_WITH(yescrypt,
48ceff86 250 [AS_HELP_STRING([--with-yescrypt], [allow the yescrypt password encryption algorithm @<:@default=no@:>@])],
5cd04d03 251 [with_yescrypt=$withval], [with_yescrypt=no])
c59126a8 252AC_ARG_WITH(nscd,
48ceff86 253 [AS_HELP_STRING([--with-nscd], [enable support for nscd @<:@default=yes@:>@])],
c59126a8 254 [with_nscd=$withval], [with_nscd=yes])
4aaf05d7 255AC_ARG_WITH(sssd,
48ceff86 256 [AS_HELP_STRING([--with-sssd], [enable support for flushing sssd caches @<:@default=yes@:>@])],
4aaf05d7 257 [with_sssd=$withval], [with_sssd=yes])
c28c443d 258AC_ARG_WITH(group-name-max-length,
48ceff86 259 [AS_HELP_STRING([--with-group-name-max-length], [set max group name length @<:@default=32@:>@])],
c28c443d 260 [with_group_name_max_length=$withval], [with_group_name_max_length=yes])
19bac44d 261AC_ARG_WITH(su,
48ceff86 262 [AS_HELP_STRING([--with-su], [build and install su program and man page @<:@default=yes@:>@])],
19bac44d 263 [with_su=$withval], [with_su=yes])
c408c4ad
IP
264AC_ARG_WITH(libbsd,
265 [AS_HELP_STRING([--with-libbsd], [use libbsd support @<:@default=yes if found@:>@])],
266 [with_libbsd=$withval], [with_libbsd=yes])
c28c443d 267
268if test "$with_group_name_max_length" = "no" ; then
269 with_group_name_max_length=0
270elif test "$with_group_name_max_length" = "yes" ; then
1882c66b 271 with_group_name_max_length=32
c28c443d 272fi
273AC_DEFINE_UNQUOTED(GROUP_NAME_MAX_LENGTH, $with_group_name_max_length, [max group name length])
4c7d7983 274AC_SUBST(GROUP_NAME_MAX_LENGTH)
275GROUP_NAME_MAX_LENGTH="$with_group_name_max_length"
4d606cc6 276
277AM_CONDITIONAL(USE_SHA_CRYPT, test "x$with_sha_crypt" = "xyes")
278if test "$with_sha_crypt" = "yes"; then
978b3ef8 279 AC_DEFINE(USE_SHA_CRYPT, 1, [Define to allow the SHA256 and SHA512 password encryption algorithms])
4d606cc6 280fi
45c6603c 281
2958bd05 282AM_CONDITIONAL(USE_BCRYPT, test "x$with_bcrypt" = "xyes")
283if test "$with_bcrypt" = "yes"; then
284 AC_DEFINE(USE_BCRYPT, 1, [Define to allow the bcrypt password encryption algorithm])
285fi
286
5cd04d03
RB
287AM_CONDITIONAL(USE_YESCRYPT, test "x$with_yescrypt" = "xyes")
288if test "$with_yescrypt" = "yes"; then
289 AC_DEFINE(USE_YESCRYPT, 1, [Define to allow the yescrypt password encryption algorithm])
290fi
291
c59126a8 292if test "$with_nscd" = "yes"; then
8075d27e 293 AC_CHECK_FUNC(posix_spawn,
294 [AC_DEFINE(USE_NSCD, 1, [Define to support flushing of nscd caches])],
295 [AC_MSG_ERROR([posix_spawn is needed for nscd support])])
c59126a8 296fi
297
4aaf05d7
JH
298if test "$with_sssd" = "yes"; then
299 AC_CHECK_FUNC(posix_spawn,
300 [AC_DEFINE(USE_SSSD, 1, [Define to support flushing of sssd caches])],
301 [AC_MSG_ERROR([posix_spawn is needed for sssd support])])
302fi
303
049f9a7f 304AS_IF([test "$with_su" != "no"], AC_DEFINE(WITH_SU, 1, [Build with su]))
19bac44d
LW
305AM_CONDITIONAL([WITH_SU], [test "x$with_su" != "xno"])
306
45c6603c 307dnl Check for some functions in libc first, only if not found check for
308dnl other libraries. This should prevent linking libnsl if not really
309dnl needed (Linux glibc, Irix), but still link it if needed (Solaris).
310
b0e078d9 311AC_SEARCH_LIBS(gethostbyname, nsl)
45c6603c 312
b52ce71c
TK
313AC_CHECK_LIB([econf],[econf_readDirs],[LIBECONF="-leconf"],[LIBECONF=""])
314if test -n "$LIBECONF"; then
a27d5c51
SS
315 AC_DEFINE_UNQUOTED([VENDORDIR], ["$enable_vendordir"],
316 [Directory for distribution provided configuration files])
b52ce71c
TK
317 ECONF_CPPFLAGS="-DUSE_ECONF=1"
318 AC_ARG_ENABLE([vendordir],
319 AS_HELP_STRING([--enable-vendordir=DIR], [Directory for distribution provided configuration files]),,[])
320fi
321AC_SUBST(ECONF_CPPFLAGS)
322AC_SUBST(LIBECONF)
323AC_SUBST([VENDORDIR], [$enable_vendordir])
a27d5c51
SS
324if test "x$enable_vendordir" != x; then
325 AC_DEFINE(HAVE_VENDORDIR, 1, [Define to support vendor settings.])
326fi
b52ce71c
TK
327AM_CONDITIONAL([HAVE_VENDORDIR], [test "x$enable_vendordir" != x])
328
b48129fc 329if test "$enable_shadowgrp" = "yes"; then
330 AC_DEFINE(SHADOWGRP, 1, [Define to support the shadow group file.])
45c6603c 331fi
b2c58c81 332AM_CONDITIONAL(SHADOWGRP, test "x$enable_shadowgrp" = "xyes")
45c6603c 333
8451bed8 334if test "$enable_man" = "yes"; then
335 dnl
336 dnl Check for xsltproc
337 dnl
338 AC_PATH_PROG([XSLTPROC], [xsltproc])
339 if test -z "$XSLTPROC"; then
340 enable_man=no
ef6890c3 341 AC_MSG_ERROR([xsltproc is missing.])
8451bed8 342 fi
343
344 dnl check for DocBook DTD and stylesheets in the local catalog.
47797ca6
JT
345 JH_CHECK_XML_CATALOG([-//OASIS//DTD DocBook XML V4.5//EN],
346 [DocBook XML DTD V4.5], [], enable_man=no)
8a78a8d6 347 JH_CHECK_XML_CATALOG([http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl],
0fa90830 348 [DocBook XSL Stylesheets >= 1.70.1], [], enable_man=no)
8451bed8 349fi
8098f639 350AM_CONDITIONAL(ENABLE_REGENERATE_MAN, test "x$enable_man" != "xno")
8451bed8 351
1a8d3862 352if test "$enable_subids" != "no"; then
d611d54e
NF
353 dnl
354 dnl FIXME: check if 32 bit UIDs/GIDs are supported by libc
355 dnl
2cb54158
JLC
356 AC_CHECK_SIZEOF([uid_t],, [#include "sys/types.h"])
357 AC_CHECK_SIZEOF([gid_t],, [#include "sys/types.h"])
358
359 if test "$ac_cv_sizeof_uid_t" -ge 4 && test "$ac_cv_sizeof_gid_t" -ge 4; then
1a8d3862
NF
360 AC_DEFINE(ENABLE_SUBIDS, 1, [Define to support the subordinate IDs.])
361 enable_subids="yes"
362 else
363 if test "x$enable_subids" = "xyes"; then
364 AC_MSG_ERROR([Cannot enable support the subordinate IDs on systems where gid_t or uid_t has less than 32 bits])
365 fi
366 enable_subids="no"
367 fi
d611d54e
NF
368fi
369AM_CONDITIONAL(ENABLE_SUBIDS, test "x$enable_subids" != "xno")
370
6f4dc321 371if test "$enable_lastlog" = "yes" && test "$ac_cv_header_lastlog_h" = "yes"; then
1bdcfa8d
IP
372 AC_CACHE_CHECK(for ll_host in struct lastlog,
373 ac_cv_struct_lastlog_ll_host,
374 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <lastlog.h>],
375 [struct lastlog ll; char *cp = ll.ll_host;]
376 )],
377 [ac_cv_struct_lastlog_ll_host=yes],
378 [ac_cv_struct_lastlog_ll_host=no]
379 )
380 )
381
382 if test "$ac_cv_struct_lastlog_ll_host" = "yes"; then
383 AC_DEFINE(HAVE_LL_HOST, 1,
384 [Define if struct lastlog has ll_host])
6f4dc321 385 AC_DEFINE(ENABLE_LASTLOG, 1, [Define to support lastlog.])
1bdcfa8d
IP
386 enable_lastlog="yes"
387 else
388 AC_MSG_ERROR([Cannot enable support for lastlog on systems where the data structures aren't available])
389 enable_subids="no"
390 fi
391fi
392AM_CONDITIONAL(ENABLE_LASTLOG, test "x$enable_lastlog" != "xno")
393
fb35ad15
IP
394AC_SUBST(LIBSYSTEMD)
395if test "$enable_logind" = "yes"; then
396 AC_CHECK_LIB(systemd, sd_session_get_remote_host,
397 [enable_logind="yes"; [LIBSYSTEMD=-lsystemd];
398 AC_DEFINE(ENABLE_LOGIND, 1,
399 [Define to manage session support with logind.])],
400 [enable_logind="no"])
401fi
402AM_CONDITIONAL(ENABLE_LOGIND, test "x$enable_logind" != "xno")
403
45c6603c 404AC_SUBST(LIBCRYPT)
b48129fc 405AC_CHECK_LIB(crypt, crypt, [LIBCRYPT=-lcrypt],
406 [AC_MSG_ERROR([crypt() not found])])
45c6603c 407
5cd04d03
RB
408AC_SUBST(LIYESCRYPT)
409AC_CHECK_LIB(crypt, crypt, [LIYESCRYPT=-lcrypt],
410 [AC_MSG_ERROR([crypt() not found])])
411
c408c4ad
IP
412AC_SUBST(LIBBSD)
413if test "$with_libbsd" != "no"; then
414 AC_SEARCH_LIBS([readpassphrase], [bsd], [], [
415 AC_MSG_ERROR([readpassphrase() is missing, either from libc or libbsd])
416 ])
417 AS_IF([test "$ac_cv_search_readpassphrase" = "-lbsd"], [
418 PKG_CHECK_MODULES([LIBBSD], [libbsd-overlay])
419 ])
420 dnl Make sure either the libc or libbsd provide the header.
421 save_CFLAGS="$CFLAGS"
422 CFLAGS="$CFLAGS $LIBBSD_CFLAGS"
423 AC_CHECK_HEADERS([readpassphrase.h])
424 AS_IF([test "$ac_cv_header_readpassphrase_h" != "yes"], [
425 AC_MSG_ERROR([readpassphrase.h is missing])
426 ])
427 CFLAGS="$save_CFLAGS"
428 AC_DEFINE(WITH_LIBBSD, 1, [Build shadow with libbsd support])
429else
430 AC_DEFINE(WITH_LIBBSD, 0, [Build shadow without libbsd support])
431fi
432AM_CONDITIONAL(WITH_LIBBSD, test x$with_libbsd = xyes)
2a5b8810 433
902aad57 434AC_SUBST(LIBACL)
435if test "$with_acl" != "no"; then
436 AC_CHECK_HEADERS(acl/libacl.h attr/error_context.h, [acl_header="yes"], [acl_header="no"])
437 if test "$acl_header$with_acl" = "noyes" ; then
438 AC_MSG_ERROR([acl/libacl.h or attr/error_context.h is missing])
439 elif test "$acl_header" = "yes" ; then
440 AC_CHECK_LIB(acl, perm_copy_file,
441 [AC_CHECK_LIB(acl, perm_copy_fd,
442 [acl_lib="yes"],
443 [acl_lib="no"])],
444 [acl_lib="no"])
445 if test "$acl_lib$with_acl" = "noyes" ; then
446 AC_MSG_ERROR([libacl not found])
447 elif test "$acl_lib" = "no" ; then
448 with_acl="no"
449 else
450 AC_DEFINE(WITH_ACL, 1,
451 [Build shadow with ACL support])
452 LIBACL="-lacl"
453 with_acl="yes"
454 fi
455 else
456 with_acl="no"
457 fi
458fi
459
460AC_SUBST(LIBATTR)
461if test "$with_attr" != "no"; then
462 AC_CHECK_HEADERS(attr/libattr.h attr/error_context.h, [attr_header="yes"], [attr_header="no"])
463 if test "$attr_header$with_attr" = "noyes" ; then
464 AC_MSG_ERROR([attr/libattr.h or attr/error_context.h is missing])
465 elif test "$attr_header" = "yes" ; then
466 AC_CHECK_LIB(attr, attr_copy_file,
467 [AC_CHECK_LIB(attr, attr_copy_fd,
468 [attr_lib="yes"],
469 [attr_lib="no"])],
470 [attr_lib="no"])
471 if test "$attr_lib$with_attr" = "noyes" ; then
472 AC_MSG_ERROR([libattr not found])
473 elif test "$attr_lib" = "no" ; then
474 with_attr="no"
475 else
476 AC_DEFINE(WITH_ATTR, 1,
477 [Build shadow with Extended Attributes support])
3f63005e 478 LIBATTR="-lattr"
902aad57 479 with_attr="yes"
480 fi
481 else
482 with_attr="no"
483 fi
484fi
485
8451bed8 486AC_SUBST(LIBAUDIT)
70bf7cca 487if test "$with_audit" != "no"; then
8451bed8 488 AC_CHECK_HEADER(libaudit.h, [audit_header="yes"], [audit_header="no"])
70bf7cca 489 if test "$audit_header$with_audit" = "noyes" ; then
490 AC_MSG_ERROR([libaudit.h is missing])
491 elif test "$audit_header" = "yes"; then
7034a913 492 AC_CHECK_DECL(AUDIT_ADD_USER,,[audit_header="no"],[#include <libaudit.h>])
493 AC_CHECK_DECL(AUDIT_DEL_USER,,[audit_header="no"],[#include <libaudit.h>])
494 AC_CHECK_DECL(AUDIT_ADD_GROUP,,[audit_header="no"],[#include <libaudit.h>])
495 AC_CHECK_DECL(AUDIT_DEL_GROUP,,[audit_header="no"],[#include <libaudit.h>])
496 if test "$audit_header$with_audit" = "noyes" ; then
497 AC_MSG_ERROR([AUDIT_ADD_USER AUDIT_DEL_USER AUDIT_ADD_GROUP or AUDIT_DEL_GROUP missing from libaudit.h])
498 fi
499 fi
500 if test "$audit_header" = "yes"; then
24178ad6 501 AC_CHECK_LIB(audit, audit_log_acct_message,
70bf7cca 502 [audit_lib="yes"], [audit_lib="no"])
503 if test "$audit_lib$with_audit" = "noyes" ; then
504 AC_MSG_ERROR([libaudit not found])
505 elif test "$audit_lib" = "no" ; then
506 with_audit="no"
507 else
508 AC_DEFINE(WITH_AUDIT, 1,
509 [Define if you want to enable Audit messages])
510 LIBAUDIT="-laudit"
511 with_audit="yes"
512 fi
513 else
514 with_audit="no"
8451bed8 515 fi
516fi
517
50b23584
AM
518if test "$with_btrfs" != "no"; then
519 AC_CHECK_HEADERS([sys/statfs.h linux/magic.h linux/btrfs_tree.h], \
520 [btrfs_headers="yes"], [btrfs_headers="no"])
521 if test "$btrfs_headers$with_btrfs" = "noyes" ; then
522 AC_MSG_ERROR([One of sys/statfs.h linux/magic.h linux/btrfs_tree.h is missing])
523 fi
524
525 if test "$btrfs_headers" = "yes" ; then
526 AC_DEFINE(WITH_BTRFS, 1, [Build shadow with BtrFS support])
527 with_btrfs="yes"
528 fi
529fi
530AM_CONDITIONAL(WITH_BTRFS, test x$with_btrfs = xyes)
531
8e82ae23 532AC_SUBST(LIBSELINUX)
29050ead 533AC_SUBST(LIBSEMANAGE)
8e82ae23 534if test "$with_selinux" != "no"; then
535 AC_CHECK_HEADERS(selinux/selinux.h, [selinux_header="yes"], [selinux_header="no"])
536 if test "$selinux_header$with_selinux" = "noyes" ; then
537 AC_MSG_ERROR([selinux/selinux.h is missing])
29050ead 538 fi
539
540 AC_CHECK_HEADERS(semanage/semanage.h, [semanage_header="yes"], [semanage_header="no"])
541 if test "$semanage_header$with_selinux" = "noyes" ; then
542 AC_MSG_ERROR([semanage/semanage.h is missing])
543 fi
544
545 if test "$selinux_header$semanage_header" = "yesyes" ; then
546 AC_CHECK_LIB(selinux, is_selinux_enabled, [selinux_lib="yes"], [selinux_lib="no"])
8e82ae23 547 if test "$selinux_lib$with_selinux" = "noyes" ; then
548 AC_MSG_ERROR([libselinux not found])
29050ead 549 fi
550
551 AC_CHECK_LIB(semanage, semanage_connect, [semanage_lib="yes"], [semanage_lib="no"])
552 if test "$semanage_lib$with_selinux" = "noyes" ; then
553 AC_MSG_ERROR([libsemanage not found])
554 fi
555
3c52a84f 556 if test "$selinux_lib$semanage_lib" = "yesyes" ; then
8e82ae23 557 AC_DEFINE(WITH_SELINUX, 1,
558 [Build shadow with SELinux support])
559 LIBSELINUX="-lselinux"
29050ead 560 LIBSEMANAGE="-lsemanage"
10ebb144 561 with_selinux="yes"
29050ead 562 else
563 with_selinux="no"
8e82ae23 564 fi
565 else
566 with_selinux="no"
567 fi
b0e078d9 568fi
569
c5c94a1d 570AC_SUBST(LIBTCB)
571if test "$with_tcb" != "no"; then
572 AC_CHECK_HEADERS(tcb.h, [tcb_header="yes"], [tcb_header="no"])
573 if test "$tcb_header$with_tcb" = "noyes" ; then
574 AC_MSG_ERROR([tcb.h is missing])
575 elif test "$tcb_header" = "yes" ; then
576 AC_CHECK_LIB(tcb, tcb_is_suspect, [tcb_lib="yes"], [tcb_lib="no"])
577 if test "$tcb_lib$with_tcb" = "noyes" ; then
578 AC_MSG_ERROR([libtcb not found])
579 elif test "$tcb_lib" = "no" ; then
580 with_tcb="no"
581 else
582 AC_DEFINE(WITH_TCB, 1, [Build shadow with tcb support (incomplete)])
583 LIBTCB="-ltcb"
584 with_tcb="yes"
585 fi
586 else
587 with_tcb="no"
588 fi
589fi
391a3847 590AM_CONDITIONAL(WITH_TCB, test x$with_tcb = xyes)
c5c94a1d 591
45c6603c 592AC_SUBST(LIBPAM)
8e82ae23 593if test "$with_libpam" != "no"; then
3bc49967 594 AC_CHECK_LIB(pam, pam_start,
8e82ae23 595 [pam_lib="yes"], [pam_lib="no"])
596 if test "$pam_lib$with_libpam" = "noyes" ; then
597 AC_MSG_ERROR(libpam not found)
598 fi
599
276e406c 600 LIBPAM="-lpam"
601 pam_conv_function="no"
602
603 AC_CHECK_LIB(pam, openpam_ttyconv,
a674a2e6 604 [pam_conv_function="openpam_ttyconv"],
605 AC_CHECK_LIB(pam_misc, misc_conv,
606 [pam_conv_function="misc_conv"; LIBPAM="$LIBPAM -lpam_misc"])
607 )
276e406c 608
609 if test "$pam_conv_function$with_libpam" = "noyes" ; then
610 AC_MSG_ERROR(PAM conversation function not found)
8e82ae23 611 fi
612
276e406c 613 pam_headers_found=no
614 AC_CHECK_HEADERS( [security/openpam.h security/pam_misc.h],
a674a2e6 615 [ pam_headers_found=yes ; break ], [],
616 [ #include <security/pam_appl.h> ] )
617 if test "$pam_headers_found$with_libpam" = "noyes" ; then
276e406c 618 AC_MSG_ERROR(PAM headers not found)
a674a2e6 619 fi
276e406c 620
621
622 if test "$pam_lib$pam_headers_found" = "yesyes" -a "$pam_conv_function" != "no" ; then
8e82ae23 623 with_libpam="yes"
624 else
625 with_libpam="no"
69fe59a6 626 unset LIBPAM
8e82ae23 627 fi
628fi
629dnl Now with_libpam is either yes or no
630if test "$with_libpam" = "yes"; then
276e406c 631 AC_CHECK_DECLS([PAM_ESTABLISH_CRED,
a674a2e6 632 PAM_DELETE_CRED,
633 PAM_NEW_AUTHTOK_REQD,
634 PAM_DATA_SILENT],
635 [], [], [#include <security/pam_appl.h>])
276e406c 636
637
638 save_libs=$LIBS
cd6a3002 639 LIBS="$LIBS $LIBPAM"
640 # We do not use AC_CHECK_FUNCS to avoid duplicated definition with
641 # Linux PAM.
642 AC_CHECK_FUNC(pam_fail_delay, [AC_DEFINE(HAS_PAM_FAIL_DELAY, 1, [Define to 1 if you have the declaration of 'pam_fail_delay'])])
276e406c 643 LIBS=$save_libs
644
8e82ae23 645 AC_DEFINE(USE_PAM, 1, [Define to support Pluggable Authentication Modules])
0fba6bd3 646 AC_DEFINE_UNQUOTED(SHADOW_PAM_CONVERSATION, [$pam_conv_function],[PAM conversation to use])
8e82ae23 647 AM_CONDITIONAL(USE_PAM, [true])
276e406c 648
3bc49967 649 AC_MSG_CHECKING(use login and su access checking if PAM not used)
650 AC_MSG_RESULT(no)
651else
b48129fc 652 AC_DEFINE(SU_ACCESS, 1, [Define to support /etc/suauth su access control.])
0fa90830 653 AM_CONDITIONAL(USE_PAM, [false])
8e82ae23 654 AC_MSG_CHECKING(use login and su access checking if PAM not used)
655 AC_MSG_RESULT(yes)
45c6603c 656fi
657
70c9eeff 658if test "$enable_acct_tools_setuid" != "no"; then
f8aef607 659 if test "$with_libpam" != "yes"; then
70c9eeff 660 if test "$enable_acct_tools_setuid" = "yes"; then
661 AC_MSG_ERROR(PAM support is required for --enable-account-tools-setuid)
662 else
663 enable_acct_tools_setuid="no"
664 fi
fcfa8128 665 else
666 enable_acct_tools_setuid="yes"
70c9eeff 667 fi
66cb5b33 668 if test "$enable_acct_tools_setuid" = "yes"; then
70c9eeff 669 AC_DEFINE(ACCT_TOOLS_SETUID,
670 1,
671 [Define if account management tools should be installed setuid and authenticate the callers])
f8aef607 672 fi
f8aef607 673fi
674AM_CONDITIONAL(ACCT_TOOLS_SETUID, test "x$enable_acct_tools_setuid" = "xyes")
675
70971457
GS
676
677AC_ARG_WITH(fcaps,
48ceff86 678 [AS_HELP_STRING([--with-fcaps], [use file capabilities instead of suid binaries for newuidmap/newgidmap @<:@default=no@:>@])],
70971457
GS
679 [with_fcaps=$withval], [with_fcaps=no])
680AM_CONDITIONAL(FCAPS, test "x$with_fcaps" = "xyes")
681
682if test "x$with_fcaps" = "xyes"; then
683 AC_CHECK_PROGS(capcmd, "setcap")
684 if test "x$capcmd" = "x" ; then
685 AC_MSG_ERROR([setcap command not available])
686 fi
687fi
688
b48129fc 689AC_SUBST(LIBSKEY)
690AC_SUBST(LIBMD)
8451bed8 691if test "$with_skey" = "yes"; then
b48129fc 692 AC_CHECK_LIB(md, MD5Init, [LIBMD=-lmd])
693 AC_CHECK_LIB(skey, skeychallenge, [LIBSKEY=-lskey],
694 [AC_MSG_ERROR([liskey missing. You can download S/Key source code from http://rsync1.it.gentoo.org/gentoo/distfiles/skey-1.1.5.tar.bz2])])
695 AC_DEFINE(SKEY, 1, [Define to support S/Key logins.])
48ceff86 696 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
591830e4 697 #include <stdio.h>
698 #include <skey.h>
48ceff86 699 ]], [[
591830e4 700 skeychallenge((void*)0, (void*)0, (void*)0, 0);
48ceff86 701 ]])],[AC_DEFINE(SKEY_BSD_STYLE, 1, [Define to support newer BSD S/Key API])],[])
b48129fc 702fi
703
163c4249
IP
704PKG_CHECK_MODULES([CMOCKA], [cmocka], [have_cmocka="yes"],
705 [AC_MSG_WARN([libcmocka not found, cmocka tests will not be built])])
706AM_CONDITIONAL([HAVE_CMOCKA], [test x$have_cmocka = xyes])
707
cc0aaaa1
JJ
708AC_CHECK_FUNC(fgetpwent_r, [AC_DEFINE(HAVE_FGETPWENT_R, 1, [Defined to 1 if you have the declaration of 'fgetpwent_r'])])
709
36ef489f 710AC_DEFINE_UNQUOTED(SHELL, ["$SHELL"], [The default shell.])
db38a728 711
af76c25f 712AM_GNU_GETTEXT_VERSION([0.19])
e89f3546 713AM_GNU_GETTEXT([external], [need-ngettext])
591830e4 714AM_CONDITIONAL(USE_NLS, test "x$USE_NLS" = "xyes")
45c6603c 715
effd479b 716AC_CONFIG_FILES([
3bc49967 717 Makefile
3bc49967 718 po/Makefile.in
719 doc/Makefile
720 man/Makefile
4c7d7983 721 man/config.xml
0398323a 722 man/po/Makefile
4903ce06 723 man/cs/Makefile
c1eecc94 724 man/da/Makefile
4903ce06 725 man/de/Makefile
effd479b 726 man/es/Makefile
24178ad6 727 man/fi/Makefile
4903ce06 728 man/fr/Makefile
9db6abfa 729 man/hu/Makefile
4903ce06 730 man/id/Makefile
731 man/it/Makefile
3bc49967 732 man/ja/Makefile
4903ce06 733 man/ko/Makefile
3bc49967 734 man/pl/Makefile
735 man/pt_BR/Makefile
effd479b 736 man/ru/Makefile
5e20c435 737 man/sv/Makefile
24178ad6 738 man/tr/Makefile
b372b8a3 739 man/uk/Makefile
effd479b 740 man/zh_CN/Makefile
741 man/zh_TW/Makefile
3bc49967 742 lib/Makefile
0a7888b1 743 libsubid/Makefile
0c9f6414 744 libsubid/subid.h
3bc49967 745 src/Makefile
746 contrib/Makefile
3bc49967 747 etc/Makefile
748 etc/pam.d/Makefile
ee3e6112 749 etc/shadow-maint/Makefile
163c4249 750 tests/unit/Makefile
effd479b 751])
752AC_OUTPUT
8451bed8 753
754echo
c187b2be 755echo "shadow will be compiled with the following features:"
8451bed8 756echo
757echo " auditing support: $with_audit"
8451bed8 758echo " PAM support: $with_libpam"
f8aef607 759if test "$with_libpam" = "yes"; then
760echo " suid account management tools: $enable_acct_tools_setuid"
761fi
8451bed8 762echo " SELinux support: $with_selinux"
50b23584 763echo " BtrFS support: $with_btrfs"
902aad57 764echo " ACL support: $with_acl"
765echo " Extended Attributes support: $with_attr"
c5c94a1d 766echo " tcb support (incomplete): $with_tcb"
8451bed8 767echo " shadow group support: $enable_shadowgrp"
768echo " S/Key support: $with_skey"
4d606cc6 769echo " SHA passwords encryption: $with_sha_crypt"
2958bd05 770echo " bcrypt passwords encryption: $with_bcrypt"
5cd04d03 771echo " yescrypt passwords encryption: $with_yescrypt"
c59126a8 772echo " nscd support: $with_nscd"
4aaf05d7 773echo " sssd support: $with_sssd"
d611d54e 774echo " subordinate IDs support: $enable_subids"
1bdcfa8d 775echo " enable lastlog: $enable_lastlog"
fb35ad15 776echo " enable logind: $enable_logind"
70971457 777echo " use file caps: $with_fcaps"
19bac44d 778echo " install su: $with_su"
a27d5c51 779echo " enabled vendor dir: $enable_vendordir"
8451bed8 780echo