From 1358893aef5a14e99e13b4843a8d880fb983c128 Mon Sep 17 00:00:00 2001 From: Quanah Gibson-Mount Date: Thu, 15 Apr 2010 01:50:43 +0000 Subject: [PATCH] Add TlsOptions --- contrib/ldapc++/doxygen.rc | 4 +- contrib/ldapc++/examples/Makefile.am | 5 +- contrib/ldapc++/examples/Makefile.in | 122 ++++++++++----- contrib/ldapc++/examples/startTls.cpp | 79 ++++++++++ contrib/ldapc++/src/LDAPAsynConnection.cpp | 15 +- contrib/ldapc++/src/LDAPAsynConnection.h | 5 +- contrib/ldapc++/src/LDAPConnection.cpp | 4 + contrib/ldapc++/src/LDAPConnection.h | 1 + contrib/ldapc++/src/LDAPUrl.cpp | 3 +- contrib/ldapc++/src/LDAPUrl.h | 2 + contrib/ldapc++/src/Makefile.am | 6 +- contrib/ldapc++/src/Makefile.in | 169 ++++++++++++++------- contrib/ldapc++/src/TlsOptions.cpp | 122 +++++++++++++++ contrib/ldapc++/src/TlsOptions.h | 162 ++++++++++++++++++++ 14 files changed, 590 insertions(+), 109 deletions(-) create mode 100644 contrib/ldapc++/examples/startTls.cpp create mode 100644 contrib/ldapc++/src/TlsOptions.cpp create mode 100644 contrib/ldapc++/src/TlsOptions.h diff --git a/contrib/ldapc++/doxygen.rc b/contrib/ldapc++/doxygen.rc index e9133a04a6..cd78a9cd9e 100644 --- a/contrib/ldapc++/doxygen.rc +++ b/contrib/ldapc++/doxygen.rc @@ -262,7 +262,7 @@ EXTRACT_ALL = YES # If the EXTRACT_PRIVATE tag is set to YES all private members of a class # will be included in the documentation. -EXTRACT_PRIVATE = YES +EXTRACT_PRIVATE = NO # If the EXTRACT_STATIC tag is set to YES all static members of a file # will be included in the documentation. @@ -273,7 +273,7 @@ EXTRACT_STATIC = NO # defined locally in source files will be included in the documentation. # If set to NO only classes defined in header files are included. -EXTRACT_LOCAL_CLASSES = YES +EXTRACT_LOCAL_CLASSES = NO # This flag is only useful for Objective-C code. When set to YES local # methods, which are defined in the implementation section but not in diff --git a/contrib/ldapc++/examples/Makefile.am b/contrib/ldapc++/examples/Makefile.am index 14a04e5919..5b6d1a3889 100644 --- a/contrib/ldapc++/examples/Makefile.am +++ b/contrib/ldapc++/examples/Makefile.am @@ -5,7 +5,7 @@ # COPYING RESTRICTIONS APPLY, see COPYRIGHT file ## AM_CPPFLAGS = -I$(top_srcdir)/src -noinst_PROGRAMS = main readSchema urlTest +noinst_PROGRAMS = main readSchema startTls urlTest main_SOURCES = main.cpp main_LDADD = ../src/libldapcpp.la @@ -13,5 +13,8 @@ main_LDADD = ../src/libldapcpp.la readSchema_SOURCES = readSchema.cpp readSchema_LDADD = ../src/libldapcpp.la +startTls_SOURCES = startTls.cpp +startTls_LDADD = ../src/libldapcpp.la + urlTest_SOURCES = urlTest.cpp urlTest_LDADD = ../src/libldapcpp.la diff --git a/contrib/ldapc++/examples/Makefile.in b/contrib/ldapc++/examples/Makefile.in index 5b7568f74c..fe7e9793c0 100644 --- a/contrib/ldapc++/examples/Makefile.in +++ b/contrib/ldapc++/examples/Makefile.in @@ -1,8 +1,9 @@ -# Makefile.in generated by automake 1.10.1 from Makefile.am. +# Makefile.in generated by automake 1.11 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -18,8 +19,9 @@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c @@ -34,7 +36,8 @@ PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ -noinst_PROGRAMS = main$(EXEEXT) readSchema$(EXEEXT) urlTest$(EXEEXT) +noinst_PROGRAMS = main$(EXEEXT) readSchema$(EXEEXT) startTls$(EXEEXT) \ + urlTest$(EXEEXT) subdir = examples DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 @@ -44,6 +47,7 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/src/config.h CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = PROGRAMS = $(noinst_PROGRAMS) am_main_OBJECTS = main.$(OBJEXT) main_OBJECTS = $(am_main_OBJECTS) @@ -51,12 +55,16 @@ main_DEPENDENCIES = ../src/libldapcpp.la am_readSchema_OBJECTS = readSchema.$(OBJEXT) readSchema_OBJECTS = $(am_readSchema_OBJECTS) readSchema_DEPENDENCIES = ../src/libldapcpp.la +am_startTls_OBJECTS = startTls.$(OBJEXT) +startTls_OBJECTS = $(am_startTls_OBJECTS) +startTls_DEPENDENCIES = ../src/libldapcpp.la am_urlTest_OBJECTS = urlTest.$(OBJEXT) urlTest_OBJECTS = $(am_urlTest_OBJECTS) urlTest_DEPENDENCIES = ../src/libldapcpp.la DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles +am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ @@ -66,9 +74,10 @@ CXXLD = $(CXX) CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ -SOURCES = $(main_SOURCES) $(readSchema_SOURCES) $(urlTest_SOURCES) -DIST_SOURCES = $(main_SOURCES) $(readSchema_SOURCES) \ +SOURCES = $(main_SOURCES) $(readSchema_SOURCES) $(startTls_SOURCES) \ $(urlTest_SOURCES) +DIST_SOURCES = $(main_SOURCES) $(readSchema_SOURCES) \ + $(startTls_SOURCES) $(urlTest_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) @@ -92,31 +101,36 @@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DSYMUTIL = @DSYMUTIL@ -ECHO = @ECHO@ +DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ -F77 = @F77@ -FFLAGS = @FFLAGS@ +FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ +NM = @NM@ NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OPENLDAP_CPP_API_VERSION = @OPENLDAP_CPP_API_VERSION@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ @@ -136,7 +150,7 @@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ -ac_ct_F77 = @ac_ct_F77@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ @@ -167,6 +181,7 @@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ +lt_ECHO = @lt_ECHO@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ @@ -179,6 +194,7 @@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ @@ -189,6 +205,8 @@ main_SOURCES = main.cpp main_LDADD = ../src/libldapcpp.la readSchema_SOURCES = readSchema.cpp readSchema_LDADD = ../src/libldapcpp.la +startTls_SOURCES = startTls.cpp +startTls_LDADD = ../src/libldapcpp.la urlTest_SOURCES = urlTest.cpp urlTest_LDADD = ../src/libldapcpp.la all: all-am @@ -199,14 +217,14 @@ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign examples/Makefile'; \ - cd $(top_srcdir) && \ - $(AUTOMAKE) --foreign examples/Makefile + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign examples/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign examples/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ @@ -224,19 +242,25 @@ $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): clean-noinstPROGRAMS: - @list='$(noinst_PROGRAMS)'; for p in $$list; do \ - f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ - echo " rm -f $$p $$f"; \ - rm -f $$p $$f ; \ - done + @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list main$(EXEEXT): $(main_OBJECTS) $(main_DEPENDENCIES) @rm -f main$(EXEEXT) $(CXXLINK) $(main_OBJECTS) $(main_LDADD) $(LIBS) readSchema$(EXEEXT): $(readSchema_OBJECTS) $(readSchema_DEPENDENCIES) @rm -f readSchema$(EXEEXT) $(CXXLINK) $(readSchema_OBJECTS) $(readSchema_LDADD) $(LIBS) +startTls$(EXEEXT): $(startTls_OBJECTS) $(startTls_DEPENDENCIES) + @rm -f startTls$(EXEEXT) + $(CXXLINK) $(startTls_OBJECTS) $(startTls_LDADD) $(LIBS) urlTest$(EXEEXT): $(urlTest_OBJECTS) $(urlTest_DEPENDENCIES) @rm -f urlTest$(EXEEXT) $(CXXLINK) $(urlTest_OBJECTS) $(urlTest_LDADD) $(LIBS) @@ -249,25 +273,26 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/readSchema.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/startTls.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/urlTest.Po@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< @@ -283,14 +308,14 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ - $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) - tags=; \ + set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ @@ -298,29 +323,34 @@ TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ - if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$tags $$unique; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) - tags=; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ - test -z "$(CTAGS_ARGS)$$tags$$unique" \ + test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$tags $$unique + $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ - && cd $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) $$here + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags @@ -341,13 +371,17 @@ distdir: $(DISTFILES) if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ - cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ - test -f $(distdir)/$$file \ - || cp -p $$d/$$file $(distdir)/$$file \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @@ -375,6 +409,7 @@ clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @@ -396,6 +431,8 @@ dvi-am: html: html-am +html-am: + info: info-am info-am: @@ -404,18 +441,28 @@ install-data-am: install-dvi: install-dvi-am +install-dvi-am: + install-exec-am: install-html: install-html-am +install-html-am: + install-info: install-info-am +install-info-am: + install-man: install-pdf: install-pdf-am +install-pdf-am: + install-ps: install-ps-am +install-ps-am: + installcheck-am: maintainer-clean: maintainer-clean-am @@ -453,6 +500,7 @@ uninstall-am: mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ pdf pdf-am ps ps-am tags uninstall uninstall-am + # 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. .NOEXPORT: diff --git a/contrib/ldapc++/examples/startTls.cpp b/contrib/ldapc++/examples/startTls.cpp new file mode 100644 index 0000000000..3d9a471b12 --- /dev/null +++ b/contrib/ldapc++/examples/startTls.cpp @@ -0,0 +1,79 @@ +// $OpenLDAP$ +/* + * Copyright 2010, OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ + +#include +#include +#include "LDAPAsynConnection.h" +#include "TlsOptions.h" + +int main( int argc, char* argv[]){ + if ( argc != 4 ){ + std::cerr << "usage: " << argv[0] << " " << std::endl; + return(-1); + } + std::string uri(argv[1]); + std::string cacert(argv[2]); + std::string cadir(argv[3]); + TlsOptions tls; + std::cout << "Current global settings:" << std::endl; + std::cout << " CaCertfile: " << tls.getStringOption( TlsOptions::CACERTFILE) << std::endl; + std::cout << " CaCertDir: " << tls.getStringOption( TlsOptions::CACERTDIR ) << std::endl; + std::cout << " Require Cert: " << tls.getIntOption( TlsOptions::REQUIRE_CERT ) << std::endl; + std::cout << "Applying new settings:" << std::endl; + tls.setOption( TlsOptions::CACERTFILE, cacert ); + tls.setOption( TlsOptions::REQUIRE_CERT, TlsOptions::DEMAND ); + std::cout << " CaCertfile: " << tls.getStringOption( TlsOptions::CACERTFILE ) << std::endl; + std::cout << " Require Cert: " << tls.getIntOption( TlsOptions::REQUIRE_CERT ) << std::endl; + + try { + // 1. connect using global options + LDAPAsynConnection l(uri); + try { + l.start_tls(); + std::cout << "StartTLS successful." << std::endl; + l.unbind(); + } catch ( LDAPException e ) { + std::cerr << e << std::endl; + } + + // 2. connect using connection specific option + l = LDAPAsynConnection(uri); + tls=l.getTlsOptions(); + std::cout << "Current connection specific settings:" << std::endl; + std::cout << " CaCertfile: " << tls.getStringOption( TlsOptions::CACERTFILE) << std::endl; + std::cout << " CaCertDir: " << tls.getStringOption( TlsOptions::CACERTDIR ) << std::endl; + std::cout << " Require Cert: " << tls.getIntOption( TlsOptions::REQUIRE_CERT ) << std::endl; + std::cout << "Applying new settings:" << std::endl; + tls.setOption( TlsOptions::CACERTDIR, cadir ); + tls.setOption( TlsOptions::REQUIRE_CERT, TlsOptions::DEMAND ); + std::cout << " CaCertDir: " << tls.getStringOption( TlsOptions::CACERTDIR ) << std::endl; + std::cout << " Require Cert: " << tls.getIntOption( TlsOptions::REQUIRE_CERT ) << std::endl; + try { + l.start_tls(); + std::cout << "StartTLS successful." << std::endl; + l.unbind(); + } catch ( LDAPException e ) { + std::cerr << e << std::endl; + } + + // 3. and once again using the globals + try { + LDAPAsynConnection l2(uri); + TlsOptions tls2; + std::cout << "Current global settings:" << std::endl; + std::cout << " CaCertfile: " << tls2.getStringOption( TlsOptions::CACERTFILE) << std::endl; + std::cout << " CaCertDir: " << tls2.getStringOption( TlsOptions::CACERTDIR ) << std::endl; + std::cout << " Require Cert: " << tls2.getIntOption( TlsOptions::REQUIRE_CERT ) << std::endl; + l2.start_tls(); + std::cout << "StartTLS successful." << std::endl; + l2.unbind(); + } catch ( LDAPException e ) { + std::cerr << e << std::endl; + } + } catch ( LDAPException e ) { + std::cerr << e << std::endl; + } +} diff --git a/contrib/ldapc++/src/LDAPAsynConnection.cpp b/contrib/ldapc++/src/LDAPAsynConnection.cpp index 13fc78d61b..21242364e1 100644 --- a/contrib/ldapc++/src/LDAPAsynConnection.cpp +++ b/contrib/ldapc++/src/LDAPAsynConnection.cpp @@ -21,6 +21,7 @@ #include "LDAPRebind.h" #include "LDAPRebindAuth.h" #include "LDAPSearchRequest.h" +#include #include using namespace std; @@ -42,12 +43,7 @@ LDAPAsynConnection::LDAPAsynConnection(const string& url, int port, this->setConstraints(cons); } -LDAPAsynConnection::~LDAPAsynConnection(){ - DEBUG(LDAP_DEBUG_DESTROY, - "LDAPAsynConnection::~LDAPAsynConnection()" << endl); - unbind(); - //delete m_constr; -} +LDAPAsynConnection::~LDAPAsynConnection(){} void LDAPAsynConnection::init(const string& hostname, int port){ DEBUG(LDAP_DEBUG_TRACE,"LDAPAsynConnection::init" << endl); @@ -81,7 +77,8 @@ void LDAPAsynConnection::initialize(const std::string& uri){ } void LDAPAsynConnection::start_tls(){ - if( ldap_start_tls_s( cur_session, NULL, NULL ) != LDAP_SUCCESS ) { + int ret = ldap_start_tls_s( cur_session, NULL, NULL ); + if( ret != LDAP_SUCCESS ) { throw LDAPException(this); } } @@ -288,6 +285,10 @@ const LDAPConstraints* LDAPAsynConnection::getConstraints() const { return m_constr; } +TlsOptions LDAPAsynConnection::getTlsOptions() const { + return TlsOptions( cur_session ); +} + LDAP* LDAPAsynConnection::getSessionHandle() const{ DEBUG(LDAP_DEBUG_TRACE,"LDAPAsynConnection::getSessionHandle()" << endl); return cur_session; diff --git a/contrib/ldapc++/src/LDAPAsynConnection.h b/contrib/ldapc++/src/LDAPAsynConnection.h index 43dcc25c43..48e16e0e23 100644 --- a/contrib/ldapc++/src/LDAPAsynConnection.h +++ b/contrib/ldapc++/src/LDAPAsynConnection.h @@ -12,7 +12,6 @@ #include #include -#include #include #include @@ -23,6 +22,7 @@ #include #include #include +#include //* Main class for an asynchronous LDAP connection /** @@ -73,7 +73,6 @@ class LDAPAsynConnection{ //* Destructor virtual ~LDAPAsynConnection(); - /** * Initializes a connection to a server. * @@ -284,7 +283,7 @@ class LDAPAsynConnection{ * used with the Connection */ const LDAPConstraints* getConstraints() const; - + TlsOptions getTlsOptions() const; /** * This method is used internally for automatic referral chasing. * It tries to bind to a destination server of the URLs of a diff --git a/contrib/ldapc++/src/LDAPConnection.cpp b/contrib/ldapc++/src/LDAPConnection.cpp index 5a86029424..d226f46fc9 100644 --- a/contrib/ldapc++/src/LDAPConnection.cpp +++ b/contrib/ldapc++/src/LDAPConnection.cpp @@ -376,3 +376,7 @@ void LDAPConnection::setConstraints(LDAPConstraints* cons){ const LDAPConstraints* LDAPConnection::getConstraints() const{ return LDAPAsynConnection::getConstraints(); } + +TlsOptions LDAPConnection::getTlsOptions() const { + return LDAPAsynConnection::getTlsOptions(); +} diff --git a/contrib/ldapc++/src/LDAPConnection.h b/contrib/ldapc++/src/LDAPConnection.h index 2e8cb0ad82..c83313fd34 100644 --- a/contrib/ldapc++/src/LDAPConnection.h +++ b/contrib/ldapc++/src/LDAPConnection.h @@ -235,6 +235,7 @@ class LDAPConnection : private LDAPAsynConnection { void setConstraints(LDAPConstraints *cons); const LDAPConstraints* getConstraints() const ; + TlsOptions getTlsOptions() const; }; #endif //LDAP_CONNECTION_H diff --git a/contrib/ldapc++/src/LDAPUrl.cpp b/contrib/ldapc++/src/LDAPUrl.cpp index c6acaba4e0..0ff8c7e582 100644 --- a/contrib/ldapc++/src/LDAPUrl.cpp +++ b/contrib/ldapc++/src/LDAPUrl.cpp @@ -195,8 +195,7 @@ void LDAPUrl::parseUrl() // no hostname and port startpos++; } else { - std::string::size_type hostend; - std::string::size_type portstart; + std::string::size_type hostend, portstart=0; pos = m_urlString.find('/', startpos); // IPv6 Address? diff --git a/contrib/ldapc++/src/LDAPUrl.h b/contrib/ldapc++/src/LDAPUrl.h index 55e5abf354..b9b17ad2d3 100644 --- a/contrib/ldapc++/src/LDAPUrl.h +++ b/contrib/ldapc++/src/LDAPUrl.h @@ -178,10 +178,12 @@ class LDAPUrl{ enum mode { base, attrs, scope, filter, extensions }; }; +/// @cond struct code2string_s { int code; const char* string; }; +/// @endcond class LDAPUrlException { public : diff --git a/contrib/ldapc++/src/Makefile.am b/contrib/ldapc++/src/Makefile.am index 7efca28ac2..ae715e68f4 100644 --- a/contrib/ldapc++/src/Makefile.am +++ b/contrib/ldapc++/src/Makefile.am @@ -48,7 +48,8 @@ libldapcpp_la_SOURCES = LDAPAddRequest.cpp \ LdifWriter.cpp \ SaslInteraction.cpp \ SaslInteractionHandler.cpp \ - StringList.cpp + StringList.cpp \ + TlsOptions.cpp include_HEADERS = LDAPAsynConnection.h \ LDAPAttribute.h \ @@ -82,7 +83,8 @@ include_HEADERS = LDAPAsynConnection.h \ LdifWriter.h \ SaslInteraction.h \ SaslInteractionHandler.h \ - StringList.h + StringList.h \ + TlsOptions.h noinst_HEADERS = ac/time.h \ debug.h \ diff --git a/contrib/ldapc++/src/Makefile.in b/contrib/ldapc++/src/Makefile.in index fcffceaa4e..09aeda938b 100644 --- a/contrib/ldapc++/src/Makefile.in +++ b/contrib/ldapc++/src/Makefile.in @@ -1,8 +1,9 @@ -# Makefile.in generated by automake 1.10.1 from Makefile.am. +# Makefile.in generated by automake 1.11 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -23,8 +24,9 @@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c @@ -50,14 +52,29 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ mkinstalldirs = $(install_sh) -d CONFIG_HEADER = config.h CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; -am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includedir)" -libLTLIBRARIES_INSTALL = $(INSTALL) LTLIBRARIES = $(lib_LTLIBRARIES) libldapcpp_la_DEPENDENCIES = am_libldapcpp_la_OBJECTS = LDAPAddRequest.lo LDAPAsynConnection.lo \ @@ -73,7 +90,8 @@ am_libldapcpp_la_OBJECTS = LDAPAddRequest.lo LDAPAsynConnection.lo \ LDAPSaslBindResult.lo LDAPSchema.lo LDAPSearchReference.lo \ LDAPSearchRequest.lo LDAPSearchResult.lo LDAPSearchResults.lo \ LDAPUrl.lo LDAPUrlList.lo LdifReader.lo LdifWriter.lo \ - SaslInteraction.lo SaslInteractionHandler.lo StringList.lo + SaslInteraction.lo SaslInteractionHandler.lo StringList.lo \ + TlsOptions.lo libldapcpp_la_OBJECTS = $(am_libldapcpp_la_OBJECTS) libldapcpp_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ @@ -81,6 +99,7 @@ libldapcpp_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \ DEFAULT_INCLUDES = -I.@am__isrc@ depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles +am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ @@ -92,7 +111,6 @@ CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ $(LDFLAGS) -o $@ SOURCES = $(libldapcpp_la_SOURCES) DIST_SOURCES = $(libldapcpp_la_SOURCES) -includeHEADERS_INSTALL = $(INSTALL_HEADER) HEADERS = $(include_HEADERS) $(noinst_HEADERS) ETAGS = etags CTAGS = ctags @@ -117,31 +135,36 @@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DSYMUTIL = @DSYMUTIL@ -ECHO = @ECHO@ +DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ -F77 = @F77@ -FFLAGS = @FFLAGS@ +FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ +NM = @NM@ NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OPENLDAP_CPP_API_VERSION = @OPENLDAP_CPP_API_VERSION@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ @@ -161,7 +184,7 @@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ -ac_ct_F77 = @ac_ct_F77@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ @@ -192,6 +215,7 @@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ +lt_ECHO = @lt_ECHO@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ @@ -204,6 +228,7 @@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ lib_LTLIBRARIES = libldapcpp.la @@ -248,7 +273,8 @@ libldapcpp_la_SOURCES = LDAPAddRequest.cpp \ LdifWriter.cpp \ SaslInteraction.cpp \ SaslInteractionHandler.cpp \ - StringList.cpp + StringList.cpp \ + TlsOptions.cpp include_HEADERS = LDAPAsynConnection.h \ LDAPAttribute.h \ @@ -282,7 +308,8 @@ include_HEADERS = LDAPAsynConnection.h \ LdifWriter.h \ SaslInteraction.h \ SaslInteractionHandler.h \ - StringList.h + StringList.h \ + TlsOptions.h noinst_HEADERS = ac/time.h \ debug.h \ @@ -307,14 +334,14 @@ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/Makefile'; \ - cd $(top_srcdir) && \ - $(AUTOMAKE) --foreign src/Makefile + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign src/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ @@ -332,6 +359,7 @@ $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): config.h: stamp-h1 @if test ! -f $@; then \ @@ -343,7 +371,7 @@ stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status @rm -f stamp-h1 cd $(top_builddir) && $(SHELL) ./config.status src/config.h $(srcdir)/config.h.in: $(am__configure_deps) - cd $(top_srcdir) && $(AUTOHEADER) + ($(am__cd) $(top_srcdir) && $(AUTOHEADER)) rm -f stamp-h1 touch $@ @@ -352,20 +380,24 @@ distclean-hdr: install-libLTLIBRARIES: $(lib_LTLIBRARIES) @$(NORMAL_INSTALL) test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)" - @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ + @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ + list2=; for p in $$list; do \ if test -f $$p; then \ - f=$(am__strip_dir) \ - echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(libdir)/$$f'"; \ - $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(libdir)/$$f"; \ + list2="$$list2 $$p"; \ else :; fi; \ - done + done; \ + test -z "$$list2" || { \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ + } uninstall-libLTLIBRARIES: @$(NORMAL_UNINSTALL) - @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ - p=$(am__strip_dir) \ - echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$p'"; \ - $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$p"; \ + @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ + for p in $$list; do \ + $(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ done clean-libLTLIBRARIES: @@ -427,24 +459,25 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SaslInteraction.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SaslInteractionHandler.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/StringList.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TlsOptions.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< @@ -457,34 +490,37 @@ clean-libtool: install-includeHEADERS: $(include_HEADERS) @$(NORMAL_INSTALL) test -z "$(includedir)" || $(MKDIR_P) "$(DESTDIR)$(includedir)" - @list='$(include_HEADERS)'; for p in $$list; do \ + @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \ + for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ - f=$(am__strip_dir) \ - echo " $(includeHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(includedir)/$$f'"; \ - $(includeHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(includedir)/$$f"; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includedir)'"; \ + $(INSTALL_HEADER) $$files "$(DESTDIR)$(includedir)" || exit $$?; \ done uninstall-includeHEADERS: @$(NORMAL_UNINSTALL) - @list='$(include_HEADERS)'; for p in $$list; do \ - f=$(am__strip_dir) \ - echo " rm -f '$(DESTDIR)$(includedir)/$$f'"; \ - rm -f "$(DESTDIR)$(includedir)/$$f"; \ - done + @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + test -n "$$files" || exit 0; \ + echo " ( cd '$(DESTDIR)$(includedir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(includedir)" && rm -f $$files ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ - $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) - tags=; \ + set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ @@ -492,29 +528,34 @@ TAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ - if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$tags $$unique; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) - tags=; \ list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ - test -z "$(CTAGS_ARGS)$$tags$$unique" \ + test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$tags $$unique + $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ - && cd $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) $$here + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags @@ -535,13 +576,17 @@ distdir: $(DISTFILES) if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ - cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ - test -f $(distdir)/$$file \ - || cp -p $$d/$$file $(distdir)/$$file \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @@ -572,6 +617,7 @@ clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @@ -593,6 +639,8 @@ dvi-am: html: html-am +html-am: + info: info-am info-am: @@ -601,18 +649,28 @@ install-data-am: install-includeHEADERS install-dvi: install-dvi-am +install-dvi-am: + install-exec-am: install-libLTLIBRARIES install-html: install-html-am +install-html-am: + install-info: install-info-am +install-info-am: + install-man: install-pdf: install-pdf-am +install-pdf-am: + install-ps: install-ps-am +install-ps-am: + installcheck-am: maintainer-clean: maintainer-clean-am @@ -635,7 +693,7 @@ ps-am: uninstall-am: uninstall-includeHEADERS uninstall-libLTLIBRARIES -.MAKE: install-am install-strip +.MAKE: all install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-libLTLIBRARIES clean-libtool ctags distclean \ @@ -653,6 +711,7 @@ uninstall-am: uninstall-includeHEADERS uninstall-libLTLIBRARIES tags uninstall uninstall-am uninstall-includeHEADERS \ uninstall-libLTLIBRARIES + # 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. .NOEXPORT: diff --git a/contrib/ldapc++/src/TlsOptions.cpp b/contrib/ldapc++/src/TlsOptions.cpp new file mode 100644 index 0000000000..3da227f874 --- /dev/null +++ b/contrib/ldapc++/src/TlsOptions.cpp @@ -0,0 +1,122 @@ +// $OpenLDAP$ +/* + * Copyright 2010, OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ + +#include "TlsOptions.h" +#include "LDAPException.h" + +enum opttype { + INT=0, + STRING, + OTHER +}; + +typedef struct tls_optmap { + int optval; + opttype type; +} tls_optmap_t; + +static tls_optmap_t optmap[] = { + { LDAP_OPT_X_TLS_CACERTFILE, STRING }, + { LDAP_OPT_X_TLS_CACERTDIR, STRING }, + { LDAP_OPT_X_TLS_CERTFILE, STRING }, + { LDAP_OPT_X_TLS_KEYFILE, STRING }, + { LDAP_OPT_X_TLS_REQUIRE_CERT, INT }, + { LDAP_OPT_X_TLS_PROTOCOL_MIN, INT }, + { LDAP_OPT_X_TLS_CIPHER_SUITE, STRING }, + { LDAP_OPT_X_TLS_RANDOM_FILE, STRING }, + { LDAP_OPT_X_TLS_CRLCHECK, INT }, + { LDAP_OPT_X_TLS_DHFILE, STRING }, + { LDAP_OPT_X_TLS_NEWCTX, INT } +}; +#if 0 /* not implemented currently */ + static const int TLS_CRLFILE /* GNUtls only */ + static const int TLS_SSL_CTX /* OpenSSL SSL* */ + static const int TLS_CONNECT_CB + static const int TLS_CONNECT_ARG +#endif + +static void checkOpt( TlsOptions::tls_option opt, opttype type ) { + if ( opt < TlsOptions::CACERTFILE || opt >= TlsOptions::LASTOPT ){ + throw( LDAPException( LDAP_PARAM_ERROR, "unknown Option" ) ); + } + + if ( optmap[opt].type != type ){ + throw( LDAPException( LDAP_PARAM_ERROR, "not a string option" ) ); + } +} + +TlsOptions::TlsOptions() : m_ld(NULL) {} + +TlsOptions::TlsOptions( LDAP* ld ): m_ld(ld) { } + +void TlsOptions::setOption( tls_option opt, const std::string& value ) const { + checkOpt(opt, STRING); + this->setOption( opt, value.empty() ? NULL : (void*) value.c_str() ); +} + +void TlsOptions::setOption( tls_option opt, int value ) const { + checkOpt(opt, INT); + this->setOption( opt, (void*) &value); +} + +void TlsOptions::setOption( tls_option opt, void *value ) const { + int ret = ldap_set_option( m_ld, optmap[opt].optval, value); + if ( ret != LDAP_OPT_SUCCESS ) + { + if ( ret != LDAP_OPT_ERROR ){ + throw( LDAPException( ret )); + } else { + throw( LDAPException( LDAP_PARAM_ERROR, "error while setting TLS option" ) ); + } + } + if ( m_ld ){ + this->newCtx(); + } +} + +void TlsOptions::getOption( tls_option opt, void* value ) const { + int ret = ldap_get_option( m_ld, optmap[opt].optval, value); + if ( ret != LDAP_OPT_SUCCESS ) + { + if ( ret != LDAP_OPT_ERROR ){ + throw( LDAPException( ret )); + } else { + throw( LDAPException( LDAP_PARAM_ERROR, "error while reading TLS option" ) ); + } + } +} + +int TlsOptions::getIntOption( tls_option opt ) const { + int value; + checkOpt(opt, INT); + ldap_get_option( m_ld, optmap[opt].optval, (void*) &value); + return value; +} + +std::string TlsOptions::getStringOption( tls_option opt ) const { + char *value; + checkOpt(opt, STRING); + ldap_get_option( m_ld, optmap[opt].optval, (void*) &value); + std::string strval; + if (value) + { + strval=std::string(value); + ldap_memfree(value); + } + return strval; +} + +void TlsOptions::newCtx() const { + int ret = ldap_set_option( m_ld, LDAP_OPT_X_TLS_NEWCTX, LDAP_OPT_ON); + if ( ret != LDAP_OPT_SUCCESS ) + { + if ( ret != LDAP_OPT_ERROR ){ + throw( LDAPException( ret )); + } else { + throw( LDAPException( LDAP_LOCAL_ERROR, "error while renewing TLS context" ) ); + } + } +} diff --git a/contrib/ldapc++/src/TlsOptions.h b/contrib/ldapc++/src/TlsOptions.h new file mode 100644 index 0000000000..0865fb240c --- /dev/null +++ b/contrib/ldapc++/src/TlsOptions.h @@ -0,0 +1,162 @@ +// $OpenLDAP$ +/* + * Copyright 2010, OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ +#ifndef TLS_OPTIONS_H +#define TLS_OPTIONS_H +#include +#include + +/** + * Class to access the global (and connection specific) TLS Settings + * To access the global TLS Settings just instantiate a TlsOption object + * using the default constructor. + * + * To access connection specific settings instantiate a TlsOption object + * through the getTlsOptions() method from the corresponding + * LDAPConnection/LDAPAsynConnection object. + * + */ +class TlsOptions { + public: + + /** + * Available TLS Options + */ + enum tls_option { + CACERTFILE=0, + CACERTDIR, + CERTFILE, + KEYFILE, + REQUIRE_CERT, + PROTOCOL_MIN, + CIPHER_SUITE, + RANDOM_FILE, + CRLCHECK, + DHFILE, + /// @cond + LASTOPT /* dummy */ + /// @endcond + }; + + /** + * Possible Values for the REQUIRE_CERT option + */ + enum verifyMode { + NEVER=0, + HARD, + DEMAND, + ALLOW, + TRY + }; + + /** + * Possible Values for the CRLCHECK option + */ + enum crlMode { + CRL_NONE=0, + CRL_PEER, + CRL_ALL + }; + + + /** + * Default constructor. Gives access to the global TlsSettings + */ + TlsOptions(); + + /** + * Set string valued options. + * @param opt The following string valued options are available: + * - TlsOptions::CACERTFILE + * - TlsOptions::CACERTDIR + * - TlsOptions::CERTFILE + * - TlsOptions::KEYFILE + * - TlsOptions::CIPHER_SUITE + * - TlsOptions::RANDOM_FILE + * - TlsOptions::DHFILE + * @param value The value to apply to that option, + * - TlsOptions::CACERTFILE: + * The path to the file containing all recognized Certificate + * Authorities + * - TlsOptions::CACERTDIR: + * The path to a directory containing individual files of all + * recognized Certificate Authority certificates + * - TlsOptions::CERTFILE: + * The path to the client certificate + * - TlsOptions::KEYFILE: + * The path to the file containing the private key matching the + * Certificate that as configured with TlsOptions::CERTFILE + * - TlsOptions::CIPHER_SUITE + * Specifies the cipher suite and preference order + * - TlsOptions::RANDOM_FILE + * Specifies the file to obtain random bits from when + * /dev/[u]random is not available. + * - TlsOptions::DHFILE + * File containing DH parameters + */ + void setOption(tls_option opt, const std::string& value) const; + + /** + * Set integer valued options. + * @param opt The following string valued options are available: + * - TlsOptions::REQUIRE_CERT + * - TlsOptions::PROTOCOL_MIN + * - TlsOptions::CRLCHECK + * @param value The value to apply to that option, + * - TlsOptions::REQUIRE_CERT: + * Possible Values (For details see the ldap.conf(5) man-page): + * - TlsOptions::NEVER + * - TlsOptions::DEMAND + * - TlsOptions::ALLOW + * - TlsOptions::TRY + * - TlsOptions::PROTOCOL_MIN + * - TlsOptions::CRLCHECK + * Possible Values: + * - TlsOptions::CRL_NONE + * - TlsOptions::CRL_PEER + * - TlsOptions::CRL_ALL + */ + void setOption(tls_option opt, int value) const; + + /** + * Generic setOption variant. Generally you should prefer to use one + * of the other variants + */ + void setOption(tls_option opt, void *value) const; + + /** + * Read integer valued options + * @return Option value + * @throws LDAPException in case of error (invalid on non-integer + * valued option is requested) + */ + int getIntOption(tls_option opt) const; + + /** + * Read string valued options + * @return Option value + * @throws LDAPException in case of error (invalid on non-string + * valued option is requested) + */ + std::string getStringOption(tls_option opt) const; + + /** + * Read options value. Usually you should prefer to use either + * getIntOption() or getStringOption() + * @param value points to a buffer containing the option value + * @throws LDAPException in case of error (invalid on non-string + * valued option is requested) + */ + void getOption(tls_option opt, void *value ) const; + + private: + TlsOptions( LDAP* ld ); + void newCtx() const; + LDAP *m_ld; + + friend class LDAPAsynConnection; +}; + +#endif /* TLS_OPTIONS_H */ -- 2.39.5