diff options
author | Michael Adam <obnox@samba.org> | 2014-01-30 10:29:49 +0100 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2014-01-30 16:57:06 +0100 |
commit | c3f93271ef447f9f16cd3002307c630c5f149f5a (patch) | |
tree | 56dcaeb51d4981fceb17141c7fa7dcfa41112b49 /source3 | |
parent | 6f748fef652bbea3c8dbbbfb96b95270e6f1dcfc (diff) | |
download | samba-c3f93271ef447f9f16cd3002307c630c5f149f5a.tar.gz |
dbwrap_tool: add option "--non-persistent" and force excatly one of "--[non-]persistent"
We want to force users of dbwrap_tool to explicitly specify
persistent or non-persistent. Otherwise, one could easily
by accident wipe a whole database that is actually persistent
but not currently opened by a samba process, just by openeing
the DB with the default non-persistent mode...
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'source3')
-rw-r--r-- | source3/utils/dbwrap_tool.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/source3/utils/dbwrap_tool.c b/source3/utils/dbwrap_tool.c index 406e89ee4de..ffca6b6d62a 100644 --- a/source3/utils/dbwrap_tool.c +++ b/source3/utils/dbwrap_tool.c @@ -411,6 +411,7 @@ int main(int argc, const char **argv) enum dbwrap_type type; const char *valuestr = "0"; int persistent = 0; + int non_persistent = 0; int tdb_flags = TDB_DEFAULT; TALLOC_CTX *mem_ctx = talloc_stackframe(); @@ -420,7 +421,13 @@ int main(int argc, const char **argv) struct poptOption popt_options[] = { POPT_AUTOHELP POPT_COMMON_SAMBA - { "persistent", 0, POPT_ARG_NONE, &persistent, 0, "treat the database as persistent", NULL }, + { "non-persistent", 0, POPT_ARG_NONE, &non_persistent, 0, + "treat the database as non-persistent " + "(CAVEAT: This mode might wipe your database!)", + NULL }, + { "persistent", 0, POPT_ARG_NONE, &persistent, 0, + "treat the database as persistent", + NULL }, POPT_TABLEEND }; int opt; @@ -463,6 +470,16 @@ int main(int argc, const char **argv) goto done; } + if ((persistent == 0 && non_persistent == 0) || + (persistent == 1 && non_persistent == 1)) + { + d_fprintf(stderr, "ERROR: you must specify exactly one " + "of --persistent and --non-persistent\n"); + goto done; + } else if (non_persistent == 1) { + tdb_flags |= TDB_CLEAR_IF_FIRST; + } + dbname = extra_argv[0]; opname = extra_argv[1]; @@ -563,10 +580,6 @@ int main(int argc, const char **argv) goto done; } - if (persistent == 0) { - tdb_flags |= TDB_CLEAR_IF_FIRST; - } - switch (op) { case OP_FETCH: case OP_STORE: |