summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/apps.c20
-rw-r--r--apps/apps.h6
-rw-r--r--apps/openssl.c1
-rw-r--r--util/perl/OpenSSL/Test.pm4
4 files changed, 29 insertions, 2 deletions
diff --git a/apps/apps.c b/apps/apps.c
index 834cedd5a3..0438bdb9bf 100644
--- a/apps/apps.c
+++ b/apps/apps.c
@@ -1,5 +1,5 @@
/*
- * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the OpenSSL license (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
@@ -2428,14 +2428,26 @@ BIO *dup_bio_in(int format)
BIO_NOCLOSE | (istext(format) ? BIO_FP_TEXT : 0));
}
+static BIO_METHOD *prefix_method = NULL;
+
BIO *dup_bio_out(int format)
{
BIO *b = BIO_new_fp(stdout,
BIO_NOCLOSE | (istext(format) ? BIO_FP_TEXT : 0));
+ void *prefix = NULL;
+
#ifdef OPENSSL_SYS_VMS
if (istext(format))
b = BIO_push(BIO_new(BIO_f_linebuffer()), b);
#endif
+
+ if (istext(format) && (prefix = getenv("HARNESS_OSSL_PREFIX")) != NULL) {
+ if (prefix_method == NULL)
+ prefix_method = apps_bf_prefix();
+ b = BIO_push(BIO_new(prefix_method), b);
+ BIO_ctrl(b, PREFIX_CTRL_SET_PREFIX, 0, prefix);
+ }
+
return b;
}
@@ -2450,6 +2462,12 @@ BIO *dup_bio_err(int format)
return b;
}
+void destroy_prefix_method()
+{
+ BIO_meth_free(prefix_method);
+ prefix_method = NULL;
+}
+
void unbuffer(FILE *fp)
{
/*
diff --git a/apps/apps.h b/apps/apps.h
index 272b967d18..daaef369bc 100644
--- a/apps/apps.h
+++ b/apps/apps.h
@@ -55,6 +55,12 @@ BIO_METHOD *apps_bf_prefix(void);
* remains unlikely for the foreseeable future and beyond.
*/
#define PREFIX_CTRL_SET_PREFIX (1 << 15)
+/*
+ * apps_bf_prefix() returns a dynamically created BIO_METHOD, which we
+ * need to destroy at some point. When created internally, it's stored
+ * in an internal pointer which can be freed with the following function
+ */
+void destroy_prefix_method(void);
BIO *dup_bio_in(int format);
BIO *dup_bio_out(int format);
diff --git a/apps/openssl.c b/apps/openssl.c
index fe1eabdede..fffa05e1c7 100644
--- a/apps/openssl.c
+++ b/apps/openssl.c
@@ -93,6 +93,7 @@ static int apps_startup()
static void apps_shutdown()
{
destroy_ui_method();
+ destroy_prefix_method();
}
static char *make_config_name()
diff --git a/util/perl/OpenSSL/Test.pm b/util/perl/OpenSSL/Test.pm
index 4afbf8551c..e363a48473 100644
--- a/util/perl/OpenSSL/Test.pm
+++ b/util/perl/OpenSSL/Test.pm
@@ -1,4 +1,4 @@
-# Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
+# Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.
#
# Licensed under the OpenSSL license (the "License"). You may not use
# this file except in compliance with the License. You can obtain a copy
@@ -476,7 +476,9 @@ sub run {
}
close $pipe;
} else {
+ $ENV{HARNESS_OSSL_PREFIX} = "# ";
system("$prefix$cmd");
+ delete $ENV{HARNESS_OSSL_PREFIX};
}
$e = ($? & 0x7f) ? ($? & 0x7f)|0x80 : ($? >> 8);
$r = $hooks{exit_checker}->($e);