>From de610363e4e8ef32826cfb8ee1fddef5347b0f75 Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik Date: Tue, 27 May 2014 23:55:17 +0200 Subject: [PATCH 6/7] PAM: Define compatible macros for some functions. Functions pam_vsyslog and pam_modutil_getlogin are not available in openpam. This patch conditionally define macros for these function if they are not available. Compatible macros use standard functions vsyslog, getlogin --- Makefile.am | 3 ++- src/external/pam.m4 | 9 ++++++++ src/sss_client/pam_sss.c | 4 ++-- src/sss_client/sss_pam_compat.h | 50 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 63 insertions(+), 3 deletions(-) create mode 100644 src/sss_client/sss_pam_compat.h diff --git a/Makefile.am b/Makefile.am index 0fa613505881a5080040a97351cd5f9b07e77b3c..f64c77a5bdd7f53b41bd37572b2d91434a9893a6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1922,7 +1922,8 @@ pam_sss_la_SOURCES = \ src/sss_client/common.c \ src/sss_client/sss_cli.h \ src/util/atomic_io.c \ - src/sss_client/sss_pam_macros.h + src/sss_client/sss_pam_macros.h \ + src/sss_client/sss_pam_compat.h pam_sss_la_LIBADD = \ $(CLIENT_LIBS) \ diff --git a/src/external/pam.m4 b/src/external/pam.m4 index 90f89bee3f3a6cdfc967498b5aea603609f92c3b..4776b6ae338409f0a2729dfc4cf5962463a40dfd 100644 --- a/src/external/pam.m4 +++ b/src/external/pam.m4 @@ -18,3 +18,12 @@ AC_CHECK_HEADERS([security/openpam.h],,,[ AC_CHECK_LIB([pam_misc], [misc_conv], [PAM_MISC_LIBS="-lpam_misc"]) + +dnl save LIBS to restore later +save_LIBS="$LIBS" +LIBS="$PAM_LIBS" + +AC_CHECK_FUNCS(pam_modutil_getlogin pam_vsyslog) + +dnl restore LIBS +LIBS="$save_LIBS" diff --git a/src/sss_client/pam_sss.c b/src/sss_client/pam_sss.c index 9fb945d97375951bfb7b608f1905227087eb9b9b..908ab128e706acfbface624a322f1b494e9aef01 100644 --- a/src/sss_client/pam_sss.c +++ b/src/sss_client/pam_sss.c @@ -35,8 +35,8 @@ #include #include -#include -#include + +#include "sss_pam_compat.h" #include "sss_pam_macros.h" #include "sss_cli.h" diff --git a/src/sss_client/sss_pam_compat.h b/src/sss_client/sss_pam_compat.h new file mode 100644 index 0000000000000000000000000000000000000000..b68f3bc705c6318cefd6d8595946e6136cd85e8c --- /dev/null +++ b/src/sss_client/sss_pam_compat.h @@ -0,0 +1,50 @@ +/* + SSSD + + Compat declarations for PAM. + + Authors: + Lukas Slebodnik + + Copyright (C) Red Hat, Inc 2014 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . +*/ + +#ifndef _SSS_PAM_COMPAT_H +#define _SSS_PAM_COMPAT_H + +#ifdef HAVE_SECURITY_PAM_MODUTIL_H +# include +#endif /* HAVE_SECURITY_PAM_MODUTIL_H */ + +#ifdef HAVE_SECURITY_PAM_EXT_H +# include +#endif /* HAVE_SECURITY_PAM_EXT_H */ + +#ifndef HAVE_PAM_VSYSLOG +#define pam_vsyslog(pamh, priority, fmt, vargs) \ + vsyslog((priority), (fmt), (vargs)) +#endif /* HAVE_PAM_VSYSLOG */ + +#ifndef HAVE_PAM_MODUTIL_GETLOGIN +#define pam_modutil_getlogin(pamh) \ + getlogin() +#endif /* HAVE_PAM_MODUTIL_GETLOGIN */ + +#ifndef PAM_BAD_ITEM +# define PAM_BAD_ITEM PAM_USER_UNKNOWN +#endif /* PAM_BAD_ITEM */ + +#endif /* _SSS_PAM_COMPAT_H */ -- 1.9.3