Review Board 1.7.16


Wrap OpenSSL library initialization to make it safe for loaded modules to also use OpenSSL.

Review Request #1006 - Created Nov. 11, 2010 and submitted

Kevin Fleming
trunk
Reviewers
asterisk-dev
Asterisk
During the devcon after AstriCon 2010, we got a report that using PostgreSQL from within Asterisk, when the PostgreSQL connections are configured to use SSL/TLS to connect to the database server, can cause random crashes and other bizarre behavior. The reporter said this was known to be an issue with some other packages as well (notably Kamailio), and had to do with both Asterisk and the PostgreSQL libraries assuming they "owned" the OpenSSL libraries in the process' memory space, and thus calling initialization code twice (or worse).

This patch addresses this problem by using dynamic linker functionality to *wrap* the real OpenSSL initialization functions (and some other dangerous ones) with versions that don't actually do anything, and then calling the real ones only *one* time during Asterisk startup. To make this work, the SSL functionality that is normally built into the main Asterisk binary now must be built into a dynamic library (libasteriskssl.so), which is installed into the standard dynamic library location on the system (this is *not* an Asterisk loadable module, just a regular dynamic library).

As part of this patch, the usage of ASTLIBDIR throughout the build system to refer to the directory where Asterisk loadable modules are installed was changed to ASTMODDIR (which matches how it is referred to in the source code and in asterisk.conf), and a new definition of ASTLIBDIR was created to point to the system's dynamic library directory.
Compiles and runs on Linux x86-64 with no apparent change in behavior. The Makefile bits to install libasteriskssl.so in the right place will probably have to be checked by Solaris, Darwin and *BSD users to get them right.

Diff revision 1

This is not the most recent revision of the diff. The latest diff is revision 3. See what's changed.

1 2 3
1 2 3

  1. /trunk/Makefile.moddir_rules: Loading...
  2. /trunk/Makefile: Loading...
  3. /trunk/configure.ac: Loading...
  4. /trunk/configure: Loading...
  5. /trunk/makeopts.in: Loading...
  6. /trunk/build_tools/make_defaults_h: Loading...
  7. /trunk/build_tools/mkpkgconfig: Loading...
  8. /trunk/main/Makefile: Loading...
  9. /trunk/main/ssl.c: Loading...
  10. /trunk/main/libasteriskssl.c: Loading...
/trunk/Makefile.moddir_rules
Revision 294735 New Change
[20] 119 lines
[+20]
120
	rm -f *.s *.i
120
	rm -f *.s *.i
121
	rm -f modules.link
121
	rm -f modules.link
122

    
   
122

   
123
install:: all
123
install:: all
124
	@echo "Installing modules from `basename $(CURDIR)`..."
124
	@echo "Installing modules from `basename $(CURDIR)`..."
125
	@for x in $(LOADABLE_MODS:%=%.so); do $(INSTALL) -m 755 $$x $(DESTDIR)$(MODULES_DIR) ; done
125
	@for x in $(LOADABLE_MODS:%=%.so); do $(INSTALL) -m 755 $$x $(DESTDIR)$(ASTMODDIR) ; done
126

    
   
126

   
127
uninstall::
127
uninstall::
128

    
   
128

   
129
dist-clean::
129
dist-clean::
130
	rm -f .*.moduleinfo .moduleinfo
130
	rm -f .*.moduleinfo .moduleinfo
[+20] [20] 36 lines
/trunk/Makefile
Revision 294735 New Change
 
/trunk/configure.ac
Revision 294735 New Change
 
/trunk/configure
Revision UNKNOWN New Change
 
/trunk/makeopts.in
Revision 294735 New Change
 
/trunk/build_tools/make_defaults_h
Revision 294735 New Change
 
/trunk/build_tools/mkpkgconfig
Revision 294735 New Change
 
/trunk/main/Makefile
Revision 294735 New Change
 
/trunk/main/ssl.c
Revision 294735 New Change
 
/trunk/main/ssl.c
Revision 294683 New Change
 
  1. /trunk/Makefile.moddir_rules: Loading...
  2. /trunk/Makefile: Loading...
  3. /trunk/configure.ac: Loading...
  4. /trunk/configure: Loading...
  5. /trunk/makeopts.in: Loading...
  6. /trunk/build_tools/make_defaults_h: Loading...
  7. /trunk/build_tools/mkpkgconfig: Loading...
  8. /trunk/main/Makefile: Loading...
  9. /trunk/main/ssl.c: Loading...
  10. /trunk/main/libasteriskssl.c: Loading...

https://reviewboard.asterisk.org/ runs on a server provided by Digium, Inc. and uses bandwidth donated to the open source Asterisk community by API Digital Communications in Huntsville, AL USA.
Please report problems with this site to asteriskteam@digium.com.