in-band unregistration doesn't work

Hello,

I want to allow clients to unregister themselves in-band. However, I have a separate registration process, i.e. out of band. Hence, I have "{access, register, [{deny, all}]}." in my config.

From looking at the code at http://www.process-one.net/docs/ejabberd/devdoc/trunk/mod_register.erl.html it doesn't seem to be possible to not allow registration but allow unregistration.

Is that correct?

Is there any module that allows me to set up unregistration?

You are right in your

You are right in your understanding. And there isn't any option right now in ejabberd to solve your question.

But if you can modify the source code and compile it, then you can apply this small change that breaks registration, so it is always disallowed:

--- a/src/mod_register.erl
+++ b/src/mod_register.erl
@@ -319,6 +319,8 @@ try_set_password(User, Server, Password, IQ, SubEl, Lang) ->
     end.
 
 try_register(User, Server, Password, SourceRaw, Lang) ->
+    {error, ?ERR_FORBIDDEN};
+try_register(User, Server, Password, SourceRaw, Lang) ->
     case jlib:is_nodename(User) of
        false ->
            {error, ?ERR_BAD_REQUEST};

Interesting approach. Is

Interesting approach.

Is there a way to put that in a module so that I don't have to patch ejabberd again once I update it?

Maybe I can copy mod_register to mod_unregister and somehow not load mod_register?

muelli wrote: Interesting

muelli wrote:

Interesting approach.

Is there a way to put that in a module so that I don't have to patch ejabberd again once I update it?

Maybe I can copy mod_register to mod_unregister and somehow not load mod_register?

Yes, and replace the line: -module(mod_register). with: -module(mod_unregister).

Compile your module, copy it where all the others, disable mod_register and enable mod_unregister.

badlop wrote: ---

badlop wrote:
--- a/src/mod_register.erl
+++ b/src/mod_register.erl
@@ -319,6 +319,8 @@ try_set_password(User, Server, Password, IQ, SubEl, Lang) ->
     end.
 
 try_register(User, Server, Password, SourceRaw, Lang) ->
+    {error, ?ERR_FORBIDDEN};
+try_register(User, Server, Password, SourceRaw, Lang) ->
     case jlib:is_nodename(User) of
        false ->
            {error, ?ERR_BAD_REQUEST};

Thanks. I created a mod_unregister and applied the patch.
I couldn't compile it outside of the ejabberd git tree though:

muelli@fs:~/ejabberd-mod_unregister$ make
erl  -pa "/var/lib/ejabberd/ejabberd-modules.svn/ejabberd-dev/trunk/ebin" -pz ebin -make
{"init terminating in do_boot",{badarg,[{erl_prim_loader,check_file_result,3,[]},{init,patch_dir,2,[]},{init,'-patch_path/2-lc$^0/1-0-',2,[]},{init,eval_script,8,[]},{init,do_boot,3,[]}]}}

Crash dump was written to: erl_crash.dump
init terminating in do_boot ()
make: *** [mod_unregister.ebeam] Error 1
muelli@fs:~/ejabberd-mod_unregister$

Letting the file live just next to mod_register works.

And the module seems to work, too :-) thanks!

I used the webinterface to load the mod_register and load mod_unregister. Interestingly, registering still works (we had it enabled for a different domain) but that's not a problem. I presume this will be solved with a restart of ejabberd.

Syndicate content