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