From fa8adede758e2b1e8ae38c84d032b354f0250f49 Mon Sep 17 00:00:00 2001
From: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
Date: Thu, 24 Jan 2013 10:11:28 -0800
Subject: [PATCH] Look for pam in both pam/ and security/ paths

Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
---
 configure.ac     | 4 ++++
 greeter/verify.c | 1 -
 include/dm.h     | 8 +++++++-
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index d20ae28..f0ea150 100644
--- a/configure.ac
+++ b/configure.ac
@@ -120,6 +120,10 @@ AC_ARG_WITH(pam, AS_HELP_STRING([--with-pam],
 	[Use PAM for authentication (default is autodetected)]),
 	[USE_PAM=$withval], [USE_PAM=auto])
 if test "x$USE_PAM" != "xno" ; then
+    AC_CHECK_HEADERS([security/pam_appl.h pam/pam_appl.h],
+                     [found=yes ; break ;], [found=no])
+    AS_IF([test "x$USE_PAM" = "xyes" -a  "x$found" = "xno"],
+	[AC_MSG_ERROR([PAM support requested, but we could not find the pam headers.])])
     AC_SEARCH_LIBS([pam_open_session], [pam],
 	[AC_CHECK_FUNC([pam_open_session],
 	    [AC_DEFINE(USE_PAM,1,[Use PAM for authentication])]
diff --git a/greeter/verify.c b/greeter/verify.c
index 1221874..db3cb7d 100644
--- a/greeter/verify.c
+++ b/greeter/verify.c
@@ -41,7 +41,6 @@ from The Open Group.
 #include	<pwd.h>
 
 #if defined(USE_PAM)
-# include	<security/pam_appl.h>
 # include	<stdlib.h>
 #elif defined(HAVE_GETSPNAM)
 # include	<shadow.h>
diff --git a/include/dm.h b/include/dm.h
index 2512e37..cd60f4b 100644
--- a/include/dm.h
+++ b/include/dm.h
@@ -105,7 +105,13 @@ typedef union wait	waitType;
 # endif /* X_NOT_POSIX */
 
 # ifdef USE_PAM
-#  include <security/pam_appl.h>
+#  ifdef HAVE_SECURITY_PAM_APPL_H
+#   include <security/pam_appl.h>
+#  elif defined(HAVE_PAM_PAM_APPL_H)
+#   include <pam/pam_appl.h>
+#  else
+#   error "Unable to determine pam headers"
+#  endif
 # endif
 
 # ifdef CSRG_BASED
-- 
1.8.1.1

