Summary:ASTERISK-11698: [patch] Add support for setting individual contexts in users.conf
Reporter:Sebastian A. Espindola (sespindola)Labels:
Date Opened:2008-03-21 18:48:54Date Closed:2011-06-07 14:03:22
Versions:Frequency of
Environment:Attachments:( 0) patch_12275_2.txt
( 1) patch_12275.txt
Description:Right now, as far as I know, the only way to configure a context for users
is to set "userscontext=mynewcontext" in the general section of extensions.conf.

Due to a project I'm currently working on, a need has arised to separate users
into multiple contexts. So I hacked together this patch that recognizes the
"context=" configuration option in each user entry and, if present, registers
the user into that context.

If the user doesn't have a context= option, the value of userscontext is set.

Comments:By: Jason Parker (jparker) 2008-03-24 09:31:43

+ usercontext = ast_calloc(1, 256);
+ usercontext = ast_variable_retrieve(cfg, cat, "context");

You're setting it, and then immediately setting it to something else, leaking 256 bytes.

Also, I really dislike the whole "usercontext" vs "userscontext" thing.

By: Sebastian A. Espindola (sespindola) 2008-03-25 08:46:45

Indeed, the calloc was uncalled for. I removed it.
I also change the usercontext variable name to entrycontext to avoid any
I have uploaded a second patch file with these changes.
Thanks for your comments!

By: Jason Parker (jparker) 2008-03-25 16:24:25

I looked at the way this is currently implemented, and...ugh.  It's going to make things quite difficult.

We don't want a context in users.conf to override userscontext because people may be relying on that value - and changing it to that could be disastrous.  At the same time, we do want to allow setting those contexts on a per user basis.

I can't really think of any ways to do this properly.  The only thing I can think of, would be adding a pbxcontext (and vmcontext, since voicemail uses similar code) to users.conf, but that would be really ugly.

By: Leif Madsen (lmadsen) 2008-10-07 13:19:31

I'm suspending this bug for now as there doesn't appear to be an easy way to move this issue forward. My personal opinion is that I don't like the idea of assigning multiple contexts to a single peer anyways -- I'd prefer you use a single context (say... "[custom_username]" and perform include =>'s within there to assign them to multiple contexts.

If someone has a way to move this issue forward, then please feel free to re-open it, or find a bug marshall on IRC to open it for you. Thanks!