]> arthur.barton.de Git - netatalk.git/blob - macros/pam-check.m4
Merge branch 'develop' of netafp.com:git/netatalk into develop
[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 Fallback
102         else
103            PAM_DIRECTIVE=required
104            PAM_AUTH=pam_unix.so
105            PAM_ACCOUNT=pam_unix.so
106            PAM_PASSWORD="pam_unix.so use_authtok"
107            PAM_SESSION=pam_unix.so
108         fi  
109
110         if test "x$PAM_DIRECTIVE" != "xrequired" ; then
111             AC_MSG_RESULT([yes ($PAM_DIRECTIVE $PAM_AUTH)])
112         else
113             AC_MSG_RESULT([no (using defaut pam_unix.so)])
114         fi
115         fi
116
117         AC_MSG_CHECKING([whether to enable PAM support])
118         if test "x$pam_found" = "xno"; then
119                 netatalk_cv_install_pam=no
120                 if test "x$require_pam" = "xyes"; then
121                         AC_MSG_ERROR([PAM support missing])
122                 else
123                         AC_MSG_RESULT([no])
124                 fi
125                 ifelse([$2], , :, [$2])
126         else
127                 AC_MSG_RESULT([yes])
128                 ifelse([$1], , :, [$1])
129         use_pam_so=yes
130             compile_pam=yes
131             netatalk_cv_use_pam=yes
132             AC_DEFINE(USE_PAM, 1, [Define to enable PAM support])
133         fi
134
135     LIB_REMOVE_USR_LIB(PAM_LIBS)
136     CFLAGS_REMOVE_USR_INCLUDE(PAM_CFLAGS)
137         AC_SUBST(PAMDIR)
138         AC_SUBST(PAM_CFLAGS)
139         AC_SUBST(PAM_LIBS)
140     AC_SUBST(PAM_DIRECTIVE)
141     AC_SUBST(PAM_AUTH)
142     AC_SUBST(PAM_ACCOUNT)
143     AC_SUBST(PAM_PASSWORD)
144     AC_SUBST(PAM_SESSION)
145 ])