s4-ldb: convert existing ldb tools to use new command line hooks
authorAndrew Tridgell <tridge@samba.org>
Mon, 1 Nov 2010 07:45:25 +0000 (18:45 +1100)
committerAndrew Tridgell <tridge@samba.org>
Mon, 1 Nov 2010 07:55:20 +0000 (18:55 +1100)
the usage() function needs to take a ldb context, as the popt_options
is specific to the ldb context

Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>

source4/lib/ldb/tools/ldbadd.c
source4/lib/ldb/tools/ldbdel.c
source4/lib/ldb/tools/ldbedit.c
source4/lib/ldb/tools/ldbmodify.c
source4/lib/ldb/tools/ldbrename.c
source4/lib/ldb/tools/ldbsearch.c
source4/lib/ldb/tools/ldbtest.c
source4/lib/ldb/wscript

index 42470656fbb2fa2a5f1d01e81f3ffa140ce4c493..ab456f3d33c782ddd53d6177318ac514b1e6cd9f 100644 (file)
 static unsigned int failures;
 static struct ldb_cmdline *options;
 
-static void usage(void)
+static void usage(struct ldb_context *ldb)
 {
        printf("Usage: ldbadd <options> <ldif...>\n");
        printf("Adds records to a ldb, reading ldif the specified list of files\n\n");
-       ldb_cmdline_help("ldbadd", stdout);
+       ldb_cmdline_help(ldb, "ldbadd", stdout);
        exit(1);
 }
 
index 6994b3ddb681051835a3b290c8801566af50835a..6f7c8ae4a3eb28763c23c97c1607a5ec1ebe4b5a 100644 (file)
@@ -73,11 +73,11 @@ static int ldb_delete_recursive(struct ldb_context *ldb, struct ldb_dn *dn,struc
        return 0;
 }
 
-static void usage(void)
+static void usage(struct ldb_context *ldb)
 {
        printf("Usage: ldbdel <options> <DN...>\n");
        printf("Deletes records from a ldb\n\n");
-       ldb_cmdline_help("ldbdel", stdout);
+       ldb_cmdline_help(ldb, "ldbdel", stdout);
        exit(1);
 }
 
@@ -94,7 +94,7 @@ int main(int argc, const char **argv)
        options = ldb_cmdline_process(ldb, argc, argv, usage);
 
        if (options->argc < 1) {
-               usage();
+               usage(ldb);
                exit(1);
        }
 
index 4deeb30ee981df62764151a9a132733496b6189b..b311073b0529e1b4649f00dc4d340a375b3acf9e 100644 (file)
  *  Author: Andrew Tridgell
  */
 
-#ifdef _SAMBA_BUILD_
-#include "includes.h"
-#include <system/filesys.h>
-#else
 #include "ldb_includes.h"
-#endif
-
+#include "system/filesys.h"
 #include "ldb.h"
 #include "tools/cmdline.h"
 #include "tools/ldbutil.h"
@@ -287,10 +282,10 @@ static int do_edit(struct ldb_context *ldb, struct ldb_message **msgs1,
        return merge_edits(ldb, msgs1, count1, msgs2, count2);
 }
 
-static void usage(void)
+static void usage(struct ldb_context *ldb)
 {
        printf("Usage: ldbedit <options> <expression> <attributes ...>\n");
-       ldb_cmdline_help("ldbedit", stdout);
+       ldb_cmdline_help(ldb, "ldbedit", stdout);
        exit(1);
 }
 
index ecbdadfd65446bdb776d4990766076538a0c01ae..d5252dc206bd30540b12aa06ee8eab63a466b70e 100644 (file)
 static int failures;
 static struct ldb_cmdline *options;
 
-static void usage(void)
+static void usage(struct ldb_context *ldb)
 {
        printf("Usage: ldbmodify <options> <ldif...>\n");
        printf("Modifies a ldb based upon ldif change records\n\n");
-       ldb_cmdline_help("ldbmodify", stdout);
+       ldb_cmdline_help(ldb, "ldbmodify", stdout);
        exit(1);
 }
 
index e0f258ce858b4dde7466dfe07fc04322889e7a5c..7473a77fda114980f2dc711308f80ee884efbd4c 100644 (file)
 #include "ldb.h"
 #include "tools/cmdline.h"
 
-static void usage(void)
+static void usage(struct ldb_context *ldb)
 {
        printf("Usage: ldbrename [<options>] <olddn> <newdn>\n");
        printf("Renames records in a ldb\n\n");
-       ldb_cmdline_help("ldbmodify", stdout);
+       ldb_cmdline_help(ldb, "ldbmodify", stdout);
        exit(1);
 }
 
@@ -58,7 +58,7 @@ int main(int argc, const char **argv)
        options = ldb_cmdline_process(ldb, argc, argv, usage);
 
        if (options->argc < 2) {
-               usage();
+               usage(ldb);
        }
 
        dn1 = ldb_dn_new(ldb, ldb, options->argv[0]);
index 55144a7a8c96b7014e03dc4acc4973c3e9454346..458d7115ed3593b7673901c1d3b41afdb75eefa8 100644 (file)
  *  Author: Andrew Tridgell
  */
 
-#ifdef _SAMBA_BUILD_
-#include "includes.h"
-#include <ldb.h>
-#else
 #include "ldb_includes.h"
 #include "ldb.h"
-#endif
-
 #include "tools/cmdline.h"
 
-static void usage(void)
+static void usage(struct ldb_context *ldb)
 {
        printf("Usage: ldbsearch <options> <expression> <attrs...>\n");
-       ldb_cmdline_help("ldbsearch", stdout);
+       ldb_cmdline_help(ldb, "ldbsearch", stdout);
        exit(1);
 }
 
