/[path-sandbox]/trunk/src/libsandbox.c
Gentoo

Diff of /trunk/src/libsandbox.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 215 Revision 216
36/* #define SB_MEM_DEBUG 1 */ 36/* #define SB_MEM_DEBUG 1 */
37 37
38#define open xxx_open 38#define open xxx_open
39#define open64 xxx_open64 39#define open64 xxx_open64
40 40
41#if defined(HAVE_GLIBC)
42# define _GNU_SOURCE
43#endif
41#include <dirent.h> 44#include <dirent.h>
42#include <dlfcn.h> 45#include <dlfcn.h>
43#include <errno.h> 46#include <errno.h>
44#include <fcntl.h> 47#include <fcntl.h>
45#include <libgen.h> 48#include <libgen.h>
180static void *get_dlsym(const char *symname, const char *symver) 183static void *get_dlsym(const char *symname, const char *symver)
181{ 184{
182 void *symaddr = NULL; 185 void *symaddr = NULL;
183 186
184 if (NULL == libc_handle) { 187 if (NULL == libc_handle) {
185#ifdef BROKEN_RTLD_NEXT 188#if defined(BROKEN_RTLD_NEXT) || !defined(RTLD_NEXT)
186 libc_handle = dlopen(LIBC_VERSION, RTLD_LAZY); 189 libc_handle = dlopen(LIBC_VERSION, RTLD_LAZY);
187 if (!libc_handle) { 190 if (!libc_handle) {
188 fprintf(stderr, "libsandbox: Can't dlopen libc: %s\n", 191 fprintf(stderr, "libsandbox: Can't dlopen libc: %s\n",
189 dlerror()); 192 dlerror());
190 exit(EXIT_FAILURE); 193 exit(EXIT_FAILURE);
301 * checking happy (don't want '/usr/lib' if we 304 * checking happy (don't want '/usr/lib' if we
302 * tried to do something with non-existing 305 * tried to do something with non-existing
303 * file '/usr/lib/cf*' ...) */ 306 * file '/usr/lib/cf*' ...) */
304 snprintf(tmp_str2, SB_PATH_MAX, "%s", path); 307 snprintf(tmp_str2, SB_PATH_MAX, "%s", path);
305 308
306 bname = basename(tmp_str2); 309 bname = gbasename(tmp_str2);
307 snprintf((char *)(filtered_path + strlen(filtered_path)), 310 snprintf((char *)(filtered_path + strlen(filtered_path)),
308 SB_PATH_MAX - strlen(filtered_path), "%s%s", 311 SB_PATH_MAX - strlen(filtered_path), "%s%s",
309 (filtered_path[strlen(filtered_path) - 1] != '/') ? "/" : "", 312 (filtered_path[strlen(filtered_path) - 1] != '/') ? "/" : "",
310 bname); 313 bname);
311 } 314 }
944 947
945 /* num_delimiters might be 0, and we need 2 entries at least */ 948 /* num_delimiters might be 0, and we need 2 entries at least */
946 pfx_array = malloc(((num_delimiters * 2) + 2) * sizeof(char *)); 949 pfx_array = malloc(((num_delimiters * 2) + 2) * sizeof(char *));
947 if (NULL == pfx_array) 950 if (NULL == pfx_array)
948 goto error; 951 goto error;
949 buffer = strndup(prefixes_env, prefixes_env_length); 952 buffer = gstrndup(prefixes_env, prefixes_env_length);
950 if (NULL == buffer) 953 if (NULL == buffer)
951 goto error; 954 goto error;
952 buffer_ptr = buffer; 955 buffer_ptr = buffer;
953 956
954#ifdef REENTRANT_STRTOK 957#ifdef REENTRANT_STRTOK

Legend:
Removed from v.215  
changed lines
  Added in v.216

  ViewVC Help
Powered by ViewVC 1.1.20