• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1dnl
2dnl PAM stuff for CUPS.
3dnl
4dnl Copyright 2007-2017 by Apple Inc.
5dnl Copyright 1997-2005 by Easy Software Products, all rights reserved.
6dnl
7dnl Licensed under Apache License v2.0.  See the file "LICENSE" for more information.
8dnl
9
10AC_ARG_ENABLE(pam, [  --disable-pam           disable PAM support])
11AC_ARG_WITH(pam_module, [  --with-pam-module       set the PAM module to use])
12
13PAMDIR=""
14PAMFILE="pam.std"
15PAMLIBS=""
16PAMMOD="pam_unknown.so"
17PAMMODAUTH="pam_unknown.so"
18
19if test x$enable_pam != xno; then
20	SAVELIBS="$LIBS"
21
22	AC_CHECK_LIB(dl,dlopen)
23	AC_CHECK_LIB(pam,pam_start)
24	AC_CHECK_LIB(pam,pam_set_item,AC_DEFINE(HAVE_PAM_SET_ITEM))
25	AC_CHECK_LIB(pam,pam_setcred,AC_DEFINE(HAVE_PAM_SETCRED))
26	AC_CHECK_HEADER(security/pam_appl.h)
27	if test x$ac_cv_header_security_pam_appl_h != xyes; then
28		AC_CHECK_HEADER(pam/pam_appl.h,
29			AC_DEFINE(HAVE_PAM_PAM_APPL_H))
30	fi
31
32	if test x$ac_cv_lib_pam_pam_start != xno; then
33		# Set the necessary libraries for PAM...
34		if test x$ac_cv_lib_dl_dlopen != xno; then
35			PAMLIBS="-lpam -ldl"
36		else
37			PAMLIBS="-lpam"
38		fi
39
40		# Find the PAM configuration directory, if any...
41		for dir in /private/etc/pam.d /etc/pam.d; do
42			if test -d $dir; then
43				PAMDIR=$dir
44				break;
45			fi
46		done
47	fi
48
49	LIBS="$SAVELIBS"
50
51	case "$host_os_name" in
52		darwin*)
53			# Darwin/macOS
54			if test "x$with_pam_module" != x; then
55				PAMFILE="pam.$with_pam_module"
56			elif test -f /usr/lib/pam/pam_opendirectory.so.2; then
57				PAMFILE="pam.opendirectory"
58			else
59				PAMFILE="pam.securityserver"
60			fi
61			;;
62
63		*)
64			# All others; this test might need to be updated
65			# as Linux distributors move things around...
66			if test "x$with_pam_module" != x; then
67				PAMMOD="pam_${with_pam_module}.so"
68			elif test -f /etc/pam.d/common-auth; then
69				PAMFILE="pam.common"
70			else
71				moddir=""
72				for dir in /lib/security /lib64/security /lib/x86_64-linux-gnu/security /var/lib/pam; do
73					if test -d $dir; then
74						moddir=$dir
75						break;
76					fi
77				done
78
79				if test -f $moddir/pam_unix2.so; then
80					PAMMOD="pam_unix2.so"
81				elif test -f $moddir/pam_unix.so; then
82					PAMMOD="pam_unix.so"
83				fi
84			fi
85
86			if test "x$PAMMOD" = xpam_unix.so; then
87				PAMMODAUTH="$PAMMOD shadow nodelay"
88			else
89				PAMMODAUTH="$PAMMOD nodelay"
90			fi
91			;;
92	esac
93fi
94
95AC_SUBST(PAMDIR)
96AC_SUBST(PAMFILE)
97AC_SUBST(PAMLIBS)
98AC_SUBST(PAMMOD)
99AC_SUBST(PAMMODAUTH)
100