/[gentoo-alt]/trunk/sys-apps/portage/files/sandbox-1.1-fbsd.diff
Gentoo

Contents of /trunk/sys-apps/portage/files/sandbox-1.1-fbsd.diff

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3 - (show annotations) (download)
Tue Sep 14 22:52:12 2004 UTC (9 years, 11 months ago) by ka0ttic
File MIME type: text/plain
File size: 6125 byte(s)
Cleaned up sandbox patch; compiles cleanly with 0 errors or warnings (test!)

1 diff -urN sandbox-1.1.orig/Makefile sandbox-1.1/Makefile
2 --- sandbox-1.1.orig/Makefile Sun Mar 21 20:40:58 2004
3 +++ sandbox-1.1/Makefile Tue Sep 14 00:50:30 2004
4 @@ -16,7 +16,8 @@
5 LD ?= ld
6 CFLAGS =
7 ARCH_CFLAGS =
8 -OBJ_CFLAGS = -D_GNU_SOURCE -DPIC -fPIC -D_REENTRANT
9 +#OBJ_CFLAGS = -D_GNU_SOURCE -DPIC -fPIC -D_REENTRANT
10 +OBJ_CFLAGS = -DPIC -fPIC -D_REENTRANT -D__LIBC -DDIRENT -DHAVE_UNISTD_H -DSTDC_HEADERS
11 LIBS =
12 LDFLAGS =
13 DESTDIR =
14 @@ -34,7 +35,7 @@
15 all: $(TARGETS)
16
17 sandbox: sandbox.o sandbox_futils.o getcwd.c
18 - $(CC) $(CFLAGS) $(ARCH_CFLAGS) $(OBJ_CFLAGS) -Wall $^ -ldl -lc -o $@
19 + $(CC) $(CFLAGS) $(ARCH_CFLAGS) $(OBJ_CFLAGS) -Wall $^ -lc -o $@
20
21 sandbox.o: sandbox.c sandbox.h
22 $(CC) $(CFLAGS) $(ARCH_CFLAGS) $(OBJ_CFLAGS) -Wall -c sandbox.c -o $@
23 @@ -43,7 +44,7 @@
24 $(CC) $(CFLAGS) $(ARCH_CFLAGS) $(OBJ_CFLAGS) -Wall -c sandbox_futils.c -o $@
25
26 libsandbox.so: libsandbox.o sandbox_futils.o
27 - $(CC) $^ -shared $(ARCH_CFLAGS) -fPIC -ldl -lc -nostdlib -lgcc -o $@
28 + $(CC) $^ -shared $(ARCH_CFLAGS) -fPIC -lc -nostdlib -lgcc -o $@
29
30 libsandbox.o: localdecls.h libsandbox.c canonicalize.c getcwd.c
31 $(CC) $(CFLAGS) $(ARCH_CFLAGS) $(OBJ_CFLAGS) -Wall -c libsandbox.c
32 @@ -52,7 +53,7 @@
33 $(CC) $(CFLAGS) -m32 $(OBJ_CFLAGS) -Wall -c sandbox_futils.c -o $@
34
35 libsandbox32.so: libsandbox32.o sandbox_futils32.o
36 - $(CC) $^ -shared -m32 -fPIC -ldl -lc -nostdlib -lgcc -o $@
37 + $(CC) $^ -shared -m32 -fPIC -lc -nostdlib -lgcc -o $@
38
39 libsandbox32.o: libsandbox.c localdecls.h canonicalize.c getcwd.c
40 $(CC) $(CFLAGS) -m32 $(OBJ_CFLAGS) -Wall -c libsandbox.c -o $@
41 diff -urN sandbox-1.1.orig/canonicalize.c sandbox-1.1/canonicalize.c
42 --- sandbox-1.1.orig/canonicalize.c Sun Jul 27 10:31:50 2003
43 +++ sandbox-1.1/canonicalize.c Tue Sep 14 01:02:12 2004
44 @@ -23,6 +23,7 @@
45
46 #include <stdlib.h>
47 #include <string.h>
48 +#include <strings.h>
49 #include <unistd.h>
50 #include <limits.h>
51 #include <sys/param.h>
52 @@ -34,6 +35,13 @@
53 # define __set_errno(val) errno = (val)
54 #endif
55
56 +#ifndef __mempcpy
57 +void *__mempcpy(void *dest, const void *src, size_t n) {
58 + bcopy (src, dest, n);
59 + return (dest+n);
60 +}
61 +#endif /* ! __mempcpy */
62 +
63 /* Return the canonical absolute name of file NAME. A canonical name
64 does not contain any `.', `..' components nor any repeated path
65 separators ('/') or symlinks. All path components must exist. If
66 @@ -160,7 +168,12 @@
67 #endif
68 *dest = '\0';
69
70 - return resolved ? memcpy(resolved, rpath, dest - rpath + 1) : rpath;
71 + /*return resolved ? memcpy(resolved, rpath, dest - rpath + 1) : rpath;*/
72 + if (resolved) {
73 + memcpy(resolved, rpath, dest - rpath + 1);
74 + return resolved;
75 + }
76 + else return rpath;
77
78 error:
79 if (resolved)
80 diff -urN sandbox-1.1.orig/getcwd.c sandbox-1.1/getcwd.c
81 --- sandbox-1.1.orig/getcwd.c Sun Jul 27 08:31:06 2003
82 +++ sandbox-1.1/getcwd.c Tue Sep 14 00:49:58 2004
83 @@ -57,6 +57,10 @@
84 # include <stddef.h>
85 #endif
86
87 +#if !defined _GNU_SOURCE
88 +# define __ptr_t void *
89 +#endif /* ! _GNU_SOURCE */
90 +
91 #if !defined __GNU_LIBRARY__ && !defined STDC_HEADERS
92 extern int errno;
93 #endif
94 @@ -183,6 +187,9 @@
95 #if defined HAVE_LIMITS_H || defined STDC_HEADERS || defined __GNU_LIBRARY__
96 # include <limits.h>
97 #else
98 +# ifdef MAX
99 +# undef MAX
100 +# endif /* MAX */
101 # include <sys/param.h>
102 #endif
103
104 @@ -206,7 +213,7 @@
105 #ifndef __GNU_LIBRARY__
106 # define __lstat stat
107 #endif
108 -
109 +
110 #ifndef _LIBC
111 # define __getcwd getcwd
112 #endif
113 @@ -220,12 +227,19 @@
114 # define OUTSIDE_LIBSANDBOX
115 #endif
116
117 -#ifndef __LIBC
118 -# define __lstat lstat
119 +#ifdef __LIBC
120 # define __readdir readdir
121 # define __closedir closedir
122 #endif
123
124 +#if !defined(_D_ALLOC_NAMLEN)
125 +# define _D_ALLOC_NAMLEN(DP) ((DP)->d_namlen)
126 +#endif
127 +
128 +#if !defined(_D_EXACT_NAMLEN)
129 +# define _D_EXACT_NAMLEN(D) ((D)->d_namlen)
130 +#endif
131 +
132 /* Get the pathname of the current working directory, and put it in SIZE
133 bytes of BUF. Returns NULL if the directory couldn't be determined or
134 SIZE was too small. If successful, returns BUF. In GNU, if BUF is
135 @@ -437,10 +451,15 @@
136
137 /* Move current contents up to the end of the buffer.
138 This is guaranteed to be non-overlapping. */
139 +/*
140 pathp =
141 memcpy(tmp + allocated -
142 (path + oldsize - pathp),
143 tmp + (pathp - path), path + oldsize - pathp);
144 +*/
145 + memcpy(tmp + allocated - (path + oldsize - pathp),
146 + tmp + (pathp - path),
147 + path + oldsize - pathp);
148 path = tmp;
149 }
150 }
151 diff -urN sandbox-1.1.orig/libsandbox.c sandbox-1.1/libsandbox.c
152 --- sandbox-1.1.orig/libsandbox.c Mon Aug 2 14:49:31 2004
153 +++ sandbox-1.1/libsandbox.c Tue Sep 14 01:03:36 2004
154 @@ -180,7 +180,7 @@
155 static int (*true_rmdir) (const char *);
156 extern int symlink(const char *, const char *);
157 static int (*true_symlink) (const char *, const char *);
158 -extern int truncate(const char *, TRUNCATE_T);
159 +/* extern int truncate(const char *, TRUNCATE_T); */
160 static int (*true_truncate) (const char *, TRUNCATE_T);
161 extern int unlink(const char *);
162 static int (*true_unlink) (const char *);
163 @@ -538,7 +538,7 @@
164
165 if (flags & O_CREAT) {
166 va_start(ap, flags);
167 - mode = va_arg(ap, mode_t);
168 + mode = va_arg(ap, int);
169 va_end(ap);
170 }
171
172 @@ -609,6 +609,7 @@
173 return result;
174 }
175
176 +/* truncate() is provided by unistd.h
177 int
178 truncate(const char *path, TRUNCATE_T length)
179 {
180 @@ -625,6 +626,7 @@
181
182 return result;
183 }
184 +*/
185
186 int
187 unlink(const char *pathname)
188 @@ -952,7 +954,11 @@
189 if (num_delimiters > 0) {
190 *prefixes_array =
191 (char **) malloc((num_delimiters + 1) * sizeof (char *));
192 +#ifdef _GNU_SOURCE /* damn GNU extensions... */
193 buffer = strndupa(prefixes_env, prefixes_env_length);
194 +#else
195 + buffer = strncat(buffer, prefixes_env, prefixes_env_length);
196 +#endif /* _GNU_SOURCE */
197
198 #ifdef REENTRANT_STRTOK
199 token = strtok_r(buffer, ":", &buffer);
200 @@ -961,7 +967,11 @@
201 #endif
202
203 while ((NULL != token) && (strlen(token) > 0)) {
204 +#ifdef _GNU_SOURCE /* more icky GNU extensions */
205 prefix = strndup(token, strlen(token));
206 +#else
207 + prefix = strncat(prefix, token, strlen(token));
208 +#endif /* _GNU_SOURCE */
209 (*prefixes_array)[(*prefixes_num)++] = filter_path(prefix);
210
211 #ifdef REENTRANT_STRTOK

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.20