PERFORCE change 164537 for review
Robert Watson
rwatson at FreeBSD.org
Tue Jun 16 21:45:40 UTC 2009
http://perforce.freebsd.org/chv.cgi?CH=164537
Change 164537 by rwatson at rwatson_freebsd_capabilities on 2009/06/16 21:45:19
Rather than a compile-time decision about the use of sandbox
vs. non-sandbox API use in libcapability for starting
sandboxes, use ld_insandbox() to check whether we're in a
sandbox. Now we're back to needing only a single libcapability
compile, rather than two versions.
Affected files ...
.. //depot/projects/trustedbsd/capabilities/src/lib/libcapability/libcapability.h#19 edit
.. //depot/projects/trustedbsd/capabilities/src/lib/libcapability/libcapability_host.c#16 edit
Differences ...
==== //depot/projects/trustedbsd/capabilities/src/lib/libcapability/libcapability.h#19 (text+ko) ====
@@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $P4: //depot/projects/trustedbsd/capabilities/src/lib/libcapability/libcapability.h#18 $
+ * $P4: //depot/projects/trustedbsd/capabilities/src/lib/libcapability/libcapability.h#19 $
*/
#ifndef _LIBCAPABILITY_H_
@@ -133,5 +133,6 @@
* applications.
*/
int ld_caplibindex_lookup(const char *libname, int *fdp);
+int ld_insandbox(void);
#endif /* !_LIBCAPABILITY_H_ */
==== //depot/projects/trustedbsd/capabilities/src/lib/libcapability/libcapability_host.c#16 (text+ko) ====
@@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $P4: //depot/projects/trustedbsd/capabilities/src/lib/libcapability/libcapability_host.c#15 $
+ * $P4: //depot/projects/trustedbsd/capabilities/src/lib/libcapability/libcapability_host.c#16 $
*/
#include <sys/param.h>
@@ -245,46 +245,43 @@
return (-1);
bzero(lcsp, sizeof(*lcsp));
-#ifdef IN_CAP_MODE
- if (ld_caplibindex_lookup(LD_ELF_CAP_SO, &fd_ldso) < 0)
- goto out_error;
- if (ld_caplibindex_lookup(LIBC_SO, &fd_libc) < 0)
- goto out_error;
- if (ld_caplibindex_lookup(LIBZ_SO, &fd_libz) < 0)
- goto out_error;
- if (ld_caplibindex_lookup(LIBBZ2_SO, &fd_libbz2) < 0)
- goto out_error;
- if (ld_caplibindex_lookup(LIBCAPABILITY_SO, &fd_libcapability) < 0)
- goto out_error;
- if (ld_caplibindex_lookup(_PATH_DEVNULL, &fd_devnull) < 0)
- goto out_error;
-#else
- fd_ldso = open(PATH_LD_ELF_CAP_SO "/" LD_ELF_CAP_SO, O_RDONLY);
- if (fd_ldso < 0)
- goto out_error;
+ if (ld_insandbox()) {
+ if (ld_caplibindex_lookup(LD_ELF_CAP_SO, &fd_ldso) < 0)
+ goto out_error;
+ if (ld_caplibindex_lookup(LIBC_SO, &fd_libc) < 0)
+ goto out_error;
+ if (ld_caplibindex_lookup(LIBZ_SO, &fd_libz) < 0)
+ goto out_error;
+ if (ld_caplibindex_lookup(LIBBZ2_SO, &fd_libbz2) < 0)
+ goto out_error;
+ if (ld_caplibindex_lookup(LIBCAPABILITY_SO,
+ &fd_libcapability) < 0)
+ goto out_error;
+ if (ld_caplibindex_lookup(_PATH_DEVNULL, &fd_devnull) < 0)
+ goto out_error;
+ } else {
+ fd_ldso = open(PATH_LD_ELF_CAP_SO "/" LD_ELF_CAP_SO,
+ O_RDONLY);
+ if (fd_ldso < 0)
+ goto out_error;
+ fd_libc = open(_PATH_LIB "/" LIBC_SO, O_RDONLY);
+ if (fd_libc < 0)
+ goto out_error;
+ fd_libz = open(_PATH_LIB "/" LIBZ_SO, O_RDONLY);
+ if (fd_libz < 0)
+ goto out_error;
+ fd_libbz2 = open(_PATH_USR_LIB "/" LIBBZ2_SO, O_RDONLY);
+ if (fd_libbz2 < 0)
+ goto out_error;
+ fd_libcapability = open(_PATH_USR_LIB "/" LIBCAPABILITY_SO,
+ O_RDONLY);
+ if (fd_libcapability < 0)
+ goto out_error;
+ fd_devnull = open(_PATH_DEVNULL, O_RDWR);
+ if (fd_devnull < 0)
+ goto out_error;
+ }
- fd_libc = open(_PATH_LIB "/" LIBC_SO, O_RDONLY);
- if (fd_libc < 0)
- goto out_error;
-
- fd_libz = open(_PATH_LIB "/" LIBZ_SO, O_RDONLY);
- if (fd_libz < 0)
- goto out_error;
-
- fd_libbz2 = open(_PATH_USR_LIB "/" LIBBZ2_SO, O_RDONLY);
- if (fd_libbz2 < 0)
- goto out_error;
-
- fd_libcapability = open(_PATH_USR_LIB "/" LIBCAPABILITY_SO,
- O_RDONLY);
- if (fd_libcapability < 0)
- goto out_error;
-
- fd_devnull = open(_PATH_DEVNULL, O_RDWR);
- if (fd_devnull < 0)
- goto out_error;
-#endif
-
if (socketpair(PF_LOCAL, SOCK_STREAM, 0, fd_sockpair) < 0)
goto out_error;
@@ -357,7 +354,6 @@
return (lch_startfd_flags(fd_sandbox, binname, argv, 0, lcspp));
}
-#ifndef IN_CAP_MODE
int
lch_start_flags(const char *sandbox, char *const argv[], u_int flags,
struct lc_sandbox **lcspp)
@@ -385,7 +381,6 @@
return (lch_start_flags(sandbox, argv, 0, lcspp));
}
-#endif
void
lch_stop(struct lc_sandbox *lcsp)
More information about the p4-projects
mailing list