Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • openldap/openldap
  • hyc/openldap
  • ryan/openldap
  • iboukris/openldap
  • ondra/openldap
  • sshanks-kx/openldap
  • blaggacao/openldap
  • pbrezina/openldap
  • quanah/openldap
  • dragos_h/openldap
  • lorenz/openldap
  • tsaarni/openldap
  • fei.ding/openldap
  • orent/openldap
  • arrowplum/openldap
  • barchiesi/openldap
  • jotik/openldap
  • hamano/openldap
  • ingovoss/openldap
  • henson/openldap
  • jlrine2/openldap
  • howeverAT/openldap
  • nivanova/openldap
  • orbea/openldap
  • rdubner/openldap
  • smckinney/openldap
  • jklowden/openldap
  • dpa-openldap/openldap
  • rouzier/openldap
  • orgads/openldap
  • ffontaine/openldap
  • jiaqingz/openldap
  • dcoutadeur/openldap
  • begeragus/openldap
  • pubellit/openldap
  • glandium/openldap
  • facboy/openldap
  • thesamesam/openldap
  • Johan/openldap
  • fkooman/openldap
  • gburd/openldap
  • h-homma/openldap
  • sgallagher/openldap
  • ahmed_zaki/openldap
  • gnoe/openldap
  • mid/openldap
  • clan/openldap
