From d171a5e059566cc99c5dd980039dd56233f91a67 Mon Sep 17 00:00:00 2001 From: Michael Meffie Date: Thu, 13 Oct 2011 12:23:35 -0400 Subject: [PATCH] DAFS: fssync online requires a partition name argument fssync-debug online silently fails when run without a partition name. Check for the required partition name on the server side and the client side. Report errors back to the client when the server side fails to pre-attach the volume. Change-Id: I454b202ac83893b1ee54d586a46d891773090a64 Reviewed-on: http://gerrit.openafs.org/5615 Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear --- src/vol/fssync-debug.c | 4 ++++ src/vol/fssync-server.c | 10 +++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/vol/fssync-debug.c b/src/vol/fssync-debug.c index ac3d122db0..820a1f719f 100644 --- a/src/vol/fssync-debug.c +++ b/src/vol/fssync-debug.c @@ -445,6 +445,10 @@ VolOnline(struct cmd_syndesc * as, void * rock) common_prolog(as, &state); common_volop_prolog(as, &state); + if (state.vop->partName==0 || *(state.vop->partName)==0) { + fprintf(stderr, "required argument -partition not given\n"); + return -1; + } do_volop(&state, FSYNC_VOL_ON, NULL); return 0; diff --git a/src/vol/fssync-server.c b/src/vol/fssync-server.c index f6e9c2f26f..d8f274c81f 100644 --- a/src/vol/fssync-server.c +++ b/src/vol/fssync-server.c @@ -674,6 +674,7 @@ FSYNC_com_VolOn(FSSYNC_VolOp_command * vcom, SYNC_response * res) Volume * vp; Error error; + /* Verify the partition name is null terminated. */ if (SYNC_verifyProtocolString(vcom->vop->partName, sizeof(vcom->vop->partName))) { res->hdr.reason = SYNC_REASON_MALFORMED_PACKET; code = SYNC_FAILED; @@ -683,6 +684,13 @@ FSYNC_com_VolOn(FSSYNC_VolOp_command * vcom, SYNC_response * res) /* so, we need to attach the volume */ #ifdef AFS_DEMAND_ATTACH_FS + /* Verify the partition name is not empty. */ + if (*vcom->vop->partName == 0) { + res->hdr.reason = FSYNC_BAD_PART; + code = SYNC_FAILED; + goto done; + } + /* check DAFS permissions */ vp = VLookupVolume_r(&error, vcom->vop->volume, NULL); if (vp && @@ -763,11 +771,11 @@ FSYNC_com_VolOn(FSSYNC_VolOp_command * vcom, SYNC_response * res) V_VOLUPD); if (vp) VPutVolume_r(vp); +#endif /* !AFS_DEMAND_ATTACH_FS */ if (error) { code = SYNC_DENIED; res->hdr.reason = error; } -#endif /* !AFS_DEMAND_ATTACH_FS */ done: return code;