Author: breed
Date: Wed May 20 18:08:28 2009
New Revision: 776793

URL: http://svn.apache.org/viewvc?rev=776793&view=rev
Log:
ZOOKEEPER-345 the CLIs should allow addAuth to be invoked.

Modified:
    hadoop/zookeeper/trunk/CHANGES.txt
    hadoop/zookeeper/trunk/src/c/src/cli.c
    hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/ZooKeeperMain.java

Modified: hadoop/zookeeper/trunk/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/CHANGES.txt?rev=776793&r1=776792&r2=776793&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/CHANGES.txt (original)
+++ hadoop/zookeeper/trunk/CHANGES.txt Wed May 20 18:08:28 2009
@@ -138,6 +138,7 @@
 
   ZOOKEEPER-404. nightly build failed on hudson. (henry robinson and pat via
 mahadev)
+  ZOOKEEPER-345. the CLIs should allow addAuth to be invoked. (henry robinson 
via breed)
  
 NEW FEATURES:
 

Modified: hadoop/zookeeper/trunk/src/c/src/cli.c
URL: 
http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/c/src/cli.c?rev=776793&r1=776792&r2=776793&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/c/src/cli.c (original)
+++ hadoop/zookeeper/trunk/src/c/src/cli.c Wed May 20 18:08:28 2009
@@ -263,7 +263,7 @@
 
 void processline(char *line) {
     int rc;
-    int async = (line[0] == 'a');
+    int async = ((line[0] == 'a') && !(startsWith(line, "addauth ")));
     if (async) {
         line++;
     }
@@ -277,6 +277,7 @@
       fprintf(stderr, "    exists <path>\n");
       fprintf(stderr, "    myid\n");
       fprintf(stderr, "    verbose\n");
+      fprintf(stderr, "    addauth <id> <scheme>\n");
       fprintf(stderr, "    quit\n");
       fprintf(stderr, "\n");
       fprintf(stderr, "    prefix the command with the character 'a' to run 
the command asynchronously.\n");
@@ -424,6 +425,15 @@
         rc = zoo_aset(zh, "/od", val, sizeof(val)-1, -1, od_completion, 0);
         if (rc)
             fprintf(stderr, "od command failed: %d\n", rc);
+    } else if (startsWith(line, "addauth ")) {
+      line += 8;
+      char *ptr;
+      ptr = strchr(line, ' ');
+      if (ptr) {
+        *ptr = '\0';
+        ptr++;
+      }
+      zoo_add_auth(zh, line, ptr, ptr ? strlen(ptr)-1 : 0, NULL, NULL);
     }
 }
 
@@ -476,8 +486,8 @@
         strncpy(p,cert,sizeof(p)-1);
         free(cert);
     } else {
-        fprintf(stderr,"Certificate for appid [%s] not found\n",appId);
-        strcpy(p,"dummy");
+      fprintf(stderr,"Certificate for appid [%s] not found\n",appId);
+      strcpy(p,"dummy");
     }
 #else
     strcpy(p, "dummy");
@@ -521,7 +531,7 @@
             bufoff = 0;
         }
     }
-#else 
+#else
     FD_ZERO(&rfds);
     FD_ZERO(&wfds);
     FD_ZERO(&efds);

Modified: 
hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/ZooKeeperMain.java
URL: 
http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/ZooKeeperMain.java?rev=776793&r1=776792&r2=776793&view=diff
==============================================================================
--- 
hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/ZooKeeperMain.java 
(original)
+++ 
hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/ZooKeeperMain.java 
Wed May 20 18:08:28 2009
@@ -76,6 +76,7 @@
         commandMap.put("redo"," cmdno");
         commandMap.put("printwatches", " on|off");
         commandMap.put("quit","");
+        commandMap.put("addauth", " scheme auth");
     }
 
     static void usage() {
@@ -719,6 +720,12 @@
             } else {
                 printWatches = args[1].equals("on");
             }
+        } else if (cmd.equals("addauth") && args.length >=2 ) {
+            byte[] b = null;
+            if (args.length >= 3)
+                b = args[2].getBytes();
+
+            zk.addAuthInfo(args[1], b);
         } else {
             usage();
         }


Reply via email to