index 94dd2c696dcdaea5271162759682578db8d208bf..c8d35732f87820471ed7e506ba2cb2f51a2fbf9d 100644 (file)
  *  Author: Andrew Tridgell
  */
 
-#ifdef _SAMBA_BUILD_
-#include "includes.h"
-#else
 #include "ldb_includes.h"
-#endif
-
 #include "ldb.h"
 #include "tools/cmdline.h"
 
index ebd653c9af78282f80192848140b6dca56d60284..3204ba8e326012c07ca6f8609346d58249993e34 100644 (file)
@@ -37,8 +37,6 @@ def configure(conf):
     #
     conf.CONFIG_PATH('LDB_MODULESDIR', conf.SUBST_ENV_VAR('MODULESDIR') + '/ldb')
 
-    s4_build = getattr(conf.env, '_SAMBA_BUILD_', 0) == 4
-
     conf.env.standalone_ldb = conf.IN_LAUNCH_DIR()
 
     if not conf.env.standalone_ldb:
@@ -72,10 +70,6 @@ def build(bld):
     bld.RECURSE('lib/popt')
     bld.RECURSE('lib/replace')
 
-    # in Samba4 we build some extra modules, and add extra
-    # capabilities to the ldb cmdline tools
-    s4_build = getattr(bld.env, '_SAMBA_BUILD_', 0) == 4
-
     LDB_MAP_SRC = bld.SUBDIR('ldb_map',
                              'ldb_map.c ldb_map_inbound.c ldb_map_outbound.c')
 
@@ -84,23 +78,13 @@ def build(bld):
                             ldb_debug.c ldb_dn.c ldb_match.c ldb_options.c
                             ldb_attributes.c attrib_handlers.c ldb_controls.c qsort.c''')
 
-    if s4_build:
-        # this is only in the s4 build
-        bld.SAMBA_MODULE('ldb_ildap', 'ldb_ildap/ldb_ildap.c',
-                         init_function='ldb_ildap_init',
-                         module_init_name='ldb_init_module',
-                         deps='talloc cli-ldap CREDENTIALS auth_system_session',
-                         internal_module=False,
-                         subsystem='ldb')
-    else:
-        # this is not included in the s4 build
-        bld.SAMBA_MODULE('ldb_ldap', 'ldb_ldap/ldb_ldap.c',
-                         init_function='ldb_ldap_init',
-                         module_init_name='ldb_init_module',
-                         deps='talloc lber ldap ldb',
-                         enabled=bld.env.ENABLE_LDAP_BACKEND,
-                         internal_module=True,
-                         subsystem='ldb')
+    bld.SAMBA_MODULE('ldb_ldap', 'ldb_ldap/ldb_ldap.c',
+                     init_function='ldb_ldap_init',
+                     module_init_name='ldb_init_module',
+                     deps='talloc lber ldap ldb',
+                     enabled=bld.env.ENABLE_LDAP_BACKEND,
+                     internal_module=False,
+                     subsystem='ldb')
 
     # we're not currently linking against the ldap libs, but ldb.pc.in
     # has @LDAP_LIBS@
@@ -127,17 +111,8 @@ def build(bld):
             # the current modules, not the installed ones
             modules_dir = os.path.join(os.getcwd(), 'bin/modules/ldb')
 
-        if bld.env.standalone_ldb:
-            # do ABI checking on the standalone ldb
-            abi_file = 'ABI/ldb-%s.sigs' % VERSION
-            abi_match = '!ldb_*module_ops !ldb_*backend_ops ldb_*'
-            private_library = False
-            vnum = VERSION
-        else:
-            abi_file = None
-            abi_match = None
-            private_library = True
-            vnum = None
+        abi_file = 'ABI/ldb-%s.sigs' % VERSION
+        abi_match = '!ldb_*module_ops !ldb_*backend_ops ldb_*'
 
         bld.SAMBA_LIBRARY('ldb',
                           COMMON_SRC + ' ' + LDB_MAP_SRC,
@@ -146,10 +121,11 @@ def build(bld):
                           public_headers='include/ldb.h include/ldb_errors.h '\
                           'include/ldb_module.h include/ldb_handlers.h',
                           pc_files='ldb.pc',
-                          vnum=vnum, manpages='man/ldb.3',
+                          vnum=VERSION,
+                          manpages='man/ldb.3',
                           abi_file = abi_file,
-                          abi_match = abi_match,
-                          private_library=private_library)
+                          abi_match = abi_match)
+
 
         bld.SAMBA_PYTHON('pyldb', 'pyldb.c',
                          deps='ldb pyldb-util',
@@ -181,7 +157,6 @@ def build(bld):
                          'modules/paged_searches.c',
                          init_function='ldb_paged_searches_init',
                          module_init_name='ldb_init_module',
-                         enabled = s4_build,
                          deps='ldb',
                          subsystem='ldb')
 
@@ -231,15 +206,9 @@ def build(bld):
                             includes='include',
                             cflags='-DLDB_MODULESDIR=\"%s\" -DLDB_VERSION=\"%s\"' % (modules_dir, VERSION))
 
-    if s4_build:
-        extra_cmdline_deps = ' LDBSAMBA POPT_SAMBA POPT_CREDENTIALS ' \
-                'cmdline-credentials gensec'
-    else:
-        extra_cmdline_deps = ''
-
     bld.SAMBA_LIBRARY('ldb-cmdline',
                       source='tools/ldbutil.c tools/cmdline.c',
-                      deps='ldb dl popt' + extra_cmdline_deps,
+                      deps='ldb dl popt',
                       private_library=True)
 
     LDB_TOOLS='ldbadd ldbsearch ldbdel ldbmodify ldbedit ldbrename'