Imported Upstream version 4.0.5

This commit is contained in:
Mario Fetka
2021-07-25 07:50:50 +02:00
parent 8ff3be4216
commit 3bfaa6e020
2049 changed files with 317193 additions and 1632423 deletions

View File

@@ -1,18 +1,9 @@
NULL =
MAINTAINERCLEANFILES = *~ Makefile.in
AM_CPPFLAGS = -I/usr/include/dirsrv
PLUGIN_COMMON_DIR = $(srcdir)/../common
AM_CPPFLAGS = \
-I$(PLUGIN_COMMON_DIR) \
$(DIRSRV_CFLAGS) \
$(NSPR_CFLAGS) \
$(NSS_CFLAGS) \
$(NULL)
noinst_LTLIBRARIES = librfc.la libotp.la
libotp_la_LIBADD = librfc.la
noinst_LTLIBRARIES = libhotp.la libotp.la
libhotp_la_SOURCES = hotp.c hotp.h
libotp_la_SOURCES = otp_config.c otp_config.h otp_token.c otp_token.h
libotp_la_LIBADD = libhotp.la
check_PROGRAMS = t_hotp
check_PROGRAMS = t_librfc
TESTS = $(check_PROGRAMS)
t_hotp_LDADD = libhotp.la $(NSPR_LIBS) $(NSS_LIBS)
t_librfc_LDADD = $(NSPR_LIBS) $(NSS_LIBS) librfc.la

View File

