Beispiel #1
0
        public virtual int Mknode(string[] args)
        {
            Options           mknodeOption = new Options();
            CommandLineParser parser       = new GnuParser();

            try
            {
                CommandLine    line     = parser.Parse(mknodeOption, args);
                IList <string> argsList = line.GetArgList();
                if (argsList.Count != 2)
                {
                    return(UsageError("mknode requires exactly one path argument", MknodeUsage));
                }
                if (!ValidatePath(argsList[1]))
                {
                    return(-1);
                }
                try
                {
                    registry.Mknode(args[1], false);
                    return(0);
                }
                catch (Exception e)
                {
                    syserr.WriteLine(AnalyzeException("mknode", e, argsList));
                }
                return(-1);
            }
            catch (ParseException exp)
            {
                return(UsageError("Invalid syntax " + exp.ToString(), MknodeUsage));
            }
        }
Beispiel #2
0
        public virtual void TestZookeeperCanWriteUnderSystem()
        {
            RMRegistryOperationsService rmRegistryOperations = StartRMRegistryOperations();
            RegistryOperations          operations           = rmRegistryOperations;

            operations.Mknode(PathSystemServices + "hdfs", false);
            ZKPathDumper pathDumper = rmRegistryOperations.DumpPath(true);

            Log.Info(pathDumper.ToString());
        }
Beispiel #3
0
        public virtual void TestAnonNoWriteAccessOffRoot()
        {
            RMRegistryOperationsService rmRegistryOperations = StartRMRegistryOperations();

            Describe(Log, "testAnonNoWriteAccessOffRoot");
            RegistryOperations operations = RegistryOperationsFactory.CreateAnonymousInstance
                                                (zkClientConf);

            AddToTeardown(operations);
            operations.Start();
            NUnit.Framework.Assert.IsFalse("mknode(/)", operations.Mknode("/", false));
            ExpectMkNodeFailure(operations, "/sub");
            ExpectDeleteFailure(operations, PathSystemServices, true);
        }
Beispiel #4
0
        public virtual void TestUserZookeeperHomePathAccess()
        {
            RMRegistryOperationsService rmRegistryOperations = StartRMRegistryOperations();
            string home = rmRegistryOperations.InitUserRegistry(Zookeeper);

            Describe(Log, "Creating ZK client");
            RegistryOperations operations = zookeeperUGI.DoAs(new _PrivilegedExceptionAction_232
                                                                  (this));

            operations.List(home);
            string path = home + "/subpath";

            operations.Mknode(path, false);
            operations.Delete(path, true);
        }
Beispiel #5
0
 /// <summary>Expect a mknode operation to fail</summary>
 /// <param name="operations">operations instance</param>
 /// <param name="path">path</param>
 /// <exception cref="System.IO.IOException">An IO failure other than those permitted</exception>
 public virtual void ExpectMkNodeFailure(RegistryOperations operations, string path
                                         )
 {
     try
     {
         operations.Mknode(path, false);
         NUnit.Framework.Assert.Fail("should have failed to create a node under " + path);
     }
     catch (PathPermissionException)
     {
     }
     catch (NoPathPermissionsException)
     {
     }
 }
Beispiel #6
0
        public virtual void TestDigestAccess()
        {
            RMRegistryOperationsService registryAdmin = StartRMRegistryOperations();
            string id   = "username";
            string pass = "******";

            registryAdmin.AddWriteAccessor(id, pass);
            IList <ACL> clientAcls = registryAdmin.GetClientAcls();

            Log.Info("Client ACLS=\n{}", RegistrySecurity.AclsToString(clientAcls));
            string @base = "/digested";

            registryAdmin.Mknode(@base, false);
            IList <ACL> baseACLs = registryAdmin.ZkGetACLS(@base);
            string      aclset   = RegistrySecurity.AclsToString(baseACLs);

            Log.Info("Base ACLs=\n{}", aclset);
            ACL found = null;

            foreach (ACL acl in baseACLs)
            {
                if (ZookeeperConfigOptions.SchemeDigest.Equals(acl.GetId().GetScheme()))
                {
                    found = acl;
                    break;
                }
            }
            NUnit.Framework.Assert.IsNotNull("Did not find digest entry in ACLs " + aclset, found
                                             );
            zkClientConf.Set(KeyRegistryUserAccounts, "sasl:[email protected], sasl:other"
                             );
            RegistryOperations operations = RegistryOperationsFactory.CreateAuthenticatedInstance
                                                (zkClientConf, id, pass);

            AddToTeardown(operations);
            operations.Start();
            RegistryOperationsClient operationsClient = (RegistryOperationsClient)operations;
            IList <ACL> digestClientACLs = operationsClient.GetClientAcls();

            Log.Info("digest client ACLs=\n{}", RegistrySecurity.AclsToString(digestClientACLs
                                                                              ));
            operations.Stat(@base);
            operations.Mknode(@base + "/subdir", false);
            ZKPathDumper pathDumper = registryAdmin.DumpPath(true);

            Log.Info(pathDumper.ToString());
        }