summaryrefslogtreecommitdiff
path: root/source3/utils
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2008-06-13 21:11:55 +0200
committerGünther Deschner <gd@samba.org>2008-06-13 23:39:08 +0200
commitcb293f50fcf6de01e5a3624d355e0c3d6be0ffbf (patch)
tree0f0b4c43c89b9bb8d1d8eaeeb329b59fbba34ddf /source3/utils
parent7a1fa41dcafc0f2c2ae1052ba7dced0c06632b72 (diff)
downloadsamba-cb293f50fcf6de01e5a3624d355e0c3d6be0ffbf.tar.gz
samba-cb293f50fcf6de01e5a3624d355e0c3d6be0ffbf.tar.bz2
samba-cb293f50fcf6de01e5a3624d355e0c3d6be0ffbf.zip
net_vampire: add samsync_debug_str().
Guenther (This used to be commit bbfe5bcaf5ec5d06ffd110ab362ea3f228867603)
Diffstat (limited to 'source3/utils')
-rw-r--r--source3/utils/net_rpc_samsync.c82
1 files changed, 52 insertions, 30 deletions
diff --git a/source3/utils/net_rpc_samsync.c b/source3/utils/net_rpc_samsync.c
index f6483bdba2..61c60b2d04 100644
--- a/source3/utils/net_rpc_samsync.c
+++ b/source3/utils/net_rpc_samsync.c
@@ -343,6 +343,54 @@ static NTSTATUS display_sam_entries(TALLOC_CTX *mem_ctx,
return NT_STATUS_OK;
}
+const char *samsync_debug_str(TALLOC_CTX *mem_ctx,
+ enum net_samsync_mode mode,
+ enum netr_SamDatabaseID database_id)
+{
+ const char *action = NULL;
+ const char *str = NULL;
+
+ switch (mode) {
+ case NET_SAMSYNC_MODE_DUMP:
+ action = "Dumping (to stdout)";
+ break;
+ case NET_SAMSYNC_MODE_FETCH_PASSDB:
+ action = "Fetching (to passdb)";
+ break;
+ case NET_SAMSYNC_MODE_FETCH_LDIF:
+ action = "Fetching (to ldif)";
+ break;
+ default:
+ action = "Unknown";
+ break;
+ }
+
+ switch (database_id) {
+ case SAM_DATABASE_DOMAIN:
+ str = talloc_asprintf(mem_ctx, "%s DOMAIN database",
+ action);
+ break;
+ case SAM_DATABASE_BUILTIN:
+ str = talloc_asprintf(mem_ctx, "%s BUILTIN database",
+ action);
+ break;
+ case SAM_DATABASE_PRIVS:
+ str = talloc_asprintf(mem_ctx, "%s PRIVS database",
+ action);
+ break;
+ default:
+ str = talloc_asprintf(mem_ctx, "%s unknown database type %u",
+ action, database_id);
+ break;
+ }
+
+ if (!str) {
+ return NULL;
+ }
+
+ return str;
+}
+
typedef NTSTATUS (*samsync_fn_t)(TALLOC_CTX *,
enum netr_SamDatabaseID,
struct netr_DELTA_ENUM_ARRAY *,
@@ -362,8 +410,8 @@ static NTSTATUS process_database(struct rpc_pipe_client *pipe_hnd,
struct netr_Authenticator return_authenticator;
uint16_t restart_state = 0;
uint32_t sync_context = 0;
+ const char *debug_str;
DATA_BLOB session_key;
- const char *action = NULL;
ZERO_STRUCT(return_authenticator);
@@ -371,35 +419,9 @@ static NTSTATUS process_database(struct rpc_pipe_client *pipe_hnd,
return NT_STATUS_NO_MEMORY;
}
- switch (ctx->mode) {
- case NET_SAMSYNC_MODE_DUMP:
- action = "Dumping (to stdout)";
- break;
- case NET_SAMSYNC_MODE_FETCH_PASSDB:
- action = "Fetching (to passdb)";
- break;
- case NET_SAMSYNC_MODE_FETCH_LDIF:
- action = "Fetching (to ldif)";
- break;
- default:
- action = "Unknown";
- break;
- }
-
- switch (database_id) {
- case SAM_DATABASE_DOMAIN:
- d_fprintf(stderr, "%s DOMAIN database\n", action);
- break;
- case SAM_DATABASE_BUILTIN:
- d_fprintf(stderr, "%s BUILTIN database\n", action);
- break;
- case SAM_DATABASE_PRIVS:
- d_fprintf(stderr, "%s PRIVS databases\n", action);
- break;
- default:
- d_fprintf(stderr, "%s unknown database type %u\n",
- action, database_id);
- break;
+ debug_str = samsync_debug_str(mem_ctx, ctx->mode, database_id);
+ if (debug_str) {
+ d_fprintf(stderr, "%s\n", debug_str);
}
do {