diff options
author | 2006-07-09 19:13:57 +0000 | |
---|---|---|
committer | 2006-07-09 19:13:57 +0000 | |
commit | af23d1cbc9351808befde8e61da51ce202eaaa64 (patch) | |
tree | 3aac0dab22ed88d4293bd28021e690ff2daf103e | |
parent | Reformat previous added code a bit, and add debug messages (diff) | |
download | sandbox-af23d1cbc9351808befde8e61da51ce202eaaa64.tar.gz sandbox-af23d1cbc9351808befde8e61da51ce202eaaa64.tar.bz2 sandbox-af23d1cbc9351808befde8e61da51ce202eaaa64.zip |
As we are using a symbol map for libsandbox, its no longer needed
to have all the internal functions static, and thus we can break
things out a bit and make the source layout more sane. Start by
moving librcutil to libsbutil, and adding all the defines and
helper functions needed by both libsandbox and sandbox.
Signed-off-by: Martin Schlemmer <azarah@gentoo.org>
-rw-r--r-- | Makefile.am | 4 | ||||
-rw-r--r-- | configure.ac | 5 | ||||
-rw-r--r-- | libsbutil/Makefile.am (renamed from librcutil/Makefile.am) | 15 | ||||
-rw-r--r-- | libsbutil/sbutil.c (renamed from src/sandbox_utils.c) | 38 | ||||
-rw-r--r-- | libsbutil/sbutil.h (renamed from src/sandbox.h) | 47 | ||||
-rw-r--r-- | src/Makefile.am | 32 | ||||
-rw-r--r-- | src/canonicalize.c | 2 | ||||
-rw-r--r-- | src/libsandbox.c | 3 | ||||
-rw-r--r-- | src/sandbox.c | 3 |
9 files changed, 88 insertions, 61 deletions
diff --git a/Makefile.am b/Makefile.am index 2cf257b..6171de7 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,7 +1,7 @@ AUTOMAKE_OPTIONS = dist-bzip2 no-dist-gzip -SUBDIRS = scripts etc data librcutil src +SUBDIRS = scripts etc data libsbutil src -src: librcutil +src: libsbutil EXTRA_DIST = localdecls.h ChangeLog.0 diff --git a/configure.ac b/configure.ac index cb70031..8c47148 100644 --- a/configure.ac +++ b/configure.ac @@ -193,11 +193,14 @@ if test x"$enable_multilib" != xno ; then AC_DEFINE([SB_HAVE_MULTILIB], [1], [Have multilib enabled system]) fi +SANDBOX_DEFINES='-DETCDIR="\"$(sysconfdir)\"" -DLIBSANDBOX_PATH="\"$(libdir)\"" -DSANDBOX_BASHRC_PATH="\"$(pkgdatadir)\""' +AC_SUBST([SANDBOX_DEFINES]) + AC_OUTPUT([ Makefile scripts/Makefile etc/Makefile data/Makefile - librcutil/Makefile + libsbutil/Makefile src/Makefile ]) diff --git a/librcutil/Makefile.am b/libsbutil/Makefile.am index 8a61775..a3229c2 100644 --- a/librcutil/Makefile.am +++ b/libsbutil/Makefile.am @@ -1,10 +1,18 @@ AUTOMAKE_OPTIONS = foreign +AM_CPPFLAGS = \ + $(SANDBOX_DEFINES) \ + -DPIC -fPIC -D_REENTRANT \ + -I$(top_srcdir) -Wall + INCLUDES = -I$(srcdir)/include +LOCAL_INCLUDES = $(top_srcdir)/localdecls.h -noinst_LTLIBRARIES = librcutil.la +noinst_LTLIBRARIES = libsbutil.la -librcutil_la_SOURCES = \ +libsbutil_la_SOURCES = \ + sbutil.h \ + sbutil.c \ include/rcscripts/rctypes.h \ include/rcscripts/rcutil.h \ include/rcscripts/util/list.h \ @@ -19,5 +27,6 @@ librcutil_la_SOURCES = \ include/rcscripts/util/config.h \ src/config.c \ include/rcscripts/util/dynbuf.h \ - src/dynbuf.c + src/dynbuf.c \ + $(LOCAL_INCLUDES) diff --git a/src/sandbox_utils.c b/libsbutil/sbutil.c index 0ce60ab..877b5f3 100644 --- a/src/sandbox_utils.c +++ b/libsbutil/sbutil.c @@ -1,13 +1,32 @@ /* - * Copyright (C) 2002 Brad House <brad@mainstreetsoftworks.com> - * Distributed under the terms of the GNU General Public License, v2 or later - * Author: Brad House <brad@mainstreetsoftworks.com> - * Author: Martin Schlemmer <azarah@gentoo.org> + * sbutil.c + * + * Util functions. + * + * Copyright 1999-2006 Gentoo Foundation + * + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Some parts might have Copyright: + * + * Copyright (C) 2002 Brad House <brad@mainstreetsoftworks.com> * * $Header$ - * */ + #include <errno.h> #include <stdio.h> #include <stdlib.h> @@ -18,10 +37,7 @@ #include <fcntl.h> #include <libgen.h> -#include "config.h" -#include "localdecls.h" - -#include "sandbox.h" +#include "sbutil.h" void get_sandbox_lib(char *path) { @@ -35,8 +51,6 @@ void get_sandbox_lib(char *path) #endif } -#ifdef OUTSIDE_LIBSANDBOX - void get_sandbox_rc(char *path) { snprintf(path, SB_PATH_MAX, "%s/%s", SANDBOX_BASHRC_PATH, BASHRC_NAME); @@ -106,8 +120,6 @@ long file_length(int fd) return (st.st_size); } -#endif /* OUTSIDE_LIBSANDBOX */ - bool is_env_on (const char *env) { if ((NULL != env) && (NULL != getenv(env)) && diff --git a/src/sandbox.h b/libsbutil/sbutil.h index a9cd3b4..64ff907 100644 --- a/src/sandbox.h +++ b/libsbutil/sbutil.h @@ -1,18 +1,37 @@ -/* - * Copyright (C) 2002 Brad House <brad@mainstreetsoftworks.com>, - * Possibly based on code from Geert Bevin, Uwyn, http://www.uwyn.com - * Distributed under the terms of the GNU General Public License, v2 or later - * Author: Brad House <brad@mainstreetsoftworks.com> - * +/* + * sbutil.h + * + * Util defines. + * + * Copyright 1999-2006 Gentoo Foundation + * + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Some parts might have Copyright: + * + * Copyright (C) 2002 Brad House <brad@mainstreetsoftworks.com> + * * $Header$ */ -#ifndef __SANDBOX_H__ -#define __SANDBOX_H__ +#ifndef __SBUTIL_H__ +#define __SBUTIL_H__ -#include "localdecls.h" #include "config.h" -#include "rcscripts/rctypes.h" +#include "localdecls.h" +#include "include/rcscripts/rcutil.h" #define SANDBOX_CONF_FILE ETCDIR "/sandbox.conf" #define SANDBOX_CONFD_DIR ETCDIR "/sandbox.d" @@ -99,22 +118,16 @@ } while (0) void get_sandbox_lib(char *path); -#ifdef OUTSIDE_LIBSANDBOX void get_sandbox_rc(char *path); void get_sandbox_log(char *path); void get_sandbox_debug_log(char *path); int get_tmp_dir(char *path); long file_length(int); -#endif /* OUTSIDE_LIBSANDBOX */ bool is_env_on (const char *); bool is_env_off (const char *); /* glibc modified realpath() function */ char *erealpath(const char *, char *); -#ifndef OUTSIDE_LIBSANDBOX char *egetcwd(char *, size_t); -#endif /* !OUTSIDE_LIBSANDBOX */ - -#endif /* __SANDBOX_H__ */ -// vim:noexpandtab noai:cindent ai +#endif /* __SBUTIL_H__ */ diff --git a/src/Makefile.am b/src/Makefile.am index c5ae5ce..bc551c8 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -4,44 +4,36 @@ lib_LTLIBRARIES = libsandbox.la bin_PROGRAMS = sandbox AM_CPPFLAGS = \ - -DPIC -fPIC -D_REENTRANT \ - -DETCDIR=\"$(sysconfdir)\" \ - -DLIBSANDBOX_PATH=\"$(libdir)\" \ - -DSANDBOX_BASHRC_PATH=\"$(pkgdatadir)\" \ + $(SANDBOX_DEFINES) \ + -DPIC -fPIC -D_REENTRANT \ -I$(top_srcdir) -Wall -INCLUDES = -I$(top_srcdir)/librcutil/include -LOCAL_INCLUDES = $(top_srcdir)/localdecls.h +INCLUDES = \ + -I$(top_srcdir)/libsbutil \ + -I$(top_srcdir)/libsbutil/include # We need -fexceptions here, else we do not catch exceptions # (nptl/tst-cancelx4.c in glibc among others fails for wrapped functions). libsandbox_la_CFLAGS = -fexceptions # Could use the following to libsandbox_la_LIBADD, but then libtool links it # with --whole-archive: -# $(top_builddir)/librcutil/librcutil.la -libsandbox_la_LIBRCOBJS = $(wildcard $(top_builddir)/librcutil/*.lo) +# $(top_builddir)/libsbutil/libsbutil.la +libsandbox_la_LIBSBOBJS = $(wildcard $(top_builddir)/libsbutil/*.lo) libsandbox_la_LIBADD = \ -lc $(LIBDL) \ - $(libsandbox_la_LIBRCOBJS) -# $(top_builddir)/librcutil/.libs/librcutil.a + $(libsandbox_la_LIBSBOBJS) # Do not add -nostdlib or -nostartfiles, as then our constructor # and destructor will not be executed ... libsandbox_la_LDFLAGS = \ -nodefaultlibs \ -Wl,--version-script,libsandbox.map libsandbox_la_SOURCES = \ - libsandbox.c \ - canonicalize.c \ - sandbox_utils.c \ - $(LOCAL_INCLUDES) + libsandbox.c \ + canonicalize.c sandbox_CFLAGS = -DOUTSIDE_LIBSANDBOX -sandbox_LDADD = $(top_builddir)/librcutil/librcutil.la -sandbox_SOURCES = \ - sandbox.c \ - sandbox.h \ - sandbox_utils.c \ - $(LOCAL_INCLUDES) +sandbox_LDADD = $(top_builddir)/libsbutil/libsbutil.la +sandbox_SOURCES = sandbox.c libsandbox.c: libsandbox.map symbols.h diff --git a/src/canonicalize.c b/src/canonicalize.c index 8a5c989..c23ae7c 100644 --- a/src/canonicalize.c +++ b/src/canonicalize.c @@ -34,7 +34,7 @@ #include "config.h" #include "localdecls.h" -#include "sandbox.h" +#include "sbutil.h" #ifndef __set_errno # define __set_errno(val) errno = (val) diff --git a/src/libsandbox.c b/src/libsandbox.c index f40e81c..83042a7 100644 --- a/src/libsandbox.c +++ b/src/libsandbox.c @@ -72,8 +72,7 @@ #undef open #undef open64 -#include "sandbox.h" -#include "rcscripts/rcutil.h" +#include "sbutil.h" #define LOG_VERSION "1.0" #define LOG_STRING "VERSION " LOG_VERSION "\n" diff --git a/src/sandbox.c b/src/sandbox.c index 11c6c2e..f4b9478 100644 --- a/src/sandbox.c +++ b/src/sandbox.c @@ -27,8 +27,7 @@ #include <unistd.h> #include <fcntl.h> -#include "sandbox.h" -#include "rcscripts/rcutil.h" +#include "sbutil.h" struct sandbox_info_t { char sandbox_log[SB_PATH_MAX]; |