[PATCH v2 1/6] s3-rpcclient: abort shadow-copy set on commit failure

David Disseldorp ddiss at samba.org
Thu Jan 16 09:48:07 MST 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 af194e2..89fc3d0 100644
--- a/source3/rpcclient/cmd_fss.c
+++ b/source3/rpcclient/cmd_fss.c
@@ -199,6 +199,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)
@@ -292,7 +310,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),
@@ -310,7 +328,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),
@@ -324,7 +342,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),
@@ -360,6 +378,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.1.4



More information about the samba-technical mailing list