@@ -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,41 +78,35 @@ PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
check_PROGRAMS = t_hotp$(EXEEXT)
subdir = daemons/ipa-slapi-plugins/libotp
check_PROGRAMS = t_librfc$(EXEEXT)
subdir = ipa-slapi-plugins/libotp
DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
$(top_srcdir)/depcomp $(top_srcdir)/test-driver
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 =
CONFIG_CLEAN_VPATH_FILES =
LTLIBRARIES = $(noinst_LTLIBRARIES)
libhotp_la_LIBADD =
am_libhotp_la_OBJECTS = hotp.lo
libhotp_la_OBJECTS = $(am_libhotp_la_OBJECTS)
libotp_la_DEPENDENCIES = librfc.la
libotp_la_SOURCES = libotp.c
libotp_la_OBJECTS = libotp.lo
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
am__v_lt_0 = --silent
am__v_lt_1 =
libotp_la_DEPENDENCIES = libhotp.la
am_libotp_la_OBJECTS = otp_config.lo otp_token.lo
libotp_la_OBJECTS = $(am_libotp_la_OBJECTS)
t_hotp_SOURCES = t_hotp.c
t_hotp_OBJECTS = t_hotp.$(OBJEXT)
librfc_la_LIBADD =
librfc_la_SOURCES = librfc.c
librfc_la_OBJECTS = librfc.lo
t_librfc_SOURCES = t_librfc.c
t_librfc_OBJECTS = t_librfc.$(OBJEXT)
am__DEPENDENCIES_1 =
t_hotp_DEPENDENCIES = libhotp.la $(am__DEPENDENCIES_1) \
$(am__DEPENDENCIES_1)
t_librfc_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
librfc.la
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
@@ -157,8 +141,8 @@ AM_V_CCLD = $(am__v_CCLD_@AM_V@)
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
SOURCES = $(libhotp_la_SOURCES) $(libotp_la_SOURCES) t_hotp.c
DIST_SOURCES = $(libhotp_la_SOURCES) $(libotp_la_SOURCES) t_hotp.c
SOURCES = libotp.c librfc.c t_librfc.c
DIST_SOURCES = libotp.c librfc.c t_librfc.c
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
@@ -387,13 +371,10 @@ TEST_LOGS = $(am__test_logs2:.test.log=.log)
TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver
TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \
$(TEST_LOG_FLAGS)
am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp \
$(top_srcdir)/test-driver
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@
@@ -402,15 +383,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@
@@ -424,61 +403,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@
@@ -491,10 +440,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@
@@ -508,15 +457,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@
@@ -524,13 +466,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@
@@ -542,16 +481,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@
@@ -582,7 +513,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@
@@ -606,33 +536,22 @@ 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@
NULL =
PLUGIN_COMMON_DIR = $(srcdir)/../common
AM_CPPFLAGS = \
-I$(PLUGIN_COMMON_DIR) \
$(DIRSRV_CFLAGS) \
$(NSPR_CFLAGS) \
$(NSS_CFLAGS) \
$(NULL)
noinst_LTLIBRARIES = libhotp.la libotp.la
libhotp_la_SOURCES = hotp.c hotp.h
libotp_la_SOURCES = otp_config.c otp_config.h otp_token.c otp_token.h
libotp_la_LIBADD = libhotp.la
MAINTAINERCLEANFILES = *~ Makefile.in
AM_CPPFLAGS = -I/usr/include/dirsrv
noinst_LTLIBRARIES = librfc.la libotp.la
libotp_la_LIBADD = librfc.la
TESTS = $(check_PROGRAMS)
t_hotp_LDADD = libhotp.la $(NSPR_LIBS) $(NSS_LIBS)
t_librfc_LDADD = $(NSPR_LIBS) $(NSS_LIBS) librfc.la
all: all-am
.SUFFIXES:
.SUFFIXES: .c .lo .log .o .obj .test .test$(EXEEXT) .trs
$(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*) \
@@ -641,9 +560,10 @@ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign daemons/ipa-slapi-plugins/libotp/Makefile'; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign ipa-slapi-plugins/libotp/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --foreign daemons/ipa-slapi-plugins/libotp/Makefile
$(AUTOMAKE) --foreign ipa-slapi-plugins/libotp/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
@@ -656,9 +576,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):
@@ -673,12 +593,12 @@ clean-noinstLTLIBRARIES:
rm -f $${locs}; \
}
libhotp.la: $(libhotp_la_OBJECTS) $(libhotp_la_DEPENDENCIES) $(EXTRA_libhotp_la_DEPENDENCIES)
$(AM_V_CCLD)$(LINK) $(libhotp_la_OBJECTS) $(libhotp_la_LIBADD) $(LIBS)
libotp.la: $(libotp_la_OBJECTS) $(libotp_la_DEPENDENCIES) $(EXTRA_libotp_la_DEPENDENCIES)
$(AM_V_CCLD)$(LINK) $(libotp_la_OBJECTS) $(libotp_la_LIBADD) $(LIBS)
librfc.la: $(librfc_la_OBJECTS) $(librfc_la_DEPENDENCIES) $(EXTRA_librfc_la_DEPENDENCIES)
$(AM_V_CCLD)$(LINK) $(librfc_la_OBJECTS) $(librfc_la_LIBADD) $(LIBS)
clean-checkPROGRAMS:
@list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \
echo " rm -f" $$list; \
@@ -688,9 +608,9 @@ clean-checkPROGRAMS:
echo " rm -f" $$list; \
rm -f $$list
t_hotp$(EXEEXT): $(t_hotp_OBJECTS) $(t_hotp_DEPENDENCIES) $(EXTRA_t_hotp_DEPENDENCIES)
@rm -f t_hotp$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(t_hotp_OBJECTS) $(t_hotp_LDADD) $(LIBS)
t_librfc$(EXEEXT): $(t_librfc_OBJECTS) $(t_librfc_DEPENDENCIES) $(EXTRA_t_librfc_DEPENDENCIES)
@rm -f t_librfc$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(t_librfc_OBJECTS) $(t_librfc_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
@@ -698,10 +618,9 @@ mostlyclean-compile:
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hotp.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/otp_config.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/otp_token.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t_hotp.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libotp.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/librfc.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t_librfc.Po@am__quote@
.c.o:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@@ -812,7 +731,7 @@ $(TEST_SUITE_LOG): $(TEST_LOGS)
if test -n "$$am__remaking_logs"; then \
echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \
"recursion detected" >&2; \
elif test -n "$$redo_logs"; then \
else \
am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \
fi; \
if $(am__make_dryrun); then :; else \
@@ -923,9 +842,9 @@ recheck: all $(check_PROGRAMS)
am__force_recheck=am--force-recheck \
TEST_LOGS="$$log_list"; \
exit $$?
t_hotp.log: t_hotp$(EXEEXT)
@p='t_hotp$(EXEEXT)'; \
b='t_hotp'; \
t_librfc.log: t_librfc$(EXEEXT)
@p='t_librfc$(EXEEXT)'; \
b='t_librfc'; \
$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
--log-file $$b.log --trs-file $$b.trs \
$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
@@ -1014,6 +933,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-checkPROGRAMS clean-generic clean-libtool \
@@ -1102,8 +1022,6 @@ uninstall-am:
pdf pdf-am ps ps-am recheck tags tags-am uninstall \
uninstall-am
.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.

View File

@@ -37,9 +37,8 @@
* All rights reserved.
* END COPYRIGHT BLOCK **/
#include "otp_token.h"
#include "otp_config.h"
#include "hotp.h"
#include "libotp.h"
#include "librfc.h"
#include <time.h>
#include <errno.h>
@@ -53,22 +52,22 @@
#define IPA_OTP_OBJCLS_FILTER \
"(|(objectClass=ipaTokenTOTP)(objectClass=ipaTokenHOTP))"
enum type {
TYPE_NONE = 0,
TYPE_TOTP,
TYPE_HOTP,
enum otptoken_type {
OTPTOKEN_NONE = 0,
OTPTOKEN_TOTP,
OTPTOKEN_HOTP,
};
struct otp_token {
const struct otp_config *cfg;
struct otptoken {
Slapi_ComponentId *plugin_id;
Slapi_DN *sdn;
struct hotp_token token;
enum type type;
struct otp_config_window window;
enum otptoken_type type;
union {
struct {
uint64_t watermark;
int step; /* Seconds. */
unsigned int step;
int offset;
} totp;
struct {
@@ -77,6 +76,21 @@ struct otp_token {
};
};
static const char *get_basedn(Slapi_DN *dn)
{
Slapi_DN *suffix = NULL;
void *node = NULL;
for (suffix = slapi_get_first_suffix(&node, 0);
suffix != NULL;
suffix = slapi_get_next_suffix(&node, 0)) {
if (slapi_sdn_issuffix(dn, suffix))
return (char *) slapi_sdn_get_dn(suffix);
}
return NULL;
}
static inline bool is_algo_valid(const char *algo)
{
static const char *valid_algos[] = { "sha1", "sha256", "sha384",
@@ -110,27 +124,31 @@ static const struct berval *entry_attr_get_berval(const Slapi_Entry* e,
return slapi_value_get_berval(v);
}
static bool writeattr(const struct otp_token *token, const char *attr,
long long val)
static bool writeattr(const struct otptoken *token, const char *attr,
int value)
{
Slapi_Value *svals[] = { NULL, NULL };
Slapi_PBlock *pb = NULL;
Slapi_Mods *mods = NULL;
bool success = false;
char value[32];
int ret;
LDAPMod *mods[] = {
&(LDAPMod) {
LDAP_MOD_REPLACE, (char *) attr,
.mod_values = (char *[]) { value, NULL }
},
NULL
};
/* Create the value. */
svals[0] = slapi_value_new();
if (slapi_value_set_int(svals[0], value) != 0) {
slapi_value_free(&svals[0]);
return false;
}
snprintf(value, sizeof(value), "%lld", val);
/* Create the mods. */
mods = slapi_mods_new();
slapi_mods_add_mod_values(mods, LDAP_MOD_REPLACE, attr, svals);
/* Perform the modification. */
pb = slapi_pblock_new();
slapi_modify_internal_set_pb(pb, slapi_sdn_get_dn(token->sdn), mods, NULL,
NULL, otp_config_plugin_id(token->cfg), 0);
slapi_modify_internal_set_pb(pb, slapi_sdn_get_dn(token->sdn),
slapi_mods_get_ldapmods_byref(mods),
NULL, NULL, token->plugin_id, 0);
if (slapi_modify_internal_pb(pb) != 0)
goto error;
if (slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &ret) != 0)
@@ -142,7 +160,9 @@ static bool writeattr(const struct otp_token *token, const char *attr,
error:
slapi_pblock_destroy(pb);
slapi_mods_free(&mods);
return success;
}
/**
@@ -150,7 +170,7 @@ error:
*
* If the second token code is specified, perform synchronization.
*/
static bool validate(struct otp_token *token, time_t now, ssize_t step,
static bool validate(struct otptoken *token, time_t now, ssize_t step,
uint32_t first, const uint32_t *second)
{
const char *attr;
@@ -158,13 +178,13 @@ static bool validate(struct otp_token *token, time_t now, ssize_t step,
/* Calculate the absolute step. */
switch (token->type) {
case TYPE_TOTP:
case OTPTOKEN_TOTP:
attr = T("watermark");
step = (now + token->totp.offset) / token->totp.step + step;
if (token->totp.watermark > 0 && step < token->totp.watermark)
return false;
break;
case TYPE_HOTP:
case OTPTOKEN_HOTP:
if (step < 0) /* NEVER go backwards! */
return false;
attr = H("counter");
@@ -188,6 +208,17 @@ static bool validate(struct otp_token *token, time_t now, ssize_t step,
if (*second != tmp)
return false;
/* Perform optional synchronization steps. */
switch (token->type) {
case OTPTOKEN_TOTP:
tmp = (step - now / token->totp.step) * token->totp.step;
if (!writeattr(token, T("clockOffset"), tmp))
return false;
break;
default:
break;
}
}
/* Write the step value. */
@@ -196,17 +227,10 @@ static bool validate(struct otp_token *token, time_t now, ssize_t step,
/* Save our modifications to the object. */
switch (token->type) {
case TYPE_TOTP:
/* Perform optional synchronization steps. */
if (second != NULL) {
long long off = (step - now / token->totp.step) * token->totp.step;
if (!writeattr(token, T("clockOffset"), off))
return false;
token->totp.offset = off;
}
case OTPTOKEN_TOTP:
token->totp.watermark = step;
break;
case TYPE_HOTP:
case OTPTOKEN_HOTP:
token->hotp.counter = step;
break;
default:
@@ -216,7 +240,8 @@ static bool validate(struct otp_token *token, time_t now, ssize_t step,
return true;
}
static void otp_token_free(struct otp_token *token)
static void otptoken_free(struct otptoken *token)
{
if (token == NULL)
return;
@@ -227,43 +252,41 @@ static void otp_token_free(struct otp_token *token)
free(token);
}
void otp_token_free_array(struct otp_token **tokens)
void otptoken_free_array(struct otptoken **tokens)
{
if (tokens == NULL)
return;
for (size_t i = 0; tokens[i] != NULL; i++)
otp_token_free(tokens[i]);
otptoken_free(tokens[i]);
free(tokens);
}
static struct otp_token *otp_token_new(const struct otp_config *cfg,
Slapi_Entry *entry)
static struct otptoken *otptoken_new(Slapi_ComponentId *id, Slapi_Entry *entry)
{
const struct berval *tmp;
struct otp_token *token;
struct otptoken *token;
char **vals;
token = calloc(1, sizeof(struct otp_token));
token = calloc(1, sizeof(struct otptoken));
if (token == NULL)
return NULL;
token->cfg = cfg;
token->window = otp_config_window(cfg, entry);
token->plugin_id = id;
/* Get the token type. */
vals = slapi_entry_attr_get_charray(entry, "objectClass");
if (vals == NULL)
goto error;
token->type = TYPE_NONE;
token->type = OTPTOKEN_NONE;
for (int i = 0; vals[i] != NULL; i++) {
if (strcasecmp(vals[i], "ipaTokenTOTP") == 0)
token->type = TYPE_TOTP;
token->type = OTPTOKEN_TOTP;
else if (strcasecmp(vals[i], "ipaTokenHOTP") == 0)
token->type = TYPE_HOTP;
token->type = OTPTOKEN_HOTP;
}
slapi_ch_array_free(vals);
if (token->type == TYPE_NONE)
if (token->type == OTPTOKEN_NONE)
goto error;
/* Get SDN. */
@@ -294,7 +317,7 @@ static struct otp_token *otp_token_new(const struct otp_config *cfg,
goto error;
switch (token->type) {
case TYPE_TOTP:
case OTPTOKEN_TOTP:
/* Get offset. */
token->totp.offset = slapi_entry_attr_get_int(entry, T("clockOffset"));
@@ -303,10 +326,10 @@ static struct otp_token *otp_token_new(const struct otp_config *cfg,
/* Get step. */
token->totp.step = slapi_entry_attr_get_uint(entry, T("timeStep"));
if (token->totp.step < 5)
if (token->totp.step == 0)
token->totp.step = IPA_OTP_DEFAULT_TOKEN_STEP;
break;
case TYPE_HOTP:
case OTPTOKEN_HOTP:
/* Get counter. */
token->hotp.counter = slapi_entry_attr_get_int(entry, H("counter"));
break;
@@ -317,20 +340,20 @@ static struct otp_token *otp_token_new(const struct otp_config *cfg,
return token;
error:
otp_token_free(token);
otptoken_free(token);
return NULL;
}
static struct otp_token **find(const struct otp_config *cfg, const char *user_dn,
const char *token_dn, const char *intfilter,
const char *extfilter)
static struct otptoken **find(Slapi_ComponentId *id, const char *user_dn,
const char *token_dn, const char *intfilter,
const char *extfilter)
{
struct otp_token **tokens = NULL;
const Slapi_DN *basedn = NULL;
struct otptoken **tokens = NULL;
Slapi_Entry **entries = NULL;
Slapi_PBlock *pb = NULL;
Slapi_DN *sdn = NULL;
char *filter = NULL;
const char *basedn = NULL;
size_t count = 0;
int result = -1;
@@ -355,19 +378,20 @@ static struct otp_token **find(const struct otp_config *cfg, const char *user_dn
if (token_dn != NULL) {
/* Find only the token specified. */
slapi_search_internal_set_pb(pb, token_dn, LDAP_SCOPE_BASE, filter,
NULL, 0, NULL, NULL,
otp_config_plugin_id(cfg), 0);
NULL, 0, NULL, NULL, id, 0);
} else {
sdn = slapi_sdn_new_dn_byval(user_dn);
basedn = slapi_get_suffix_by_dn(sdn);
slapi_sdn_free(&sdn);
if (sdn == NULL)
goto error;
basedn = get_basedn(sdn);
if (basedn == NULL)
goto error;
/* Find all user tokens. */
slapi_search_internal_set_pb(pb, slapi_sdn_get_dn(basedn),
LDAP_SCOPE_SUBTREE, filter, NULL, 0,
NULL, NULL, otp_config_plugin_id(cfg), 0);
slapi_search_internal_set_pb(pb, basedn,
LDAP_SCOPE_SUBTREE, filter, NULL,
0, NULL, NULL, id, 0);
}
slapi_search_internal_pb(pb);
slapi_ch_free_string(&filter);
@@ -389,22 +413,24 @@ static struct otp_token **find(const struct otp_config *cfg, const char *user_dn
if (tokens == NULL)
goto error;
for (count = 0; entries[count] != NULL; count++) {
tokens[count] = otp_token_new(cfg, entries[count]);
tokens[count] = otptoken_new(id, entries[count]);
if (tokens[count] == NULL) {
otp_token_free_array(tokens);
otptoken_free_array(tokens);
tokens = NULL;
goto error;
}
}
error:
if (sdn != NULL)
slapi_sdn_free(&sdn);
slapi_pblock_destroy(pb);
return tokens;
}
struct otp_token **otp_token_find(const struct otp_config *cfg,
const char *user_dn, const char *token_dn,
bool active, const char *filter)
struct otptoken **otptoken_find(Slapi_ComponentId *id, const char *user_dn,
const char *token_dn, bool active,
const char *filter)
{
static const char template[] =
"(|(ipatokenNotBefore<=%04d%02d%02d%02d%02d%02dZ)(!(ipatokenNotBefore=*)))"
@@ -415,7 +441,7 @@ struct otp_token **otp_token_find(const struct otp_config *cfg,
time_t now;
if (!active)
return find(cfg, user_dn, token_dn, NULL, filter);
return find(id, user_dn, token_dn, NULL, filter);
/* Get the current time. */
if (time(&now) == (time_t) -1)
@@ -431,14 +457,45 @@ struct otp_token **otp_token_find(const struct otp_config *cfg,
tm.tm_hour, tm.tm_min, tm.tm_sec) < 0)
return NULL;
return find(cfg, user_dn, token_dn, actfilt, filter);
return find(id, user_dn, token_dn, actfilt, filter);
}
const Slapi_DN *otp_token_get_sdn(struct otp_token *token)
int otptoken_get_digits(struct otptoken *token)
{
return token == NULL ? 0 : token->token.digits;
}
const Slapi_DN *otptoken_get_sdn(struct otptoken *token)
{
return token->sdn;
}
static bool otptoken_validate(struct otptoken *token, size_t steps,
uint32_t code)
{
time_t now = 0;
if (token == NULL)
return false;
/* We only need the local time for time-based tokens. */
if (token->type == OTPTOKEN_TOTP && time(&now) == (time_t) -1)
return false;
for (int i = 0; i <= steps; i++) {
/* Validate the positive step. */
if (validate(token, now, i, code, NULL))
return true;
/* Validate the negative step. */
if (validate(token, now, 0 - i, code, NULL))
return true;
}
return false;
}
/*
* Convert code berval to decimal.
*
@@ -446,40 +503,45 @@ const Slapi_DN *otp_token_get_sdn(struct otp_token *token)
* 1. If we have leading zeros, atol() fails.
* 2. Neither support limiting conversion by length.
*/
static bool bvtod(const struct berval *code, int digits, uint32_t *out)
static bool bvtod(const struct berval *code, uint32_t *out)
{
*out = 0;
if (code == NULL || digits <= 0 || code->bv_len < digits)
return false;
for (ber_len_t i = code->bv_len - digits; i < code->bv_len; i++) {
for (ber_len_t i = 0; i < code->bv_len; i++) {
if (code->bv_val[i] < '0' || code->bv_val[i] > '9')
return false;
*out *= 10;
*out += code->bv_val[i] - '0';
}
return true;
return code->bv_len != 0;
}
static bool step_is_valid(struct otp_token *token, bool sync, uint32_t i)
bool otptoken_validate_berval(struct otptoken *token, size_t steps,
const struct berval *code, bool tail)
{
uint32_t window = sync ? token->window.sync : token->window.auth;
struct berval tmp;
uint32_t otp;
switch (token->type) {
case TYPE_TOTP:
return i * token->totp.step < window;
case TYPE_HOTP:
return i < window;
default:
if (token == NULL || code == NULL)
return false;
}
tmp = *code;
if (tmp.bv_len < token->token.digits)
return false;
if (tail)
tmp.bv_val = &tmp.bv_val[tmp.bv_len - token->token.digits];
tmp.bv_len = token->token.digits;
if (!bvtod(&tmp, &otp))
return false;
return otptoken_validate(token, steps, otp);
}
bool otp_token_validate_berval(struct otp_token * const *tokens,
struct berval *first_code,
struct berval *second_code)
static bool otptoken_sync(struct otptoken * const *tokens, size_t steps,
uint32_t first_code, uint32_t second_code)
{
time_t now = 0;
@@ -489,45 +551,33 @@ bool otp_token_validate_berval(struct otp_token * const *tokens,
if (time(&now) == (time_t) -1)
return false;
for (ssize_t i = 0, cnt = 1; cnt != 0; i++) {
cnt = 0;
for (int i = 0; i <= steps; i++) {
for (int j = 0; tokens[j] != NULL; j++) {
uint32_t *secondp = NULL;
uint32_t second;
uint32_t first;
/* Validate the positive step. */
if (validate(tokens[j], now, i, first_code, &second_code))
return true;
/* Don't validate beyond the specified window. */
if (!step_is_valid(tokens[j], second_code != NULL, i))
continue;
cnt++;
/* Parse the first code. */
if (!bvtod(first_code, tokens[j]->token.digits, &first))
continue;
/* Parse the second code. */
if (second_code != NULL) {
secondp = &second;
if (!bvtod(second_code, tokens[j]->token.digits, secondp))
continue;
}
/* Validate the positive/negative steps. */
if (!validate(tokens[j], now, i, first, secondp) &&
!validate(tokens[j], now, -i, first, secondp))
continue;
/* Codes validated; strip. */
first_code->bv_len -= tokens[j]->token.digits;
first_code->bv_val[first_code->bv_len] = '\0';
if (second_code != NULL) {
second_code->bv_len -= tokens[j]->token.digits;
second_code->bv_val[second_code->bv_len] = '\0';
}
return true;
/* Validate the negative step. */
if (validate(tokens[j], now, 0 - i, first_code, &second_code))
return true;
}
}
return false;
}
bool otptoken_sync_berval(struct otptoken * const *tokens, size_t steps,
const struct berval *first_code,
const struct berval *second_code)
{
uint32_t second = 0;
uint32_t first = 0;
if (!bvtod(first_code, &first))
return false;
if (!bvtod(second_code, &second))
return false;
return otptoken_sync(tokens, steps, first, second);
}

View File

@@ -37,17 +37,21 @@
* All rights reserved.
* END COPYRIGHT BLOCK **/
#pragma once
#ifndef LIBOTP_H_
#define LIBOTP_H_
#include "otp_config.h"
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <dirsrv/slapi-plugin.h>
#include <stdbool.h>
#include <stdlib.h>
struct otp_token;
struct otptoken;
/* Frees the token array. */
void
otp_token_free_array(struct otp_token **tokens);
void otptoken_free_array(struct otptoken **tokens);
/* Find tokens.
*
@@ -66,23 +70,24 @@ otp_token_free_array(struct otp_token **tokens);
* Returns NULL on error. If no tokens are found, an empty array is returned.
* The array is NULL terminated.
*/
struct otp_token **otp_token_find(const struct otp_config *cfg,
const char *user_dn, const char *token_dn,
bool active, const char *filter);
struct otptoken **otptoken_find(Slapi_ComponentId *id, const char *user_dn,
const char *token_dn, bool active,
const char *filter);
/* Get the length of the token code. */
int otptoken_get_digits(struct otptoken *token);
/* Get the SDN of the token. */
const Slapi_DN *otp_token_get_sdn(struct otp_token *token);
const Slapi_DN *otptoken_get_sdn(struct otptoken *token);
/* Perform OTP authentication.
*
* If only the first code is specified, validation will be performed and the
* validated token will be stripped.
*
* If both codes are specified, synchronization will be performed and the
* validated tokens will be stripped.
*
* Returns true if and only if all specified tokens were validated.
*/
bool otp_token_validate_berval(struct otp_token * const *tokens,
struct berval *first_code,
struct berval *second_code);
/* Validate the token code within a range of steps. If tail is true,
* it will be assumed that the token is specified at the end of the string. */
bool otptoken_validate_berval(struct otptoken *token, size_t steps,
const struct berval *code, bool tail);
/* Synchronize the token within a range of steps. */
bool otptoken_sync_berval(struct otptoken * const *tokens, size_t steps,
const struct berval *first_code,
const struct berval *second_code);
#endif /* LIBOTP_H_ */

View File

@@ -42,7 +42,7 @@
* For details of how these algorithms work, please see the relevant RFCs.
*/
#include "hotp.h"
#include "librfc.h"
#include <time.h>
#include <nss.h>

View File

@@ -37,7 +37,8 @@
* All rights reserved.
* END COPYRIGHT BLOCK **/
#pragma once
#ifndef LIBRFC_H_
#define LIBRFC_H_
#include <stdbool.h>
#include <stdint.h>
@@ -58,3 +59,5 @@ struct hotp_token {
* An implementation of HOTP (RFC 4226).
*/
bool hotp(const struct hotp_token *token, uint64_t counter, uint32_t *out);
#endif /* LIBRFC_H_ */

View File

@@ -1,364 +0,0 @@
/** BEGIN COPYRIGHT BLOCK
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional permission under GPLv3 section 7:
*
* In the following paragraph, "GPL" means the GNU General Public
* License, version 3 or any later version, and "Non-GPL Code" means
* code that is governed neither by the GPL nor a license
* compatible with the GPL.
*
* You may link the code of this Program with Non-GPL Code and convey
* linked combinations including the two, provided that such Non-GPL
* Code only links to the code of this Program through those well
* defined interfaces identified in the file named EXCEPTION found in
* the source code files (the "Approved Interfaces"). The files of
* Non-GPL Code may instantiate templates or use macros or inline
* functions from the Approved Interfaces without causing the resulting
* work to be covered by the GPL. Only the copyright holders of this
* Program may make changes or additions to the list of Approved
* Interfaces.
*
* Authors:
* Nathaniel McCallum <npmccallum@redhat.com>
*
* Copyright (C) 2014 Red Hat, Inc.
* All rights reserved.
* END COPYRIGHT BLOCK **/
#include "otp_config.h"
#include "util.h"
#include <pratom.h>
#include <plstr.h>
#define OTP_CONFIG_AUTH_TYPE_DISABLED (1 << 31)
struct spec {
uint32_t (*func)(Slapi_Entry *, const char *attr);
const char *prefix;
const char *attr;
uint32_t dflt;
};
struct record {
struct record *next;
const struct spec *spec;
Slapi_DN *sdn;
uint32_t value;
};
struct otp_config {
Slapi_ComponentId *plugin_id;
struct record *records;
};
static uint32_t string_to_types(const char *str)
{
static const struct {
const char *string;
uint32_t config;
} map[] = {
{ "disabled", OTP_CONFIG_AUTH_TYPE_DISABLED },
{ "password", OTP_CONFIG_AUTH_TYPE_PASSWORD },
{ "otp", OTP_CONFIG_AUTH_TYPE_OTP },
{ "pkinit", OTP_CONFIG_AUTH_TYPE_PKINIT },
{ "radius", OTP_CONFIG_AUTH_TYPE_RADIUS },
{}
};
for (uint32_t i = 0; map[i].string != NULL; i++) {
if (strcasecmp(map[i].string, str) == 0)
return map[i].config;
}
return OTP_CONFIG_AUTH_TYPE_NONE;
}
static uint32_t entry_to_authtypes(Slapi_Entry *e, const char *attr)
{
char **auth_types = NULL;
if (e == NULL)
return OTP_CONFIG_AUTH_TYPE_NONE;
/* Fetch the auth type values from the config entry. */
auth_types = slapi_entry_attr_get_charray(e, attr);
if (auth_types == NULL)
return OTP_CONFIG_AUTH_TYPE_NONE;
uint32_t types = OTP_CONFIG_AUTH_TYPE_NONE;
for (uint32_t i = 0; auth_types[i] != NULL; i++)
types |= string_to_types(auth_types[i]);
slapi_ch_array_free(auth_types);
return types;
}
static uint32_t entry_to_window(Slapi_Entry *e, const char *attr)
{
long long val;
if (e == NULL)
return 0;
val = slapi_entry_attr_get_longlong(e, attr);
return val > 0 ? val : 0;
}
static const struct spec authtypes = {
entry_to_authtypes,
"cn=ipaConfig,cn=etc,%s",
"ipaUserAuthType",
OTP_CONFIG_AUTH_TYPE_PASSWORD
};
static const struct spec totp_auth_window = {
entry_to_window,
"cn=otp,cn=etc,%s",
"ipatokenTOTPauthWindow",
300
};
static const struct spec totp_sync_window = {
entry_to_window,
"cn=otp,cn=etc,%s",
"ipatokenTOTPsyncWindow",
86400
};
static const struct spec hotp_auth_window = {
entry_to_window,
"cn=otp,cn=etc,%s",
"ipatokenHOTPauthWindow",
10
};
static const struct spec hotp_sync_window = {
entry_to_window,
"cn=otp,cn=etc,%s",
"ipatokenHOTPsyncWindow",
100
};
static Slapi_DN *make_sdn(const char *prefix, const Slapi_DN *suffix)
{
char *dn = slapi_ch_smprintf(prefix, slapi_sdn_get_dn(suffix));
return slapi_sdn_new_dn_passin(dn);
}
static uint32_t find_value(const struct otp_config *cfg,
const Slapi_DN *suffix, const struct spec *spec)
{
uint32_t value = 0;
Slapi_DN *sdn;
sdn = make_sdn(spec->prefix, suffix);
for (struct record *rec = cfg->records; rec != NULL; rec = rec->next) {
if (rec->spec != spec)
continue;
if (slapi_sdn_compare(sdn, rec->sdn) != 0)
continue;
value = PR_ATOMIC_ADD(&rec->value, 0);
break;
}
slapi_sdn_free(&sdn);
return value;
}
static void update(const struct otp_config *cfg, Slapi_DN *src,
Slapi_Entry *entry)
{
Slapi_DN *dst = entry == NULL ? NULL : slapi_entry_get_sdn(entry);
for (struct record *rec = cfg->records; rec != NULL; rec = rec->next) {
uint32_t val = rec->spec->dflt;
/* If added, modified or moved into place... */
if (dst != NULL && slapi_sdn_compare(rec->sdn, dst) == 0) {
Slapi_Attr *attr = NULL;
if (slapi_entry_attr_find(entry, rec->spec->attr, &attr) == 0)
val = rec->spec->func(entry, rec->spec->attr);
/* If NOT deleted or moved out of place... */
} else if (slapi_sdn_compare(rec->sdn, src) != 0)
continue;
PR_ATOMIC_SET(&rec->value, val);
}
}
struct otp_config *otp_config_init(Slapi_ComponentId *plugin_id)
{
static const struct spec *specs[] = {
&authtypes,
&totp_auth_window,
&totp_sync_window,
&hotp_auth_window,
&hotp_sync_window,
NULL
};
struct otp_config *cfg = NULL;
void *node = NULL;
int search_result = 0;
cfg = (typeof(cfg)) slapi_ch_calloc(1, sizeof(*cfg));
cfg->plugin_id = plugin_id;
/* Build the config table. */
for (Slapi_DN *sfx = slapi_get_first_suffix(&node, 0);
sfx != NULL;
sfx = slapi_get_next_suffix(&node, 0)) {
for (size_t i = 0; specs[i] != NULL; i++) {
Slapi_Entry *entry = NULL;
struct record *rec;
/* Create the config entry. */
rec = (typeof(rec)) slapi_ch_calloc(1, sizeof(*rec));
rec->spec = specs[i];
rec->sdn = make_sdn(rec->spec->prefix, sfx);
/* Add config to the list. */
rec->next = cfg->records;
cfg->records = rec;
/* Load the specified entry. */
search_result = slapi_search_internal_get_entry(rec->sdn,
NULL, &entry, plugin_id);
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(rec->sdn), search_result);
}
update(cfg, rec->sdn, entry);
slapi_entry_free(entry);
}
}
return cfg;
}
static void record_fini(struct record **rec)
{
if (rec == NULL || *rec == NULL)
return;
record_fini(&(*rec)->next);
slapi_sdn_free(&(*rec)->sdn);
slapi_ch_free((void **) rec);
}
void otp_config_fini(struct otp_config **cfg)
{
if (cfg == NULL || *cfg == NULL)
return;
record_fini(&(*cfg)->records);
slapi_ch_free((void **) cfg);
}
void otp_config_update(struct otp_config *cfg, Slapi_PBlock *pb)
{
Slapi_Entry *entry = NULL;
Slapi_DN *src = NULL;
int oprc = 0;
/* Just bail if the operation failed. */
if (slapi_pblock_get(pb, SLAPI_PLUGIN_OPRETURN, &oprc) != 0 || oprc != 0)
return;
/* Get the source SDN. */
if (slapi_pblock_get(pb, SLAPI_TARGET_SDN, &src) != 0)
return;
/* Ignore the error here (delete operations). */
(void) slapi_pblock_get(pb, SLAPI_ENTRY_POST_OP, &entry);
update(cfg, src, entry);
}
Slapi_ComponentId *otp_config_plugin_id(const struct otp_config *cfg)
{
if (cfg == NULL)
return NULL;
return cfg->plugin_id;
}
uint32_t otp_config_auth_types(const struct otp_config *cfg,
Slapi_Entry *user_entry)
{
uint32_t glbl = OTP_CONFIG_AUTH_TYPE_NONE;
uint32_t user = OTP_CONFIG_AUTH_TYPE_NONE;
const Slapi_DN *sfx;
/* Load the global value. */
sfx = slapi_get_suffix_by_dn(slapi_entry_get_sdn(user_entry));
glbl = find_value(cfg, sfx, &authtypes);
/* Load the user value if not disabled. */
if ((glbl & OTP_CONFIG_AUTH_TYPE_DISABLED) == 0)
user = entry_to_authtypes(user_entry, authtypes.attr);
/* Filter out the disabled flag. */
glbl &= ~OTP_CONFIG_AUTH_TYPE_DISABLED;
user &= ~OTP_CONFIG_AUTH_TYPE_DISABLED;
if (user != OTP_CONFIG_AUTH_TYPE_NONE)
return user;
if (glbl != OTP_CONFIG_AUTH_TYPE_NONE)
return glbl;
return OTP_CONFIG_AUTH_TYPE_PASSWORD;
}
struct otp_config_window
otp_config_window(const struct otp_config *cfg, Slapi_Entry *token_entry)
{
const struct spec *auth = NULL, *sync = NULL;
struct otp_config_window wndw = { 0, 0 };
const Slapi_DN *sfx;
char **clses;
sfx = slapi_get_suffix_by_dn(slapi_entry_get_sdn_const(token_entry));
clses = slapi_entry_attr_get_charray(token_entry, SLAPI_ATTR_OBJECTCLASS);
for (size_t i = 0; clses != NULL && clses[i] != NULL; i++) {
if (strcasecmp(clses[i], "ipatokenTOTP") == 0) {
auth = &totp_auth_window;
sync = &totp_sync_window;
break;
}
if (strcasecmp(clses[i], "ipatokenHOTP") == 0) {
auth = &hotp_auth_window;
sync = &hotp_sync_window;
break;
}
}
slapi_ch_array_free(clses);
if (auth == NULL || sync == NULL)
return wndw;
wndw.auth = find_value(cfg, sfx, auth);
wndw.sync = find_value(cfg, sfx, sync);
return wndw;
}

View File

@@ -1,82 +0,0 @@
/** BEGIN COPYRIGHT BLOCK
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional permission under GPLv3 section 7:
*
* In the following paragraph, "GPL" means the GNU General Public
* License, version 3 or any later version, and "Non-GPL Code" means
* code that is governed neither by the GPL nor a license
* compatible with the GPL.
*
* You may link the code of this Program with Non-GPL Code and convey
* linked combinations including the two, provided that such Non-GPL
* Code only links to the code of this Program through those well
* defined interfaces identified in the file named EXCEPTION found in
* the source code files (the "Approved Interfaces"). The files of
* Non-GPL Code may instantiate templates or use macros or inline
* functions from the Approved Interfaces without causing the resulting
* work to be covered by the GPL. Only the copyright holders of this
* Program may make changes or additions to the list of Approved
* Interfaces.
*
* Authors:
* Nathaniel McCallum <npmccallum@redhat.com>
*
* Copyright (C) 2014 Red Hat, Inc.
* All rights reserved.
* END COPYRIGHT BLOCK **/
#pragma once
#include <dirsrv/slapi-plugin.h>
#define OTP_CONFIG_AUTH_TYPE_NONE 0
#define OTP_CONFIG_AUTH_TYPE_PASSWORD (1 << 0)
#define OTP_CONFIG_AUTH_TYPE_OTP (1 << 1)
#define OTP_CONFIG_AUTH_TYPE_PKINIT (1 << 2)
#define OTP_CONFIG_AUTH_TYPE_RADIUS (1 << 3)
struct otp_config;
struct otp_config_window {
uint32_t auth;
uint32_t sync;
};
struct otp_config *otp_config_init(Slapi_ComponentId *plugin_id);
void otp_config_fini(struct otp_config **cfg);
void otp_config_update(struct otp_config *cfg, Slapi_PBlock *pb);
Slapi_ComponentId *otp_config_plugin_id(const struct otp_config *cfg);
/* Gets the permitted authentication types for the given user entry.
*
* The entry should be queried for the "ipaUserAuthType" attribute.
*/
uint32_t otp_config_auth_types(const struct otp_config *cfg,
Slapi_Entry *user_entry);
/* Gets the window sizes for a token.
*
* The entry should be queried for the following attributes:
* objectClass
* ipatokenTOTPauthWindow
* ipatokenTOTPsyncWindow
* ipatokenHOTPauthWindow
* ipatokenHOTPsyncWindow
*/
struct otp_config_window otp_config_window(const struct otp_config *cfg,
Slapi_Entry *token_entry);

View File

@@ -37,7 +37,7 @@
* All rights reserved.
* END COPYRIGHT BLOCK **/
#include "hotp.h"
#include "librfc.h"
#include <assert.h>
#include <stddef.h>