summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorMatthias Dieter Wallnöfer <mdw@samba.org>2011-02-01 20:34:44 +0100
committerMatthias Dieter Wallnöfer <mdw@samba.org>2011-02-09 18:59:19 +0100
commit8d80225afb764e937e41e0d52586e1f038871734 (patch)
treec0b5baaec572fe09490f9b04bb5ce011d6f8475d /source4
parent5e06b21cc1553606efaeae03504e91d811793085 (diff)
downloadsamba-8d80225afb764e937e41e0d52586e1f038871734.tar.gz
samba-8d80225afb764e937e41e0d52586e1f038871734.tar.bz2
samba-8d80225afb764e937e41e0d52586e1f038871734.zip
ldb:tools - return LDB_ERR_OPERATIONS_ERROR on generic errors
Use "return" when located in "main" for consistency ("exit" would do the same). The patchset has been discussed with Jelmer Vernooij and afterwards LDB maintainer Simo Sorce.
Diffstat (limited to 'source4')
-rw-r--r--source4/lib/ldb/tools/cmdline.c2
-rw-r--r--source4/lib/ldb/tools/ldbadd.c4
-rw-r--r--source4/lib/ldb/tools/ldbdel.c8
-rw-r--r--source4/lib/ldb/tools/ldbedit.c8
-rw-r--r--source4/lib/ldb/tools/ldbmodify.c7
-rw-r--r--source4/lib/ldb/tools/ldbrename.c2
-rw-r--r--source4/lib/ldb/tools/ldbsearch.c4
-rw-r--r--source4/lib/ldb/tools/ldbtest.c4
8 files changed, 20 insertions, 19 deletions
diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c
index c5391cce8f..b2be54ebf9 100644
--- a/source4/lib/ldb/tools/cmdline.c
+++ b/source4/lib/ldb/tools/cmdline.c
@@ -313,7 +313,7 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb,
failed:
talloc_free(ret);
- exit(1);
+ exit(LDB_ERR_OPERATIONS_ERROR);
return NULL;
}
diff --git a/source4/lib/ldb/tools/ldbadd.c b/source4/lib/ldb/tools/ldbadd.c
index 184fba5dd7..a5285121c7 100644
--- a/source4/lib/ldb/tools/ldbadd.c
+++ b/source4/lib/ldb/tools/ldbadd.c
@@ -43,7 +43,7 @@ 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(ldb, "ldbadd", stdout);
- exit(1);
+ exit(LDB_ERR_OPERATIONS_ERROR);
}
@@ -127,7 +127,7 @@ int main(int argc, const char **argv)
f = fopen(fname, "r");
if (!f) {
perror(fname);
- exit(1);
+ return LDB_ERR_OPERATIONS_ERROR;
}
ret = process_file(ldb, f, &count);
fclose(f);
diff --git a/source4/lib/ldb/tools/ldbdel.c b/source4/lib/ldb/tools/ldbdel.c
index 274a41c6e9..d374fa96e3 100644
--- a/source4/lib/ldb/tools/ldbdel.c
+++ b/source4/lib/ldb/tools/ldbdel.c
@@ -78,7 +78,7 @@ static void usage(struct ldb_context *ldb)
printf("Usage: ldbdel <options> <DN...>\n");
printf("Deletes records from a ldb\n\n");
ldb_cmdline_help(ldb, "ldbdel", stdout);
- exit(1);
+ exit(LDB_ERR_OPERATIONS_ERROR);
}
int main(int argc, const char **argv)
@@ -98,13 +98,13 @@ int main(int argc, const char **argv)
if (options->argc < 1) {
usage(ldb);
- exit(1);
+ return LDB_ERR_OPERATIONS_ERROR;
}
req_ctrls = ldb_parse_control_strings(ldb, ldb, (const char **)options->controls);
if (options->controls != NULL && req_ctrls== NULL) {
printf("parsing controls failed: %s\n", ldb_errstring(ldb));
- return -1;
+ return LDB_ERR_OPERATIONS_ERROR;
}
for (i=0;i<options->argc;i++) {
@@ -113,7 +113,7 @@ int main(int argc, const char **argv)
dn = ldb_dn_new(ldb, ldb, options->argv[i]);
if ( ! ldb_dn_validate(dn)) {
printf("Invalid DN format\n");
- exit(1);
+ return LDB_ERR_OPERATIONS_ERROR;
}
if (options->recursive) {
ret = ldb_delete_recursive(ldb, dn,req_ctrls);
diff --git a/source4/lib/ldb/tools/ldbedit.c b/source4/lib/ldb/tools/ldbedit.c
index a046b17d5d..6509263a58 100644
--- a/source4/lib/ldb/tools/ldbedit.c
+++ b/source4/lib/ldb/tools/ldbedit.c
@@ -291,7 +291,7 @@ static void usage(struct ldb_context *ldb)
{
printf("Usage: ldbedit <options> <expression> <attributes ...>\n");
ldb_cmdline_help(ldb, "ldbedit", stdout);
- exit(1);
+ exit(LDB_ERR_OPERATIONS_ERROR);
}
int main(int argc, const char **argv)
@@ -328,20 +328,20 @@ int main(int argc, const char **argv)
basedn = ldb_dn_new(ldb, ldb, options->basedn);
if ( ! ldb_dn_validate(basedn)) {
printf("Invalid Base DN format\n");
- exit(1);
+ return LDB_ERR_OPERATIONS_ERROR;
}
}
req_ctrls = ldb_parse_control_strings(ldb, ldb, (const char **)options->controls);
if (options->controls != NULL && req_ctrls== NULL) {
printf("parsing controls failed: %s\n", ldb_errstring(ldb));
- return -1;
+ return LDB_ERR_OPERATIONS_ERROR;
}
ret = ldb_search_ctrl(ldb, ldb, &result, basedn, options->scope, attrs, req_ctrls, "%s", expression);
if (ret != LDB_SUCCESS) {
printf("search failed - %s\n", ldb_errstring(ldb));
- exit(1);
+ return ret;
}
if (result->count == 0) {
diff --git a/source4/lib/ldb/tools/ldbmodify.c b/source4/lib/ldb/tools/ldbmodify.c
index 8d5e04b81c..1484bbf655 100644
--- a/source4/lib/ldb/tools/ldbmodify.c
+++ b/source4/lib/ldb/tools/ldbmodify.c
@@ -43,7 +43,7 @@ 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(ldb, "ldbmodify", stdout);
- exit(1);
+ exit(LDB_ERR_OPERATIONS_ERROR);
}
/*
@@ -54,9 +54,10 @@ static int process_file(struct ldb_context *ldb, FILE *f, unsigned int *count)
struct ldb_ldif *ldif;
int ret = LDB_SUCCESS;
struct ldb_control **req_ctrls = ldb_parse_control_strings(ldb, ldb, (const char **)options->controls);
+
if (options->controls != NULL && req_ctrls== NULL) {
printf("parsing controls failed: %s\n", ldb_errstring(ldb));
- return -1;
+ exit(LDB_ERR_OPERATIONS_ERROR);
}
while ((ldif = ldb_ldif_read_file(ldb, f))) {
@@ -112,7 +113,7 @@ int main(int argc, const char **argv)
f = fopen(fname, "r");
if (!f) {
perror(fname);
- exit(1);
+ return LDB_ERR_OPERATIONS_ERROR;
}
ret = process_file(ldb, f, &count);
fclose(f);
diff --git a/source4/lib/ldb/tools/ldbrename.c b/source4/lib/ldb/tools/ldbrename.c
index 518358c9a3..0a539cc651 100644
--- a/source4/lib/ldb/tools/ldbrename.c
+++ b/source4/lib/ldb/tools/ldbrename.c
@@ -41,7 +41,7 @@ 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(ldb, "ldbmodify", stdout);
- exit(1);
+ exit(LDB_ERR_OPERATIONS_ERROR);
}
diff --git a/source4/lib/ldb/tools/ldbsearch.c b/source4/lib/ldb/tools/ldbsearch.c
index cd746749d0..398710c658 100644
--- a/source4/lib/ldb/tools/ldbsearch.c
+++ b/source4/lib/ldb/tools/ldbsearch.c
@@ -41,7 +41,7 @@ static void usage(struct ldb_context *ldb)
{
printf("Usage: ldbsearch <options> <expression> <attrs...>\n");
ldb_cmdline_help(ldb, "ldbsearch", stdout);
- exit(1);
+ exit(LDB_ERR_OPERATIONS_ERROR);
}
static int do_compare_msg(struct ldb_message **el1,
@@ -299,7 +299,7 @@ int main(int argc, const char **argv)
basedn = ldb_dn_new(ldb, ldb, options->basedn);
if ( ! ldb_dn_validate(basedn)) {
fprintf(stderr, "Invalid Base DN format\n");
- exit(1);
+ return LDB_ERR_OPERATIONS_ERROR;
}
}
diff --git a/source4/lib/ldb/tools/ldbtest.c b/source4/lib/ldb/tools/ldbtest.c
index 45d16bad4a..28c0674fdf 100644
--- a/source4/lib/ldb/tools/ldbtest.c
+++ b/source4/lib/ldb/tools/ldbtest.c
@@ -396,7 +396,7 @@ static void usage(struct ldb_context *ldb)
printf(" --num-searches nsearches number of searches to do\n");
printf("\n");
printf("tests ldb API\n\n");
- exit(1);
+ exit(LDB_ERR_OPERATIONS_ERROR);
}
int main(int argc, const char **argv)
@@ -430,5 +430,5 @@ int main(int argc, const char **argv)
talloc_free(mem_ctx);
- return 0;
+ return LDB_SUCCESS;
}