From 9e09d100f6e6a660e69cc003eabb9193c7a2e5f8 Mon Sep 17 00:00:00 2001 From: Jason Edgecombe Date: Tue, 16 Oct 2007 18:20:09 +0000 Subject: [PATCH] STABLE14-fs-uuid-20071016 FIXES 74473 Change "fs uuid" to "fs uuid -generate" where "-generate" is a required parameter. This command requires root access to execute it. Unlike the Windows variant, the UNIX version does not yet support displaying the current UUID to the user. When this functionality is added, "-generate" should become an optional parameter. (cherry picked from commit 7b2fc6e8d53d1ca8f111cd757e723ab27e9a31d9) --- src/venus/fs.c | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/src/venus/fs.c b/src/venus/fs.c index cd107c518..fe23dbeb8 100644 --- a/src/venus/fs.c +++ b/src/venus/fs.c @@ -69,7 +69,7 @@ static char tspace[1024]; static struct ubik_client *uclient; static int GetClientAddrsCmd(), SetClientAddrsCmd(), FlushMountCmd(); -static int RxStatProcCmd(), RxStatPeerCmd(), GetFidCmd(), NewUuidCmd(); +static int RxStatProcCmd(), RxStatPeerCmd(), GetFidCmd(), UuidCmd(); extern char *hostutil_GetNameByINet(); extern struct hostent *hostutil_GetHostByName(); @@ -1244,21 +1244,40 @@ FlushVolumeCmd(struct cmd_syndesc *as, char *arock) return error; } +/* + * The Windows version of UuidCmd displays the UUID. + * When the UNIX version is updated to do the same + * be sure to replace the CMD_REQUIRED flag with + * CMD_OPTIONAL in the cmd_AddParam(-generate) call + */ static int -NewUuidCmd(struct cmd_syndesc *as, char *arock) +UuidCmd(struct cmd_syndesc *as, char *arock) { afs_int32 code; struct ViceIoctl blob; blob.in_size = 0; blob.out_size = 0; - code = pioctl(0, VIOC_NEWUUID, &blob, 1); - if (code) { - Die(errno, 0); - return 1; - } + + if (as->parms[0].items) { + if (geteuid()) { + fprintf (stderr, "Permission denied: requires root access.\n"); + return EACCES; + } + + /* generate new UUID */ + code = pioctl(0, VIOC_NEWUUID, &blob, 1); - printf("New uuid generated.\n"); + if (code) { + Die(errno, 0); + return 1; + } + + printf("New uuid generated.\n"); + } else { + /* This will never execute */ + printf("Please add the '-generate' option to generate a new UUID.\n"); + } return 0; } @@ -3460,8 +3479,8 @@ defect 3069 "get fid for file(s)"); cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path"); - ts = cmd_CreateSyntax("newuuid", NewUuidCmd, 0, - "force a new uuid"); + ts = cmd_CreateSyntax("uuid", UuidCmd, 0, "manage the UUID for the cache manager"); + cmd_AddParm(ts, "-generate", CMD_FLAG, CMD_REQUIRED, "generate a new UUID"); code = cmd_Dispatch(argc, argv); if (rxInitDone) -- 2.39.5