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