mirror of
https://github.com/samba-team/samba.git
synced 2025-08-02 00:22:11 +03:00
r7709: - convert ldb to use popt, so that it can interact with the samba
cmdline credentials code (which will be done soon)
- added a ldb_init() call, and changed ldb_connect() to take a ldb
context. This allows for much better error handling in
ldb_connect(), and also made the popt conversion easier
- fixed up all the existing backends with the new syntax
- improved error handling in *_connect()
- fixed a crash bug in the new case_fold_required() code
- ensured that ltdb_rename() and all ltdb_search() paths get the read lock
- added a ldb_oom() macro to make it easier to report out of memory
situations in ldb code
(This used to be commit f648fdf187
)
This commit is contained in:
committed by
Gerald (Jerry) Carter
parent
d4d6d0d2e5
commit
ed3d8091ce
@ -37,6 +37,7 @@
|
||||
#include "includes.h"
|
||||
#include "ldb/include/ldb.h"
|
||||
#include "ldb/include/ldb_private.h"
|
||||
#include "ldb/tools/cmdline.h"
|
||||
|
||||
#ifdef _SAMBA_BUILD_
|
||||
#include "system/filesys.h"
|
||||
@ -55,61 +56,38 @@ static void usage(void)
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char * const argv[])
|
||||
int main(int argc, const char **argv)
|
||||
{
|
||||
struct ldb_context *ldb;
|
||||
const char *ldb_url;
|
||||
const char **options = NULL;
|
||||
int ldbopts;
|
||||
int opt, ret;
|
||||
int ret;
|
||||
struct ldb_cmdline *options;
|
||||
const char *dn1, *dn2;
|
||||
|
||||
ldb_url = getenv("LDB_URL");
|
||||
ldb = ldb_init(NULL);
|
||||
|
||||
ldbopts = 0;
|
||||
while ((opt = getopt(argc, argv, "hH:o:")) != EOF) {
|
||||
switch (opt) {
|
||||
case 'H':
|
||||
ldb_url = optarg;
|
||||
break;
|
||||
options = ldb_cmdline_process(ldb, argc, argv, usage);
|
||||
|
||||
case 'o':
|
||||
options = ldb_options_parse(options, &ldbopts, optarg);
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
default:
|
||||
usage();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ldb_url) {
|
||||
fprintf(stderr, "You must specify a ldb URL\n\n");
|
||||
usage();
|
||||
}
|
||||
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
ldb = ldb_connect(ldb_url, 0, options);
|
||||
|
||||
if (!ldb) {
|
||||
perror("ldb_connect");
|
||||
ret = ldb_connect(ldb, options->url, 0, options->options);
|
||||
if (ret != 0) {
|
||||
fprintf(stderr, "Failed to connect to %s - %s\n",
|
||||
options->url, ldb_errstring(ldb));
|
||||
talloc_free(ldb);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ldb_set_debug_stderr(ldb);
|
||||
|
||||
if (argc < 2) {
|
||||
if (options->argc < 2) {
|
||||
usage();
|
||||
}
|
||||
|
||||
ret = ldb_rename(ldb, argv[0], argv[1]);
|
||||
dn1 = options->argv[0];
|
||||
dn2 = options->argv[1];
|
||||
|
||||
ret = ldb_rename(ldb, dn1, dn2);
|
||||
if (ret == 0) {
|
||||
printf("Renamed 1 record\n");
|
||||
} else {
|
||||
printf("rename of '%s' to '%s' failed - %s\n",
|
||||
argv[0], argv[1], ldb_errstring(ldb));
|
||||
dn1, dn2, ldb_errstring(ldb));
|
||||
}
|
||||
|
||||
talloc_free(ldb);
|
||||
|
Reference in New Issue
Block a user