diff options
author | 2012-06-22 14:19:14 -0700 | |
---|---|---|
committer | 2012-06-23 18:02:43 -0400 | |
commit | 40abb498ca4a24495fe34e133379382ce8c3eaca (patch) | |
tree | a8779b17558a4c96eb2d5c56e82cee4743d408aa /src | |
parent | use m4_flatten to make multiline lists easier to handle (diff) | |
download | sandbox-40abb498ca4a24495fe34e133379382ce8c3eaca.tar.gz sandbox-40abb498ca4a24495fe34e133379382ce8c3eaca.tar.bz2 sandbox-40abb498ca4a24495fe34e133379382ce8c3eaca.zip |
significantly overhaul output helpers
There are a few major points we want to hit here:
- have all output from libsandbox go through portage helpers when we are
in the portage environment so that output is properly logged
- convert SB_E{info,warn,error} to sb_e{info,warn,error} to match style
of other functions and cut down on confusion
- move all abort/output helpers to libsbutil so it can be used in all
source trees and not just by libsandbox
- migrate all abort points to the centralized sb_ebort helper
Unfortunately, it's not terribly easy to untangle these into separate
patches, but hopefully this shouldn't be too messy as much of it is
mechanical: move funcs between files, and change the name of funcs
that get called.
URL: http://bugs.gentoo.org/278761
Reported-by: Mounir Lamouri <volkmar@gentoo.org>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 6 | ||||
-rw-r--r-- | src/sandbox.c | 17 |
2 files changed, 7 insertions, 16 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 3e7e31c..c3c1f45 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -13,9 +13,3 @@ sandbox_SOURCES = \ environ.c \ sandbox.h \ sandbox.c - -install-exec-hook: - sed -i.tmp \ - 's:__SANDBOX_TESTING:\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00:' \ - $(DESTDIR)$(bindir)/sandbox - rm -f $(DESTDIR)$(bindir)/sandbox.tmp diff --git a/src/sandbox.c b/src/sandbox.c index 69ab18e..54fbb98 100644 --- a/src/sandbox.c +++ b/src/sandbox.c @@ -19,14 +19,14 @@ static int print_debug = 0; #define dprintf(fmt, args...) do { if (print_debug) printf(fmt, ## args); } while (0) #define dputs(str) do { if (print_debug) puts(str); } while (0) int (*sbio_open)(const char *, int, mode_t) = (void *)open; +FILE *(*sbio_popen)(const char *, const char *) = popen; volatile static int stop_called = 0; volatile static pid_t child_pid = 0; static const char sandbox_banner[] = "============================= Gentoo path sandbox =============================="; static const char sandbox_footer[] = "--------------------------------------------------------------------------------"; - -const char env_sandbox_testing[] = "__SANDBOX_TESTING"; +const char sbio_fallback_path[] = "/dev/stderr"; static int setup_sandbox(struct sandbox_info_t *sandbox_info, bool interactive) { @@ -87,7 +87,7 @@ static void print_sandbox_log(char *sandbox_log) { int sandbox_log_file; size_t len; - char buffer[1024]; + char buffer[8192]; sandbox_log_file = sb_open(sandbox_log, O_RDONLY, 0); if (-1 == sandbox_log_file) { @@ -95,8 +95,8 @@ static void print_sandbox_log(char *sandbox_log) return; } - SB_EERROR("--------------------------- ACCESS VIOLATION SUMMARY ---------------------------", "\n"); - SB_EERROR("LOG FILE", " \"%s\"\n\n", sandbox_log); + sb_eerror("--------------------------- ACCESS VIOLATION SUMMARY ---------------------------\n"); + sb_eerror("LOG FILE: \"%s\"\n", sandbox_log); while (1) { len = sb_read(sandbox_log_file, buffer, sizeof(buffer)); @@ -105,14 +105,11 @@ static void print_sandbox_log(char *sandbox_log) break; } else if (!len) break; - if (sb_write(STDERR_FILENO, buffer, len) != len) { - sb_pwarn("sb_write(logfile) failed"); - break; - } + sb_eerror("\n%s", buffer); } sb_close(sandbox_log_file); - SB_EERROR("--------------------------------------------------------------------------------", "\n"); + sb_eerror("--------------------------------------------------------------------------------\n"); } static void stop(int signum) |