From: Nicolas Thill Date: Sun, 16 Sep 2007 19:06:01 +0000 (+0000) Subject: fix updatedd service plugin lookup and loading X-Git-Url: http://git.openwrt.org/?p=openwrt%2Fsvn-archive%2Farchive.git;a=commitdiff_plain;h=6b96184ac1e7087e523dde19d4aa83e9f25607c9;hp=f4c16b768b8ee2a0f83a9c46101255d63514dc01 fix updatedd service plugin lookup and loading SVN-Revision: 8810 --- diff --git a/net/updatedd/patches/001-service_libname.patch b/net/updatedd/patches/001-service_libname.patch new file mode 100644 index 0000000000..a4750516ef --- /dev/null +++ b/net/updatedd/patches/001-service_libname.patch @@ -0,0 +1,86 @@ +Index: updatedd-2.6/src/updatedd.c +=================================================================== +--- updatedd-2.6.orig/src/updatedd.c 2007-09-16 21:00:07.000000000 +0200 ++++ updatedd-2.6/src/updatedd.c 2007-09-16 21:00:07.000000000 +0200 +@@ -36,7 +36,8 @@ + #include /* PATH_MAX */ + #include "updatedd.h" + +-#define PLUGIN_ENDING ".so" ++#define LIBPREFIX "lib" ++#define LIBSUFFIX ".so" + + void + print_usage(char *pname, FILE *fp) +@@ -92,23 +93,7 @@ + void + get_plugin_path(char *service, char *buffer, size_t len) + { +- FILE *pipe; +- char la_path[PATH_MAX]; +- char lib_name[256]; +- char command[1024]; +- +- (void)snprintf(la_path, PATH_MAX-1, LIBPATH "/lib%s.la", service); +- +- snprintf(command, 1023, ". %s; echo $dlname", la_path); +- if((pipe = popen(command, "r")) == NULL) +- err(PERR, "popen() failed"); +- fscanf(pipe, "%255s", lib_name); +- +- if(fclose(pipe) == EOF) +- err(PERR, "fclose() failed"); +- +- (void)memset(buffer, 0, len); +- snprintf(buffer, len-1, LIBPATH"/%s", lib_name); ++ snprintf(buffer, len-1, LIBPATH "/" LIBPREFIX "%s" LIBSUFFIX, service); + } + + void * +@@ -139,6 +124,7 @@ + + } + ++#define SERVICE_MAXLEN 20 + int + get_service(DIR *dir, char *buf, size_t size) + { +@@ -146,26 +132,19 @@ + struct dirent *dir_info; + + while( (dir_info = readdir(dir)) ) { ++ char *p = dir_info->d_name; + int n; +- char *ptr = strstr(dir_info->d_name, ".la"); +- +- if(strlen(dir_info->d_name) < 6) +- continue; +- +- if(ptr != NULL) { +- if(!dir_info->d_name[0] == 'l') +- continue; +- if(!dir_info->d_name[1] == 'i') +- continue; +- if(!dir_info->d_name[2] == 'b') +- continue; +- +- for(n = 0; dir_info->d_name+n+3 != ptr; n++) { +- buf[n] = dir_info->d_name[n+3]; +- } +- buf[n] = '\0'; +- return 1; +- } ++ if( strlen(p) <= strlen(LIBPREFIX LIBSUFFIX) ) ++ continue; ++ if( strstr(p, LIBPREFIX) != p ) ++ continue; ++ p += strlen(LIBPREFIX); ++ n = strlen(p) - strlen(LIBSUFFIX); ++ if( strstr(p + n, LIBSUFFIX) != p + n ) ++ continue; ++ p[n] = 0; ++ strncpy(buf, p, size); ++ return 1; + } + + return 0;