Problem with Function Pointers in my Module in Apache 1.3.33 on AIX

This is a discussion on Problem with Function Pointers in my Module in Apache 1.3.33 on AIX within the Linux Web Servers forums, part of the Web Server and Related Forums category; The Problem : I am using a function pointer in my WebServer module to call OpenSSL function - SSL_get_peer_certificate() from the main ...


Go Back   Usenet Forums > Web Server and Related Forums > Linux Web Servers

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-10-2005
Prashant Shetty
 
Posts: n/a
Default Problem with Function Pointers in my Module in Apache 1.3.33 on AIX

The Problem :
I am using a function pointer in my WebServer module to call OpenSSL
function - SSL_get_peer_certificate() from the main Apache process.
The function definition is taken from the OpenSSL Library : libssl.a .
On execution, I get the following error in my Apache Error Log file :
Error: Look up of symbol - SSL_get_peer_certificate failed - Function
not implemented (SSL_get_peer_certificate).

Modules used to build Apache WebServer :
mod_ssl version : 2.8.22-1.3.33
OpenSSL version : 0.9.7d ( openssl-0.9.7e is giving problem while
building on AIX )
Apache version : 1.3.33
AIX version : 4.3 and 5.2
gcc version : 2.95.3

Code :
------------------------------------------------------
void * libssl = NULL;
typedef X509* (*funcptr)(SSL*);
funcptr fptr = NULL;

// Get the handle to main Apache process
libssl = dlopen (NULL, RTLD_NOW | RTLD_GLOBAL | RTLD_MEMBER );
fptr = (funcptr) dlsym(libssl, "SSL_get_peer_certificate");
------------------------------------------------------

Details :
Initially, the problem I faced was that the function symbol
SSL_get_peer_certificate, was getting garbage collected ( During
linking and binding on AIX, any unused or unreferenced symbols are
deleted ). This was the output of nm command on httpd executable :
..SSL_get_peer_certificate T 269039260
... ie .. the function definition was visible only in the Text Section.

Hence, while building Apache, I specifically exported the function
symbol using -u flag with ld. The make command is :
make MFLAGS="EXTRA_LDFLAGS='-uSSL_get_peer_certificate'"

The output of nm command on httpd executable now is :
..SSL_get_peer_certificate T 269039260
SSL_get_peer_certificate D 536993772
SSL_get_peer_certificate d 536993772 12
Now, the function is visible in the Data Section both at global and
local level.

But I am still not able to access the function using the pointer. Same
is the case with accessing the functions in my own module, using a
pointer.

Further Observations :
- If we do a dlsym to get the handle of a function defined inside
Apache Code, there is no such problem.
- There is no problem using function pointers in the rest of our
application.

Has anybody else faced a similar problem? Any pointers or related
links would be of great help.

Thanks in Advance,
Prashant.
  #2 (permalink)  
Old 01-14-2005
Gary R. Hook
 
Posts: n/a
Default Re: Problem with Function Pointers in my Module in Apache 1.3.33on AIX

Prashant Shetty wrote:
> Code :
> ------------------------------------------------------
> void * libssl = NULL;
> typedef X509* (*funcptr)(SSL*);
> funcptr fptr = NULL;
>
> // Get the handle to main Apache process
> libssl = dlopen (NULL, RTLD_NOW | RTLD_GLOBAL | RTLD_MEMBER );
> fptr = (funcptr) dlsym(libssl, "SSL_get_peer_certificate");
> ------------------------------------------------------
>

<...snip...>
>
> The output of nm command on httpd executable now is :
> .SSL_get_peer_certificate T 269039260
> SSL_get_peer_certificate D 536993772
> SSL_get_peer_certificate d 536993772 12
> Now, the function is visible in the Data Section both at global and
> local level.


Not good enough. -u only prevents garbage collection. The real
question is, is the symbol _exported_? dump -Tv <file> | grep peer
will tell you this. nm and dump -tv are useless when what you need to
examine is the API of the module. You'll need to add an export list
(-bE:<explist>) to your build command.

Otherwise, your dlopen/dlsym usage appears correct.

--
Gary R. Hook
__________________________________________________ ______________________
Vocatus atque non vocatus deus aderit
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 09:04 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0