aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2009-03-11 07:28:09 -0400
committerMike Frysinger <vapier@gentoo.org>2009-03-11 10:23:58 -0400
commit99e318c1a2640091204f970a2e9ff4bdc238980d (patch)
treeacbb87b380e0c7e5e54194328400dafff658c842 /libsandbox/wrapper-funcs
parentimprove configure argument recording (diff)
downloadsandbox-99e318c1a2640091204f970a2e9ff4bdc238980d.tar.gz
sandbox-99e318c1a2640091204f970a2e9ff4bdc238980d.tar.bz2
sandbox-99e318c1a2640091204f970a2e9ff4bdc238980d.zip
libsandbox: dump exec QA static notice to /dev/tty
Rather than dump the QA static notice to stderr when trying to execute a static binary, write directly to /dev/tty. This prevents breaking things like testsuites that validate the exact stderr output. URL: http://bugs.gentoo.org/261957 Signed-off-by: Mike Frysinger <vapier@gentoo.org> Reported-by: Kent Fredric <kentfredric@gmail.com>
Diffstat (limited to 'libsandbox/wrapper-funcs')
-rw-r--r--libsandbox/wrapper-funcs/execve.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/libsandbox/wrapper-funcs/execve.c b/libsandbox/wrapper-funcs/execve.c
index 90ffe1c..f36b012 100644
--- a/libsandbox/wrapper-funcs/execve.c
+++ b/libsandbox/wrapper-funcs/execve.c
@@ -12,6 +12,7 @@
#define WRAPPER_ARGS filename, argv, envp
extern int EXTERN_NAME(WRAPPER_ARGS_PROTO);
static int (*WRAPPER_TRUE_NAME)(WRAPPER_ARGS_PROTO) = NULL;
+static FILE *tty_fp = NULL;
/* See to see if this an ELF and if so, is it static which we can't wrap */
static void check_exec(const char *filename, char *const argv[])
@@ -20,6 +21,11 @@ static void check_exec(const char *filename, char *const argv[])
unsigned char *elf;
struct stat st;
+ if (!tty_fp)
+ tty_fp = fopen("/dev/tty", "ae");
+ if (!tty_fp)
+ return;
+
#ifdef __linux__
/* Filter some common safe static things */
if (!strncmp(argv[0], "/lib", 4) && strstr(argv[0], ".so.")) {
@@ -68,14 +74,19 @@ static void check_exec(const char *filename, char *const argv[])
else
PARSE_ELF(64);
- SB_EWARN("QA: Static ELF", " %s: ", filename);
+ /* Write to tty_fd because stderr is not always 100% safe. If running
+ * tests and validating output, this may break things. #261957
+ * Writing to /dev/tty directly might annoy some people ... perhaps
+ * we should attempt to hijack the log fd from portage ...
+ */
+ sb_fprintf(tty_fp, "QA: Static ELF: %s: ", filename);
size_t i;
for (i = 0; argv[i]; ++i)
if (strchr(argv[i], ' '))
- sb_printf("'%s' ", argv[i]);
+ sb_fprintf(tty_fp, "'%s' ", argv[i]);
else
- sb_printf("%s ", argv[i]);
- sb_printf("\n");
+ sb_fprintf(tty_fp, "%s ", argv[i]);
+ sb_fprintf(tty_fp, "\n");
done: