[asterisk-dev] PATCHES: Fixes and updates for Asterisk 1.6beta5 LDAP support

Jason Parker jparker at digium.com
Mon Mar 17 10:34:10 CDT 2008


Tuomas Jormola wrote:
> Hello,
> 
> I played a little bit with Asterisk using LDAP as backend for SIP users.
> To get everything working, I needed to hack the Asterisk source code
> a bit. Here are the results as 4 separate patches. More detailed
> explanation of each patch follows. Feel free to use them as is or as
> basis for further development.
> 
> fix-ldap-bugs.diff
> ==================
> This patch fixes two simple bugs in res_config_ldap.c. In function
> realtime_ldap_base_ap(), due to missing brackets in an if block, the
> execution will always stop to the return NULL statement. In fucntcion
> update_ldap(), error checking after call to ldap_modify_ext_s() is not
> good. It's better to compare the returned value to LDAP_SUCCESS
> constant. Also the formatting of the error message is missing "\n".
> 
> use-ldap-url.diff
> =================
> This patch alters res_config_ldap.c so that full LDAP URL is used
> internally to represent the LDAP server to use instead of using hostname
> and port variables. It's also possible to specify the full URL in
> res_ldap.conf using the new url keyword instead of just specifying host
> and port (but this works too, of course, so existing configurations
> should not break due to this change). Rationale behind this is that
> using a URL you can specify extra settings for the connections that
> are not available otherwise (e.g. you can use ldapi:// urls when
> connecting to a local OpenLDAP server, or you can specify the scope of
> the queries, see ldap_url(3) manual page for more info). Also currently
> the port setting code is broken. It generates invalid LDAP URLs if both
> host and port of the LDAP server is specified in the configuration file.
> The patch also fixes setting of the protocol. You can specify this in
> the configuration file, but the setting was never applied to the LDAP
> connection. Thus all connections were using LDAPv2 by default (at least
> when Asterisk is compiled against OpenLDAP 2.4).
> 
> update-asterisk-ldap-schema.diff
> ================================
> I notcied that in order to get the LDAP/SIP support working, you need to
> add attributes ipaddr, defaultuser and regserver to the [sip] section of
> res_ldap.conf. These did not have corresponding LDAP attributes in the
> included asterisk.ldap-schema, so I created them.
> 
> update-ldap-default-config.diff
> ===============================
> This patch adds afformentioned SIP attributes to the sample
> res_ldap.conf. It also renames PBXAccount* LDAP attributes to the
> current AstAccount* form. Also realmedPassword is renamed to
> AstAccountRealmedPassword.
> 
> I also experience a segfault with each call to ber_bvecfree() in
> res_config_ldap.c. I'm not sure how to handle that correctly. For my
> testing, I just commented out these calls, but that's hardly a long-term
> solution due to memory leaking. I've attached a gdb backtrace of such
> a segfault.
> 
> Regards,
> 

All patches must go through the bug tracker at bugs.digium.com.  They
cannot (and will not) be committed otherwise.  Please open a new bug
report, and post them there.



More information about the asterisk-dev mailing list