47 results
Show changes
Showing with 540 additions and 493 deletions
:: $OpenLDAP$ :: $OpenLDAP$
:: This work is part of OpenLDAP Software <http://www.openldap.org/>. :: This work is part of OpenLDAP Software <http://www.openldap.org/>.
:: ::
:: Copyright 1998-2008 The OpenLDAP Foundation. :: Copyright 1998-2010 The OpenLDAP Foundation.
:: All rights reserved. :: All rights reserved.
:: ::
:: Redistribution and use in source and binary forms, with or without :: Redistribution and use in source and binary forms, with or without
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
# $OpenLDAP$ # $OpenLDAP$
## This work is part of OpenLDAP Software <http://www.openldap.org/>. ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
## ##
## Copyright 1998-2008 The OpenLDAP Foundation. ## Copyright 1998-2010 The OpenLDAP Foundation.
## All rights reserved. ## All rights reserved.
## ##
## Redistribution and use in source and binary forms, with or without ## Redistribution and use in source and binary forms, with or without
...@@ -55,7 +55,7 @@ WHOWHERE="$USER@`uname -n`:`pwd`" ...@@ -55,7 +55,7 @@ WHOWHERE="$USER@`uname -n`:`pwd`"
cat << __EOF__ cat << __EOF__
/* This work is part of OpenLDAP Software <http://www.openldap.org/>. /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
* *
* Copyright 1998-2008 The OpenLDAP Foundation. * Copyright 1998-2010 The OpenLDAP Foundation.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
...@@ -68,7 +68,7 @@ cat << __EOF__ ...@@ -68,7 +68,7 @@ cat << __EOF__
*/ */
static const char copyright[] = static const char copyright[] =
"Copyright 1998-2008 The OpenLDAP Foundation. All rights reserved.\n" "Copyright 1998-2010 The OpenLDAP Foundation. All rights reserved.\n"
"COPYING RESTRICTIONS APPLY\n"; "COPYING RESTRICTIONS APPLY\n";
$static $const char $SYMBOL[] = $static $const char $SYMBOL[] =
......
# $OpenLDAP$ # $OpenLDAP$
## This work is part of OpenLDAP Software <http://www.openldap.org/>. ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
## ##
## Copyright 1998-2008 The OpenLDAP Foundation. ## Copyright 1998-2010 The OpenLDAP Foundation.
## All rights reserved. ## All rights reserved.
## ##
## Redistribution and use in source and binary forms, with or without ## Redistribution and use in source and binary forms, with or without
......
...@@ -2,7 +2,7 @@ dnl OpenLDAP Autoconf Macros ...@@ -2,7 +2,7 @@ dnl OpenLDAP Autoconf Macros
dnl $OpenLDAP$ dnl $OpenLDAP$
dnl This work is part of OpenLDAP Software <http://www.openldap.org/>. dnl This work is part of OpenLDAP Software <http://www.openldap.org/>.
dnl dnl
dnl Copyright 1998-2008 The OpenLDAP Foundation. dnl Copyright 1998-2010 The OpenLDAP Foundation.
dnl All rights reserved. dnl All rights reserved.
dnl dnl
dnl Redistribution and use in source and binary forms, with or without dnl Redistribution and use in source and binary forms, with or without
...@@ -119,6 +119,17 @@ if test $ol_cv_cpp_ebcdic = yes ; then ...@@ -119,6 +119,17 @@ if test $ol_cv_cpp_ebcdic = yes ; then
fi fi
]) ])
dnl dnl
dnl --------------------------------------------------------------------
dnl Check for MSVC
AC_DEFUN([OL_MSVC],
[AC_REQUIRE_CPP()dnl
AC_CACHE_CHECK([whether we are using MS Visual C++], ol_cv_msvc,
[AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
#ifndef _MSC_VER
#include <__FOO__/generate_error.h>
#endif
]])],[ol_cv_msvc=yes],[ol_cv_msvc=no])])])
dnl -------------------------------------------------------------------- dnl --------------------------------------------------------------------
dnl OpenLDAP version of STDC header check w/ EBCDIC support dnl OpenLDAP version of STDC header check w/ EBCDIC support
AC_DEFUN([OL_HEADER_STDC], AC_DEFUN([OL_HEADER_STDC],
...@@ -288,24 +299,6 @@ AC_DEFUN([OL_BERKELEY_DB_TRY], ...@@ -288,24 +299,6 @@ AC_DEFUN([OL_BERKELEY_DB_TRY],
#define NULL ((void*)0) #define NULL ((void*)0)
#endif #endif
]], [[ ]], [[
#if DB_VERSION_MAJOR > 1
{
char *version;
int major, minor, patch;
version = db_version( &major, &minor, &patch );
if( major != DB_VERSION_MAJOR ||
minor < DB_VERSION_MINOR )
{
printf("Berkeley DB version mismatch\n"
"\theader: %s\n\tlibrary: %s\n",
DB_VERSION_STRING, version);
return 1;
}
}
#endif
#if DB_VERSION_MAJOR > 2 #if DB_VERSION_MAJOR > 2
db_env_create( NULL, 0 ); db_env_create( NULL, 0 );
#elif DB_VERSION_MAJOR > 1 #elif DB_VERSION_MAJOR > 1
...@@ -325,209 +318,53 @@ fi ...@@ -325,209 +318,53 @@ fi
]) ])
dnl dnl
dnl -------------------------------------------------------------------- dnl --------------------------------------------------------------------
dnl Try to locate appropriate library dnl Get major and minor version from <db.h>
AC_DEFUN([OL_BERKELEY_DB_LINK], AC_DEFUN([OL_BDB_HEADER_VERSION],
[ol_cv_lib_db=no [AC_CACHE_CHECK([for Berkeley DB major version in db.h], [ol_cv_bdb_major],[
AC_LANG_CONFTEST([
dnl Determine major version
AC_CACHE_CHECK([for Berkeley DB major version], [ol_cv_bdb_major],[
ol_cv_bdb_major=0
if test $ol_cv_bdb_major = 0 ; then
AC_EGREP_CPP(__db_version, [
#include <db.h>
#ifndef DB_VERSION_MAJOR
# define DB_VERSION_MAJOR 1
#endif
#if DB_VERSION_MAJOR == 4
__db_version
#endif
], [ol_cv_bdb_major=4], [:])
fi
if test $ol_cv_bdb_major = 0 ; then
AC_EGREP_CPP(__db_version, [
#include <db.h> #include <db.h>
#ifndef DB_VERSION_MAJOR #ifndef DB_VERSION_MAJOR
# define DB_VERSION_MAJOR 1 # define DB_VERSION_MAJOR 1
#endif #endif
#if DB_VERSION_MAJOR == 3 __db_version DB_VERSION_MAJOR
__db_version ])
#endif set X `eval "$ac_cpp conftest.$ac_ext" | $EGREP __db_version` none none
], [ol_cv_bdb_major=3], [:]) ol_cv_bdb_major=${3}
fi
if test $ol_cv_bdb_major = 0 ; then
AC_EGREP_CPP(__db_version, [
#include <db.h>
#ifndef DB_VERSION_MAJOR
# define DB_VERSION_MAJOR 1
#endif
#if DB_VERSION_MAJOR == 2
__db_version
#endif
], [ol_cv_bdb_major=2], [:])
fi
if test $ol_cv_bdb_major = 0 ; then
AC_EGREP_CPP(__db_version, [
#include <db.h>
#ifndef DB_VERSION_MAJOR
# define DB_VERSION_MAJOR 1
#endif
#if DB_VERSION_MAJOR == 1
__db_version
#endif
], [ol_cv_bdb_major=1], [:])
fi
if test $ol_cv_bdb_major = 0 ; then
AC_MSG_ERROR([Unknown Berkeley DB major version])
fi
]) ])
case $ol_cv_bdb_major in [[1-9]]*) : ;; *)
AC_MSG_ERROR([Unknown Berkeley DB major version in db.h]) ;;
esac
dnl Determine minor version dnl Determine minor version
AC_CACHE_CHECK([for Berkeley DB minor version], [ol_cv_bdb_minor],[ AC_CACHE_CHECK([for Berkeley DB minor version in db.h], [ol_cv_bdb_minor],[
ol_cv_bdb_minor=0 AC_LANG_CONFTEST([
if test $ol_cv_bdb_minor = 0 ; then
AC_EGREP_CPP(__db_version, [
#include <db.h> #include <db.h>
#ifndef DB_VERSION_MINOR #ifndef DB_VERSION_MINOR
# define DB_VERSION_MINOR 0 # define DB_VERSION_MINOR 0
#endif #endif
#if DB_VERSION_MINOR == 9 __db_version DB_VERSION_MINOR
__db_version ])
#endif set X `eval "$ac_cpp conftest.$ac_ext" | $EGREP __db_version` none none
], [ol_cv_bdb_minor=9], [:]) ol_cv_bdb_minor=${3}
fi ])
if test $ol_cv_bdb_minor = 0 ; then case $ol_cv_bdb_minor in [[0-9]]*) : ;; *)
AC_EGREP_CPP(__db_version, [ AC_MSG_ERROR([Unknown Berkeley DB minor version in db.h]) ;;
#include <db.h> esac
#ifndef DB_VERSION_MINOR
# define DB_VERSION_MINOR 0
#endif
#if DB_VERSION_MINOR == 8
__db_version
#endif
], [ol_cv_bdb_minor=8], [:])
fi
if test $ol_cv_bdb_minor = 0 ; then
AC_EGREP_CPP(__db_version, [
#include <db.h>
#ifndef DB_VERSION_MINOR
# define DB_VERSION_MINOR 0
#endif
#if DB_VERSION_MINOR == 7
__db_version
#endif
], [ol_cv_bdb_minor=7], [:])
fi
if test $ol_cv_bdb_minor = 0 ; then
AC_EGREP_CPP(__db_version, [
#include <db.h>
#ifndef DB_VERSION_MINOR
# define DB_VERSION_MINOR 0
#endif
#if DB_VERSION_MINOR == 6
__db_version
#endif
], [ol_cv_bdb_minor=6], [:])
fi
if test $ol_cv_bdb_minor = 0 ; then
AC_EGREP_CPP(__db_version, [
#include <db.h>
#ifndef DB_VERSION_MINOR
# define DB_VERSION_MINOR 0
#endif
#if DB_VERSION_MINOR == 5
__db_version
#endif
], [ol_cv_bdb_minor=5], [:])
fi
if test $ol_cv_bdb_minor = 0 ; then
AC_EGREP_CPP(__db_version, [
#include <db.h>
#ifndef DB_VERSION_MINOR
# define DB_VERSION_MINOR 0
#endif
#if DB_VERSION_MINOR == 4
__db_version
#endif
], [ol_cv_bdb_minor=4], [:])
fi
if test $ol_cv_bdb_minor = 0 ; then
AC_EGREP_CPP(__db_version, [
#include <db.h>
#ifndef DB_VERSION_MINOR
# define DB_VERSION_MINOR 0
#endif
#if DB_VERSION_MINOR == 3
__db_version
#endif
], [ol_cv_bdb_minor=3], [:])
fi
if test $ol_cv_bdb_minor = 0 ; then
AC_EGREP_CPP(__db_version, [
#include <db.h>
#ifndef DB_VERSION_MINOR
# define DB_VERSION_MINOR 0
#endif
#if DB_VERSION_MINOR == 2
__db_version
#endif
], [ol_cv_bdb_minor=2], [:])
fi
if test $ol_cv_bdb_minor = 0 ; then
AC_EGREP_CPP(__db_version, [
#include <db.h>
#ifndef DB_VERSION_MINOR
# define DB_VERSION_MINOR 0
#endif
#if DB_VERSION_MINOR == 1
__db_version
#endif
], [ol_cv_bdb_minor=1], [:])
fi
]) ])
dnl
dnl --------------------------------------------------------------------
dnl Try to locate appropriate library
AC_DEFUN([OL_BERKELEY_DB_LINK],
[ol_cv_lib_db=no
if test $ol_cv_bdb_major = 4 ; then if test $ol_cv_bdb_major = 4 ; then
if test $ol_cv_bdb_minor = 6 ; then OL_BERKELEY_DB_TRY(ol_cv_db_db_4_dot_m,[-ldb-4.$ol_cv_bdb_minor])
OL_BERKELEY_DB_TRY(ol_cv_db_db_4_dot_6,[-ldb-4.6]) OL_BERKELEY_DB_TRY(ol_cv_db_db4m,[-ldb4$ol_cv_bdb_minor])
OL_BERKELEY_DB_TRY(ol_cv_db_db46,[-ldb46]) OL_BERKELEY_DB_TRY(ol_cv_db_db_4m,[-ldb-4$ol_cv_bdb_minor])
OL_BERKELEY_DB_TRY(ol_cv_db_db_46,[-ldb-46]) OL_BERKELEY_DB_TRY(ol_cv_db_db_4_m,[-ldb-4-$ol_cv_bdb_minor])
OL_BERKELEY_DB_TRY(ol_cv_db_db_4_6,[-ldb-4-6])
elif test $ol_cv_bdb_minor = 5 ; then
OL_BERKELEY_DB_TRY(ol_cv_db_db_4_dot_5,[-ldb-4.5])
OL_BERKELEY_DB_TRY(ol_cv_db_db45,[-ldb45])
OL_BERKELEY_DB_TRY(ol_cv_db_db_45,[-ldb-45])
OL_BERKELEY_DB_TRY(ol_cv_db_db_4_5,[-ldb-4-5])
elif test $ol_cv_bdb_minor = 4 ; then
OL_BERKELEY_DB_TRY(ol_cv_db_db_4_dot_4,[-ldb-4.4])
OL_BERKELEY_DB_TRY(ol_cv_db_db44,[-ldb44])
OL_BERKELEY_DB_TRY(ol_cv_db_db_44,[-ldb-44])
OL_BERKELEY_DB_TRY(ol_cv_db_db_4_4,[-ldb-4-4])
elif test $ol_cv_bdb_minor = 3 ; then
OL_BERKELEY_DB_TRY(ol_cv_db_db_4_dot_3,[-ldb-4.3])
OL_BERKELEY_DB_TRY(ol_cv_db_db43,[-ldb43])
OL_BERKELEY_DB_TRY(ol_cv_db_db_43,[-ldb-43])
OL_BERKELEY_DB_TRY(ol_cv_db_db_4_3,[-ldb-4-3])
elif test $ol_cv_bdb_minor = 2 ; then
OL_BERKELEY_DB_TRY(ol_cv_db_db_4_dot_2,[-ldb-4.2])
OL_BERKELEY_DB_TRY(ol_cv_db_db42,[-ldb42])
OL_BERKELEY_DB_TRY(ol_cv_db_db_42,[-ldb-42])
OL_BERKELEY_DB_TRY(ol_cv_db_db_4_2,[-ldb-4-2])
fi
OL_BERKELEY_DB_TRY(ol_cv_db_db_4,[-ldb-4]) OL_BERKELEY_DB_TRY(ol_cv_db_db_4,[-ldb-4])
OL_BERKELEY_DB_TRY(ol_cv_db_db4,[-ldb4]) OL_BERKELEY_DB_TRY(ol_cv_db_db4,[-ldb4])
OL_BERKELEY_DB_TRY(ol_cv_db_db,[-ldb]) OL_BERKELEY_DB_TRY(ol_cv_db_db,[-ldb])
elif test $ol_cv_bdb_major = 3 ; then
OL_BERKELEY_DB_TRY(ol_cv_db_db3,[-ldb3])
OL_BERKELEY_DB_TRY(ol_cv_db_db_3,[-ldb-3])
elif test $ol_cv_bdb_major = 2 ; then
OL_BERKELEY_DB_TRY(ol_cv_db_db2,[-ldb2])
OL_BERKELEY_DB_TRY(ol_cv_db_db_2,[-ldb-2])
elif test $ol_cv_bdb_major = 1 ; then
OL_BERKELEY_DB_TRY(ol_cv_db_db1,[-ldb1])
OL_BERKELEY_DB_TRY(ol_cv_db_db_1,[-ldb-1])
fi fi
OL_BERKELEY_DB_TRY(ol_cv_db_none) OL_BERKELEY_DB_TRY(ol_cv_db_none)
]) ])
...@@ -535,7 +372,7 @@ dnl ...@@ -535,7 +372,7 @@ dnl
dnl -------------------------------------------------------------------- dnl --------------------------------------------------------------------
dnl Check if Berkeley DB version dnl Check if Berkeley DB version
AC_DEFUN([OL_BERKELEY_DB_VERSION], AC_DEFUN([OL_BERKELEY_DB_VERSION],
[AC_CACHE_CHECK([for Berkeley DB version match], [ol_cv_berkeley_db_version], [ [AC_CACHE_CHECK([for Berkeley DB library and header version match], [ol_cv_berkeley_db_version], [
ol_LIBS="$LIBS" ol_LIBS="$LIBS"
LIBS="$LTHREAD_LIBS $LIBS" LIBS="$LTHREAD_LIBS $LIBS"
if test $ol_cv_lib_db != yes ; then if test $ol_cv_lib_db != yes ; then
...@@ -674,6 +511,13 @@ AC_DEFUN([OL_BERKELEY_DB], ...@@ -674,6 +511,13 @@ AC_DEFUN([OL_BERKELEY_DB],
[ol_cv_berkeley_db=no [ol_cv_berkeley_db=no
AC_CHECK_HEADERS(db.h) AC_CHECK_HEADERS(db.h)
if test $ac_cv_header_db_h = yes; then if test $ac_cv_header_db_h = yes; then
OL_BDB_HEADER_VERSION
OL_BDB_COMPAT
if test $ol_cv_bdb_compat != yes ; then
AC_MSG_ERROR([BerkeleyDB version incompatible with BDB/HDB backends])
fi
OL_BERKELEY_DB_LINK OL_BERKELEY_DB_LINK
if test "$ol_cv_lib_db" != no ; then if test "$ol_cv_lib_db" != no ; then
ol_cv_berkeley_db=yes ol_cv_berkeley_db=yes
...@@ -685,7 +529,7 @@ fi ...@@ -685,7 +529,7 @@ fi
dnl -------------------------------------------------------------------- dnl --------------------------------------------------------------------
dnl Check for version compatility with back-bdb dnl Check for version compatility with back-bdb
AC_DEFUN([OL_BDB_COMPAT], AC_DEFUN([OL_BDB_COMPAT],
[AC_CACHE_CHECK([Berkeley DB version for BDB/HDB backends], [ol_cv_bdb_compat],[ [AC_CACHE_CHECK([if Berkeley DB version supported by BDB/HDB backends], [ol_cv_bdb_compat],[
AC_EGREP_CPP(__db_version_compat,[ AC_EGREP_CPP(__db_version_compat,[
#include <db.h> #include <db.h>
...@@ -697,44 +541,15 @@ AC_DEFUN([OL_BDB_COMPAT], ...@@ -697,44 +541,15 @@ AC_DEFUN([OL_BDB_COMPAT],
# define DB_VERSION_MINOR 0 # define DB_VERSION_MINOR 0
#endif #endif
/* require 4.2 or later, but exclude 4.3 */ #define DB_VERSION_MM ((DB_VERSION_MAJOR<<8)|DB_VERSION_MINOR)
#if (DB_VERSION_MAJOR >= 4) && (DB_VERSION_MINOR >= 2) && (DB_VERSION_MINOR !=3)
/* require 4.4 or later */
#if DB_VERSION_MM >= 0x0404
__db_version_compat __db_version_compat
#endif #endif
], [ol_cv_bdb_compat=yes], [ol_cv_bdb_compat=no])]) ], [ol_cv_bdb_compat=yes], [ol_cv_bdb_compat=no])])
]) ])
dnl --------------------------------------------------------------------
dnl Find old Berkeley DB 1.85/1.86
AC_DEFUN([OL_BERKELEY_COMPAT_DB],
[AC_CHECK_HEADERS(db_185.h db.h)
if test $ac_cv_header_db_185_h = yes || test $ac_cv_header_db_h = yes; then
AC_CACHE_CHECK([if Berkeley DB header compatibility], [ol_cv_header_db1],[
AC_EGREP_CPP(__db_version_1,[
#if HAVE_DB_185_H
# include <db_185.h>
#else
# include <db.h>
#endif
/* this check could be improved */
#ifndef DB_VERSION_MAJOR
# define DB_VERSION_MAJOR 1
#endif
#if DB_VERSION_MAJOR == 1
__db_version_1
#endif
], [ol_cv_header_db1=yes], [ol_cv_header_db1=no])])
if test $ol_cv_header_db1 = yes ; then
OL_BERKELEY_DB_LINK
if test "$ol_cv_lib_db" != no ; then
ol_cv_berkeley_db=yes
fi
fi
fi
])
dnl dnl
dnl ==================================================================== dnl ====================================================================
dnl Check POSIX Thread version dnl Check POSIX Thread version
...@@ -1106,7 +921,9 @@ AC_DEFUN([OL_LIB_FETCH], ...@@ -1106,7 +921,9 @@ AC_DEFUN([OL_LIB_FETCH],
LIBS="-lfetch -lcom_err $LIBS" LIBS="-lfetch -lcom_err $LIBS"
AC_CACHE_CHECK([fetch(3) library],ol_cv_lib_fetch,[ AC_CACHE_CHECK([fetch(3) library],ol_cv_lib_fetch,[
AC_LINK_IFELSE([AC_LANG_PROGRAM([[ AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h> #include <sys/param.h>
#endif
#include <stdio.h> #include <stdio.h>
#include <fetch.h>]], [[struct url *u = fetchParseURL("file:///"); ]])],[ol_cv_lib_fetch=yes],[ol_cv_lib_fetch=no])]) #include <fetch.h>]], [[struct url *u = fetchParseURL("file:///"); ]])],[ol_cv_lib_fetch=yes],[ol_cv_lib_fetch=no])])
LIBS=$ol_LIBS LIBS=$ol_LIBS
......
# $OpenLDAP$ # $OpenLDAP$
## This work is part of OpenLDAP Software <http://www.openldap.org/>. ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
## ##
## Copyright 1998-2008 The OpenLDAP Foundation. ## Copyright 1998-2010 The OpenLDAP Foundation.
## All rights reserved. ## All rights reserved.
## ##
## Redistribution and use in source and binary forms, with or without ## Redistribution and use in source and binary forms, with or without
......
# $OpenLDAP$ # $OpenLDAP$
## This work is part of OpenLDAP Software <http://www.openldap.org/>. ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
## ##
## Copyright 1998-2008 The OpenLDAP Foundation. ## Copyright 1998-2010 The OpenLDAP Foundation.
## All rights reserved. ## All rights reserved.
## ##
## Redistribution and use in source and binary forms, with or without ## Redistribution and use in source and binary forms, with or without
......
# $OpenLDAP$ # $OpenLDAP$
## This work is part of OpenLDAP Software <http://www.openldap.org/>. ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
## ##
## Copyright 1998-2008 The OpenLDAP Foundation. ## Copyright 1998-2010 The OpenLDAP Foundation.
## All rights reserved. ## All rights reserved.
## ##
## Redistribution and use in source and binary forms, with or without ## Redistribution and use in source and binary forms, with or without
...@@ -32,6 +32,7 @@ exec_prefix = @exec_prefix@ ...@@ -32,6 +32,7 @@ exec_prefix = @exec_prefix@
ldap_subdir = @ldap_subdir@ ldap_subdir = @ldap_subdir@
bindir = @bindir@ bindir = @bindir@
datarootdir = @datarootdir@
datadir = @datadir@$(ldap_subdir) datadir = @datadir@$(ldap_subdir)
includedir = @includedir@ includedir = @includedir@
infodir = @infodir@ infodir = @infodir@
...@@ -159,6 +160,7 @@ LUTIL_LIBS = @LUTIL_LIBS@ ...@@ -159,6 +160,7 @@ LUTIL_LIBS = @LUTIL_LIBS@
LTHREAD_LIBS = @LTHREAD_LIBS@ LTHREAD_LIBS = @LTHREAD_LIBS@
BDB_LIBS = @BDB_LIBS@ BDB_LIBS = @BDB_LIBS@
SLAPD_NDB_LIBS = @SLAPD_NDB_LIBS@
LDAP_LIBLBER_LA = $(LDAP_LIBDIR)/liblber/liblber.la LDAP_LIBLBER_LA = $(LDAP_LIBDIR)/liblber/liblber.la
LDAP_LIBLDAP_LA = $(LDAP_LIBDIR)/libldap/libldap.la LDAP_LIBLDAP_LA = $(LDAP_LIBDIR)/libldap/libldap.la
......
/* This work is part of OpenLDAP Software <http://www.openldap.org/>. /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
* *
* Copyright 1998-2008 The OpenLDAP Foundation. * Copyright 1998-2010 The OpenLDAP Foundation.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
...@@ -13,6 +13,6 @@ ...@@ -13,6 +13,6 @@
*/ */
static const char copyright[] = static const char copyright[] =
"Copyright 1998-2008 The OpenLDAP Foundation. All rights reserved.\n" "Copyright 1998-2010 The OpenLDAP Foundation. All rights reserved.\n"
"COPYING RESTRICTIONS APPLY.\n"; "COPYING RESTRICTIONS APPLY.\n";
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# $OpenLDAP$ # $OpenLDAP$
## This work is part of OpenLDAP Software <http://www.openldap.org/>. ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
## ##
## Copyright 1998-2008 The OpenLDAP Foundation. ## Copyright 1998-2010 The OpenLDAP Foundation.
## All rights reserved. ## All rights reserved.
## ##
## Redistribution and use in source and binary forms, with or without ## Redistribution and use in source and binary forms, with or without
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# $OpenLDAP$ # $OpenLDAP$
## This work is part of OpenLDAP Software <http://www.openldap.org/>. ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
## ##
## Copyright 1998-2008 The OpenLDAP Foundation. ## Copyright 1998-2010 The OpenLDAP Foundation.
## All rights reserved. ## All rights reserved.
## ##
## Redistribution and use in source and binary forms, with or without ## Redistribution and use in source and binary forms, with or without
...@@ -14,10 +14,10 @@ ...@@ -14,10 +14,10 @@
## <http://www.OpenLDAP.org/license.html>. ## <http://www.OpenLDAP.org/license.html>.
ol_package=OpenLDAP ol_package=OpenLDAP
ol_major=2 ol_major=2
ol_minor=X ol_minor=4
ol_patch=X ol_patch=X
ol_api_inc=000000 ol_api_inc=20422
ol_api_current=0 ol_api_current=7
ol_api_revision=0 ol_api_revision=5
ol_api_age=0 ol_api_age=5
ol_release_date="0000/00/00" ol_release_date="2010/04/24"
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# $OpenLDAP$ # $OpenLDAP$
## This work is part of OpenLDAP Software <http://www.openldap.org/>. ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
## ##
## Copyright 1998-2008 The OpenLDAP Foundation. ## Copyright 1998-2010 The OpenLDAP Foundation.
## All rights reserved. ## All rights reserved.
## ##
## Redistribution and use in source and binary forms, with or without ## Redistribution and use in source and binary forms, with or without
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# $OpenLDAP$ # $OpenLDAP$
## This work is part of OpenLDAP Software <http://www.openldap.org/>. ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
## ##
## Copyright 1998-2008 The OpenLDAP Foundation. ## Copyright 1998-2010 The OpenLDAP Foundation.
## All rights reserved. ## All rights reserved.
## ##
## Redistribution and use in source and binary forms, with or without ## Redistribution and use in source and binary forms, with or without
...@@ -15,10 +15,10 @@ ...@@ -15,10 +15,10 @@
SRCS = ldapsearch.c ldapmodify.c ldapdelete.c ldapmodrdn.c \ SRCS = ldapsearch.c ldapmodify.c ldapdelete.c ldapmodrdn.c \
ldappasswd.c ldapwhoami.c ldapcompare.c \ ldappasswd.c ldapwhoami.c ldapcompare.c \
ldapexop.c common.c ldapexop.c ldapurl.c common.c
OBJS = ldapsearch.o ldapmodify.o ldapdelete.o ldapmodrdn.o \ OBJS = ldapsearch.o ldapmodify.o ldapdelete.o ldapmodrdn.o \
ldappasswd.o ldapwhoami.o ldapcompare.o \ ldappasswd.o ldapwhoami.o ldapcompare.o \
ldapexop.o common.o ldapexop.o ldapurl.o common.o
LDAP_INCDIR= ../../include LDAP_INCDIR= ../../include
LDAP_LIBDIR= ../../libraries LDAP_LIBDIR= ../../libraries
...@@ -29,10 +29,10 @@ XLIBS = $(LDAP_L) ...@@ -29,10 +29,10 @@ XLIBS = $(LDAP_L)
XXLIBS = $(SECURITY_LIBS) $(LUTIL_LIBS) XXLIBS = $(SECURITY_LIBS) $(LUTIL_LIBS)
XSRCS = ldsversion.c ldmversion.c lddversion.c ldrversion.c \ XSRCS = ldsversion.c ldmversion.c lddversion.c ldrversion.c \
ldpversion.c ldwversion.c ldcversion.c ldeversion.c ldpversion.c ldwversion.c ldcversion.c ldeversion.c lduversion.c
PROGRAMS = ldapsearch ldapmodify ldapdelete ldapmodrdn \ PROGRAMS = ldapsearch ldapmodify ldapdelete ldapmodrdn \
ldappasswd ldapwhoami ldapcompare ldapexop ldappasswd ldapwhoami ldapcompare ldapexop ldapurl
ldapsearch: ldsversion.o ldapsearch: ldsversion.o
...@@ -59,6 +59,9 @@ ldapcompare: ldcversion.o ...@@ -59,6 +59,9 @@ ldapcompare: ldcversion.o
ldapexop: ldeversion.o ldapexop: ldeversion.o
$(LTLINK) -o $@ ldapexop.o common.o ldeversion.o $(LIBS) $(LTLINK) -o $@ ldapexop.o common.o ldeversion.o $(LIBS)
ldapurl: lduversion.o
$(LTLINK) -o $@ ldapurl.o lduversion.o $(LIBS)
ldsversion.c: Makefile ldsversion.c: Makefile
@-$(RM) $@ @-$(RM) $@
$(MKVERSION) $(MKVOPTS) ldapsearch > $@ $(MKVERSION) $(MKVOPTS) ldapsearch > $@
...@@ -107,6 +110,12 @@ ldeversion.c: Makefile ...@@ -107,6 +110,12 @@ ldeversion.c: Makefile
ldeversion.o: ldapexop.o common.o $(XLIBS) ldeversion.o: ldapexop.o common.o $(XLIBS)
lduversion.c: Makefile
@-$(RM) $@
$(MKVERSION) $(MKVOPTS) ldapurl > $@
lduversion.o: ldapurl.o $(XLIBS)
install-local: FORCE install-local: FORCE
-$(MKDIR) $(DESTDIR)$(bindir) -$(MKDIR) $(DESTDIR)$(bindir)
@( \ @( \
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/* $OpenLDAP$ */ /* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>. /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
* *
* Copyright 1998-2008 The OpenLDAP Foundation. * Copyright 1998-2010 The OpenLDAP Foundation.
* Portions Copyright 2003 Kurt D. Zeilenga. * Portions Copyright 2003 Kurt D. Zeilenga.
* Portions Copyright 2003 IBM Corporation. * Portions Copyright 2003 IBM Corporation.
* All rights reserved. * All rights reserved.
...@@ -62,6 +62,7 @@ int contoper = 0; ...@@ -62,6 +62,7 @@ int contoper = 0;
int debug = 0; int debug = 0;
char *infile = NULL; char *infile = NULL;
int dont = 0; int dont = 0;
int nocanon = 0;
int referrals = 0; int referrals = 0;
int verbose = 0; int verbose = 0;
int ldif = 0; int ldif = 0;
...@@ -93,6 +94,7 @@ char *sasl_secprops = NULL; ...@@ -93,6 +94,7 @@ char *sasl_secprops = NULL;
/* controls */ /* controls */
int assertctl; int assertctl;
char *assertion = NULL; char *assertion = NULL;
struct berval assertionvalue = BER_BVNULL;
char *authzid = NULL; char *authzid = NULL;
/* support deprecated early version of proxyAuthz */ /* support deprecated early version of proxyAuthz */
#define LDAP_CONTROL_OBSOLETE_PROXY_AUTHZ "2.16.840.1.113730.3.4.12" #define LDAP_CONTROL_OBSOLETE_PROXY_AUTHZ "2.16.840.1.113730.3.4.12"
...@@ -118,6 +120,9 @@ static int chainingContinuation = -1; ...@@ -118,6 +120,9 @@ static int chainingContinuation = -1;
static int sessionTracking = 0; static int sessionTracking = 0;
struct berval stValue; struct berval stValue;
#endif /* LDAP_CONTROL_X_SESSION_TRACKING */ #endif /* LDAP_CONTROL_X_SESSION_TRACKING */
ber_int_t vlvPos;
ber_int_t vlvCount;
struct berval *vlvContext;
LDAPControl *unknown_ctrls = NULL; LDAPControl *unknown_ctrls = NULL;
int unknown_ctrls_num = 0; int unknown_ctrls_num = 0;
...@@ -133,6 +138,14 @@ static int print_paged_results( LDAP *ld, LDAPControl *ctrl ); ...@@ -133,6 +138,14 @@ static int print_paged_results( LDAP *ld, LDAPControl *ctrl );
#ifdef LDAP_CONTROL_PASSWORDPOLICYREQUEST #ifdef LDAP_CONTROL_PASSWORDPOLICYREQUEST
static int print_ppolicy( LDAP *ld, LDAPControl *ctrl ); static int print_ppolicy( LDAP *ld, LDAPControl *ctrl );
#endif #endif
static int print_sss( LDAP *ld, LDAPControl *ctrl );
static int print_vlv( LDAP *ld, LDAPControl *ctrl );
#ifdef LDAP_CONTROL_X_DEREF
static int print_deref( LDAP *ld, LDAPControl *ctrl );
#endif
#ifdef LDAP_CONTROL_X_WHATFAILED
static int print_whatfailed( LDAP *ld, LDAPControl *ctrl );
#endif
static struct tool_ctrls_t { static struct tool_ctrls_t {
const char *oid; const char *oid;
...@@ -144,6 +157,14 @@ static struct tool_ctrls_t { ...@@ -144,6 +157,14 @@ static struct tool_ctrls_t {
{ LDAP_CONTROL_PAGEDRESULTS, TOOL_SEARCH, print_paged_results }, { LDAP_CONTROL_PAGEDRESULTS, TOOL_SEARCH, print_paged_results },
#ifdef LDAP_CONTROL_PASSWORDPOLICYREQUEST #ifdef LDAP_CONTROL_PASSWORDPOLICYREQUEST
{ LDAP_CONTROL_PASSWORDPOLICYRESPONSE, TOOL_ALL, print_ppolicy }, { LDAP_CONTROL_PASSWORDPOLICYRESPONSE, TOOL_ALL, print_ppolicy },
#endif
{ LDAP_CONTROL_SORTRESPONSE, TOOL_SEARCH, print_sss },
{ LDAP_CONTROL_VLVRESPONSE, TOOL_SEARCH, print_vlv },
#ifdef LDAP_CONTROL_X_DEREF
{ LDAP_CONTROL_X_DEREF, TOOL_SEARCH, print_deref },
#endif
#ifdef LDAP_CONTROL_X_WHATFAILED
{ LDAP_CONTROL_X_WHATFAILED, TOOL_ALL, print_whatfailed },
#endif #endif
{ NULL, 0, NULL } { NULL, 0, NULL }
}; };
...@@ -234,18 +255,29 @@ tool_destroy( void ) ...@@ -234,18 +255,29 @@ tool_destroy( void )
pr_cookie.bv_val = NULL; pr_cookie.bv_val = NULL;
pr_cookie.bv_len = 0; pr_cookie.bv_len = 0;
} }
if ( binddn != NULL ) {
ber_memfree( binddn );
}
if ( passwd.bv_val != NULL ) {
ber_memfree( passwd.bv_val );
}
if ( infile != NULL ) {
ber_memfree( infile );
}
} }
void void
tool_common_usage( void ) tool_common_usage( void )
{ {
static const char *const descriptions[] = { static const char *const descriptions[] = {
N_(" -c continuous operation mode (do not stop on errors)\n"),
N_(" -d level set LDAP debugging level to `level'\n"), N_(" -d level set LDAP debugging level to `level'\n"),
N_(" -D binddn bind DN\n"), N_(" -D binddn bind DN\n"),
N_(" -e [!]<ext>[=<extparam>] general extensions (! indicates criticality)\n") N_(" -e [!]<ext>[=<extparam>] general extensions (! indicates criticality)\n")
N_(" [!]assert=<filter> (a RFC 4515 Filter string)\n") N_(" [!]assert=<filter> (RFC 4528; a RFC 4515 Filter string)\n")
N_(" [!]authzid=<authzid> (\"dn:<dn>\" or \"u:<user>\")\n") N_(" [!]authzid=<authzid> (RFC 4370; \"dn:<dn>\" or \"u:<user>\")\n")
#ifdef LDAP_CONTROL_OBSOLETE_PROXY_AUTHZ #ifdef LDAP_CONTROL_OBSOLETE_PROXY_AUTHZ
#if 0 #if 0
/* non-advertized support for proxyDN */ /* non-advertized support for proxyDN */
...@@ -257,13 +289,13 @@ N_(" [!]chaining[=<resolveBehavior>[/<continuationBehavior>]]\n") ...@@ -257,13 +289,13 @@ N_(" [!]chaining[=<resolveBehavior>[/<continuationBehavior>]]\n")
N_(" one of \"chainingPreferred\", \"chainingRequired\",\n") N_(" one of \"chainingPreferred\", \"chainingRequired\",\n")
N_(" \"referralsPreferred\", \"referralsRequired\"\n") N_(" \"referralsPreferred\", \"referralsRequired\"\n")
#endif /* LDAP_CONTROL_X_CHAINING_BEHAVIOR */ #endif /* LDAP_CONTROL_X_CHAINING_BEHAVIOR */
N_(" [!]manageDSAit\n") N_(" [!]manageDSAit (RFC 3296)\n")
N_(" [!]noop\n") N_(" [!]noop\n")
#ifdef LDAP_CONTROL_PASSWORDPOLICYREQUEST #ifdef LDAP_CONTROL_PASSWORDPOLICYREQUEST
N_(" ppolicy\n") N_(" ppolicy\n")
#endif #endif
N_(" [!]postread[=<attrs>] (a comma-separated attribute list)\n") N_(" [!]postread[=<attrs>] (RFC 4527; comma-separated attr list)\n")
N_(" [!]preread[=<attrs>] (a comma-separated attribute list)\n") N_(" [!]preread[=<attrs>] (RFC 4527; comma-separated attr list)\n")
N_(" [!]relax\n") N_(" [!]relax\n")
#ifdef LDAP_CONTROL_X_SESSION_TRACKING #ifdef LDAP_CONTROL_X_SESSION_TRACKING
N_(" [!]sessiontracking\n") N_(" [!]sessiontracking\n")
...@@ -271,17 +303,15 @@ N_(" [!]sessiontracking\n") ...@@ -271,17 +303,15 @@ N_(" [!]sessiontracking\n")
N_(" abandon, cancel, ignore (SIGINT sends abandon/cancel,\n" N_(" abandon, cancel, ignore (SIGINT sends abandon/cancel,\n"
" or ignores response; if critical, doesn't wait for SIGINT.\n" " or ignores response; if critical, doesn't wait for SIGINT.\n"
" not really controls)\n") " not really controls)\n")
N_(" -f file read operations from `file'\n"),
N_(" -h host LDAP server\n"), N_(" -h host LDAP server\n"),
N_(" -H URI LDAP Uniform Resource Identifier(s)\n"), N_(" -H URI LDAP Uniform Resource Identifier(s)\n"),
N_(" -I use SASL Interactive mode\n"), N_(" -I use SASL Interactive mode\n"),
N_(" -M enable Manage DSA IT control (-MM to make critical)\n"),
N_(" -n show what would be done but don't actually do it\n"), N_(" -n show what would be done but don't actually do it\n"),
N_(" -N do not use reverse DNS to canonicalize SASL host name\n"),
N_(" -O props SASL security properties\n"), N_(" -O props SASL security properties\n"),
N_(" -o <opt>[=<optparam] general options\n"), N_(" -o <opt>[=<optparam] general options\n"),
N_(" nettimeout=<timeout> (in seconds, or \"none\" or \"max\")\n"), N_(" nettimeout=<timeout> (in seconds, or \"none\" or \"max\")\n"),
N_(" -p port port on LDAP server\n"), N_(" -p port port on LDAP server\n"),
N_(" -P version protocol version (default: 3)\n"),
N_(" -Q use SASL Quiet mode\n"), N_(" -Q use SASL Quiet mode\n"),
N_(" -R realm SASL realm\n"), N_(" -R realm SASL realm\n"),
N_(" -U authcid SASL authentication identity\n"), N_(" -U authcid SASL authentication identity\n"),
...@@ -598,7 +628,7 @@ tool_args( int argc, char **argv ) ...@@ -598,7 +628,7 @@ tool_args( int argc, char **argv )
} else if ( tool_is_oid( control ) ) { } else if ( tool_is_oid( control ) ) {
LDAPControl *tmpctrls, ctrl; LDAPControl *tmpctrls, ctrl;
tmpctrls = (LDAPControl *)realloc( unknown_ctrls, tmpctrls = (LDAPControl *)ber_memrealloc( unknown_ctrls,
(unknown_ctrls_num + 1)*sizeof( LDAPControl ) ); (unknown_ctrls_num + 1)*sizeof( LDAPControl ) );
if ( tmpctrls == NULL ) { if ( tmpctrls == NULL ) {
fprintf( stderr, "%s: no memory?\n", prog ); fprintf( stderr, "%s: no memory?\n", prog );
...@@ -622,7 +652,7 @@ tool_args( int argc, char **argv ) ...@@ -622,7 +652,7 @@ tool_args( int argc, char **argv )
(unsigned char *)bv.bv_val, (unsigned char *)bv.bv_val,
bv.bv_len ); bv.bv_len );
if ( retcode == -1 || retcode > bv.bv_len ) { if ( retcode == -1 || (unsigned) retcode > bv.bv_len ) {
fprintf( stderr, "Unable to parse value of general control %s\n", fprintf( stderr, "Unable to parse value of general control %s\n",
control ); control );
usage(); usage();
...@@ -685,6 +715,9 @@ tool_args( int argc, char **argv ) ...@@ -685,6 +715,9 @@ tool_args( int argc, char **argv )
case 'n': /* print operations, don't actually do them */ case 'n': /* print operations, don't actually do them */
dont++; dont++;
break; break;
case 'N':
nocanon++;
break;
case 'o': case 'o':
control = ber_strdup( optarg ); control = ber_strdup( optarg );
if ( (cvalue = strchr( control, '=' )) != NULL ) { if ( (cvalue = strchr( control, '=' )) != NULL ) {
...@@ -978,7 +1011,11 @@ tool_args( int argc, char **argv ) ...@@ -978,7 +1011,11 @@ tool_args( int argc, char **argv )
if (authmethod == -1 && protocol > LDAP_VERSION2) { if (authmethod == -1 && protocol > LDAP_VERSION2) {
#ifdef HAVE_CYRUS_SASL #ifdef HAVE_CYRUS_SASL
authmethod = LDAP_AUTH_SASL; if ( binddn != NULL ) {
authmethod = LDAP_AUTH_SIMPLE;
} else {
authmethod = LDAP_AUTH_SASL;
}
#else #else
authmethod = LDAP_AUTH_SIMPLE; authmethod = LDAP_AUTH_SIMPLE;
#endif #endif
...@@ -1137,7 +1174,7 @@ tool_conn_setup( int dont, void (*private_setup)( LDAP * ) ) ...@@ -1137,7 +1174,7 @@ tool_conn_setup( int dont, void (*private_setup)( LDAP * ) )
for ( i = 0; hosts[ i ] != NULL; i++ ) for ( i = 0; hosts[ i ] != NULL; i++ )
/* count'em */ ; /* count'em */ ;
tmp = (char **)realloc( urls, sizeof( char * ) * ( nurls + i + 1 ) ); tmp = (char **)ber_memrealloc( urls, sizeof( char * ) * ( nurls + i + 1 ) );
if ( tmp == NULL ) { if ( tmp == NULL ) {
fprintf( stderr, fprintf( stderr,
"DNS SRV: out of memory?\n" ); "DNS SRV: out of memory?\n" );
...@@ -1171,7 +1208,7 @@ dnssrv_free:; ...@@ -1171,7 +1208,7 @@ dnssrv_free:;
ber_memfree( domain ); ber_memfree( domain );
} else { } else {
tmp = (char **)realloc( urls, sizeof( char * ) * ( nurls + 2 ) ); tmp = (char **)ber_memrealloc( urls, sizeof( char * ) * ( nurls + 2 ) );
if ( tmp == NULL ) { if ( tmp == NULL ) {
fprintf( stderr, fprintf( stderr,
"DNS SRV: out of memory?\n" ); "DNS SRV: out of memory?\n" );
...@@ -1231,6 +1268,16 @@ dnssrv_free:; ...@@ -1231,6 +1268,16 @@ dnssrv_free:;
exit( EXIT_FAILURE ); exit( EXIT_FAILURE );
} }
#ifdef HAVE_CYRUS_SASL
/* canon */
if( ldap_set_option( ld, LDAP_OPT_X_SASL_NOCANON,
nocanon ? LDAP_OPT_ON : LDAP_OPT_OFF ) != LDAP_OPT_SUCCESS )
{
fprintf( stderr, "Could not set LDAP_OPT_X_SASL_NOCANON %s\n",
nocanon ? "on" : "off" );
exit( EXIT_FAILURE );
}
#endif
if( ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &protocol ) if( ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &protocol )
!= LDAP_OPT_SUCCESS ) != LDAP_OPT_SUCCESS )
{ {
...@@ -1242,7 +1289,10 @@ dnssrv_free:; ...@@ -1242,7 +1289,10 @@ dnssrv_free:;
if ( use_tls ) { if ( use_tls ) {
rc = ldap_start_tls_s( ld, NULL, NULL ); rc = ldap_start_tls_s( ld, NULL, NULL );
if ( rc != LDAP_SUCCESS ) { if ( rc != LDAP_SUCCESS ) {
tool_perror( "ldap_start_tls", rc, NULL, NULL, NULL, NULL ); char *msg=NULL;
ldap_get_option( ld, LDAP_OPT_DIAGNOSTIC_MESSAGE, (void*)&msg);
tool_perror( "ldap_start_tls", rc, NULL, NULL, msg, NULL );
ldap_memfree(msg);
if ( use_tls > 1 ) { if ( use_tls > 1 ) {
exit( EXIT_FAILURE ); exit( EXIT_FAILURE );
} }
...@@ -1307,7 +1357,24 @@ tool_bind( LDAP *ld ) ...@@ -1307,7 +1357,24 @@ tool_bind( LDAP *ld )
sctrlsp = sctrls; sctrlsp = sctrls;
} }
assert( nsctrls < sizeof(sctrls)/sizeof(sctrls[0]) ); assert( nsctrls < (int) (sizeof(sctrls)/sizeof(sctrls[0])) );
if ( pw_file || want_bindpw ) {
assert( passwd.bv_val == NULL && passwd.bv_len == 0 );
if ( pw_file ) {
if ( lutil_get_filed_password( pw_file, &passwd ) ) {
exit( EXIT_FAILURE );
}
} else {
char *pw = getpassphrase( _("Enter LDAP Password: ") );
if ( pw ) {
passwd.bv_val = ber_strdup( pw );
passwd.bv_len = strlen( passwd.bv_val );
}
}
}
if ( authmethod == LDAP_AUTH_SASL ) { if ( authmethod == LDAP_AUTH_SASL ) {
#ifdef HAVE_CYRUS_SASL #ifdef HAVE_CYRUS_SASL
...@@ -1339,8 +1406,11 @@ tool_bind( LDAP *ld ) ...@@ -1339,8 +1406,11 @@ tool_bind( LDAP *ld )
lutil_sasl_freedefs( defaults ); lutil_sasl_freedefs( defaults );
if( rc != LDAP_SUCCESS ) { if( rc != LDAP_SUCCESS ) {
char *msg=NULL;
ldap_get_option( ld, LDAP_OPT_DIAGNOSTIC_MESSAGE, (void*)&msg);
tool_perror( "ldap_sasl_interactive_bind_s", tool_perror( "ldap_sasl_interactive_bind_s",
rc, NULL, NULL, NULL, NULL ); rc, NULL, NULL, msg, NULL );
ldap_memfree(msg);
exit( rc ); exit( rc );
} }
#else #else
...@@ -1369,11 +1439,17 @@ tool_bind( LDAP *ld ) ...@@ -1369,11 +1439,17 @@ tool_bind( LDAP *ld )
} }
} }
if ( ldap_result( ld, msgid, LDAP_MSG_ALL, NULL, &result ) == -1 ) { rc = ldap_result( ld, msgid, LDAP_MSG_ALL, NULL, &result );
if ( rc == -1 ) {
tool_perror( "ldap_result", -1, NULL, NULL, NULL, NULL ); tool_perror( "ldap_result", -1, NULL, NULL, NULL, NULL );
exit( LDAP_LOCAL_ERROR ); exit( LDAP_LOCAL_ERROR );
} }
if ( rc == 0 ) {
tool_perror( "ldap_result", LDAP_TIMEOUT, NULL, NULL, NULL, NULL );
exit( LDAP_LOCAL_ERROR );
}
rc = ldap_parse_result( ld, result, &err, &matched, &info, &refs, rc = ldap_parse_result( ld, result, &err, &matched, &info, &refs,
&ctrls, 1 ); &ctrls, 1 );
if ( rc != LDAP_SUCCESS ) { if ( rc != LDAP_SUCCESS ) {
...@@ -1485,29 +1561,18 @@ tool_server_controls( LDAP *ld, LDAPControl *extra_c, int count ) ...@@ -1485,29 +1561,18 @@ tool_server_controls( LDAP *ld, LDAPControl *extra_c, int count )
} }
if ( assertctl ) { if ( assertctl ) {
BerElementBuffer berbuf; if ( BER_BVISNULL( &assertionvalue ) ) {
BerElement *ber = (BerElement *)&berbuf; err = ldap_create_assertion_control_value( ld,
assertion, &assertionvalue );
if( assertion == NULL || *assertion == '\0' ) { if ( err ) {
fprintf( stderr, "Assertion=<empty>\n" ); fprintf( stderr,
exit( EXIT_FAILURE ); "Unable to create assertion value "
} "\"%s\" (%d)\n", assertion, err );
}
ber_init2( ber, NULL, LBER_USE_DER );
err = ldap_pvt_put_filter( ber, assertion );
if( err < 0 ) {
fprintf( stderr, "assertion encode failed (%d)\n", err );
exit( EXIT_FAILURE );
}
err = ber_flatten2( ber, &c[i].ldctl_value, 0 );
if( err < 0 ) {
fprintf( stderr, "assertion flatten failed (%d)\n", err );
exit( EXIT_FAILURE );
} }
c[i].ldctl_oid = LDAP_CONTROL_ASSERT; c[i].ldctl_oid = LDAP_CONTROL_ASSERT;
c[i].ldctl_value = assertionvalue;
c[i].ldctl_iscritical = assertctl > 1; c[i].ldctl_iscritical = assertctl > 1;
ctrls[i] = &c[i]; ctrls[i] = &c[i];
i++; i++;
...@@ -1531,7 +1596,7 @@ tool_server_controls( LDAP *ld, LDAPControl *extra_c, int count ) ...@@ -1531,7 +1596,7 @@ tool_server_controls( LDAP *ld, LDAPControl *extra_c, int count )
ber_init2( ber, NULL, LBER_USE_DER ); ber_init2( ber, NULL, LBER_USE_DER );
if ( ber_printf( ber, "s", proxydn ) == LBER_ERROR ) { if ( ber_printf( ber, "s", proxydn ) == -1 ) {
exit( EXIT_FAILURE ); exit( EXIT_FAILURE );
} }
...@@ -1581,8 +1646,8 @@ tool_server_controls( LDAP *ld, LDAPControl *extra_c, int count ) ...@@ -1581,8 +1646,8 @@ tool_server_controls( LDAP *ld, LDAPControl *extra_c, int count )
#endif #endif
if ( preread ) { if ( preread ) {
char berbuf[LBER_ELEMENT_SIZEOF]; BerElementBuffer berbuf;
BerElement *ber = (BerElement *)berbuf; BerElement *ber = (BerElement *)&berbuf;
char **attrs = NULL; char **attrs = NULL;
if( preread_attrs ) { if( preread_attrs ) {
...@@ -1611,8 +1676,8 @@ tool_server_controls( LDAP *ld, LDAPControl *extra_c, int count ) ...@@ -1611,8 +1676,8 @@ tool_server_controls( LDAP *ld, LDAPControl *extra_c, int count )
} }
if ( postread ) { if ( postread ) {
char berbuf[LBER_ELEMENT_SIZEOF]; BerElementBuffer berbuf;
BerElement *ber = (BerElement *)berbuf; BerElement *ber = (BerElement *)&berbuf;
char **attrs = NULL; char **attrs = NULL;
if( postread_attrs ) { if( postread_attrs ) {
...@@ -1874,6 +1939,190 @@ print_paged_results( LDAP *ld, LDAPControl *ctrl ) ...@@ -1874,6 +1939,190 @@ print_paged_results( LDAP *ld, LDAPControl *ctrl )
return 0; return 0;
} }
static int
print_sss( LDAP *ld, LDAPControl *ctrl )
{
int rc;
ber_int_t err;
char *attr;
rc = ldap_parse_sortresponse_control( ld, ctrl, &err, &attr );
if ( rc == LDAP_SUCCESS ) {
char buf[ BUFSIZ ];
rc = snprintf( buf, sizeof(buf), "(%d) %s%s%s",
err, ldap_err2string(err), attr ? " " : "", attr ? attr : "" );
tool_write_ldif( ldif ? LDIF_PUT_COMMENT : LDIF_PUT_VALUE,
"sortResult", buf, rc );
}
return rc;
}
static int
print_vlv( LDAP *ld, LDAPControl *ctrl )
{
int rc;
ber_int_t err;
struct berval bv;
rc = ldap_parse_vlvresponse_control( ld, ctrl, &vlvPos, &vlvCount,
&vlvContext, &err );
if ( rc == LDAP_SUCCESS ) {
char buf[ BUFSIZ ];
if ( vlvContext && vlvContext->bv_len > 0 ) {
bv.bv_len = LUTIL_BASE64_ENCODE_LEN(
vlvContext->bv_len ) + 1;
bv.bv_val = ber_memalloc( bv.bv_len + 1 );
bv.bv_len = lutil_b64_ntop(
(unsigned char *) vlvContext->bv_val,
vlvContext->bv_len,
bv.bv_val, bv.bv_len );
} else {
bv.bv_val = "";
bv.bv_len = 0;
}
rc = snprintf( buf, sizeof(buf), "pos=%d count=%d context=%s (%d) %s",
vlvPos, vlvCount, bv.bv_val,
err, ldap_err2string(err));
if ( bv.bv_len )
ber_memfree( bv.bv_val );
tool_write_ldif( ldif ? LDIF_PUT_COMMENT : LDIF_PUT_VALUE,
"vlvResult", buf, rc );
}
return rc;
}
#ifdef LDAP_CONTROL_X_DEREF
static int
print_deref( LDAP *ld, LDAPControl *ctrl )
{
LDAPDerefRes *drhead = NULL, *dr;
int rc;
rc = ldap_parse_derefresponse_control( ld, ctrl, &drhead );
if ( rc != LDAP_SUCCESS ) {
return rc;
}
for ( dr = drhead; dr != NULL; dr = dr->next ) {
LDAPDerefVal *dv;
ber_len_t len;
char *buf, *ptr;
len = strlen( dr->derefAttr ) + STRLENOF(": ");
for ( dv = dr->attrVals; dv != NULL; dv = dv->next ) {
if ( dv->vals != NULL ) {
int j;
ber_len_t tlen = strlen(dv->type);
for ( j = 0; dv->vals[ j ].bv_val != NULL; j++ ) {
len += STRLENOF("<:=>;") + tlen + 4*((dv->vals[ j ].bv_len - 1)/3 + 1);
}
}
}
len += dr->derefVal.bv_len + STRLENOF("\n");
buf = ldap_memalloc( len + 1 );
if ( buf == NULL ) {
rc = LDAP_NO_MEMORY;
goto done;
}
ptr = buf;
ptr = lutil_strcopy( ptr, dr->derefAttr );
*ptr++ = ':';
*ptr++ = ' ';
for ( dv = dr->attrVals; dv != NULL; dv = dv->next ) {
if ( dv->vals != NULL ) {
int j;
for ( j = 0; dv->vals[ j ].bv_val != NULL; j++ ) {
int k = ldif_is_not_printable( dv->vals[ j ].bv_val, dv->vals[ j ].bv_len );
*ptr++ = '<';
ptr = lutil_strcopy( ptr, dv->type );
if ( k ) {
*ptr++ = ':';
}
*ptr++ = '=';
if ( k ) {
k = lutil_b64_ntop(
(unsigned char *) dv->vals[ j ].bv_val,
dv->vals[ j ].bv_len,
ptr, buf + len - ptr );
assert( k >= 0 );
ptr += k;
} else {
ptr = lutil_memcopy( ptr, dv->vals[ j ].bv_val, dv->vals[ j ].bv_len );
}
*ptr++ = '>';
*ptr++ = ';';
}
}
}
ptr = lutil_strncopy( ptr, dr->derefVal.bv_val, dr->derefVal.bv_len );
*ptr++ = '\n';
*ptr = '\0';
assert( ptr <= buf + len );
tool_write_ldif( LDIF_PUT_COMMENT, NULL, buf, ptr - buf);
ldap_memfree( buf );
}
rc = LDAP_SUCCESS;
done:;
ldap_derefresponse_free( drhead );
return rc;
}
#endif
#ifdef LDAP_CONTROL_X_WHATFAILED
static int
print_whatfailed( LDAP *ld, LDAPControl *ctrl )
{
BerElement *ber;
ber_tag_t tag;
ber_len_t siz;
BerVarray bva = NULL;
/* Create a BerElement from the berval returned in the control. */
ber = ber_init( &ctrl->ldctl_value );
if ( ber == NULL ) {
return LDAP_NO_MEMORY;
}
siz = sizeof(struct berval);
tag = ber_scanf( ber, "[M]", &bva, &siz, 0 );
if ( tag != LBER_ERROR ) {
int i;
tool_write_ldif( LDIF_PUT_COMMENT, " what failed:", NULL, 0 );
for ( i = 0; bva[i].bv_val != NULL; i++ ) {
tool_write_ldif( LDIF_PUT_COMMENT, NULL, bva[i].bv_val, bva[i].bv_len );
}
ldap_memfree( bva );
}
ber_free( ber, 1 );
return 0;
}
#endif
#ifdef LDAP_CONTROL_PASSWORDPOLICYREQUEST #ifdef LDAP_CONTROL_PASSWORDPOLICYREQUEST
static int static int
print_ppolicy( LDAP *ld, LDAPControl *ctrl ) print_ppolicy( LDAP *ld, LDAPControl *ctrl )
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/* $OpenLDAP$ */ /* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>. /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
* *
* Copyright 1998-2008 The OpenLDAP Foundation. * Copyright 1998-2010 The OpenLDAP Foundation.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
...@@ -93,6 +93,9 @@ extern struct berval pr_cookie; ...@@ -93,6 +93,9 @@ extern struct berval pr_cookie;
#ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR #ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR
extern int chaining; extern int chaining;
#endif /* LDAP_CONTROL_X_CHAINING_BEHAVIOR */ #endif /* LDAP_CONTROL_X_CHAINING_BEHAVIOR */
extern ber_int_t vlvPos;
extern ber_int_t vlvCount;
extern struct berval *vlvContext;
/* options */ /* options */
extern struct timeval nettimeout; extern struct timeval nettimeout;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/* $OpenLDAP$ */ /* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>. /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
* *
* Copyright 1998-2008 The OpenLDAP Foundation. * Copyright 1998-2010 The OpenLDAP Foundation.
* Portions Copyright 1998-2003 Kurt D. Zeilenga. * Portions Copyright 1998-2003 Kurt D. Zeilenga.
* Portions Copyright 1998-2001 Net Boolean Incorporated. * Portions Copyright 1998-2001 Net Boolean Incorporated.
* All rights reserved. * All rights reserved.
...@@ -85,6 +85,8 @@ usage( void ) ...@@ -85,6 +85,8 @@ usage( void )
fprintf( stderr, _("Compare options:\n")); fprintf( stderr, _("Compare options:\n"));
fprintf( stderr, _(" -E [!]<ext>[=<extparam>] compare extensions (! indicates criticality)\n")); fprintf( stderr, _(" -E [!]<ext>[=<extparam>] compare extensions (! indicates criticality)\n"));
fprintf( stderr, _(" !dontUseCopy (Don't Use Copy)\n")); fprintf( stderr, _(" !dontUseCopy (Don't Use Copy)\n"));
fprintf( stderr, _(" -M enable Manage DSA IT control (-MM to make critical)\n"));
fprintf( stderr, _(" -P version protocol version (default: 3)\n"));
fprintf( stderr, _(" -z Quiet mode," fprintf( stderr, _(" -z Quiet mode,"
" don't print anything, use return values\n")); " don't print anything, use return values\n"));
tool_common_usage(); tool_common_usage();
...@@ -102,7 +104,7 @@ static int docompare LDAP_P(( ...@@ -102,7 +104,7 @@ static int docompare LDAP_P((
const char options[] = "z" const char options[] = "z"
"Cd:D:e:h:H:IMnO:o:p:P:QR:U:vVw:WxX:y:Y:Z"; "Cd:D:e:h:H:IMnNO:o:p:P:QR:U:vVw:WxX:y:Y:Z";
#ifdef LDAP_CONTROL_DONTUSECOPY #ifdef LDAP_CONTROL_DONTUSECOPY
int dontUseCopy = 0; int dontUseCopy = 0;
...@@ -228,16 +230,6 @@ main( int argc, char **argv ) ...@@ -228,16 +230,6 @@ main( int argc, char **argv )
ld = tool_conn_setup( 0, 0 ); ld = tool_conn_setup( 0, 0 );
if ( pw_file || want_bindpw ) {
if ( pw_file ) {
rc = lutil_get_filed_password( pw_file, &passwd );
if( rc ) return EXIT_FAILURE;
} else {
passwd.bv_val = getpassphrase( _("Enter LDAP Password: ") );
passwd.bv_len = passwd.bv_val ? strlen( passwd.bv_val ) : 0;
}
}
tool_bind( ld ); tool_bind( ld );
if ( 0 if ( 0
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/* $OpenLDAP$ */ /* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>. /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
* *
* Copyright 1998-2008 The OpenLDAP Foundation. * Copyright 1998-2010 The OpenLDAP Foundation.
* Portions Copyright 1998-2003 Kurt D. Zeilenga. * Portions Copyright 1998-2003 Kurt D. Zeilenga.
* All rights reserved. * All rights reserved.
* *
...@@ -71,6 +71,10 @@ usage( void ) ...@@ -71,6 +71,10 @@ usage( void )
fprintf( stderr, _(" dn: list of DNs to delete. If not given, it will be readed from stdin\n")); fprintf( stderr, _(" dn: list of DNs to delete. If not given, it will be readed from stdin\n"));
fprintf( stderr, _(" or from the file specified with \"-f file\".\n")); fprintf( stderr, _(" or from the file specified with \"-f file\".\n"));
fprintf( stderr, _("Delete Options:\n")); fprintf( stderr, _("Delete Options:\n"));
fprintf( stderr, _(" -c continuous operation mode (do not stop on errors)\n"));
fprintf( stderr, _(" -f file read operations from `file'\n"));
fprintf( stderr, _(" -M enable Manage DSA IT control (-MM to make critical)\n"));
fprintf( stderr, _(" -P version protocol version (default: 3)\n"));
fprintf( stderr, _(" -r delete recursively\n")); fprintf( stderr, _(" -r delete recursively\n"));
tool_common_usage(); tool_common_usage();
exit( EXIT_FAILURE ); exit( EXIT_FAILURE );
...@@ -78,7 +82,7 @@ usage( void ) ...@@ -78,7 +82,7 @@ usage( void )
const char options[] = "r" const char options[] = "r"
"cd:D:e:f:h:H:IMnO:o:p:P:QR:U:vVw:WxX:y:Y:z:Z"; "cd:D:e:f:h:H:IMnNO:o:p:P:QR:U:vVw:WxX:y:Y:z:Z";
int int
handle_private_option( int i ) handle_private_option( int i )
...@@ -162,12 +166,10 @@ int ...@@ -162,12 +166,10 @@ int
main( int argc, char **argv ) main( int argc, char **argv )
{ {
char buf[ 4096 ]; char buf[ 4096 ];
FILE *fp; FILE *fp = NULL;
LDAP *ld; LDAP *ld;
int rc, retval; int rc, retval;
fp = NULL;
tool_init( TOOL_DELETE ); tool_init( TOOL_DELETE );
prog = lutil_progname( "ldapdelete", argc, argv ); prog = lutil_progname( "ldapdelete", argc, argv );
...@@ -179,23 +181,13 @@ main( int argc, char **argv ) ...@@ -179,23 +181,13 @@ main( int argc, char **argv )
exit( EXIT_FAILURE ); exit( EXIT_FAILURE );
} }
} else { } else {
if ( optind >= argc ) { if ( optind >= argc ) {
fp = stdin; fp = stdin;
}
} }
}
ld = tool_conn_setup( 0, &private_conn_setup ); ld = tool_conn_setup( 0, &private_conn_setup );
if ( pw_file || want_bindpw ) {
if ( pw_file ) {
rc = lutil_get_filed_password( pw_file, &passwd );
if( rc ) return EXIT_FAILURE;
} else {
passwd.bv_val = getpassphrase( _("Enter LDAP Password: ") );
passwd.bv_len = passwd.bv_val ? strlen( passwd.bv_val ) : 0;
}
}
tool_bind( ld ); tool_bind( ld );
tool_server_controls( ld, NULL, 0 ); tool_server_controls( ld, NULL, 0 );
...@@ -222,6 +214,8 @@ main( int argc, char **argv ) ...@@ -222,6 +214,8 @@ main( int argc, char **argv )
retval = rc; retval = rc;
} }
} }
if ( fp != stdin )
fclose( fp );
} }
tool_unbind( ld ); tool_unbind( ld );
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/* $OpenLDAP$ */ /* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>. /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
* *
* Copyright 2005-2008 The OpenLDAP Foundation. * Copyright 2005-2010 The OpenLDAP Foundation.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
...@@ -43,13 +43,16 @@ usage( void ) ...@@ -43,13 +43,16 @@ usage( void )
{ {
fprintf( stderr, _("Issue LDAP extended operations\n\n")); fprintf( stderr, _("Issue LDAP extended operations\n\n"));
fprintf( stderr, _("usage: %s [options] <oid|oid:data|oid::b64data>\n"), prog); fprintf( stderr, _("usage: %s [options] <oid|oid:data|oid::b64data>\n"), prog);
fprintf( stderr, _(" %s [options] whoami\n"), prog);
fprintf( stderr, _(" %s [options] cancel <id>\n"), prog);
fprintf( stderr, _(" %s [options] refresh <DN> [<ttl>]\n"), prog);
tool_common_usage(); tool_common_usage();
exit( EXIT_FAILURE ); exit( EXIT_FAILURE );
} }
const char options[] = "" const char options[] = ""
"d:D:e:h:H:InO:o:p:QR:U:vVw:WxX:y:Y:Z"; "d:D:e:h:H:InNO:o:p:QR:U:vVw:WxX:y:Y:Z";
int int
handle_private_option( int i ) handle_private_option( int i )
...@@ -86,16 +89,6 @@ main( int argc, char *argv[] ) ...@@ -86,16 +89,6 @@ main( int argc, char *argv[] )
usage(); usage();
} }
if ( pw_file || want_bindpw ) {
if ( pw_file ) {
rc = lutil_get_filed_password( pw_file, &passwd );
if( rc ) return EXIT_FAILURE;
} else {
passwd.bv_val = getpassphrase( _("Enter LDAP Password: ") );
passwd.bv_len = passwd.bv_val ? strlen( passwd.bv_val ) : 0;
}
}
ld = tool_conn_setup( 0, 0 ); ld = tool_conn_setup( 0, 0 );
tool_bind( ld ); tool_bind( ld );
...@@ -152,8 +145,6 @@ main( int argc, char *argv[] ) ...@@ -152,8 +145,6 @@ main( int argc, char *argv[] )
case 2: case 2:
dn.bv_val = argv[ 1 ]; dn.bv_val = argv[ 1 ];
dn.bv_len = strlen( dn.bv_val ); dn.bv_len = strlen( dn.bv_val );
case 1:
break; break;
default: default:
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/* $OpenLDAP$ */ /* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>. /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
* *
* Copyright 1998-2008 The OpenLDAP Foundation. * Copyright 1998-2010 The OpenLDAP Foundation.
* Portions Copyright 2006 Howard Chu. * Portions Copyright 2006 Howard Chu.
* Portions Copyright 1998-2003 Kurt D. Zeilenga. * Portions Copyright 1998-2003 Kurt D. Zeilenga.
* Portions Copyright 1998-2001 Net Boolean Incorporated. * Portions Copyright 1998-2001 Net Boolean Incorporated.
...@@ -95,8 +95,8 @@ static struct berval BV_NEWRDN = BER_BVC("newrdn"); ...@@ -95,8 +95,8 @@ static struct berval BV_NEWRDN = BER_BVC("newrdn");
static struct berval BV_DELETEOLDRDN = BER_BVC("deleteoldrdn"); static struct berval BV_DELETEOLDRDN = BER_BVC("deleteoldrdn");
static struct berval BV_NEWSUP = BER_BVC("newsuperior"); static struct berval BV_NEWSUP = BER_BVC("newsuperior");
#define BVICMP(a,b) ((a)->bv_len != (b)->bv_len ? \ #define BV_CASEMATCH(a, b) \
(a)->bv_len - (b)->bv_len : strcasecmp((a)->bv_val, (b)->bv_val)) ((a)->bv_len == (b)->bv_len && 0 == strcasecmp((a)->bv_val, (b)->bv_val))
static int process_ldif_rec LDAP_P(( char *rbuf, int lineno )); static int process_ldif_rec LDAP_P(( char *rbuf, int lineno ));
static int parse_ldif_control LDAP_P(( struct berval *val, LDAPControl ***pctrls )); static int parse_ldif_control LDAP_P(( struct berval *val, LDAPControl ***pctrls ));
...@@ -137,8 +137,12 @@ usage( void ) ...@@ -137,8 +137,12 @@ usage( void )
fprintf( stderr, _("Add or modify options:\n")); fprintf( stderr, _("Add or modify options:\n"));
fprintf( stderr, _(" -a add values (%s)\n"), fprintf( stderr, _(" -a add values (%s)\n"),
(ldapadd ? _("default") : _("default is to replace"))); (ldapadd ? _("default") : _("default is to replace")));
fprintf( stderr, _(" -c continuous operation mode (do not stop on errors)\n"));
fprintf( stderr, _(" -E [!]ext=extparam modify extensions" fprintf( stderr, _(" -E [!]ext=extparam modify extensions"
" (! indicate s criticality)\n")); " (! indicate s criticality)\n"));
fprintf( stderr, _(" -f file read operations from `file'\n"));
fprintf( stderr, _(" -M enable Manage DSA IT control (-MM to make critical)\n"));
fprintf( stderr, _(" -P version protocol version (default: 3)\n"));
#ifdef LDAP_X_TXN #ifdef LDAP_X_TXN
fprintf( stderr, fprintf( stderr,
_(" [!]txn=<commit|abort> (transaction)\n")); _(" [!]txn=<commit|abort> (transaction)\n"));
...@@ -151,7 +155,7 @@ usage( void ) ...@@ -151,7 +155,7 @@ usage( void )
const char options[] = "aE:rS:" const char options[] = "aE:rS:"
"cd:D:e:f:h:H:IMnO:o:p:P:QR:U:vVw:WxX:y:Y:Z"; "cd:D:e:f:h:H:IMnNO:o:p:P:QR:U:vVw:WxX:y:Y:Z";
int int
handle_private_option( int i ) handle_private_option( int i )
...@@ -240,7 +244,7 @@ main( int argc, char **argv ) ...@@ -240,7 +244,7 @@ main( int argc, char **argv )
FILE *rejfp; FILE *rejfp;
struct LDIFFP *ldiffp, ldifdummy = {0}; struct LDIFFP *ldiffp, ldifdummy = {0};
char *matched_msg, *error_msg; char *matched_msg, *error_msg;
int rc, retval; int rc, retval, ldifrc;
int len; int len;
int i = 0; int i = 0;
int lineno, nextline = 0, lmax = 0; int lineno, nextline = 0, lmax = 0;
...@@ -281,15 +285,6 @@ main( int argc, char **argv ) ...@@ -281,15 +285,6 @@ main( int argc, char **argv )
ld = tool_conn_setup( dont, 0 ); ld = tool_conn_setup( dont, 0 );
if ( !dont ) { if ( !dont ) {
if ( pw_file || want_bindpw ) {
if ( pw_file ) {
rc = lutil_get_filed_password( pw_file, &passwd );
if( rc ) return EXIT_FAILURE;
} else {
passwd.bv_val = getpassphrase( _("Enter LDAP Password: ") );
passwd.bv_len = passwd.bv_val ? strlen( passwd.bv_val ) : 0;
}
}
tool_bind( ld ); tool_bind( ld );
} }
...@@ -326,8 +321,8 @@ main( int argc, char **argv ) ...@@ -326,8 +321,8 @@ main( int argc, char **argv )
rc = 0; rc = 0;
retval = 0; retval = 0;
lineno = 1; lineno = 1;
while (( rc == 0 || contoper ) && ldif_read_record( ldiffp, &nextline, while (( rc == 0 || contoper ) && ( ldifrc = ldif_read_record( ldiffp, &nextline,
&rbuf, &lmax )) &rbuf, &lmax )) > 0 )
{ {
if ( rejfp ) { if ( rejfp ) {
len = strlen( rbuf ); len = strlen( rbuf );
...@@ -369,6 +364,9 @@ main( int argc, char **argv ) ...@@ -369,6 +364,9 @@ main( int argc, char **argv )
} }
ber_memfree( rbuf ); ber_memfree( rbuf );
if ( ldifrc < 0 )
retval = LDAP_OTHER;
#ifdef LDAP_X_TXN #ifdef LDAP_X_TXN
if( retval == 0 && txn ) { if( retval == 0 && txn ) {
rc = ldap_set_option( ld, LDAP_OPT_SERVER_CONTROLS, NULL ); rc = ldap_set_option( ld, LDAP_OPT_SERVER_CONTROLS, NULL );
...@@ -457,7 +455,7 @@ process_ldif_rec( char *rbuf, int linenum ) ...@@ -457,7 +455,7 @@ process_ldif_rec( char *rbuf, int linenum )
freeval[i] = freev; freeval[i] = freev;
if ( dn == NULL ) { if ( dn == NULL ) {
if ( linenum+i == 1 && !BVICMP( btype+i, &BV_VERSION )) { if ( linenum+i == 1 && BV_CASEMATCH( btype+i, &BV_VERSION )) {
int v; int v;
if( vals[i].bv_len == 0 || lutil_atoi( &v, vals[i].bv_val) != 0 || v != 1 ) { if( vals[i].bv_len == 0 || lutil_atoi( &v, vals[i].bv_val) != 0 || v != 1 ) {
fprintf( stderr, fprintf( stderr,
...@@ -466,7 +464,7 @@ process_ldif_rec( char *rbuf, int linenum ) ...@@ -466,7 +464,7 @@ process_ldif_rec( char *rbuf, int linenum )
} }
version++; version++;
} else if ( !BVICMP( btype+i, &BV_DN )) { } else if ( BV_CASEMATCH( btype+i, &BV_DN )) {
dn = vals[i].bv_val; dn = vals[i].bv_val;
idn = i; idn = i;
} }
...@@ -494,7 +492,7 @@ process_ldif_rec( char *rbuf, int linenum ) ...@@ -494,7 +492,7 @@ process_ldif_rec( char *rbuf, int linenum )
i = idn+1; i = idn+1;
/* Check for "control" tag after dn and before changetype. */ /* Check for "control" tag after dn and before changetype. */
if (!BVICMP( btype+i, &BV_CONTROL)) { if ( BV_CASEMATCH( btype+i, &BV_CONTROL )) {
/* Parse and add it to the list of controls */ /* Parse and add it to the list of controls */
rc = parse_ldif_control( vals+i, &pctrls ); rc = parse_ldif_control( vals+i, &pctrls );
if (rc != 0) { if (rc != 0) {
...@@ -515,7 +513,7 @@ short_input: ...@@ -515,7 +513,7 @@ short_input:
} }
/* Check for changetype */ /* Check for changetype */
if ( !BVICMP( btype+i, &BV_CHANGETYPE )) { if ( BV_CASEMATCH( btype+i, &BV_CHANGETYPE )) {
#ifdef LIBERAL_CHANGETYPE_MODOP #ifdef LIBERAL_CHANGETYPE_MODOP
/* trim trailing spaces (and log warning ...) */ /* trim trailing spaces (and log warning ...) */
int icnt; int icnt;
...@@ -533,20 +531,20 @@ short_input: ...@@ -533,20 +531,20 @@ short_input:
} }
#endif /* LIBERAL_CHANGETYPE_MODOP */ #endif /* LIBERAL_CHANGETYPE_MODOP */
if ( BVICMP( vals+i, &BV_MODIFYCT ) == 0 ) { if ( BV_CASEMATCH( vals+i, &BV_MODIFYCT )) {
new_entry = 0; new_entry = 0;
expect_modop = 1; expect_modop = 1;
} else if ( BVICMP( vals+i, &BV_ADDCT ) == 0 ) { } else if ( BV_CASEMATCH( vals+i, &BV_ADDCT )) {
new_entry = 1; new_entry = 1;
modop = LDAP_MOD_ADD; modop = LDAP_MOD_ADD;
} else if ( BVICMP( vals+i, &BV_MODRDNCT ) == 0 } else if ( BV_CASEMATCH( vals+i, &BV_MODRDNCT )
|| BVICMP( vals+i, &BV_MODDNCT ) == 0 || BV_CASEMATCH( vals+i, &BV_MODDNCT )
|| BVICMP( vals+i, &BV_RENAMECT ) == 0) || BV_CASEMATCH( vals+i, &BV_RENAMECT ))
{ {
i++; i++;
if ( i >= lines ) if ( i >= lines )
goto short_input; goto short_input;
if ( BVICMP( btype+i, &BV_NEWRDN )) { if ( !BV_CASEMATCH( btype+i, &BV_NEWRDN )) {
fprintf( stderr, _("%s: expecting \"%s:\" but saw" fprintf( stderr, _("%s: expecting \"%s:\" but saw"
" \"%s:\" (line %d, entry \"%s\")\n"), " \"%s:\" (line %d, entry \"%s\")\n"),
prog, BV_NEWRDN.bv_val, btype[i].bv_val, linenum+i, dn ); prog, BV_NEWRDN.bv_val, btype[i].bv_val, linenum+i, dn );
...@@ -557,7 +555,7 @@ short_input: ...@@ -557,7 +555,7 @@ short_input:
i++; i++;
if ( i >= lines ) if ( i >= lines )
goto short_input; goto short_input;
if ( BVICMP( btype+i, &BV_DELETEOLDRDN )) { if ( !BV_CASEMATCH( btype+i, &BV_DELETEOLDRDN )) {
fprintf( stderr, _("%s: expecting \"%s:\" but saw" fprintf( stderr, _("%s: expecting \"%s:\" but saw"
" \"%s:\" (line %d, entry \"%s\")\n"), " \"%s:\" (line %d, entry \"%s\")\n"),
prog, BV_DELETEOLDRDN.bv_val, btype[i].bv_val, linenum+i, dn ); prog, BV_DELETEOLDRDN.bv_val, btype[i].bv_val, linenum+i, dn );
...@@ -567,7 +565,7 @@ short_input: ...@@ -567,7 +565,7 @@ short_input:
deleteoldrdn = ( vals[i].bv_val[0] == '0' ) ? 0 : 1; deleteoldrdn = ( vals[i].bv_val[0] == '0' ) ? 0 : 1;
i++; i++;
if ( i < lines ) { if ( i < lines ) {
if ( BVICMP( btype+i, &BV_NEWSUP )) { if ( !BV_CASEMATCH( btype+i, &BV_NEWSUP )) {
fprintf( stderr, _("%s: expecting \"%s:\" but saw" fprintf( stderr, _("%s: expecting \"%s:\" but saw"
" \"%s:\" (line %d, entry \"%s\")\n"), " \"%s:\" (line %d, entry \"%s\")\n"),
prog, BV_NEWSUP.bv_val, btype[i].bv_val, linenum+i, dn ); prog, BV_NEWSUP.bv_val, btype[i].bv_val, linenum+i, dn );
...@@ -578,7 +576,7 @@ short_input: ...@@ -578,7 +576,7 @@ short_input:
i++; i++;
} }
got_all = 1; got_all = 1;
} else if ( BVICMP( vals+i, &BV_DELETECT ) == 0 ) { } else if ( BV_CASEMATCH( vals+i, &BV_DELETECT )) {
got_all = delete_entry = 1; got_all = delete_entry = 1;
} else { } else {
fprintf( stderr, fprintf( stderr,
...@@ -615,7 +613,7 @@ short_input: ...@@ -615,7 +613,7 @@ short_input:
/* Make sure all attributes with multiple values are contiguous */ /* Make sure all attributes with multiple values are contiguous */
for (; i<lines; i++) { for (; i<lines; i++) {
for (j=i+1; j<lines; j++) { for (j=i+1; j<lines; j++) {
if ( !BVICMP( btype+i, btype+j )) { if ( BV_CASEMATCH( btype+i, btype+j )) {
nmods--; nmods--;
/* out of order, move intervening attributes down */ /* out of order, move intervening attributes down */
if ( j != i+1 ) { if ( j != i+1 ) {
...@@ -649,13 +647,13 @@ short_input: ...@@ -649,13 +647,13 @@ short_input:
k = -1; k = -1;
BER_BVZERO(&bv); BER_BVZERO(&bv);
for (i=idn; i<lines; i++) { for (i=idn; i<lines; i++) {
if ( !BVICMP( btype+i, &BV_DN )) { if ( BV_CASEMATCH( btype+i, &BV_DN )) {
fprintf( stderr, _("%s: attributeDescription \"%s\":" fprintf( stderr, _("%s: attributeDescription \"%s\":"
" (possible missing newline" " (possible missing newline"
" after line %d, entry \"%s\"?)\n"), " after line %d, entry \"%s\"?)\n"),
prog, btype[i].bv_val, linenum+i - 1, dn ); prog, btype[i].bv_val, linenum+i - 1, dn );
} }
if ( BVICMP(btype+i,&bv)) { if ( !BV_CASEMATCH( btype+i, &bv )) {
bvl[k++] = NULL; bvl[k++] = NULL;
bv = btype[i]; bv = btype[i];
lm[j].mod_op = LDAP_MOD_ADD | LDAP_MOD_BVALUES; lm[j].mod_op = LDAP_MOD_ADD | LDAP_MOD_BVALUES;
...@@ -694,11 +692,11 @@ short_input: ...@@ -694,11 +692,11 @@ short_input:
expect_modop = 0; expect_modop = 0;
expect_sep = 1; expect_sep = 1;
if ( BVICMP( btype+i, &BV_MODOPADD ) == 0 ) { if ( BV_CASEMATCH( btype+i, &BV_MODOPADD )) {
modop = LDAP_MOD_ADD; modop = LDAP_MOD_ADD;
mops[i] = M_SEP; mops[i] = M_SEP;
nmods--; nmods--;
} else if ( BVICMP( btype+i, &BV_MODOPREPLACE ) == 0 ) { } else if ( BV_CASEMATCH( btype+i, &BV_MODOPREPLACE )) {
/* defer handling these since they might have no values. /* defer handling these since they might have no values.
* Use the BVALUES flag to signal that these were * Use the BVALUES flag to signal that these were
* deferred. If values are provided later, this * deferred. If values are provided later, this
...@@ -707,11 +705,11 @@ short_input: ...@@ -707,11 +705,11 @@ short_input:
modop = LDAP_MOD_REPLACE; modop = LDAP_MOD_REPLACE;
mops[i] = modop | LDAP_MOD_BVALUES; mops[i] = modop | LDAP_MOD_BVALUES;
btype[i] = vals[i]; btype[i] = vals[i];
} else if ( BVICMP( btype+i, &BV_MODOPDELETE ) == 0 ) { } else if ( BV_CASEMATCH( btype+i, &BV_MODOPDELETE )) {
modop = LDAP_MOD_DELETE; modop = LDAP_MOD_DELETE;
mops[i] = modop | LDAP_MOD_BVALUES; mops[i] = modop | LDAP_MOD_BVALUES;
btype[i] = vals[i]; btype[i] = vals[i];
} else if ( BVICMP( btype+i, &BV_MODOPINCREMENT ) == 0 ) { } else if ( BV_CASEMATCH( btype+i, &BV_MODOPINCREMENT )) {
modop = LDAP_MOD_INCREMENT; modop = LDAP_MOD_INCREMENT;
mops[i] = M_SEP; mops[i] = M_SEP;
nmods--; nmods--;
...@@ -729,7 +727,7 @@ short_input: ...@@ -729,7 +727,7 @@ short_input:
expect_modop = 1; expect_modop = 1;
nmods--; nmods--;
} else { } else {
if ( BVICMP( btype+i, &bv )) { if ( !BV_CASEMATCH( btype+i, &bv )) {
fprintf( stderr, _("%s: wrong attributeType at" fprintf( stderr, _("%s: wrong attributeType at"
" line %d, entry \"%s\"\n"), " line %d, entry \"%s\"\n"),
prog, linenum+i, dn ); prog, linenum+i, dn );
...@@ -740,8 +738,9 @@ short_input: ...@@ -740,8 +738,9 @@ short_input:
/* If prev op was deferred and matches this type, /* If prev op was deferred and matches this type,
* clear the flag * clear the flag
*/ */
if ( (mops[i-1]&LDAP_MOD_BVALUES) && !BVICMP(btype+i, if ( (mops[i-1] & LDAP_MOD_BVALUES)
btype+i-1)) { && BV_CASEMATCH( btype+i, btype+i-1 ))
{
mops[i-1] = M_SEP; mops[i-1] = M_SEP;
nmods--; nmods--;
} }
...@@ -756,7 +755,7 @@ short_input: ...@@ -756,7 +755,7 @@ short_input:
for (j=i+1; j<lines; j++) { for (j=i+1; j<lines; j++) {
if ( mops[j] == M_SEP || mops[i] != mops[j] ) if ( mops[j] == M_SEP || mops[i] != mops[j] )
continue; continue;
if ( !BVICMP( btype+i, btype+j )) { if ( BV_CASEMATCH( btype+i, btype+j )) {
nmods--; nmods--;
/* out of order, move intervening attributes down */ /* out of order, move intervening attributes down */
if ( j != i+1 ) { if ( j != i+1 ) {
...@@ -802,7 +801,7 @@ short_input: ...@@ -802,7 +801,7 @@ short_input:
for (i=idn; i<lines; i++) { for (i=idn; i<lines; i++) {
if ( mops[i] == M_SEP ) if ( mops[i] == M_SEP )
continue; continue;
if ( mops[i] != mops[i-1] || BVICMP(btype+i,&bv)) { if ( mops[i] != mops[i-1] || !BV_CASEMATCH( btype+i, &bv )) {
bvl[k++] = NULL; bvl[k++] = NULL;
bv = btype[i]; bv = btype[i];
lm[j].mod_op = mops[i] | LDAP_MOD_BVALUES; lm[j].mod_op = mops[i] | LDAP_MOD_BVALUES;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/* $OpenLDAP$ */ /* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>. /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
* *
* Copyright 1998-2008 The OpenLDAP Foundation. * Copyright 1998-2010 The OpenLDAP Foundation.
* Portions Copyright 1998-2003 Kurt D. Zeilenga. * Portions Copyright 1998-2003 Kurt D. Zeilenga.
* Portions Copyright 1998-2001 Net Boolean Incorporated. * Portions Copyright 1998-2001 Net Boolean Incorporated.
* Portions Copyright 2001-2003 IBM Corporation. * Portions Copyright 2001-2003 IBM Corporation.
...@@ -38,8 +38,8 @@ ...@@ -38,8 +38,8 @@
* This work was originally developed by the University of Michigan * This work was originally developed by the University of Michigan
* (as part of U-MICH LDAP). Additional significant contributors * (as part of U-MICH LDAP). Additional significant contributors
* include: * include:
* Kurt D. Zeilenga * Kurt D. Zeilenga
* Juan C Gomez * Juan C Gomez
*/ */
...@@ -68,11 +68,11 @@ static int remove_old_RDN = 0; ...@@ -68,11 +68,11 @@ static int remove_old_RDN = 0;
static int domodrdn( static int domodrdn(
LDAP *ld, LDAP *ld,
char *dn, char *dn,
char *rdn, char *rdn,
char *newSuperior, char *newSuperior,
int remove ); /* flag: remove old RDN */ int remove ); /* flag: remove old RDN */
void void
usage( void ) usage( void )
...@@ -83,7 +83,11 @@ usage( void ) ...@@ -83,7 +83,11 @@ usage( void )
fprintf( stderr, _(" If not given, the list of modifications is read from stdin or\n")); fprintf( stderr, _(" If not given, the list of modifications is read from stdin or\n"));
fprintf( stderr, _(" from the file specified by \"-f file\" (see man page).\n")); fprintf( stderr, _(" from the file specified by \"-f file\" (see man page).\n"));
fprintf( stderr, _("Rename options:\n")); fprintf( stderr, _("Rename options:\n"));
fprintf( stderr, _(" -r remove old RDN\n")); fprintf( stderr, _(" -c continuous operation mode (do not stop on errors)\n"));
fprintf( stderr, _(" -f file read operations from `file'\n"));
fprintf( stderr, _(" -M enable Manage DSA IT control (-MM to make critical)\n"));
fprintf( stderr, _(" -P version protocol version (default: 3)\n"));
fprintf( stderr, _(" -r remove old RDN\n"));
fprintf( stderr, _(" -s newsup new superior entry\n")); fprintf( stderr, _(" -s newsup new superior entry\n"));
tool_common_usage(); tool_common_usage();
exit( EXIT_FAILURE ); exit( EXIT_FAILURE );
...@@ -91,7 +95,7 @@ usage( void ) ...@@ -91,7 +95,7 @@ usage( void )
const char options[] = "rs:" const char options[] = "rs:"
"cd:D:e:f:h:H:IMnO:o:p:P:QR:U:vVw:WxX:y:Y:Z"; "cd:D:e:f:h:H:IMnNO:o:p:P:QR:U:vVw:WxX:y:Y:Z";
int int
handle_private_option( int i ) handle_private_option( int i )
...@@ -127,8 +131,8 @@ handle_private_option( int i ) ...@@ -127,8 +131,8 @@ handle_private_option( int i )
#endif #endif
case 'r': /* remove old RDN */ case 'r': /* remove old RDN */
remove_old_RDN++; remove_old_RDN++;
break; break;
case 's': /* newSuperior */ case 's': /* newSuperior */
if( protocol == LDAP_VERSION2 ) { if( protocol == LDAP_VERSION2 ) {
...@@ -136,9 +140,9 @@ handle_private_option( int i ) ...@@ -136,9 +140,9 @@ handle_private_option( int i )
prog, protocol ); prog, protocol );
exit( EXIT_FAILURE ); exit( EXIT_FAILURE );
} }
newSuperior = strdup( optarg ); newSuperior = strdup( optarg );
protocol = LDAP_VERSION3; protocol = LDAP_VERSION3;
break; break;
default: default:
return 0; return 0;
...@@ -150,101 +154,101 @@ handle_private_option( int i ) ...@@ -150,101 +154,101 @@ handle_private_option( int i )
int int
main(int argc, char **argv) main(int argc, char **argv)
{ {
char *entrydn = NULL, *rdn = NULL, buf[ 4096 ]; char *entrydn = NULL, *rdn = NULL, buf[ 4096 ];
FILE *fp; FILE *fp = NULL;
LDAP *ld; LDAP *ld;
int rc, retval, havedn; int rc, retval, havedn;
tool_init( TOOL_MODRDN ); tool_init( TOOL_MODRDN );
prog = lutil_progname( "ldapmodrdn", argc, argv ); prog = lutil_progname( "ldapmodrdn", argc, argv );
tool_args( argc, argv ); tool_args( argc, argv );
havedn = 0; havedn = 0;
if (argc - optind == 2) { if (argc - optind == 2) {
if (( rdn = strdup( argv[argc - 1] )) == NULL ) { if (( rdn = strdup( argv[argc - 1] )) == NULL ) {
perror( "strdup" ); perror( "strdup" );
return( EXIT_FAILURE ); retval = EXIT_FAILURE;
} goto fail;
if (( entrydn = strdup( argv[argc - 2] )) == NULL ) { }
perror( "strdup" ); if (( entrydn = strdup( argv[argc - 2] )) == NULL ) {
return( EXIT_FAILURE ); perror( "strdup" );
} retval = EXIT_FAILURE;
++havedn; goto fail;
} else if ( argc - optind != 0 ) { }
fprintf( stderr, _("%s: invalid number of arguments (%d), only two allowed\n"), prog, argc-optind ); ++havedn;
usage(); } else if ( argc - optind != 0 ) {
} fprintf( stderr, _("%s: invalid number of arguments (%d), only two allowed\n"), prog, argc-optind );
usage();
if ( infile != NULL ) {
if (( fp = fopen( infile, "r" )) == NULL ) {
perror( infile );
return( EXIT_FAILURE );
} }
} else {
fp = stdin;
}
ld = tool_conn_setup( 0, 0 );
if ( pw_file || want_bindpw ) { if ( infile != NULL ) {
if ( pw_file ) { if (( fp = fopen( infile, "r" )) == NULL ) {
rc = lutil_get_filed_password( pw_file, &passwd ); perror( infile );
if( rc ) return EXIT_FAILURE; retval = EXIT_FAILURE;
} else { goto fail;
passwd.bv_val = getpassphrase( _("Enter LDAP Password: ") );
passwd.bv_len = passwd.bv_val ? strlen( passwd.bv_val ) : 0;
} }
} else {
fp = stdin;
} }
ld = tool_conn_setup( 0, 0 );
tool_bind( ld ); tool_bind( ld );
tool_server_controls( ld, NULL, 0 ); tool_server_controls( ld, NULL, 0 );
retval = rc = 0; retval = rc = 0;
if (havedn) if (havedn)
retval = domodrdn( ld, entrydn, rdn, newSuperior, remove_old_RDN ); retval = domodrdn( ld, entrydn, rdn, newSuperior, remove_old_RDN );
else while ((rc == 0 || contoper) && fgets(buf, sizeof(buf), fp) != NULL) { else while ((rc == 0 || contoper) && fgets(buf, sizeof(buf), fp) != NULL) {
if ( *buf != '\n' ) { /* blank lines optional, skip */ if ( *buf != '\n' ) { /* blank lines optional, skip */
buf[ strlen( buf ) - 1 ] = '\0'; /* remove nl */ buf[ strlen( buf ) - 1 ] = '\0'; /* remove nl */
if ( havedn ) { /* have DN, get RDN */ if ( havedn ) { /* have DN, get RDN */
if (( rdn = strdup( buf )) == NULL ) { if (( rdn = strdup( buf )) == NULL ) {
perror( "strdup" ); perror( "strdup" );
return( EXIT_FAILURE ); retval = EXIT_FAILURE;
goto fail;
}
rc = domodrdn(ld, entrydn, rdn, newSuperior, remove_old_RDN );
if ( rc != 0 )
retval = rc;
havedn = 0;
free( rdn ); rdn = NULL;
free( entrydn ); entrydn = NULL;
} else if ( !havedn ) { /* don't have DN yet */
if (( entrydn = strdup( buf )) == NULL ) {
retval = EXIT_FAILURE;
goto fail;
}
++havedn;
}
} }
rc = domodrdn(ld, entrydn, rdn, newSuperior, remove_old_RDN );
if ( rc != 0 )
retval = rc;
havedn = 0;
} else if ( !havedn ) { /* don't have DN yet */
if (( entrydn = strdup( buf )) == NULL ) {
perror( "strdup" );
return( EXIT_FAILURE );
}
++havedn;
}
} }
}
tool_unbind( ld ); tool_unbind( ld );
tool_destroy(); tool_destroy();
return( retval ); fail:
if ( fp && fp != stdin ) fclose( fp );
if ( entrydn ) free( entrydn );
if ( rdn ) free( rdn );
return( retval );
} }
static int domodrdn( static int domodrdn(
LDAP *ld, LDAP *ld,
char *dn, char *dn,
char *rdn, char *rdn,
char *newSuperior, char *newSuperior,
int remove ) /* flag: remove old RDN */ int remove ) /* flag: remove old RDN */
{ {
int rc, code, id; int rc, code, id;
char *matcheddn=NULL, *text=NULL, **refs=NULL; char *matcheddn=NULL, *text=NULL, **refs=NULL;
LDAPControl **ctrls = NULL; LDAPControl **ctrls = NULL;
LDAPMessage *res; LDAPMessage *res;
if ( verbose ) { if ( verbose ) {
printf( _("Renaming \"%s\"\n"), dn ); printf( _("Renaming \"%s\"\n"), dn );
printf( _("\tnew rdn=\"%s\" (%s old rdn)\n"), printf( _("\tnew rdn=\"%s\" (%s old rdn)\n"),
rdn, remove ? _("delete") : _("keep") ); rdn, remove ? _("delete") : _("keep") );
...@@ -318,7 +322,7 @@ static int domodrdn( ...@@ -318,7 +322,7 @@ static int domodrdn(
if (ctrls) { if (ctrls) {
tool_print_ctrls( ld, ctrls ); tool_print_ctrls( ld, ctrls );
ldap_controls_free( ctrls ); ldap_controls_free( ctrls );
} }
ber_memfree( text ); ber_memfree( text );
ber_memfree( matcheddn ); ber_memfree( matcheddn );
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/* $OpenLDAP$ */ /* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>. /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
* *
* Copyright 1998-2008 The OpenLDAP Foundation. * Copyright 1998-2010 The OpenLDAP Foundation.
* Portions Copyright 1998-2003 Kurt D. Zeilenga. * Portions Copyright 1998-2003 Kurt D. Zeilenga.
* Portions Copyright 1998-2001 Net Boolean Incorporated. * Portions Copyright 1998-2001 Net Boolean Incorporated.
* Portions Copyright 2001-2003 IBM Corporation. * Portions Copyright 2001-2003 IBM Corporation.
...@@ -81,7 +81,7 @@ usage( void ) ...@@ -81,7 +81,7 @@ usage( void )
const char options[] = "a:As:St:T:" const char options[] = "a:As:St:T:"
"d:D:e:h:H:InO:o:p:QR:U:vVw:WxX:y:Y:Z"; "d:D:e:h:H:InNO:o:p:QR:U:vVw:WxX:y:Y:Z";
int int
handle_private_option( int i ) handle_private_option( int i )
...@@ -245,18 +245,6 @@ main( int argc, char *argv[] ) ...@@ -245,18 +245,6 @@ main( int argc, char *argv[] )
newpw.bv_len = strlen( newpw.bv_val ); newpw.bv_len = strlen( newpw.bv_val );
} }
if ( pw_file ) {
rc = lutil_get_filed_password( pw_file, &passwd );
if( rc ) {
rc = EXIT_FAILURE;
goto done;
}
} else if ( want_bindpw ) {
passwd.bv_val = getpassphrase( _("Enter LDAP Password: ") );
passwd.bv_len = passwd.bv_val ? strlen( passwd.bv_val ) : 0;
}
ld = tool_conn_setup( 0, 0 ); ld = tool_conn_setup( 0, 0 );
tool_bind( ld ); tool_bind( ld );
...@@ -379,7 +367,7 @@ main( int argc, char *argv[] ) ...@@ -379,7 +367,7 @@ main( int argc, char *argv[] )
perror( "ber_scanf" ); perror( "ber_scanf" );
} else { } else {
printf(_("New password: %s\n"), s); printf(_("New password: %s\n"), s);
free( s ); ber_memfree( s );
} }
ber_free( ber, 1 ); ber_free( ber, 1 );
...@@ -389,7 +377,6 @@ main( int argc, char *argv[] ) ...@@ -389,7 +377,6 @@ main( int argc, char *argv[] )
" new password expected", NULL, NULL, NULL ); " new password expected", NULL, NULL, NULL );
} }
skip:
if( verbose || code != LDAP_SUCCESS || if( verbose || code != LDAP_SUCCESS ||
matcheddn || text || refs || ctrls ) matcheddn || text || refs || ctrls )
{ {
......