[PATCH 3/3] rpcclient: abort shadow-copy set on commit failure

David Disseldorp ddiss at samba.org
Fri Mar 28 19:18:20 MDT 2014


Use similar behaviour to the diskshadow.exe FSRVP client, which aborts
the shadow-copy set if it receives a failed commit response.

Signed-off-by: David Disseldorp <ddiss at samba.org>
---
 source3/rpcclient/cmd_fss.c | 29 ++++++++++++++++++++++++++---
 1 file changed, 26 insertions(+), 3 deletions(-)

diff --git a/source3/rpcclient/cmd_fss.c b/source3/rpcclient/cmd_fss.c
index a2e26c6..945f4d9 100644
--- a/source3/rpcclient/cmd_fss.c
+++ b/source3/rpcclient/cmd_fss.c
@@ -263,6 +263,24 @@ static NTSTATUS cmd_fss_create_expose_parse(TALLOC_CTX *mem_ctx, int argc,
 	return NT_STATUS_OK;
 }
 
+static NTSTATUS cmd_fss_abort(TALLOC_CTX *mem_ctx,
+			      struct dcerpc_binding_handle *b,
+			      struct GUID *sc_set_id)
+{
+	NTSTATUS status;
+	struct fss_AbortShadowCopySet r_scset_abort;
+
+	ZERO_STRUCT(r_scset_abort);
+	r_scset_abort.in.ShadowCopySetId = *sc_set_id;
+	status = dcerpc_fss_AbortShadowCopySet_r(b, mem_ctx, &r_scset_abort);
+	if (!NT_STATUS_IS_OK(status) || (r_scset_abort.out.result != 0)) {
+		DEBUG(0, ("AbortShadowCopySet failed: %s result: 0x%x\n",
+			  nt_errstr(status), r_scset_abort.out.result));
+		return NT_STATUS_UNSUCCESSFUL;
+	}
+	return NT_STATUS_OK;
+}
+
 static NTSTATUS cmd_fss_create_expose(struct rpc_pipe_client *cli,
 				     TALLOC_CTX *mem_ctx, int argc,
 				     const char **argv)
@@ -356,7 +374,7 @@ static NTSTATUS cmd_fss_create_expose(struct rpc_pipe_client *cli,
 		if (!NT_STATUS_IS_OK(status) || (r_scset_add.out.result != 0)) {
 			DEBUG(0, ("AddToShadowCopySet failed: %s result: 0x%x\n",
 				  nt_errstr(status), r_scset_add.out.result));
-			goto err_out;
+			goto err_sc_set_abort;
 		}
 		printf("%s(%s): %s shadow-copy added to set\n",
 		       GUID_string(tmp_ctx, r_scset_start.out.pShadowCopySetId),
@@ -374,7 +392,7 @@ static NTSTATUS cmd_fss_create_expose(struct rpc_pipe_client *cli,
 	if (!NT_STATUS_IS_OK(status) || (r_scset_prep.out.result != 0)) {
 		DEBUG(0, ("PrepareShadowCopySet failed: %s result: 0x%x\n",
 			  nt_errstr(status), r_scset_prep.out.result));
-		goto err_out;
+		goto err_sc_set_abort;
 	}
 	printf("%s: prepare completed in %llu secs\n",
 	       GUID_string(tmp_ctx, r_scset_start.out.pShadowCopySetId),
@@ -388,7 +406,7 @@ static NTSTATUS cmd_fss_create_expose(struct rpc_pipe_client *cli,
 	if (!NT_STATUS_IS_OK(status) || (r_scset_commit.out.result != 0)) {
 		DEBUG(0, ("CommitShadowCopySet failed: %s result: 0x%x\n",
 			  nt_errstr(status), r_scset_commit.out.result));
-		goto err_out;
+		goto err_sc_set_abort;
 	}
 	printf("%s: commit completed in %llu secs\n",
 	       GUID_string(tmp_ctx, r_scset_start.out.pShadowCopySetId),
@@ -424,6 +442,11 @@ static NTSTATUS cmd_fss_create_expose(struct rpc_pipe_client *cli,
 		       map->ShadowCopyShareName, map->ShareNameUNC);
 	}
 
+	talloc_free(tmp_ctx);
+	return NT_STATUS_OK;
+
+err_sc_set_abort:
+	cmd_fss_abort(tmp_ctx, b, r_scset_start.out.pShadowCopySetId);
 err_out:
 	talloc_free(tmp_ctx);
 	return status;
-- 
1.8.4.5



More information about the samba-technical mailing list