zklua icon indicating copy to clipboard operation
zklua copied to clipboard

how to set the ACL parameter

Open hy05190134 opened this issue 10 years ago • 2 comments

anybody know how to set the format of ACL when to call acreate function

hy05190134 avatar Dec 19 '14 07:12 hy05190134

zookeeper.h /** This is a completely open ACL_/ extern ZOOAPI struct ACL_vector ZOO_OPEN_ACL_UNSAFE; /_* This ACL gives the world the ability to read. / extern ZOOAPI struct ACL_vector ZOO_READ_ACL_UNSAFE; /* This ACL gives the creators authentication id's all permissions. */ extern ZOOAPI struct ACL_vector ZOO_CREATOR_ALL_ACL;

so you can register these struct to lua.

gocpp avatar Jul 14 '16 02:07 gocpp

from zklua.c(line 320) function _zklua_parse_acls, we can see ACL is a table in Lua, and you can pass N ACL, each ACL is consist of three items, the code is like below

local acl = { 
    {   
        perms = 31,  -- const int ZOO_PERM_ALL = 0x1f;
        scheme = "world",
        id = "anyone" -- world:anyone means anybody
    }   
}
local ret, err = zklua.create(zh, "/zklua/test", "test", acl, 0)
if ret ~= 0 then
     print("error:"..err)
end

the normal return code of the create is 0 and error code is descripted in https://github.com/apache/zookeeper/blob/master/src/c/include/zookeeper.h#120.

Hope to help.

ghost avatar Aug 27 '17 03:08 ghost