2 * Unix SMB/CIFS implementation.
4 * File Server Remote VSS Protocol (FSRVP) client
6 * Copyright (C) David Disseldorp 2012
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #include "rpcclient.h"
24 #include "../librpc/gen_ndr/ndr_fsrvp.h"
25 #include "../librpc/gen_ndr/ndr_fsrvp_c.h"
26 #include "../libcli/util/hresult.h"
30 const char *error_str
;
34 "A method call was invalid because of the state of the server."
37 FSRVP_E_SHADOW_COPY_SET_IN_PROGRESS
,
38 "A call was made to either \'SetContext\' or \'StartShadowCopySet\' while the creation of another shadow copy set is in progress."
41 FSRVP_E_NOT_SUPPORTED
,
42 "The file store which contains the share to be shadow copied is not supported by the server."
46 "The wait for a shadow copy commit or expose operation has timed out."
50 "The wait for a shadow copy commit expose operation has failed."
53 FSRVP_E_OBJECT_NOT_FOUND
,
54 "The specified object does not exist."
57 FSRVP_E_UNSUPPORTED_CONTEXT
,
58 "The specified context value is invalid."
62 struct fss_context_map
{
67 struct fss_context_map ctx_map
[] = {
69 .ctx_val
= FSRVP_CTX_BACKUP
,
71 .ctx_desc
= "auto-release, non-persistent shadow-copy.",
74 .ctx_val
= FSRVP_CTX_FILE_SHARE_BACKUP
,
75 .ctx_str
= "file_share_backup",
76 .ctx_desc
= "auto-release, non-persistent shadow-copy created "
77 "without writer involvement.",
80 .ctx_val
= FSRVP_CTX_NAS_ROLLBACK
,
81 .ctx_str
= "nas_rollback",
82 .ctx_desc
= "non-auto-release, persistent shadow-copy created "
83 "without writer involvement.",
86 .ctx_val
= FSRVP_CTX_APP_ROLLBACK
,
87 .ctx_str
= "app_rollback",
88 .ctx_desc
= "non-auto-release, persistent shadow-copy.",
93 static const char *get_error_str(uint32_t code
)
95 static const char *default_err
= "Unknown Error";
96 const char *result
= default_err
;
98 for (i
= 0; i
< ARRAY_SIZE(fss_errors
); ++i
) {
99 if (code
== fss_errors
[i
].error_code
) {
100 result
= fss_errors
[i
].error_str
;
104 /* error isn't specific fsrvp one, check hresult errors */
105 if (result
== default_err
) {
106 const char *hres_err
= hresult_errstr_const(HRES_ERROR(code
));
114 static bool map_fss_ctx_str(const char *ctx_str
,
119 for (i
= 0; ctx_map
[i
].ctx_str
!= NULL
; i
++) {
120 if (!strcmp(ctx_map
[i
].ctx_str
, ctx_str
)) {
121 *ctx_val
= ctx_map
[i
].ctx_val
;
128 static void cmd_fss_is_path_sup_usage(const char *script_name
)
130 printf("usage: %s [share_name]\n", script_name
);
133 static NTSTATUS
cmd_fss_is_path_sup(struct rpc_pipe_client
*cli
,
134 TALLOC_CTX
*mem_ctx
, int argc
,
138 struct fss_IsPathSupported r
;
139 struct dcerpc_binding_handle
*b
= cli
->binding_handle
;
142 cmd_fss_is_path_sup_usage(argv
[0]);
143 return NT_STATUS_UNSUCCESSFUL
;
147 r
.in
.ShareName
= talloc_asprintf(mem_ctx
, "%s\\%s\\",
148 cli
->srv_name_slash
, argv
[1]);
149 if (r
.in
.ShareName
== NULL
) {
150 return NT_STATUS_NO_MEMORY
;
153 status
= dcerpc_fss_IsPathSupported_r(b
, mem_ctx
, &r
);
154 if (!NT_STATUS_IS_OK(status
)) {
155 DEBUG(0, ("IsPathSupported failed with UNC %s\n",
157 return NT_STATUS_UNSUCCESSFUL
;
158 } else if (r
.out
.result
) {
159 DEBUG(0, ("failed IsPathSupported response: 0x%x - \"%s\"\n",
160 r
.out
.result
, get_error_str(r
.out
.result
)));
161 return NT_STATUS_UNSUCCESSFUL
;
163 printf("UNC %s %s shadow copy requests\n", r
.in
.ShareName
,
164 *r
.out
.SupportedByThisProvider
? "supports" : "does not support");
169 static void cmd_fss_get_sup_version_usage(const char *script_name
)
171 printf("usage: %s\n", script_name
);
174 static NTSTATUS
cmd_fss_get_sup_version(struct rpc_pipe_client
*cli
,
175 TALLOC_CTX
*mem_ctx
, int argc
,
179 struct fss_GetSupportedVersion r
;
180 struct dcerpc_binding_handle
*b
= cli
->binding_handle
;
183 cmd_fss_get_sup_version_usage(argv
[0]);
184 return NT_STATUS_UNSUCCESSFUL
;
188 status
= dcerpc_fss_GetSupportedVersion_r(b
, mem_ctx
, &r
);
189 if (!NT_STATUS_IS_OK(status
) || (r
.out
.result
!= 0)) {
190 DEBUG(0, ("GetSupportedVersion failed: %s result: 0x%x\n",
191 nt_errstr(status
), r
.out
.result
));
192 return NT_STATUS_UNSUCCESSFUL
;
194 printf("server %s supports FSRVP versions from %u to %u\n",
195 cli
->desthost
, *r
.out
.MinVersion
, *r
.out
.MaxVersion
);
200 static void cmd_fss_create_expose_usage(const char *script_name
)
204 printf("usage: %s [fss_context] [ro|rw] [share1] <share2> ...\n"
205 "[fss_context] values:\n", script_name
);
206 for (i
= 0; ctx_map
[i
].ctx_str
!= NULL
; i
++) {
207 printf("\t%s: %s\n", ctx_map
[i
].ctx_str
, ctx_map
[i
].ctx_desc
);
211 static NTSTATUS
cmd_fss_create_expose_parse(TALLOC_CTX
*mem_ctx
, int argc
,
213 const char *desthost
,
214 uint32_t *fss_ctx_val
,
216 struct fssagent_share_mapping_1
**maps
)
218 int num_non_share_args
= 3;
221 struct fssagent_share_mapping_1
*map_array
;
224 return NT_STATUS_INVALID_PARAMETER
;
227 if (!map_fss_ctx_str(argv
[1], fss_ctx_val
)) {
228 return NT_STATUS_INVALID_PARAMETER
;
231 if (!strcmp(argv
[2], "rw")) {
232 /* shadow-copy is created as read-write */
233 *fss_ctx_val
|= ATTR_AUTO_RECOVERY
;
234 } else if (strcmp(argv
[2], "ro")) {
235 return NT_STATUS_INVALID_PARAMETER
;
238 num_share_args
= argc
- num_non_share_args
;
239 map_array
= talloc_array(mem_ctx
, struct fssagent_share_mapping_1
,
241 if (map_array
== NULL
) {
242 return NT_STATUS_NO_MEMORY
;
245 for (i
= 0; i
< num_share_args
; i
++) {
247 * A trailing slash should to be present in the request UNC,
248 * otherwise Windows Server 2012 FSRVP servers don't append
249 * a '$' to exposed hidden share shadow-copies. E.g.
250 * AddToShadowCopySet(UNC=\\server\hidden$)
251 * CommitShadowCopySet()
252 * ExposeShadowCopySet()
253 * -> new share = \\server\hidden$@{ShadowCopy.ShadowCopyId}
255 * AddToShadowCopySet(UNC=\\server\hidden$\)
256 * CommitShadowCopySet()
257 * ExposeShadowCopySet()
258 * -> new share = \\server\hidden$@{ShadowCopy.ShadowCopyId}$
260 map_array
[i
].ShareNameUNC
= talloc_asprintf(mem_ctx
,
263 argv
[i
+ num_non_share_args
]);
264 if (map_array
[i
].ShareNameUNC
== NULL
) {
265 return NT_STATUS_NO_MEMORY
;
268 *num_maps
= num_share_args
;
274 static NTSTATUS
cmd_fss_abort(TALLOC_CTX
*mem_ctx
,
275 struct dcerpc_binding_handle
*b
,
276 struct GUID
*sc_set_id
)
279 struct fss_AbortShadowCopySet r_scset_abort
;
281 ZERO_STRUCT(r_scset_abort
);
282 r_scset_abort
.in
.ShadowCopySetId
= *sc_set_id
;
283 status
= dcerpc_fss_AbortShadowCopySet_r(b
, mem_ctx
, &r_scset_abort
);
284 if (!NT_STATUS_IS_OK(status
) || (r_scset_abort
.out
.result
!= 0)) {
285 DEBUG(0, ("AbortShadowCopySet failed: %s result: 0x%x\n",
286 nt_errstr(status
), r_scset_abort
.out
.result
));
287 return NT_STATUS_UNSUCCESSFUL
;
292 static NTSTATUS
cmd_fss_create_expose(struct rpc_pipe_client
*cli
,
293 TALLOC_CTX
*mem_ctx
, int argc
,
297 struct fss_GetSupportedVersion r_version_get
;
298 struct fss_SetContext r_context_set
;
299 struct fss_StartShadowCopySet r_scset_start
;
300 struct fss_PrepareShadowCopySet r_scset_prep
;
301 struct fss_CommitShadowCopySet r_scset_commit
;
302 struct fss_ExposeShadowCopySet r_scset_expose
;
303 struct dcerpc_binding_handle
*b
= cli
->binding_handle
;
306 uint32_t fss_ctx_val
;
308 struct fssagent_share_mapping_1
*req_maps
;
311 tmp_ctx
= talloc_new(mem_ctx
);
312 if (tmp_ctx
== NULL
) {
313 return NT_STATUS_NO_MEMORY
;
316 status
= cmd_fss_create_expose_parse(tmp_ctx
, argc
, argv
, cli
->desthost
,
317 &fss_ctx_val
, &num_maps
, &req_maps
);
318 if (!NT_STATUS_IS_OK(status
)) {
319 cmd_fss_create_expose_usage(argv
[0]);
324 * PrepareShadowCopySet & CommitShadowCopySet often exceed the default
325 * 60 second dcerpc request timeout against Windows Server "8" Beta.
326 * ACHTUNG! dcerpc_binding_handle_set_timeout() value is interpreted as
327 * seconds on a source4 transport and as msecs here.
329 dcerpc_binding_handle_set_timeout(b
, 240 * 1000);
331 for (i
= 0; i
< num_maps
; i
++) {
332 struct fss_IsPathSupported r_pathsupport_get
;
333 r_pathsupport_get
.in
.ShareName
= req_maps
[i
].ShareNameUNC
;
334 status
= dcerpc_fss_IsPathSupported_r(b
, tmp_ctx
, &r_pathsupport_get
);
335 if (!NT_STATUS_IS_OK(status
) || (r_pathsupport_get
.out
.result
!= 0)) {
336 DEBUG(0, ("IsPathSupported failed: %s result: 0x%x\n",
337 nt_errstr(status
), r_pathsupport_get
.out
.result
));
340 if (!r_pathsupport_get
.out
.SupportedByThisProvider
) {
341 printf("path %s does not supported shadow-copies\n",
342 req_maps
[i
].ShareNameUNC
);
343 status
= NT_STATUS_NOT_SUPPORTED
;
348 ZERO_STRUCT(r_version_get
);
349 status
= dcerpc_fss_GetSupportedVersion_r(b
, tmp_ctx
, &r_version_get
);
350 if (!NT_STATUS_IS_OK(status
) || (r_version_get
.out
.result
!= 0)) {
351 DEBUG(0, ("GetSupportedVersion failed: %s result: 0x%x\n",
352 nt_errstr(status
), r_version_get
.out
.result
));
356 ZERO_STRUCT(r_context_set
);
357 r_context_set
.in
.Context
= fss_ctx_val
;
358 status
= dcerpc_fss_SetContext_r(b
, tmp_ctx
, &r_context_set
);
359 if (!NT_STATUS_IS_OK(status
) || (r_context_set
.out
.result
!= 0)) {
360 DEBUG(0, ("SetContext failed: %s result: 0x%x\n",
361 nt_errstr(status
), r_context_set
.out
.result
));
365 ZERO_STRUCT(r_scset_start
);
366 r_scset_start
.in
.ClientShadowCopySetId
= GUID_random();
367 status
= dcerpc_fss_StartShadowCopySet_r(b
, tmp_ctx
, &r_scset_start
);
368 if (!NT_STATUS_IS_OK(status
) || (r_scset_start
.out
.result
!= 0)) {
369 DEBUG(0, ("StartShadowCopySet failed: %s result: 0x%x\n",
370 nt_errstr(status
), r_scset_start
.out
.result
));
373 printf("%s: shadow-copy set created\n",
374 GUID_string(tmp_ctx
, r_scset_start
.out
.pShadowCopySetId
));
376 for (i
= 0; i
< num_maps
; i
++) {
377 struct fss_AddToShadowCopySet r_scset_add
;
378 r_scset_add
.in
.ClientShadowCopyId
= GUID_random();
379 r_scset_add
.in
.ShadowCopySetId
= *r_scset_start
.out
.pShadowCopySetId
;
380 r_scset_add
.in
.ShareName
= req_maps
[i
].ShareNameUNC
;
381 status
= dcerpc_fss_AddToShadowCopySet_r(b
, tmp_ctx
, &r_scset_add
);
382 if (!NT_STATUS_IS_OK(status
) || (r_scset_add
.out
.result
!= 0)) {
383 DEBUG(0, ("AddToShadowCopySet failed: %s result: 0x%x\n",
384 nt_errstr(status
), r_scset_add
.out
.result
));
385 goto err_sc_set_abort
;
387 printf("%s(%s): %s shadow-copy added to set\n",
388 GUID_string(tmp_ctx
, r_scset_start
.out
.pShadowCopySetId
),
389 GUID_string(tmp_ctx
, r_scset_add
.out
.pShadowCopyId
),
390 r_scset_add
.in
.ShareName
);
391 req_maps
[i
].ShadowCopySetId
= *r_scset_start
.out
.pShadowCopySetId
;
392 req_maps
[i
].ShadowCopyId
= *r_scset_add
.out
.pShadowCopyId
;
395 start_time
= time_mono(NULL
);
396 ZERO_STRUCT(r_scset_prep
);
397 r_scset_prep
.in
.ShadowCopySetId
= *r_scset_start
.out
.pShadowCopySetId
;
398 r_scset_prep
.in
.TimeOutInMilliseconds
= (240 * 1000);
399 status
= dcerpc_fss_PrepareShadowCopySet_r(b
, tmp_ctx
, &r_scset_prep
);
400 if (!NT_STATUS_IS_OK(status
) || (r_scset_prep
.out
.result
!= 0)) {
401 DEBUG(0, ("PrepareShadowCopySet failed: %s result: 0x%x\n",
402 nt_errstr(status
), r_scset_prep
.out
.result
));
403 goto err_sc_set_abort
;
405 printf("%s: prepare completed in %llu secs\n",
406 GUID_string(tmp_ctx
, r_scset_start
.out
.pShadowCopySetId
),
407 (long long unsigned int)(time_mono(NULL
) - start_time
));
409 start_time
= time_mono(NULL
);
410 ZERO_STRUCT(r_scset_commit
);
411 r_scset_commit
.in
.ShadowCopySetId
= *r_scset_start
.out
.pShadowCopySetId
;
412 r_scset_commit
.in
.TimeOutInMilliseconds
= (180 * 1000); /* win8 */
413 status
= dcerpc_fss_CommitShadowCopySet_r(b
, tmp_ctx
, &r_scset_commit
);
414 if (!NT_STATUS_IS_OK(status
) || (r_scset_commit
.out
.result
!= 0)) {
415 DEBUG(0, ("CommitShadowCopySet failed: %s result: 0x%x\n",
416 nt_errstr(status
), r_scset_commit
.out
.result
));
417 goto err_sc_set_abort
;
419 printf("%s: commit completed in %llu secs\n",
420 GUID_string(tmp_ctx
, r_scset_start
.out
.pShadowCopySetId
),
421 (long long unsigned int)(time_mono(NULL
) - start_time
));
423 ZERO_STRUCT(r_scset_expose
);
424 r_scset_expose
.in
.ShadowCopySetId
= *r_scset_start
.out
.pShadowCopySetId
;
425 r_scset_expose
.in
.TimeOutInMilliseconds
= (120 * 1000); /* win8 */
426 status
= dcerpc_fss_ExposeShadowCopySet_r(b
, tmp_ctx
, &r_scset_expose
);
427 if (!NT_STATUS_IS_OK(status
) || (r_scset_expose
.out
.result
!= 0)) {
428 DEBUG(0, ("ExposeShadowCopySet failed: %s result: 0x%x\n",
429 nt_errstr(status
), r_scset_expose
.out
.result
));
433 for (i
= 0; i
< num_maps
; i
++) {
434 struct fss_GetShareMapping r_sharemap_get
;
435 struct fssagent_share_mapping_1
*map
;
436 r_sharemap_get
.in
.ShadowCopyId
= req_maps
[i
].ShadowCopyId
;
437 r_sharemap_get
.in
.ShadowCopySetId
= req_maps
[i
].ShadowCopySetId
;
438 r_sharemap_get
.in
.ShareName
= req_maps
[i
].ShareNameUNC
;
439 r_sharemap_get
.in
.Level
= 1;
440 status
= dcerpc_fss_GetShareMapping_r(b
, tmp_ctx
, &r_sharemap_get
);
441 if (!NT_STATUS_IS_OK(status
) || (r_sharemap_get
.out
.result
!= 0)) {
442 DEBUG(0, ("GetShareMapping failed: %s result: 0x%x\n",
443 nt_errstr(status
), r_sharemap_get
.out
.result
));
446 map
= r_sharemap_get
.out
.ShareMapping
->ShareMapping1
;
447 printf("%s(%s): share %s exposed as a snapshot of %s\n",
448 GUID_string(tmp_ctx
, &map
->ShadowCopySetId
),
449 GUID_string(tmp_ctx
, &map
->ShadowCopyId
),
450 map
->ShadowCopyShareName
, map
->ShareNameUNC
);
453 talloc_free(tmp_ctx
);
457 cmd_fss_abort(tmp_ctx
, b
, r_scset_start
.out
.pShadowCopySetId
);
459 talloc_free(tmp_ctx
);
463 static void cmd_fss_delete_usage(const char *script_name
)
465 printf("usage: %s [base_share] [shadow_copy_set_id] [shadow_copy_id]\n",
469 static NTSTATUS
cmd_fss_delete(struct rpc_pipe_client
*cli
,
470 TALLOC_CTX
*mem_ctx
, int argc
,
473 struct dcerpc_binding_handle
*b
= cli
->binding_handle
;
474 struct fss_DeleteShareMapping r_sharemap_del
;
475 const char *sc_set_id
;
481 cmd_fss_delete_usage(argv
[0]);
482 return NT_STATUS_UNSUCCESSFUL
;
487 tmp_ctx
= talloc_new(mem_ctx
);
488 if (tmp_ctx
== NULL
) {
489 return NT_STATUS_NO_MEMORY
;
492 ZERO_STRUCT(r_sharemap_del
);
493 r_sharemap_del
.in
.ShareName
= talloc_asprintf(tmp_ctx
, "\\\\%s\\%s\\",
494 cli
->desthost
, argv
[1]);
495 if (r_sharemap_del
.in
.ShareName
== NULL
) {
496 status
= NT_STATUS_NO_MEMORY
;
499 status
= GUID_from_string(sc_set_id
, &r_sharemap_del
.in
.ShadowCopySetId
);
500 if (!NT_STATUS_IS_OK(status
)) {
501 DEBUG(0, ("Invalid shadow_copy_set_id parameter\n"));
504 status
= GUID_from_string(sc_id
, &r_sharemap_del
.in
.ShadowCopyId
);
505 if (!NT_STATUS_IS_OK(status
)) {
506 DEBUG(0, ("Invalid shadow_copy_id parameter\n"));
509 status
= dcerpc_fss_DeleteShareMapping_r(b
, tmp_ctx
, &r_sharemap_del
);
510 if (!NT_STATUS_IS_OK(status
)) {
511 DEBUG(0, ("DeleteShareMapping failed\n"));
513 } else if (r_sharemap_del
.out
.result
!= 0) {
514 DEBUG(0, ("failed DeleteShareMapping response: 0x%x\n",
515 r_sharemap_del
.out
.result
));
516 status
= NT_STATUS_UNSUCCESSFUL
;
520 printf("%s(%s): %s shadow-copy deleted\n",
521 sc_set_id
, sc_id
, r_sharemap_del
.in
.ShareName
);
524 talloc_free(tmp_ctx
);
528 static void cmd_fss_is_shadow_copied_usage(const char *script_name
)
530 printf("usage: %s [share_name]\n", script_name
);
533 static NTSTATUS
cmd_fss_is_shadow_copied(struct rpc_pipe_client
*cli
,
534 TALLOC_CTX
*mem_ctx
, int argc
,
538 struct fss_IsPathShadowCopied r
;
539 struct dcerpc_binding_handle
*b
= cli
->binding_handle
;
542 cmd_fss_is_shadow_copied_usage(argv
[0]);
543 return NT_STATUS_UNSUCCESSFUL
;
547 r
.in
.ShareName
= talloc_asprintf(mem_ctx
, "%s\\%s\\",
548 cli
->srv_name_slash
, argv
[1]);
549 if (r
.in
.ShareName
== NULL
) {
550 return NT_STATUS_NO_MEMORY
;
553 status
= dcerpc_fss_IsPathShadowCopied_r(b
, mem_ctx
, &r
);
554 if (!NT_STATUS_IS_OK(status
)) {
555 DEBUG(0, ("IsPathShadowCopied failed with UNC %s\n",
557 return NT_STATUS_UNSUCCESSFUL
;
558 } else if (r
.out
.result
) {
559 DEBUG(0, ("failed IsPathShadowCopied response: 0x%x\n",
561 return NT_STATUS_UNSUCCESSFUL
;
563 printf("UNC %s %s an associated shadow-copy with compatibility 0x%x\n",
565 *r
.out
.ShadowCopyPresent
? "has" : "does not have",
566 *r
.out
.ShadowCopyCompatibility
);
571 static void cmd_fss_get_mapping_usage(const char *script_name
)
573 printf("usage: %s [base_share] [shadow_copy_set_id] [shadow_copy_id]\n",
577 static NTSTATUS
cmd_fss_get_mapping(struct rpc_pipe_client
*cli
,
578 TALLOC_CTX
*mem_ctx
, int argc
,
581 struct dcerpc_binding_handle
*b
= cli
->binding_handle
;
582 struct fss_GetShareMapping r_sharemap_get
;
583 const char *sc_set_id
;
585 struct fssagent_share_mapping_1
*map
;
590 cmd_fss_get_mapping_usage(argv
[0]);
591 return NT_STATUS_UNSUCCESSFUL
;
596 tmp_ctx
= talloc_new(mem_ctx
);
597 if (tmp_ctx
== NULL
) {
598 return NT_STATUS_NO_MEMORY
;
601 ZERO_STRUCT(r_sharemap_get
);
602 r_sharemap_get
.in
.ShareName
= talloc_asprintf(tmp_ctx
, "\\\\%s\\%s\\",
603 cli
->desthost
, argv
[1]);
604 if (r_sharemap_get
.in
.ShareName
== NULL
) {
605 status
= NT_STATUS_NO_MEMORY
;
608 status
= GUID_from_string(sc_set_id
, &r_sharemap_get
.in
.ShadowCopySetId
);
609 if (!NT_STATUS_IS_OK(status
)) {
610 DEBUG(0, ("Invalid shadow_copy_set_id parameter\n"));
613 status
= GUID_from_string(sc_id
, &r_sharemap_get
.in
.ShadowCopyId
);
614 if (!NT_STATUS_IS_OK(status
)) {
615 DEBUG(0, ("Invalid shadow_copy_id parameter\n"));
618 r_sharemap_get
.in
.Level
= 1;
619 status
= dcerpc_fss_GetShareMapping_r(b
, tmp_ctx
, &r_sharemap_get
);
620 if (!NT_STATUS_IS_OK(status
)) {
621 DEBUG(0, ("GetShareMapping failed\n"));
623 } else if (r_sharemap_get
.out
.result
!= 0) {
624 DEBUG(0, ("failed GetShareMapping response: 0x%x\n",
625 r_sharemap_get
.out
.result
));
626 status
= NT_STATUS_UNSUCCESSFUL
;
630 map
= r_sharemap_get
.out
.ShareMapping
->ShareMapping1
;
631 printf("%s(%s): share %s is a shadow-copy of %s at %s\n",
632 GUID_string(tmp_ctx
, &map
->ShadowCopySetId
),
633 GUID_string(tmp_ctx
, &map
->ShadowCopyId
),
634 map
->ShadowCopyShareName
, map
->ShareNameUNC
,
635 nt_time_string(tmp_ctx
, map
->tstamp
));
638 talloc_free(tmp_ctx
);
642 static void cmd_fss_recov_complete_usage(const char *script_name
)
644 printf("usage: %s [shadow_copy_set_id]\n", script_name
);
647 static NTSTATUS
cmd_fss_recov_complete(struct rpc_pipe_client
*cli
,
648 TALLOC_CTX
*mem_ctx
, int argc
,
652 struct fss_RecoveryCompleteShadowCopySet r
;
653 struct dcerpc_binding_handle
*b
= cli
->binding_handle
;
654 const char *sc_set_id
;
657 cmd_fss_recov_complete_usage(argv
[0]);
658 return NT_STATUS_UNSUCCESSFUL
;
663 status
= GUID_from_string(sc_set_id
, &r
.in
.ShadowCopySetId
);
664 if (!NT_STATUS_IS_OK(status
)) {
665 DEBUG(0, ("Invalid shadow_copy_set_id\n"));
666 return NT_STATUS_INVALID_PARAMETER
;
669 status
= dcerpc_fss_RecoveryCompleteShadowCopySet_r(b
, mem_ctx
, &r
);
670 if (!NT_STATUS_IS_OK(status
) || (r
.out
.result
!= 0)) {
671 DEBUG(0, ("RecoveryCompleteShadowCopySet failed: %s "
672 "result: 0x%x\n", nt_errstr(status
), r
.out
.result
));
675 printf("%s: shadow-copy set marked recovery complete\n", sc_set_id
);
680 /* List of commands exported by this module */
681 struct cmd_set fss_commands
[] = {
686 .name
= "fss_is_path_sup",
687 .returntype
= RPC_RTYPE_NTSTATUS
,
688 .ntfn
= cmd_fss_is_path_sup
,
689 .table
= &ndr_table_FileServerVssAgent
,
691 .description
= "Check whether a share supports shadow-copy "
696 .name
= "fss_get_sup_version",
697 .returntype
= RPC_RTYPE_NTSTATUS
,
698 .ntfn
= cmd_fss_get_sup_version
,
699 .table
= &ndr_table_FileServerVssAgent
,
701 .description
= "Get supported FSRVP version from server",
705 .name
= "fss_create_expose",
706 .returntype
= RPC_RTYPE_NTSTATUS
,
707 .ntfn
= cmd_fss_create_expose
,
708 .table
= &ndr_table_FileServerVssAgent
,
710 .description
= "Request shadow-copy creation and exposure",
714 .name
= "fss_delete",
715 .returntype
= RPC_RTYPE_NTSTATUS
,
716 .ntfn
= cmd_fss_delete
,
717 .table
= &ndr_table_FileServerVssAgent
,
719 .description
= "Request shadow-copy share deletion",
723 .name
= "fss_has_shadow_copy",
724 .returntype
= RPC_RTYPE_NTSTATUS
,
725 .ntfn
= cmd_fss_is_shadow_copied
,
726 .table
= &ndr_table_FileServerVssAgent
,
728 .description
= "Check for an associated share shadow-copy",
732 .name
= "fss_get_mapping",
733 .returntype
= RPC_RTYPE_NTSTATUS
,
734 .ntfn
= cmd_fss_get_mapping
,
735 .table
= &ndr_table_FileServerVssAgent
,
737 .description
= "Get shadow-copy share mapping information",
741 .name
= "fss_recovery_complete",
742 .returntype
= RPC_RTYPE_NTSTATUS
,
743 .ntfn
= cmd_fss_recov_complete
,
744 .table
= &ndr_table_FileServerVssAgent
,
746 .description
= "Flag read-write snapshot as recovery complete, "
747 "allowing further shadow-copy requests",