mod_admin_extra not working with ejabberd 13.12

Hello,

I've installed ejabberd 13.12 using the binary installer for linux 64 Bit on Debian wheezy 7.3
Everything works as expected except the fact that the lib libyaml-0-2 is missing, so installing it before running Ejabberd binary installer.

My problem here is that I've installed mod_admin_extra but it is not working at all.

My configuration:
- Debian Wheezy 7.3 64 Bit
- Ejabberd 13.12
- vHost: xmpp.mydomain.com
- Auth : internal

I've:
1 - downloaded the erl file from git
2 - compiled it using this command

./ercl -I /op/ejabberd-13.12/lib/ejabberd-13.12/include /user/neodolphin/mod_admin_extra.erl

3 - copied the beam file in the folder

/opt/ejabberd-13.12/lib/ejabberd-13.12/ebin/

4 - Modified the configuration file ejabberd.yml to enable mod_admin_extra with this line

mod_admin_extra: {}

5 - restarted ejabberd

When I type :

./ejabberdctl srg_list xmpp.mydomain.com

the command return me nothing but on the web site I can see my two Share Roster Group

I have launch a debug using :

./ejabberdctl debug

then typed

lists:sort(mod_shared_roster:list_groups('xmpp.mydomain.com')).

which is corresponding in the source code to the function srg_list and this command return me

[]

If you have any idea :)

UPDATE: I've dug deeper in

UPDATE:

I've dug deeper in the code.

The command srg_list give you this code mod_shared_roster:list_groups(Host) which correspond to list_groups(Host, gen_mod:db_type(Host, ?MODULE)). since the db_type I'm using is mnesia I take the function list_groups(Host, mnesia).

This function give me this code:

    mnesia:dirty_select(sr_group,
[{#sr_group{group_host = {'$1', '$2'}, _ = '_'},
  [{'==', '$2', Host}], ['$1']}]);

If I copy and paste this code it gives me this error: record sr_group undefined

From then I've done a basic select on the sr_group table using this code :

F = fun() -> mnesia:select('sr_group',[{'_',[],['$_']}]) end,
mnesia:activity(transaction, F).

and this gave this result :

[{sr_group,{<<"SharedRosterTest1">>,<<"xmpp.mydomain.com">>},
           [{name,<<"SharedRosterTest1">>},
            {displayed_groups,[<<"SharedRosterTest1">>,<<"SharedRosterTest2">>]}]},
{sr_group,{<<"SharedRosterTest2">>,<<"xmpp.mydomain.com">>},
           [{name,<<"SharedRosterTest2">>},
            {displayed_groups,[<<"SharedRosterTest2">>]},
            {all_users,true}]}]

So I tried to modified the dirty_select to a select because it is the same according the mnesia documentation here : http://www.erlang.org/doc/man/mnesia.html#dirty_select-2

Here the modified version

F = fun() ->
Host = 'xmpp.mydomain.com',
MatchHead = #sr_group{group_host = {'$1', '$2'}, _ = '_'},
Guard = {'==', '$2', Host},
Result = '$1',
mnesia:select('sr_group',[{MatchHead, [Guard], [Result]}]) end,
mnesia:activity(transaction, F).

and this give the same error : * 3: record sr_group undefined

So I dug deeper in the mnesia database and in the table sr_group using this command mnesia:schema(sr_group)

Here is the result:

-- Properties for sr_group table ---
access_mode          -> read_write
active_replicas      -> [ejabberd@localhost]
all_nodes            -> [ejabberd@localhost]
arity                -> 3
attributes           -> [group_host,opts]
checkpoints          -> []
commit_work          -> []
cookie               -> {{1388,483739,236368},ejabberd@localhost}
disc_copies          -> [ejabberd@localhost]
disc_only_copies     -> []
frag_properties      -> []
index                -> []
load_by_force        -> false
load_node            -> ejabberd@localhost
load_order           -> 0
load_reason          -> local_only
local_content        -> false
majority             -> false
master_nodes         -> []
memory               -> 635
ram_copies           -> []
record_name          -> sr_group
record_validation    -> {sr_group,3,set}
setorbag             -> set
size                 -> 7
snmp                 -> []
storage_properties   -> []
storage_type         -> disc_copies
subscribers          -> []
user_properties      -> []
version              -> {{2,0},[]}
where_to_commit      -> [{ejabberd@localhost,disc_copies}]
where_to_read        -> ejabberd@localhost
where_to_wlock       -> {[ejabberd@localhost],false}
where_to_write       -> [ejabberd@localhost]
wild_pattern         -> {sr_group,'_','_'}

ok

As we see the record sr_group exist and the group_host attribute also as written in the original dirty_select

So after a little google I've seen that in erlang you have to define the record in the shell before using it so fair enough I've user this command rd(sr_group, {group_host, opts})

then I can select with

mnesia:dirty_select(sr_group, [{#sr_group{group_host = {'$1', '$2'}, _ = '_'}, [{'==', '$2', 'xmpp.mydomain.com'}], ['$1']}]).

but it return me nothing.

mnesia:dirty_select(sr_group, [{#sr_group{group_host = {'$1', '$2'}, _ = '_'}, [], ['$2']}]).

returns me

[<<"SharedRosterTest1">>,<<"SharedRosterTest1">>,'test']

Note the test at the end, this one has been created with mod_admin_extra:srg_create so I see that when your creating a shared roster using the webadmin you can't retreive it using srg_list.

You have to create it using srg_create
I think it is a bug because when you type ejabberdctl with a command from admin extra it dose interpret well the argument

Syndicate content