From ace2f7f5ce13502f5cb6ec39a9e84864b80ec76b Mon Sep 17 00:00:00 2001 From: Michael Meffie Date: Mon, 23 Dec 2019 18:37:21 -0500 Subject: [PATCH] vos: Add missing -partition requires -server checks The `vos remove` command was missing a check for the -server option when the -partition option is given. This command requires the -server option when the -partition is given, as documented in the man page. The `vos syncvldb` command performed the check for the -server option when the -partition option is given, but in the wrong location. As documented, the `vos unlockvldb` command permits the -partition option without a -server option, in which case all of the volumes listed in the VLDB with sites on the specified partition are unlocked. However, this command incorrectly issued an RPC to a volume server at address 0.0.0.0 when only the partition is given. Change-Id: I6b878678e28b34250e63d2d082747f6fd416972d Reviewed-on: https://gerrit.openafs.org/14005 Reviewed-by: Benjamin Kaduk Tested-by: BuildBot Reviewed-by: Michael Meffie --- src/volser/vos.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/src/volser/vos.c b/src/volser/vos.c index be487b2..da09a32 100644 --- a/src/volser/vos.c +++ b/src/volser/vos.c @@ -2081,6 +2081,11 @@ DeleteVolume(struct cmd_syndesc *as, void *arock) char pname[10]; afs_int32 idx, j; + if (as->parms[1].items && !as->parms[0].items) { + fprintf(STDERR, "vos: The -partition option requires the -server option.\n"); + return EINVAL; + } + if (as->parms[0].items) { server = GetServer(as->parms[0].items->data); if (!server) { @@ -3812,6 +3817,12 @@ SyncVldb(struct cmd_syndesc *as, void *arock) afs_uint32 tserver; tserver = 0; + + if (as->parms[1].items && !as->parms[0].items) { + fprintf(STDERR, "vos: The -partition option requires the -server option.\n"); + exit(1); + } + if (as->parms[0].items) { tserver = GetServer(as->parms[0].items->data); if (!tserver) { @@ -3838,12 +3849,6 @@ SyncVldb(struct cmd_syndesc *as, void *arock) exit(1); } flags = 1; - - if (!tserver) { - fprintf(STDERR, - "The -partition option requires a -server option\n"); - exit(1); - } } if (as->parms[3].items) { @@ -5047,14 +5052,17 @@ UnlockVLDB(struct cmd_syndesc *as, void *arock) as->parms[1].items->data); exit(1); } - if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */ - if (code) - PrintError("", code); - else - fprintf(STDERR, - "vos : partition %s does not exist on the server\n", - as->parms[1].items->data); - exit(1); + if (aserver) { + /* Check for validity of the partition if a server was given. */ + if (!IsPartValid(apart, aserver, &code)) { + if (code) + PrintError("", code); + else + fprintf(STDERR, + "vos : partition %s does not exist on the server\n", + as->parms[1].items->data); + exit(1); + } } attributes.partition = apart; attributes.Mask |= VLLIST_PARTITION; -- 1.9.4