]> arthur.barton.de Git - netatalk.git/blob - macros/pam-check.m4
Writing metadata xattr on directories with sticky bit set, FR#94
[netatalk.git] / macros / pam-check.m4
1 dnl PAM finding macro
2
3 AC_DEFUN([AC_NETATALK_PATH_PAM], [
4     netatalk_cv_use_pam=no
5         AC_ARG_WITH(pam, [  --with-pam[[=PATH]]       specify path to PAM installation [[auto]]],
6                 [
7                         require_pam="yes"
8                         if test "x$withval" = "xno"; then
9                                 PAMDIR="NONE"
10                                 require_pam="never"
11                         elif test "x$withval" = "xyes"; then
12                                 PAMDIR="NONE"
13                         else
14                                 PAMDIR="$withval"
15                         fi
16                 ],
17                 [PAMDIR="NONE";require_pam="no"]
18         )
19
20         AC_MSG_CHECKING([for PAM installation directory])
21         if test "$host_os" != "solaris"; then
22                 if test "x$PAMDIR" = "xNONE" -a "x$require_pam" != "xnever"; then
23                   dnl Test for PAM
24                   pam_paths="/ /usr/ /usr/local/"
25                   for path in $pam_paths; do
26                         if test -d "${path}etc/pam.d"; then
27                                 PAMDIR="$path"
28                                 break
29                         fi
30                   done
31                 fi
32
33                 if test "x$PAMDIR" != "xNONE"; then
34                         AC_MSG_RESULT([yes (path: ${PAMDIR}etc/pam.d)])
35                 else
36                         AC_MSG_RESULT([no])
37                 fi
38         else
39                 AC_MSG_RESULT([/etc/pam.conf (solaris)])
40         fi
41                 
42         pam_found="no"
43         if test "x$require_pam" != "xnever"; then
44
45                 savedCFLAGS="$CFLAGS"
46                 savedLDFLAGS="$LDFLAGS"
47                 savedLIBS="$LIBS"
48
49                 if test "x$PAMDIR" != "xNONE" -a "x$PAMDIR" != "x/"; then
50                         PAM_CFLAGS="-I${PAMDIR}include"
51                         PAM_LDFLAGS="-L${PAMDIR}lib"
52                         LDFLAGS="$LDFLAGS $PAM_LDFLAGS"
53                         CFLAGS="$CFLAGS $PAM_CFLAGS"
54                 fi
55
56                 AC_CHECK_HEADERS(security/pam_appl.h pam/pam_appl.h)
57
58                 if test x"$ac_cv_header_security_pam_appl_h" = x"no" -a x"$ac_cv_header_pam_pam_appl_h" = x"no"; then
59                         pam_found=no
60                 else
61                         AC_CHECK_LIB(pam, pam_set_item, [
62                                 PAM_LIBS="$PAM_LDFLAGS -lpam"
63                                 pam_found="yes"
64                         ])
65                 fi
66                 CFLAGS="$savedCFLAGS"
67                 LDFLAGS="$savedLDFLAGS"
68                 LIBS="$savedLIBS"
69         fi
70
71         netatalk_cv_install_pam=yes
72         if test x"$pam_found" = "xyes" -a "x$PAMDIR" = "xNONE"; then
73                 AC_MSG_WARN([PAM support can be compiled, but the install location for the netatalk.pamd file could not be determined. Either install this file by hand or specify the install path.])
74                 netatalk_cv_install_pam=no
75     else
76         dnl Check for some system|common auth file
77         AC_MSG_CHECKING([for includable common PAM config])
78         pampath="${PAMDIR}etc/pam.d"
79         dnl Debian/SuSE
80         if test -f "$pampath/common-auth" ; then
81            PAM_DIRECTIVE=include
82            PAM_AUTH=common-auth
83            PAM_ACCOUNT=common-account
84            PAM_PASSWORD=common-password
85            PAM_SESSION=common-session
86         dnl RHEL/FC
87         elif test -f "$pampath/system-auth" ; then
88            PAM_DIRECTIVE=include
89            PAM_AUTH=system-auth
90            PAM_ACCOUNT=system-auth
91            PAM_PASSWORD=system-auth
92            PAM_SESSION=system-auth
93         dnl FreeBSD
94         elif test -f "$pampath/system" ; then
95            PAM_DIRECTIVE=include
96            PAM_AUTH=system
97            PAM_ACCOUNT=system
98            PAM_PASSWORD=system
99            PAM_SESSION=system
100         dnl Solaris 11+
101         elif test -f "$pampath/other" ; then
102            PAM_DIRECTIVE=include
103            PAM_AUTH=${PAMDIR}etc/pam.d/other
104            PAM_ACCOUNT=${PAMDIR}etc/pam.d/other
105            PAM_PASSWORD=${PAMDIR}etc/pam.d/other
106            PAM_SESSION=${PAMDIR}etc/pam.d/other
107         dnl Fallback
108         else
109            PAM_DIRECTIVE=required
110            PAM_AUTH=pam_unix.so
111            PAM_ACCOUNT=pam_unix.so
112            PAM_PASSWORD="pam_unix.so use_authtok"
113            PAM_SESSION=pam_unix.so
114         fi  
115
116         if test "x$PAM_DIRECTIVE" != "xrequired" ; then
117             AC_MSG_RESULT([yes ($PAM_DIRECTIVE $PAM_AUTH)])
118         else
119             AC_MSG_RESULT([no (using defaut pam_unix.so)])
120         fi
121         fi
122
123         AC_MSG_CHECKING([whether to enable PAM support])
124         if test "x$pam_found" = "xno"; then
125                 netatalk_cv_install_pam=no
126                 if test "x$require_pam" = "xyes"; then
127                         AC_MSG_ERROR([PAM support missing])
128                 else
129                         AC_MSG_RESULT([no])
130                 fi
131                 ifelse([$2], , :, [$2])
132         else
133                 AC_MSG_RESULT([yes])
134                 ifelse([$1], , :, [$1])
135         use_pam_so=yes
136             compile_pam=yes
137             netatalk_cv_use_pam=yes
138             AC_DEFINE(USE_PAM, 1, [Define to enable PAM support])
139         fi
140
141     AC_ARG_WITH(
142         pam-confdir,
143         [AS_HELP_STRING([--with-pam-confdir=PATH],[Path to PAM config dir (default: ${sysconfdir}/pam.d)])],
144         ac_cv_pamdir=$withval,
145         ac_cv_pamdir='${sysconfdir}/pam.d'
146     )
147
148     PAMDIR="$ac_cv_pamdir"
149
150     LIB_REMOVE_USR_LIB(PAM_LIBS)
151     CFLAGS_REMOVE_USR_INCLUDE(PAM_CFLAGS)
152         AC_SUBST(PAMDIR)
153         AC_SUBST(PAM_CFLAGS)
154         AC_SUBST(PAM_LIBS)
155     AC_SUBST(PAM_DIRECTIVE)
156     AC_SUBST(PAM_AUTH)
157     AC_SUBST(PAM_ACCOUNT)
158     AC_SUBST(PAM_PASSWORD)
159     AC_SUBST(PAM_SESSION)
160 ])