/[path-sandbox]/trunk/sandbox_futils.c
Gentoo

Diff of /trunk/sandbox_futils.c

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

Revision 82 Revision 92
37/* glibc modified getcwd() functions */ 37/* glibc modified getcwd() functions */
38SB_STATIC char *egetcwd(char *, size_t); 38SB_STATIC char *egetcwd(char *, size_t);
39 39
40SB_STATIC char *get_sandbox_path(char *argv0) 40SB_STATIC char *get_sandbox_path(char *argv0)
41{ 41{
42 char path[255]; 42 char path[SB_PATH_MAX];
43 char *cwd = NULL;
44 43
45 memset(path, 0, sizeof(path)); 44 memset(path, 0, sizeof(path));
46 /* ARGV[0] specifies full path */ 45 /* ARGV[0] specifies full path */
47 if (argv0[0] == '/') { 46 if (argv0[0] == '/') {
48 strncpy(path, argv0, sizeof(path) - 1); 47 strncpy(path, argv0, sizeof(path) - 1);
49 48
50 /* ARGV[0] specifies relative path */ 49 /* ARGV[0] specifies relative path */
51 } else { 50 } else {
52 egetcwd(cwd, sizeof(path) - 2); 51 if (-1 != readlink("/proc/self/exe", path, sizeof(path)))
53 snprintf(path, sizeof(path), "%s/%s", cwd, argv0); 52 path[sizeof(path) - 1] = '\0';
54 if (cwd) 53 else
55 free(cwd); 54 path[0] = '\0';
56 cwd = NULL;
57 } 55 }
58 56
59 /* Return just directory */ 57 /* Return just directory */
60 return (sb_dirname(path)); 58 return (sb_dirname(path));
61} 59}
62 60
63SB_STATIC char *get_sandbox_lib(char *sb_path) 61SB_STATIC char *get_sandbox_lib(char *sb_path)
64{ 62{
65 char path[255]; 63 char path[SB_PATH_MAX];
66 64
67#ifdef SB_HAVE_64BIT_ARCH 65#ifdef SB_HAVE_64BIT_ARCH
68 snprintf(path, sizeof(path), "%s", LIB_NAME); 66 snprintf(path, sizeof(path), "%s", LIB_NAME);
69#else 67#else
70 snprintf(path, sizeof(path), "%s/%s", LIBSANDBOX_PATH, LIB_NAME); 68 snprintf(path, sizeof(path), "%s/%s", LIBSANDBOX_PATH, LIB_NAME);
83 return (strdup(PIDS_FILE)); 81 return (strdup(PIDS_FILE));
84} 82}
85 83
86SB_STATIC char *get_sandbox_rc(char *sb_path) 84SB_STATIC char *get_sandbox_rc(char *sb_path)
87{ 85{
88 char path[255]; 86 char path[SB_PATH_MAX];
89 87
90 snprintf(path, sizeof(path), "%s/%s", SANDBOX_BASHRC_PATH, BASHRC_NAME); 88 snprintf(path, sizeof(path), "%s/%s", SANDBOX_BASHRC_PATH, BASHRC_NAME);
91 if (file_exist(path, 0) <= 0) { 89 if (file_exist(path, 0) <= 0) {
92 snprintf(path, sizeof(path), "%s%s", sb_path, BASHRC_NAME); 90 snprintf(path, sizeof(path), "%s%s", sb_path, BASHRC_NAME);
93 } 91 }
94 return (strdup(path)); 92 return (strdup(path));
95} 93}
96 94
97SB_STATIC char *get_sandbox_log() 95SB_STATIC char *get_sandbox_log()
98{ 96{
99 char path[255]; 97 char path[SB_PATH_MAX];
100 char *sandbox_log_env = NULL; 98 char *sandbox_log_env = NULL;
101 99
102 /* THIS CHUNK BREAK THINGS BY DOING THIS: 100 /* THIS CHUNK BREAK THINGS BY DOING THIS:
103 * SANDBOX_LOG=/tmp/sandbox-app-admin/superadduser-1.0.7-11063.log 101 * SANDBOX_LOG=/tmp/sandbox-app-admin/superadduser-1.0.7-11063.log
104 */ 102 */

Legend:
Removed from v.82  
changed lines
  Added in v.92

  ViewVC Help
Powered by ViewVC 1.1.20