]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
STABLE14-fs-uuid-20071016
authorJason Edgecombe <jason@rampaginggeek.com>
Tue, 16 Oct 2007 18:20:09 +0000 (18:20 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Tue, 16 Oct 2007 18:20:09 +0000 (18:20 +0000)
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

index cd107c5187585b5c7708a19a060774e308e25071..fe23dbeb8531ecc6cbb785f4de8d0253e596c0fe 100644 (file)
@@ -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)