summaryrefslogtreecommitdiff
path: root/accel-pptpd
diff options
context:
space:
mode:
authorDmitry Kozlov <xeb@mail.ru>2010-09-27 22:08:48 +0400
committerDmitry Kozlov <xeb@mail.ru>2010-09-27 22:08:48 +0400
commitf9bc7d57b20a0165862cfab7259f6147fcb15733 (patch)
tree4256cee8383599dd0690e9ebde8a0b9c4881d06e /accel-pptpd
parentf122327288ae4429bb88a0fefdcef0bf80f54023 (diff)
downloadaccel-ppp-f9bc7d57b20a0165862cfab7259f6147fcb15733.tar.gz
accel-ppp-f9bc7d57b20a0165862cfab7259f6147fcb15733.zip
triton: loader: trying various paths to find module
Diffstat (limited to 'accel-pptpd')
-rw-r--r--accel-pptpd/accel-pptpd.conf18
-rw-r--r--accel-pptpd/triton/loader.c44
2 files changed, 38 insertions, 24 deletions
diff --git a/accel-pptpd/accel-pptpd.conf b/accel-pptpd/accel-pptpd.conf
index d14fe180..40413bbc 100644
--- a/accel-pptpd/accel-pptpd.conf
+++ b/accel-pptpd/accel-pptpd.conf
@@ -1,13 +1,13 @@
[modules]
-./liblog_file.so
-./liblog_pgsql.so
-./libpptp.so
-./libauth_pap.so
-./libauth_chap_md5.so
-./libauth_mschap_v1.so
-./libauth_mschap_v2.so
-./libradius.so
-./libpppd_compat.so
+log_file
+log_pgsql
+pptp
+auth_pap
+auth_chap_md5
+auth_mschap_v1
+auth_mschap_v2
+libradius.so
+pppd_compat
[core]
log-error=/dev/stderr
diff --git a/accel-pptpd/triton/loader.c b/accel-pptpd/triton/loader.c
index a8b9c500..0fef03da 100644
--- a/accel-pptpd/triton/loader.c
+++ b/accel-pptpd/triton/loader.c
@@ -4,6 +4,7 @@
#include <stdio.h>
#include <errno.h>
#include <dlfcn.h>
+#include <limits.h>
#include "triton_p.h"
@@ -13,6 +14,8 @@ int load_modules(const char *name)
{
struct conf_sect_t *sect;
struct conf_option_t *opt;
+ char *fname;
+ char *path=".";
sect = conf_get_section(name);
if (!sect) {
@@ -20,29 +23,40 @@ int load_modules(const char *name)
return -1;
}
- char *cwd = getcwd(NULL,0);
+ fname = _malloc(PATH_MAX);
list_for_each_entry(opt, &sect->items, entry) {
if (!strcmp(opt->name,"path") && opt->val) {
- if (chdir(opt->val)) {
- fprintf(stderr,"loader: chdir '%s': %s\n", opt->val, strerror(errno));
- goto out_err;
- }
+ path = opt->val;
continue;
}
- if (!dlopen(opt->name, RTLD_NOW | RTLD_GLOBAL)) {
- fprintf(stderr,"loader: failed to load module '%s': %s\n",opt->name, dlerror());
- goto out_err;
+
+ strcpy(fname, path);
+ strcat(fname, "/");
+ strcat(fname, opt->name);
+ if (access(fname, F_OK)) {
+ strcpy(fname, path);
+ strcat(fname, "/lib");
+ strcat(fname, opt->name);
+ strcat(fname, ".so");
+ if (access(fname, F_OK)) {
+ strcpy(fname, opt->name);
+ if (access(opt->name, F_OK)) {
+ triton_log_error("loader: '%s' not found\n", opt->name);
+ continue;
+ }
+ }
+ }
+
+ if (!dlopen(fname, RTLD_NOW | RTLD_GLOBAL)) {
+ triton_log_error("loader: failed to load '%s': %s\n", opt->name, dlerror());
+ _free(fname);
+ return -1;
}
}
- chdir(cwd);
- free(cwd);
- return 0;
+ _free(fname);
-out_err:
- chdir(cwd);
- _free(cwd);
- return -1;
+ return 0;
}