Imported Upstream version 4.0.5
This commit is contained in:
@@ -1,21 +1,24 @@
|
||||
PLUGIN_COMMON_DIR = $(srcdir)/../common
|
||||
MAINTAINERCLEANFILES = *~ Makefile.in
|
||||
PLUGIN_COMMON_DIR = ../common
|
||||
AM_CPPFLAGS = \
|
||||
-I. \
|
||||
-I$(srcdir) \
|
||||
-I$(srcdir)/../libotp \
|
||||
-I$(PLUGIN_COMMON_DIR) \
|
||||
-I/usr/include/dirsrv \
|
||||
-DPREFIX=\""$(prefix)"\" \
|
||||
-DBINDIR=\""$(bindir)"\" \
|
||||
-DLIBDIR=\""$(libdir)"\" \
|
||||
-DLIBEXECDIR=\""$(libexecdir)"\" \
|
||||
-DDATADIR=\""$(datadir)"\" \
|
||||
$(AM_CFLAGS) \
|
||||
$(DIRSRV_CFLAGS) \
|
||||
$(LDAP_CFLAGS) \
|
||||
$(WARN_CFLAGS)
|
||||
|
||||
plugindir = $(libdir)/dirsrv/plugins
|
||||
plugin_LTLIBRARIES = libipa_otp_lasttoken.la
|
||||
libipa_otp_lasttoken_la_SOURCES = ipa_otp_lasttoken.c ipa-otp-lasttoken.sym
|
||||
libipa_otp_lasttoken_la_LDFLAGS = -avoid-version -export-symbols $(srcdir)/ipa-otp-lasttoken.sym
|
||||
libipa_otp_lasttoken_la_SOURCES = ipa_otp_lasttoken.c
|
||||
libipa_otp_lasttoken_la_LDFLAGS = -avoid-version -export-symbols ipa-otp-lasttoken.sym
|
||||
libipa_otp_lasttoken_la_LIBADD = \
|
||||
$(LDAP_LIBS) \
|
||||
$(builddir)/../libotp/libotp.la
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Makefile.in generated by automake 1.15.1 from Makefile.am.
|
||||
# Makefile.in generated by automake 1.14.1 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994-2017 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1994-2013 Free Software Foundation, Inc.
|
||||
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -15,17 +15,7 @@
|
||||
@SET_MAKE@
|
||||
|
||||
VPATH = @srcdir@
|
||||
am__is_gnu_make = { \
|
||||
if test -z '$(MAKELEVEL)'; then \
|
||||
false; \
|
||||
elif test -n '$(MAKE_HOST)'; then \
|
||||
true; \
|
||||
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
|
||||
true; \
|
||||
else \
|
||||
false; \
|
||||
fi; \
|
||||
}
|
||||
am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
|
||||
am__make_running_with_option = \
|
||||
case $${target_option-} in \
|
||||
?) ;; \
|
||||
@@ -88,20 +78,14 @@ PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
build_triplet = @build@
|
||||
host_triplet = @host@
|
||||
subdir = daemons/ipa-slapi-plugins/ipa-otp-lasttoken
|
||||
subdir = ipa-slapi-plugins/ipa-otp-lasttoken
|
||||
DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
|
||||
$(top_srcdir)/depcomp
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/m4/gettext.m4 \
|
||||
$(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/intlmacosx.m4 \
|
||||
$(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \
|
||||
$(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libtool.m4 \
|
||||
$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
|
||||
$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
|
||||
$(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/po.m4 \
|
||||
$(top_srcdir)/m4/progtest.m4 $(top_srcdir)/VERSION.m4 \
|
||||
$(top_srcdir)/server.m4 $(top_srcdir)/configure.ac
|
||||
am__aclocal_m4_deps = $(top_srcdir)/../version.m4 \
|
||||
$(top_srcdir)/configure.ac
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
|
||||
mkinstalldirs = $(install_sh) -d
|
||||
CONFIG_HEADER = $(top_builddir)/config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
@@ -209,12 +193,10 @@ am__define_uniq_tagged_files = \
|
||||
done | $(am__uniquify_input)`
|
||||
ETAGS = etags
|
||||
CTAGS = ctags
|
||||
am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AMTAR = @AMTAR@
|
||||
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
|
||||
API_VERSION = @API_VERSION@
|
||||
AR = @AR@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
@@ -223,15 +205,13 @@ AWK = @AWK@
|
||||
CC = @CC@
|
||||
CCDEPMODE = @CCDEPMODE@
|
||||
CFLAGS = @CFLAGS@
|
||||
CHECK_CFLAGS = @CHECK_CFLAGS@
|
||||
CHECK_LIBS = @CHECK_LIBS@
|
||||
CMOCKA_CFLAGS = @CMOCKA_CFLAGS@
|
||||
CMOCKA_LIBS = @CMOCKA_LIBS@
|
||||
CONFIG_STATUS = @CONFIG_STATUS@
|
||||
CPP = @CPP@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CRYPTO_CFLAGS = @CRYPTO_CFLAGS@
|
||||
CRYPTO_LIBS = @CRYPTO_LIBS@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
DATA_VERSION = @DATA_VERSION@
|
||||
DEFS = @DEFS@
|
||||
DEPDIR = @DEPDIR@
|
||||
DIRSRV_CFLAGS = @DIRSRV_CFLAGS@
|
||||
@@ -245,61 +225,31 @@ ECHO_T = @ECHO_T@
|
||||
EGREP = @EGREP@
|
||||
EXEEXT = @EXEEXT@
|
||||
FGREP = @FGREP@
|
||||
GETTEXT_DOMAIN = @GETTEXT_DOMAIN@
|
||||
GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@
|
||||
GIT_BRANCH = @GIT_BRANCH@
|
||||
GIT_VERSION = @GIT_VERSION@
|
||||
GMSGFMT = @GMSGFMT@
|
||||
GMSGFMT_015 = @GMSGFMT_015@
|
||||
GREP = @GREP@
|
||||
INI_CFLAGS = @INI_CFLAGS@
|
||||
INI_LIBS = @INI_LIBS@
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
|
||||
INTLLIBS = @INTLLIBS@
|
||||
INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@
|
||||
IPAPLATFORM = @IPAPLATFORM@
|
||||
IPA_DATA_DIR = @IPA_DATA_DIR@
|
||||
IPA_SYSCONF_DIR = @IPA_SYSCONF_DIR@
|
||||
JSLINT = @JSLINT@
|
||||
KRAD_LIBS = @KRAD_LIBS@
|
||||
KRB5KDC_SERVICE = @KRB5KDC_SERVICE@
|
||||
KRB5_CFLAGS = @KRB5_CFLAGS@
|
||||
KRB5_LIBS = @KRB5_LIBS@
|
||||
LD = @LD@
|
||||
LDAP_CFLAGS = @LDAP_CFLAGS@
|
||||
LDAP_LIBS = @LDAP_LIBS@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBICONV = @LIBICONV@
|
||||
LIBINTL = @LIBINTL@
|
||||
LIBINTL_LIBS = @LIBINTL_LIBS@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBPDB_NAME = @LIBPDB_NAME@
|
||||
LIBS = @LIBS@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
LIBVERTO_CFLAGS = @LIBVERTO_CFLAGS@
|
||||
LIBVERTO_LIBS = @LIBVERTO_LIBS@
|
||||
LIPO = @LIPO@
|
||||
LN_S = @LN_S@
|
||||
LTLIBICONV = @LTLIBICONV@
|
||||
LTLIBINTL = @LTLIBINTL@
|
||||
LTLIBOBJS = @LTLIBOBJS@
|
||||
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
|
||||
MAINT = @MAINT@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MANIFEST_TOOL = @MANIFEST_TOOL@
|
||||
MKDIR_P = @MKDIR_P@
|
||||
MK_ASSIGN = @MK_ASSIGN@
|
||||
MK_ELSE = @MK_ELSE@
|
||||
MK_ENDIF = @MK_ENDIF@
|
||||
MK_IFEQ = @MK_IFEQ@
|
||||
MSGATTRIB = @MSGATTRIB@
|
||||
MSGFMT = @MSGFMT@
|
||||
MSGFMT_015 = @MSGFMT_015@
|
||||
MSGMERGE = @MSGMERGE@
|
||||
NAMED_GROUP = @NAMED_GROUP@
|
||||
NDRNBT_CFLAGS = @NDRNBT_CFLAGS@
|
||||
NDRNBT_LIBS = @NDRNBT_LIBS@
|
||||
NDRPAC_CFLAGS = @NDRPAC_CFLAGS@
|
||||
@@ -312,10 +262,10 @@ NSPR_CFLAGS = @NSPR_CFLAGS@
|
||||
NSPR_LIBS = @NSPR_LIBS@
|
||||
NSS_CFLAGS = @NSS_CFLAGS@
|
||||
NSS_LIBS = @NSS_LIBS@
|
||||
NUM_VERSION = @NUM_VERSION@
|
||||
OBJDUMP = @OBJDUMP@
|
||||
OBJEXT = @OBJEXT@
|
||||
ODS_USER = @ODS_USER@
|
||||
OPENLDAP_CFLAGS = @OPENLDAP_CFLAGS@
|
||||
OPENLDAP_LIBS = @OPENLDAP_LIBS@
|
||||
OTOOL = @OTOOL@
|
||||
OTOOL64 = @OTOOL64@
|
||||
PACKAGE = @PACKAGE@
|
||||
@@ -329,15 +279,8 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
|
||||
PKG_CONFIG = @PKG_CONFIG@
|
||||
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
|
||||
PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
|
||||
POPT_CFLAGS = @POPT_CFLAGS@
|
||||
POPT_LIBS = @POPT_LIBS@
|
||||
POSUB = @POSUB@
|
||||
PYLINT = @PYLINT@
|
||||
PYTHON = @PYTHON@
|
||||
PYTHON2 = @PYTHON2@
|
||||
PYTHON3 = @PYTHON3@
|
||||
PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
|
||||
PYTHON_INSTALL_EXTRA_OPTIONS = @PYTHON_INSTALL_EXTRA_OPTIONS@
|
||||
PYTHON_PLATFORM = @PYTHON_PLATFORM@
|
||||
PYTHON_PREFIX = @PYTHON_PREFIX@
|
||||
PYTHON_VERSION = @PYTHON_VERSION@
|
||||
@@ -345,13 +288,10 @@ RANLIB = @RANLIB@
|
||||
SAMBA40EXTRA_LIBPATH = @SAMBA40EXTRA_LIBPATH@
|
||||
SAMBAUTIL_CFLAGS = @SAMBAUTIL_CFLAGS@
|
||||
SAMBAUTIL_LIBS = @SAMBAUTIL_LIBS@
|
||||
SASL_CFLAGS = @SASL_CFLAGS@
|
||||
SASL_LIBS = @SASL_LIBS@
|
||||
SED = @SED@
|
||||
SET_MAKE = @SET_MAKE@
|
||||
SHELL = @SHELL@
|
||||
SSSCERTMAP_CFLAGS = @SSSCERTMAP_CFLAGS@
|
||||
SSSCERTMAP_LIBS = @SSSCERTMAP_LIBS@
|
||||
SSL_LIBS = @SSL_LIBS@
|
||||
SSSIDMAP_CFLAGS = @SSSIDMAP_CFLAGS@
|
||||
SSSIDMAP_LIBS = @SSSIDMAP_LIBS@
|
||||
SSSNSSIDMAP_CFLAGS = @SSSNSSIDMAP_CFLAGS@
|
||||
@@ -363,16 +303,8 @@ TEVENT_CFLAGS = @TEVENT_CFLAGS@
|
||||
TEVENT_LIBS = @TEVENT_LIBS@
|
||||
UNISTRING_LIBS = @UNISTRING_LIBS@
|
||||
UNLINK = @UNLINK@
|
||||
USE_NLS = @USE_NLS@
|
||||
UUID_CFLAGS = @UUID_CFLAGS@
|
||||
UUID_LIBS = @UUID_LIBS@
|
||||
VENDOR_SUFFIX = @VENDOR_SUFFIX@
|
||||
VERSION = @VERSION@
|
||||
XGETTEXT = @XGETTEXT@
|
||||
XGETTEXT_015 = @XGETTEXT_015@
|
||||
XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@
|
||||
XMLRPC_CFLAGS = @XMLRPC_CFLAGS@
|
||||
XMLRPC_LIBS = @XMLRPC_LIBS@
|
||||
abs_builddir = @abs_builddir@
|
||||
abs_srcdir = @abs_srcdir@
|
||||
abs_top_builddir = @abs_top_builddir@
|
||||
@@ -403,7 +335,6 @@ host_cpu = @host_cpu@
|
||||
host_os = @host_os@
|
||||
host_vendor = @host_vendor@
|
||||
htmldir = @htmldir@
|
||||
i18ntests = @i18ntests@
|
||||
includedir = @includedir@
|
||||
infodir = @infodir@
|
||||
install_sh = @install_sh@
|
||||
@@ -427,31 +358,32 @@ sbindir = @sbindir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
srcdir = @srcdir@
|
||||
sysconfdir = @sysconfdir@
|
||||
sysconfenvdir = @sysconfenvdir@
|
||||
systemdsystemunitdir = @systemdsystemunitdir@
|
||||
systemdtmpfilesdir = @systemdtmpfilesdir@
|
||||
target_alias = @target_alias@
|
||||
top_build_prefix = @top_build_prefix@
|
||||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
PLUGIN_COMMON_DIR = $(srcdir)/../common
|
||||
MAINTAINERCLEANFILES = *~ Makefile.in
|
||||
PLUGIN_COMMON_DIR = ../common
|
||||
AM_CPPFLAGS = \
|
||||
-I. \
|
||||
-I$(srcdir) \
|
||||
-I$(srcdir)/../libotp \
|
||||
-I$(PLUGIN_COMMON_DIR) \
|
||||
-I/usr/include/dirsrv \
|
||||
-DPREFIX=\""$(prefix)"\" \
|
||||
-DBINDIR=\""$(bindir)"\" \
|
||||
-DLIBDIR=\""$(libdir)"\" \
|
||||
-DLIBEXECDIR=\""$(libexecdir)"\" \
|
||||
-DDATADIR=\""$(datadir)"\" \
|
||||
$(AM_CFLAGS) \
|
||||
$(DIRSRV_CFLAGS) \
|
||||
$(LDAP_CFLAGS) \
|
||||
$(WARN_CFLAGS)
|
||||
|
||||
plugindir = $(libdir)/dirsrv/plugins
|
||||
plugin_LTLIBRARIES = libipa_otp_lasttoken.la
|
||||
libipa_otp_lasttoken_la_SOURCES = ipa_otp_lasttoken.c ipa-otp-lasttoken.sym
|
||||
libipa_otp_lasttoken_la_LDFLAGS = -avoid-version -export-symbols $(srcdir)/ipa-otp-lasttoken.sym
|
||||
libipa_otp_lasttoken_la_SOURCES = ipa_otp_lasttoken.c
|
||||
libipa_otp_lasttoken_la_LDFLAGS = -avoid-version -export-symbols ipa-otp-lasttoken.sym
|
||||
libipa_otp_lasttoken_la_LIBADD = \
|
||||
$(LDAP_LIBS) \
|
||||
$(builddir)/../libotp/libotp.la
|
||||
@@ -460,7 +392,7 @@ all: all-am
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .c .lo .o .obj
|
||||
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
|
||||
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
|
||||
@for dep in $?; do \
|
||||
case '$(am__configure_deps)' in \
|
||||
*$$dep*) \
|
||||
@@ -469,9 +401,10 @@ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
|
||||
exit 1;; \
|
||||
esac; \
|
||||
done; \
|
||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign daemons/ipa-slapi-plugins/ipa-otp-lasttoken/Makefile'; \
|
||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign ipa-slapi-plugins/ipa-otp-lasttoken/Makefile'; \
|
||||
$(am__cd) $(top_srcdir) && \
|
||||
$(AUTOMAKE) --foreign daemons/ipa-slapi-plugins/ipa-otp-lasttoken/Makefile
|
||||
$(AUTOMAKE) --foreign ipa-slapi-plugins/ipa-otp-lasttoken/Makefile
|
||||
.PRECIOUS: Makefile
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
@case '$?' in \
|
||||
*config.status*) \
|
||||
@@ -484,9 +417,9 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
|
||||
$(top_srcdir)/configure: $(am__configure_deps)
|
||||
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
|
||||
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
$(am__aclocal_m4_deps):
|
||||
|
||||
@@ -682,6 +615,7 @@ distclean-generic:
|
||||
maintainer-clean-generic:
|
||||
@echo "This command is intended for maintainers to use"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
-test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
|
||||
clean: clean-am
|
||||
|
||||
clean-am: clean-generic clean-libtool clean-pluginLTLIBRARIES \
|
||||
@@ -770,8 +704,6 @@ uninstall-am: uninstall-pluginLTLIBRARIES
|
||||
pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \
|
||||
uninstall-pluginLTLIBRARIES
|
||||
|
||||
.PRECIOUS: Makefile
|
||||
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
|
||||
@@ -41,182 +41,116 @@
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "../libotp/otp_token.h"
|
||||
#include <libotp.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "util.h"
|
||||
#define PLUGIN_NAME "ipa-otp-lasttoken"
|
||||
#define LOG(sev, ...) \
|
||||
slapi_log_error(SLAPI_LOG_ ## sev, PLUGIN_NAME, \
|
||||
"%s: %s\n", __func__, __VA_ARGS__), -1
|
||||
|
||||
#define PLUGIN_NAME "ipa-otp-lasttoken"
|
||||
#define OTP_CONTAINER "cn=otp,%s"
|
||||
static void *plugin_id;
|
||||
static const Slapi_PluginDesc preop_desc = {
|
||||
PLUGIN_NAME,
|
||||
"FreeIPA",
|
||||
"FreeIPA/1.0",
|
||||
"Protect the user's last active token"
|
||||
};
|
||||
|
||||
static struct otp_config *otp_config;
|
||||
|
||||
static bool entry_is_token(Slapi_Entry *entry)
|
||||
{
|
||||
char **ocls;
|
||||
|
||||
ocls = slapi_entry_attr_get_charray(entry, SLAPI_ATTR_OBJECTCLASS);
|
||||
for (size_t i = 0; ocls != NULL && ocls[i] != NULL; i++) {
|
||||
if (strcasecmp(ocls[i], "ipaToken") == 0) {
|
||||
slapi_ch_array_free(ocls);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool sdn_in_otp_container(Slapi_DN *sdn)
|
||||
{
|
||||
const Slapi_DN *base;
|
||||
Slapi_DN *container;
|
||||
bool result;
|
||||
char *dn;
|
||||
|
||||
base = slapi_get_suffix_by_dn(sdn);
|
||||
if (base == NULL)
|
||||
return false;
|
||||
|
||||
dn = slapi_ch_smprintf(OTP_CONTAINER, slapi_sdn_get_dn(base));
|
||||
if (dn == NULL)
|
||||
return false;
|
||||
|
||||
container = slapi_sdn_new_dn_passin(dn);
|
||||
result = slapi_sdn_issuffix(sdn, container);
|
||||
slapi_sdn_free(&container);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static bool sdn_is_only_enabled_token(Slapi_DN *target_sdn, const char *user_dn)
|
||||
{
|
||||
struct otp_token **tokens;
|
||||
bool result = false;
|
||||
|
||||
tokens = otp_token_find(otp_config, user_dn, NULL, true, NULL);
|
||||
|
||||
if (tokens != NULL && tokens[0] != NULL && tokens[1] == NULL) {
|
||||
const Slapi_DN *token_sdn = otp_token_get_sdn(tokens[0]);
|
||||
if (token_sdn != NULL)
|
||||
result = slapi_sdn_compare(token_sdn, target_sdn) == 0;
|
||||
}
|
||||
|
||||
otp_token_free_array(tokens);
|
||||
return result;
|
||||
}
|
||||
|
||||
static bool is_pwd_enabled(const char *user_dn)
|
||||
{
|
||||
char *attrs[] = { "ipaUserAuthType", NULL };
|
||||
Slapi_Entry *entry = NULL;
|
||||
uint32_t authtypes;
|
||||
Slapi_DN *sdn;
|
||||
int search_result = 0;
|
||||
|
||||
sdn = slapi_sdn_new_dn_byval(user_dn);
|
||||
if (sdn == NULL)
|
||||
return false;
|
||||
|
||||
search_result = slapi_search_internal_get_entry(sdn, attrs, &entry,
|
||||
otp_config_plugin_id(otp_config));
|
||||
if (search_result != LDAP_SUCCESS) {
|
||||
LOG_TRACE("File '%s' line %d: Unable to access LDAP entry '%s'. "
|
||||
"Perhaps it doesn't exist? Error code: %d\n", __FILE__,
|
||||
__LINE__, slapi_sdn_get_dn(sdn), search_result);
|
||||
}
|
||||
slapi_sdn_free(&sdn);
|
||||
if (entry == NULL)
|
||||
return false;
|
||||
|
||||
authtypes = otp_config_auth_types(otp_config, entry);
|
||||
slapi_entry_free(entry);
|
||||
|
||||
return authtypes & OTP_CONFIG_AUTH_TYPE_PASSWORD;
|
||||
}
|
||||
|
||||
static bool is_allowed(Slapi_PBlock *pb, Slapi_Entry *entry)
|
||||
static bool
|
||||
target_is_only_enabled_token(Slapi_PBlock *pb)
|
||||
{
|
||||
Slapi_DN *target_sdn = NULL;
|
||||
const char *bind_dn;
|
||||
Slapi_DN *token_sdn = NULL;
|
||||
struct otptoken **tokens;
|
||||
char *user_dn = NULL;
|
||||
bool match;
|
||||
|
||||
/* Ignore internal operations. */
|
||||
if (slapi_op_internal(pb))
|
||||
return true;
|
||||
return false;
|
||||
|
||||
/* Load parameters. */
|
||||
(void) slapi_pblock_get(pb, SLAPI_TARGET_SDN, &target_sdn);
|
||||
(void) slapi_pblock_get(pb, SLAPI_CONN_DN, &bind_dn);
|
||||
if (target_sdn == NULL || bind_dn == NULL) {
|
||||
LOG_FATAL("Missing parameters!\n");
|
||||
/* Get the current user's SDN. */
|
||||
slapi_pblock_get(pb, SLAPI_CONN_DN, &user_dn);
|
||||
if (user_dn == NULL)
|
||||
return false;
|
||||
|
||||
/* Get the SDN of the only enabled token. */
|
||||
tokens = otptoken_find(plugin_id, user_dn, NULL, true, NULL);
|
||||
if (tokens != NULL && tokens[0] != NULL && tokens[1] == NULL)
|
||||
token_sdn = slapi_sdn_dup(otptoken_get_sdn(tokens[0]));
|
||||
otptoken_free_array(tokens);
|
||||
if (token_sdn == NULL)
|
||||
return false;
|
||||
|
||||
/* Get the target SDN. */
|
||||
slapi_pblock_get(pb, SLAPI_TARGET_SDN, &target_sdn);
|
||||
if (target_sdn == NULL) {
|
||||
slapi_sdn_free(&token_sdn);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (entry != NULL
|
||||
? !entry_is_token(entry)
|
||||
: !sdn_in_otp_container(target_sdn))
|
||||
return true;
|
||||
|
||||
if (!sdn_is_only_enabled_token(target_sdn, bind_dn))
|
||||
return true;
|
||||
|
||||
if (is_pwd_enabled(bind_dn))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
/* Does the target SDN match the only enabled token SDN? */
|
||||
match = slapi_sdn_compare(token_sdn, target_sdn) == 0;
|
||||
slapi_sdn_free(&token_sdn);
|
||||
return match;
|
||||
}
|
||||
|
||||
static inline int send_error(Slapi_PBlock *pb, int rc, const char *errstr)
|
||||
static inline int
|
||||
send_error(Slapi_PBlock *pb, int rc, char *errstr)
|
||||
{
|
||||
slapi_send_ldap_result(pb, rc, NULL, (char *) errstr, 0, NULL);
|
||||
if (slapi_pblock_set(pb, SLAPI_RESULT_CODE, &rc)) {
|
||||
LOG_FATAL("slapi_pblock_set failed!\n");
|
||||
}
|
||||
slapi_send_ldap_result(pb, rc, NULL, errstr, 0, NULL);
|
||||
slapi_pblock_set(pb, SLAPI_RESULT_CODE, &rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int preop_del(Slapi_PBlock *pb)
|
||||
static int
|
||||
preop_del(Slapi_PBlock *pb)
|
||||
{
|
||||
if (is_allowed(pb, NULL))
|
||||
if (!target_is_only_enabled_token(pb))
|
||||
return 0;
|
||||
|
||||
return send_error(pb, LDAP_UNWILLING_TO_PERFORM,
|
||||
"Can't delete last active token");
|
||||
}
|
||||
|
||||
static int preop_mod(Slapi_PBlock *pb)
|
||||
static int
|
||||
preop_mod(Slapi_PBlock *pb)
|
||||
{
|
||||
static const struct {
|
||||
const char *attr;
|
||||
const char *msg;
|
||||
} errors[] = {
|
||||
{"ipatokenDisabled", "Can't disable last active token"},
|
||||
{"ipatokenOwner", "Can't change last active token's owner"},
|
||||
{"ipatokenNotBefore", "Can't change last active token's start time"},
|
||||
{"ipatokenNotAfter", "Can't change last active token's end time"},
|
||||
{}
|
||||
};
|
||||
LDAPMod **mods = NULL;
|
||||
|
||||
const LDAPMod **mods = NULL;
|
||||
Slapi_Entry *entry = NULL;
|
||||
|
||||
(void) slapi_pblock_get(pb, SLAPI_ENTRY_PRE_OP, &entry);
|
||||
(void) slapi_pblock_get(pb, SLAPI_MODIFY_MODS, &mods);
|
||||
|
||||
if (is_allowed(pb, entry))
|
||||
if (!target_is_only_enabled_token(pb))
|
||||
return 0;
|
||||
|
||||
/* If a protected attribute is modified, deny. */
|
||||
/* Do not permit deactivation of the last active token. */
|
||||
slapi_pblock_get(pb, SLAPI_MODIFY_MODS, &mods);
|
||||
for (int i = 0; mods != NULL && mods[i] != NULL; i++) {
|
||||
for (int j = 0; errors[j].attr != NULL; j++) {
|
||||
if (strcasecmp(mods[i]->mod_type, errors[j].attr) == 0)
|
||||
return send_error(pb, LDAP_UNWILLING_TO_PERFORM, errors[j].msg);
|
||||
if (strcasecmp(mods[i]->mod_type, "ipatokenDisabled") == 0) {
|
||||
return send_error(pb, LDAP_UNWILLING_TO_PERFORM,
|
||||
"Can't disable last active token");
|
||||
}
|
||||
|
||||
if (strcasecmp(mods[i]->mod_type, "ipatokenOwner") == 0) {
|
||||
return send_error(pb, LDAP_UNWILLING_TO_PERFORM,
|
||||
"Can't change last active token's owner");
|
||||
}
|
||||
|
||||
if (strcasecmp(mods[i]->mod_type, "ipatokenNotBefore") == 0) {
|
||||
return send_error(pb, LDAP_UNWILLING_TO_PERFORM,
|
||||
"Can't change last active token's start time");
|
||||
}
|
||||
|
||||
if (strcasecmp(mods[i]->mod_type, "ipatokenNotAfter") == 0) {
|
||||
return send_error(pb, LDAP_UNWILLING_TO_PERFORM,
|
||||
"Can't change last active token's end time");
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int preop_init(Slapi_PBlock *pb)
|
||||
static int
|
||||
preop_init(Slapi_PBlock *pb)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
@@ -225,59 +159,15 @@ static int preop_init(Slapi_PBlock *pb)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int update_config(Slapi_PBlock *pb)
|
||||
int
|
||||
ipa_otp_lasttoken_init(Slapi_PBlock *pb)
|
||||
{
|
||||
otp_config_update(otp_config, pb);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int intpostop_init(Slapi_PBlock *pb)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
ret |= slapi_pblock_set(pb, SLAPI_PLUGIN_INTERNAL_POST_ADD_FN, (void *) update_config);
|
||||
ret |= slapi_pblock_set(pb, SLAPI_PLUGIN_INTERNAL_POST_DELETE_FN, (void *) update_config);
|
||||
ret |= slapi_pblock_set(pb, SLAPI_PLUGIN_INTERNAL_POST_MODIFY_FN, (void *) update_config);
|
||||
ret |= slapi_pblock_set(pb, SLAPI_PLUGIN_INTERNAL_POST_MODRDN_FN, (void *) update_config);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int postop_init(Slapi_PBlock *pb)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
ret |= slapi_pblock_set(pb, SLAPI_PLUGIN_POST_ADD_FN, (void *) update_config);
|
||||
ret |= slapi_pblock_set(pb, SLAPI_PLUGIN_POST_DELETE_FN, (void *) update_config);
|
||||
ret |= slapi_pblock_set(pb, SLAPI_PLUGIN_POST_MODIFY_FN, (void *) update_config);
|
||||
ret |= slapi_pblock_set(pb, SLAPI_PLUGIN_POST_MODRDN_FN, (void *) update_config);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ipa_otp_lasttoken_init(Slapi_PBlock *pb)
|
||||
{
|
||||
static const Slapi_PluginDesc preop_desc = {
|
||||
PLUGIN_NAME,
|
||||
"FreeIPA",
|
||||
"FreeIPA/1.0",
|
||||
"Protect the user's last active token"
|
||||
};
|
||||
|
||||
Slapi_ComponentId *plugin_id = NULL;
|
||||
int ret = 0;
|
||||
|
||||
ret |= slapi_pblock_get(pb, SLAPI_PLUGIN_IDENTITY, &plugin_id);
|
||||
ret |= slapi_pblock_set(pb, SLAPI_PLUGIN_VERSION, SLAPI_PLUGIN_VERSION_01);
|
||||
ret |= slapi_pblock_set(pb, SLAPI_PLUGIN_DESCRIPTION, (void *) &preop_desc);
|
||||
ret |= slapi_register_plugin("betxnpreoperation", 1, __func__, preop_init,
|
||||
PLUGIN_NAME " betxnpreoperation", NULL, plugin_id);
|
||||
ret |= slapi_register_plugin("postoperation", 1, __func__, postop_init,
|
||||
PLUGIN_NAME " postoperation", NULL, plugin_id);
|
||||
ret |= slapi_register_plugin("internalpostoperation", 1, __func__, intpostop_init,
|
||||
PLUGIN_NAME " internalpostoperation", NULL, plugin_id);
|
||||
|
||||
/* NOTE: leak otp_config on process exit. */
|
||||
otp_config = otp_config_init(plugin_id);
|
||||
PLUGIN_NAME, NULL, plugin_id);
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user