version 1.1, 2012/02/21 16:23:02
|
version 1.1.1.3, 2013/07/22 10:46:11
|
Line 1
|
Line 1
|
/* |
/* |
* Copyright (c) 2010 Todd C. Miller <Todd.Miller@courtesan.com> | * Copyright (c) 2010, 2012-2013 Todd C. Miller <Todd.Miller@courtesan.com> |
* |
* |
* Permission to use, copy, modify, and distribute this software for any |
* Permission to use, copy, modify, and distribute this software for any |
* purpose with or without fee is hereby granted, provided that the above |
* purpose with or without fee is hereby granted, provided that the above |
Line 16
|
Line 16
|
|
|
#include <config.h> |
#include <config.h> |
|
|
|
#ifndef HAVE_DLOPEN |
|
|
#include <sys/types.h> |
#include <sys/types.h> |
|
|
#include <stdio.h> |
#include <stdio.h> |
Line 51
|
Line 53
|
void * |
void * |
sudo_dlopen(const char *path, int mode) |
sudo_dlopen(const char *path, int mode) |
{ |
{ |
int flags = DYNAMIC_PATH; | int flags = DYNAMIC_PATH | BIND_VERBOSE; |
|
|
if (mode == 0) |
if (mode == 0) |
mode = RTLD_LAZY; /* default behavior */ |
mode = RTLD_LAZY; /* default behavior */ |
Line 77 sudo_dlsym(void *vhandle, const char *symbol)
|
Line 79 sudo_dlsym(void *vhandle, const char *symbol)
|
shl_t handle = vhandle; |
shl_t handle = vhandle; |
void *value = NULL; |
void *value = NULL; |
|
|
(void)shl_findsym(&handle, symbol, TYPE_UNDEFINED, &value); | /* |
| * Note that the behavior of of RTLD_NEXT and RTLD_SELF |
| * differs from most implementations when called from |
| * a shared library. |
| */ |
| if (vhandle == RTLD_NEXT) { |
| /* Iterate over all shared libs looking for symbol. */ |
| struct shl_descriptor *desc; |
| int idx = 0; |
| while (shl_get(idx++, &desc) == 0) { |
| if (shl_findsym(&desc->handle, symbol, TYPE_UNDEFINED, &value) == 0) |
| break; |
| } |
| } else { |
| if (vhandle == RTLD_DEFAULT) |
| handle = NULL; |
| else if (vhandle == RTLD_SELF) |
| handle = PROG_HANDLE; |
| (void)shl_findsym(&handle, symbol, TYPE_UNDEFINED, &value); |
| } |
|
|
return value; |
return value; |
} |
} |
Line 117 sudo_dlsym(void *handle, const char *symbol)
|
Line 138 sudo_dlsym(void *handle, const char *symbol)
|
{ |
{ |
struct sudo_preload_table *sym; |
struct sudo_preload_table *sym; |
|
|
for (sym = sudo_preload_table; sym->name != NULL; sym++) { | if (symbol != RTLD_NEXT && symbol != RTLD_DEFAULT && symbol != RTLD_SELF) { |
if (strcmp(symbol, sym->name) == 0) | for (sym = sudo_preload_table; sym->name != NULL; sym++) { |
return sym->address; | if (strcmp(symbol, sym->name) == 0) |
| return sym->address; |
| } |
} |
} |
return NULL; |
return NULL; |
} |
} |
Line 129 sudo_dlerror(void)
|
Line 152 sudo_dlerror(void)
|
{ |
{ |
return strerror(errno); |
return strerror(errno); |
} |
} |
|
|
#endif /* HAVE_SHL_LOAD */ |
#endif /* HAVE_SHL_LOAD */ |
|
#endif /* HAVE_DLOPEN */ |