diff options
-rw-r--r-- | libsandbox/wrapper-funcs/execve.c | 19 | ||||
-rw-r--r-- | libsbutil/sbutil.h | 1 |
2 files changed, 16 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: diff --git a/libsbutil/sbutil.h b/libsbutil/sbutil.h index 7a0db55..eef65bf 100644 --- a/libsbutil/sbutil.h +++ b/libsbutil/sbutil.h @@ -103,6 +103,7 @@ __attribute__((__format__(__printf__, 1, 2))) void sb_printf(const char *format, __attribute__((__format__(__printf__, 2, 3))) void sb_fdprintf(int fd, const char *format, ...); __attribute__((__format__(__printf__, 2, 0))) void sb_vfdprintf(int fd, const char *format, va_list args); __attribute__((__format__(__printf__, 3, 4))) void sb_efunc(const char *color, const char *hilight, const char *format, ...); +#define sb_fprintf(fp, ...) sb_fdprintf(fileno(fp), __VA_ARGS__) /* Macro for sb_read() to goto an label on error */ #define SB_WRITE(_fd, _buf, _count, _error) \ |