1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-12 09:18:10 +03:00

s4-ldb: convert existing ldb tools to use new command line hooks

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>
This commit is contained in:
Andrew Tridgell 2010-11-01 18:45:25 +11:00
parent f924a022cb
commit 6f2c4abadd
8 changed files with 29 additions and 76 deletions

View File

@ -38,11 +38,11 @@
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);
}

View 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);
}

View File

@ -31,13 +31,8 @@
* 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);
}

View File

@ -38,11 +38,11 @@
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);
}

View File

@ -36,11 +36,11 @@
#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]);

View File

@ -31,20 +31,14 @@
* 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);
}

View File

@ -31,12 +31,7 @@
* Author: Andrew Tridgell
*/
#ifdef _SAMBA_BUILD_
#include "includes.h"
#else
#include "ldb_includes.h"
#endif
#include "ldb.h"
#include "tools/cmdline.h"

View 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'