Skip to content
Snippets Groups Projects
Commit 4532b452 authored by nkennedy's avatar nkennedy
Browse files

Factor out and expose get_real_dlsym() function to initialize and return real_dlsym.

Other preloads that call dlsym to hook functions which are called by dlsym were getting bit by appfw.
Provides a mechanism for them to identify appfw and get to libdl dlsym.
ok nkennedy@ ip:peasoup


Former-commit-id: 397c30e57798e861f948752449f9b8eaf73fab90
parent c9448057
No related branches found
No related tags found
No related merge requests found
......@@ -36,8 +36,8 @@ int execl(const char *path, const char *arg, ...);
int execlp(const char *file, const char *arg, ...);
int execle(const char *path, const char *arg, ...);
void* (*real_dlsym)()=NULL;
typedef void* (*dlsym_t)(void*, const char*);
dlsym_t real_dlsym=NULL;
struct mapper
{
......@@ -76,6 +76,24 @@ struct mapper dlsym_mapper[] =
};
dlsym_t get_real_dlsym()
{
char *verbose= getenv("APPFW_VERY_VERBOSE");
if (real_dlsym == NULL)
{
if(verbose !=0)
fprintf(stderr, "Initing dlsym handle\n");
void* handler = dlopen("libdl.so", RTLD_LAZY);
assert(handler);
extern void* __libc_dlsym(void*, const char*);
real_dlsym = (void*)__libc_dlsym(handler, "dlsym"); /* now, this will call dlsym() library function */
assert(real_dlsym);
if(verbose !=0)
fprintf(stderr, "Finished initing dlsym handle\n");
}
return real_dlsym;
}
void* dl_sym_helper(void* handle, const char* symbol, struct mapper *sym_map)
......@@ -154,27 +172,19 @@ extern void appfw_ldap_init();
void *dlsym(void *handle, const char *symbol)
{
char *verbose= getenv("APPFW_VERY_VERBOSE");
if(verbose !=0)
static init = 0;
if(verbose !=0)
fprintf(stderr, "Ha Ha...dlsym() Hooked with handle=%p, symbol=%s\n", (void*)handle,symbol);
if(real_dlsym==NULL)
if(init == 0)
{
if(verbose !=0)
fprintf(stderr, "Initing dlsym handle\n");
void* handler = dlopen("libdl.so", RTLD_LAZY);
assert(handler);
extern void* __libc_dlsym(void*, const char*);
real_dlsym = (void*)__libc_dlsym(handler, "dlsym"); /* now, this will call dlsym() library function */
assert(real_dlsym);
if(verbose !=0)
fprintf(stderr, "Finished initing dlsym handle\n");
/* init it all */
get_real_dlsym();
sqlfw_init();
oscfw_init();
xqfw_init();
appfw_ldap_init();
init = 1;
}
if(handle!=RTLD_NEXT && handle!=RTLD_DEFAULT)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment