? pledge_err.diff
Index: asn1pars.c
===================================================================
RCS file: /cvs/src/usr.bin/openssl/asn1pars.c,v
retrieving revision 1.6
diff -u -p -r1.6 asn1pars.c
--- asn1pars.c	17 Oct 2015 15:00:11 -0000	1.6
+++ asn1pars.c	4 Apr 2016 21:59:06 -0000
@@ -64,6 +64,7 @@
 #include <stdlib.h>
 #include <limits.h>
 #include <string.h>
+#include <err.h>
 
 #include "apps.h"
 #include "progs.h"
@@ -247,12 +248,9 @@ asn1parse_main(int argc, char **argv)
 	BUF_MEM *buf = NULL;
 	ASN1_TYPE *at = NULL;
 
-	if (single_execution) {
-		if (pledge("stdio rpath wpath cpath", NULL) == -1) {
-			perror("pledge");
-			exit(1);
-		}
-	}
+	if (single_execution)
+		if (pledge("stdio rpath wpath cpath", NULL) == -1)
+			err(1, "pledge");
 
 	memset(&asn1pars_config, 0, sizeof(asn1pars_config));
 
Index: ca.c
===================================================================
RCS file: /cvs/src/usr.bin/openssl/ca.c,v
retrieving revision 1.20
diff -u -p -r1.20 ca.c
--- ca.c	24 Dec 2015 16:54:37 -0000	1.20
+++ ca.c	4 Apr 2016 21:59:07 -0000
@@ -66,6 +66,7 @@
 #include <limits.h>
 #include <string.h>
 #include <unistd.h>
+#include <err.h>
 
 #include "apps.h"
 
@@ -286,12 +287,9 @@ ca_main(int argc, char **argv)
 	const char *errstr = NULL;
 	DB_ATTR db_attr;
 
-	if (single_execution) {
-		if (pledge("stdio rpath wpath cpath tty", NULL) == -1) {
-			perror("pledge");
-			exit(1);
-		}
-	}
+	if (single_execution)
+		if (pledge("stdio rpath wpath cpath tty", NULL) == -1)
+			err(1, "pledge");
 
 	conf = NULL;
 	key = NULL;
Index: certhash.c
===================================================================
RCS file: /cvs/src/usr.bin/openssl/certhash.c,v
retrieving revision 1.14
diff -u -p -r1.14 certhash.c
--- certhash.c	20 Nov 2015 16:16:59 -0000	1.14
+++ certhash.c	4 Apr 2016 21:59:07 -0000
@@ -24,6 +24,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <unistd.h>
+#include <err.h>
 
 #include <openssl/bio.h>
 #include <openssl/evp.h>
@@ -648,12 +649,9 @@ certhash_main(int argc, char **argv)
 	int argsused;
 	int i, cwdfd, ret = 0;
 
-	if (single_execution) {
-		if (pledge("stdio rpath wpath cpath", NULL) == -1) {
-			perror("pledge");
-			exit(1);
-		}
-	}
+	if (single_execution)
+		if (pledge("stdio rpath wpath cpath", NULL) == -1)
+			err(1, "pledge");
 
 	memset(&certhash_config, 0, sizeof(certhash_config));
 
Index: ciphers.c
===================================================================
RCS file: /cvs/src/usr.bin/openssl/ciphers.c,v
retrieving revision 1.8
diff -u -p -r1.8 ciphers.c
--- ciphers.c	17 Oct 2015 15:00:11 -0000	1.8
+++ ciphers.c	4 Apr 2016 21:59:07 -0000
@@ -17,6 +17,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <err.h>
 
 #include <openssl/err.h>
 #include <openssl/ssl.h>
@@ -81,12 +82,9 @@ ciphers_main(int argc, char **argv)
 	int i, rv = 0;
 	char *desc;
 
-	if (single_execution) {
-		if (pledge("stdio rpath", NULL) == -1) {
-			perror("pledge");
-			exit(1);
-		}
-	}
+	if (single_execution) 
+		if (pledge("stdio rpath", NULL) == -1)
+			err(1, "pledge");
 
 	memset(&ciphers_config, 0, sizeof(ciphers_config));
 
Index: cms.c
===================================================================
RCS file: /cvs/src/usr.bin/openssl/cms.c,v
retrieving revision 1.6
diff -u -p -r1.6 cms.c
--- cms.c	17 Oct 2015 15:00:11 -0000	1.6
+++ cms.c	4 Apr 2016 21:59:07 -0000
@@ -55,6 +55,7 @@
 
 #include <stdio.h>
 #include <string.h>
+#include <err.h>
 
 #include "apps.h"
 
@@ -135,12 +136,9 @@ cms_main(int argc, char **argv)
 
 	X509_VERIFY_PARAM *vpm = NULL;
 
-	if (single_execution) {
-		if (pledge("stdio rpath wpath cpath tty", NULL) == -1) {
-			perror("pledge");
-			exit(1);
-		}
-	}
+	if (single_execution)
+		if (pledge("stdio rpath wpath cpath tty", NULL) == -1)
+			err(1, "pledge");
 
 	args = argv + 1;
 	ret = 1;
Index: crl.c
===================================================================
RCS file: /cvs/src/usr.bin/openssl/crl.c,v
retrieving revision 1.9
diff -u -p -r1.9 crl.c
--- crl.c	17 Oct 2015 15:00:11 -0000	1.9
+++ crl.c	4 Apr 2016 21:59:08 -0000
@@ -59,6 +59,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <err.h>
 
 #include "apps.h"
 
@@ -230,12 +231,9 @@ crl_main(int argc, char **argv)
 	const EVP_MD *digest;
 	char *digest_name = NULL;
 
-	if (single_execution) {
-		if (pledge("stdio rpath wpath cpath", NULL) == -1) {
-			perror("pledge");
-			exit(1);
-		}
-	}
+	if (single_execution)
+		if (pledge("stdio rpath wpath cpath", NULL) == -1)
+			err(1, "pledge");
 
 	if (bio_out == NULL) {
 		if ((bio_out = BIO_new(BIO_s_file())) != NULL) {
Index: crl2p7.c
===================================================================
RCS file: /cvs/src/usr.bin/openssl/crl2p7.c,v
retrieving revision 1.6
diff -u -p -r1.6 crl2p7.c
--- crl2p7.c	17 Oct 2015 15:00:11 -0000	1.6
+++ crl2p7.c	4 Apr 2016 21:59:08 -0000
@@ -64,6 +64,7 @@
 
 #include <stdio.h>
 #include <string.h>
+#include <err.h>
 
 #include "apps.h"
 
@@ -169,12 +170,9 @@ crl2pkcs7_main(int argc, char **argv)
 	STACK_OF(X509) *cert_stack = NULL;
 	int ret = 1;
 
-	if (single_execution) {
-		if (pledge("stdio rpath wpath cpath", NULL) == -1) {
-			perror("pledge");
-			exit(1);
-		}
-	}
+	if (single_execution)
+		if (pledge("stdio rpath wpath cpath", NULL) == -1) 
+			err(1, "pledge");
 
 	memset(&crl2p7_config, 0, sizeof(crl2p7_config));
 
Index: dgst.c
===================================================================
RCS file: /cvs/src/usr.bin/openssl/dgst.c,v
retrieving revision 1.9
diff -u -p -r1.9 dgst.c
--- dgst.c	17 Oct 2015 15:00:11 -0000	1.9
+++ dgst.c	4 Apr 2016 21:59:08 -0000
@@ -59,6 +59,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <err.h>
 
 #include "apps.h"
 
@@ -102,7 +103,7 @@ int
 dgst_main(int argc, char **argv)
 {
 	unsigned char *buf = NULL;
-	int i, err = 1;
+	int i, arg_err = 1;
 	const EVP_MD *md = NULL, *m;
 	BIO *in = NULL, *inp;
 	BIO *bmd = NULL;
@@ -123,12 +124,9 @@ dgst_main(int argc, char **argv)
 	char *mac_name = NULL;
 	STACK_OF(OPENSSL_STRING) * sigopts = NULL, *macopts = NULL;
 
-	if (single_execution) {
-		if (pledge("stdio rpath wpath cpath tty", NULL) == -1) {
-			perror("pledge");
-			exit(1);
-		}
-	}
+	if (single_execution)
+		if (pledge("stdio rpath wpath cpath tty", NULL) == -1)
+			err(1, "pledge");
 
 	if ((buf = malloc(BUFSIZE)) == NULL) {
 		BIO_printf(bio_err, "out of memory\n");
@@ -415,7 +413,7 @@ mac_end:
 	}
 	if (argc == 0) {
 		BIO_set_fp(in, stdin, BIO_NOCLOSE);
-		err = do_fp(out, buf, inp, separator, out_bin, sigkey, sigbuf,
+		arg_err = do_fp(out, buf, inp, separator, out_bin, sigkey, sigbuf,
 		    siglen, NULL, NULL, "stdin", bmd);
 	} else {
 		const char *md_name = NULL, *sig_name = NULL;
@@ -429,12 +427,12 @@ mac_end:
 			}
 			md_name = EVP_MD_name(md);
 		}
-		err = 0;
+		arg_err = 0;
 		for (i = 0; i < argc; i++) {
 			int r;
 			if (BIO_read_filename(in, argv[i]) <= 0) {
 				perror(argv[i]);
-				err++;
+				arg_err++;
 				continue;
 			} else {
 				r = do_fp(out, buf, inp, separator, out_bin,
@@ -442,7 +440,7 @@ mac_end:
 				    argv[i], bmd);
 			}
 			if (r)
-				err = r;
+				arg_err = r;
 			(void) BIO_reset(bmd);
 		}
 	}
@@ -465,7 +463,7 @@ end:
 	if (bmd != NULL)
 		BIO_free(bmd);
 
-	return (err);
+	return (arg_err);
 }
 
 int
Index: dh.c
===================================================================
RCS file: /cvs/src/usr.bin/openssl/dh.c,v
retrieving revision 1.8
diff -u -p -r1.8 dh.c
--- dh.c	17 Oct 2015 15:00:11 -0000	1.8
+++ dh.c	4 Apr 2016 21:59:08 -0000
@@ -64,6 +64,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
+#include <err.h>
 
 #include "apps.h"
 
@@ -158,12 +159,9 @@ dh_main(int argc, char **argv)
 	BIO *in = NULL, *out = NULL;
 	int ret = 1;
 
-	if (single_execution) {
-		if (pledge("stdio rpath wpath cpath", NULL) == -1) {
-			perror("pledge");
-			exit(1);
-		}
-	}
+	if (single_execution)
+		if (pledge("stdio rpath wpath cpath", NULL) == -1)
+			err(1, "pledge");
 
 	memset(&dh_config, 0, sizeof(dh_config));
 
Index: dhparam.c
===================================================================
RCS file: /cvs/src/usr.bin/openssl/dhparam.c,v
retrieving revision 1.8
diff -u -p -r1.8 dhparam.c
--- dhparam.c	17 Oct 2015 15:00:11 -0000	1.8
+++ dhparam.c	4 Apr 2016 21:59:09 -0000
@@ -117,6 +117,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
+#include <err.h>
 
 #include "apps.h"
 
@@ -243,12 +244,9 @@ dhparam_main(int argc, char **argv)
 	int ret = 1;
 	int i;
 
-	if (single_execution) {
-		if (pledge("stdio rpath wpath cpath", NULL) == -1) {
-			perror("pledge");
-			exit(1);
-		}
-	}
+	if (single_execution)
+		if (pledge("stdio rpath wpath cpath", NULL) == -1)
+			err(1, "pledge");
 
 	memset(&dhparam_config, 0, sizeof(dhparam_config));
 
Index: dsa.c
===================================================================
RCS file: /cvs/src/usr.bin/openssl/dsa.c,v
retrieving revision 1.8
diff -u -p -r1.8 dsa.c
--- dsa.c	17 Oct 2015 15:00:11 -0000	1.8
+++ dsa.c	4 Apr 2016 21:59:09 -0000
@@ -63,6 +63,7 @@
 #include <stdlib.h>
 #include <time.h>
 #include <string.h>
+#include <err.h>
 
 #include "apps.h"
 
@@ -240,12 +241,9 @@ dsa_main(int argc, char **argv)
 	BIO *in = NULL, *out = NULL;
 	char *passin = NULL, *passout = NULL;
 
-	if (single_execution) {
-		if (pledge("stdio rpath wpath cpath tty", NULL) == -1) {
-			perror("pledge");
-			exit(1);
-		}
-	}
+	if (single_execution)
+		if (pledge("stdio rpath wpath cpath tty", NULL) == -1)
+			err(1, "pledge");
 
 	memset(&dsa_config, 0, sizeof(dsa_config));
 
Index: dsaparam.c
===================================================================
RCS file: /cvs/src/usr.bin/openssl/dsaparam.c,v
retrieving revision 1.7
diff -u -p -r1.7 dsaparam.c
--- dsaparam.c	17 Oct 2015 15:00:11 -0000	1.7
+++ dsaparam.c	4 Apr 2016 21:59:09 -0000
@@ -69,6 +69,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
+#include <err.h>
 
 #include "apps.h"
 
@@ -168,12 +169,9 @@ dsaparam_main(int argc, char **argv)
 	int numbits = -1;
 	char *strbits = NULL;
 
-	if (single_execution) {
-		if (pledge("stdio rpath wpath cpath", NULL) == -1) {
-			perror("pledge");
-			exit(1);
-		}
-	}
+	if (single_execution)
+		if (pledge("stdio rpath wpath cpath", NULL) == -1) 
+			err(1, "pledge");
 
 	memset(&dsaparam_config, 0, sizeof(dsaparam_config));
 
Index: ec.c
===================================================================
RCS file: /cvs/src/usr.bin/openssl/ec.c,v
retrieving revision 1.8
diff -u -p -r1.8 ec.c
--- ec.c	17 Oct 2015 15:00:11 -0000	1.8
+++ ec.c	4 Apr 2016 21:59:09 -0000
@@ -64,6 +64,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <err.h>
 
 #include "apps.h"
 
@@ -277,12 +278,9 @@ ec_main(int argc, char **argv)
 	BIO *in = NULL, *out = NULL;
 	char *passin = NULL, *passout = NULL;
 
-	if (single_execution) {
-		if (pledge("stdio rpath wpath cpath tty", NULL) == -1) {
-			perror("pledge");
-			exit(1);
-		}
-	}
+	if (single_execution)
+		if (pledge("stdio rpath wpath cpath tty", NULL) == -1)
+			err(1, "pledge");
 
 	memset(&ec_config, 0, sizeof(ec_config));
 
Index: ecparam.c
===================================================================
RCS file: /cvs/src/usr.bin/openssl/ecparam.c,v
retrieving revision 1.15
diff -u -p -r1.15 ecparam.c
--- ecparam.c	17 Oct 2015 15:00:11 -0000	1.15
+++ ecparam.c	4 Apr 2016 21:59:09 -0000
@@ -77,6 +77,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
+#include <err.h>
 
 #include "apps.h"
 
@@ -259,12 +260,9 @@ ecparam_main(int argc, char **argv)
 	BIO *in = NULL, *out = NULL;
 	int i, ret = 1;
 
-	if (single_execution) {
-		if (pledge("stdio rpath wpath cpath", NULL) == -1) {
-			perror("pledge");
-			exit(1);
-		}
-	}
+	if (single_execution)
+		if (pledge("stdio rpath wpath cpath", NULL) == -1)
+			err(1, "pledge");
 
 	memset(&ecparam_config, 0, sizeof(ecparam_config));
 	ecparam_config.asn1_flag = OPENSSL_EC_NAMED_CURVE;
Index: enc.c
===================================================================
RCS file: /cvs/src/usr.bin/openssl/enc.c,v
retrieving revision 1.10
diff -u -p -r1.10 enc.c
--- enc.c	17 Oct 2015 15:00:11 -0000	1.10
+++ enc.c	4 Apr 2016 21:59:09 -0000
@@ -60,6 +60,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <err.h>
 
 #include "apps.h"
 
@@ -338,12 +339,9 @@ enc_main(int argc, char **argv)
 	char pname[PROG_NAME_SIZE + 1];
 	int i;
 
-	if (single_execution) {
-		if (pledge("stdio rpath wpath cpath tty", NULL) == -1) {
-			perror("pledge");
-			exit(1);
-		}
-	}
+	if (single_execution)
+		if (pledge("stdio rpath wpath cpath tty", NULL) == -1) 
+			err(1, "pledge");
 
 	memset(&enc_config, 0, sizeof(enc_config));
 	enc_config.enc = 1;
Index: errstr.c
===================================================================
RCS file: /cvs/src/usr.bin/openssl/errstr.c,v
retrieving revision 1.6
diff -u -p -r1.6 errstr.c
--- errstr.c	17 Oct 2015 15:00:11 -0000	1.6
+++ errstr.c	4 Apr 2016 21:59:09 -0000
@@ -60,6 +60,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <err.h>
 
 #include "apps.h"
 
@@ -98,12 +99,9 @@ errstr_main(int argc, char **argv)
 	char buf[256];
 	int ret = 0;
 
-	if (single_execution) {
-		if (pledge("stdio rpath", NULL) == -1) {
-			perror("pledge");
-			exit(1);
-		}
-	}
+	if (single_execution)
+		if (pledge("stdio rpath", NULL) == -1)
+			err(1, "pledge");
 
 	memset(&errstr_config, 0, sizeof(errstr_config));
 
Index: gendh.c
===================================================================
RCS file: /cvs/src/usr.bin/openssl/gendh.c,v
retrieving revision 1.7
diff -u -p -r1.7 gendh.c
--- gendh.c	17 Oct 2015 15:00:11 -0000	1.7
+++ gendh.c	4 Apr 2016 21:59:09 -0000
@@ -72,6 +72,7 @@
 #include <limits.h>
 #include <stdio.h>
 #include <string.h>
+#include <err.h>
 
 #include "apps.h"
 
@@ -134,12 +135,9 @@ gendh_main(int argc, char **argv)
 	BIO *out = NULL;
 	char *strbits = NULL;
 
-	if (single_execution) {
-		if (pledge("stdio rpath wpath cpath", NULL) == -1) {
-			perror("pledge");
-			exit(1);
-		}
-	}
+	if (single_execution) 
+		if (pledge("stdio rpath wpath cpath", NULL) == -1)
+			err(1, "pledge");
 
 	BN_GENCB_set(&cb, dh_cb, bio_err);
 
Index: gendsa.c
===================================================================
RCS file: /cvs/src/usr.bin/openssl/gendsa.c,v
retrieving revision 1.7
diff -u -p -r1.7 gendsa.c
--- gendsa.c	17 Oct 2015 15:00:11 -0000	1.7
+++ gendsa.c	4 Apr 2016 21:59:09 -0000
@@ -64,6 +64,7 @@
 
 #include <stdio.h>
 #include <string.h>
+#include <err.h>
 
 #include "apps.h"
 
@@ -85,12 +86,9 @@ gendsa_main(int argc, char **argv)
 	BIO *out = NULL, *in = NULL;
 	const EVP_CIPHER *enc = NULL;
 
-	if (single_execution) {
-		if (pledge("stdio rpath wpath cpath tty", NULL) == -1) {
-			perror("pledge");
-			exit(1);
-		}
-	}
+	if (single_execution)
+		if (pledge("stdio rpath wpath cpath tty", NULL) == -1)
+			err(1, "pledge");
 
 	argv++;
 	argc--;
Index: genpkey.c
===================================================================
RCS file: /cvs/src/usr.bin/openssl/genpkey.c,v
retrieving revision 1.8
diff -u -p -r1.8 genpkey.c
--- genpkey.c	17 Oct 2015 15:00:11 -0000	1.8
+++ genpkey.c	4 Apr 2016 21:59:09 -0000
@@ -58,6 +58,7 @@
 
 #include <stdio.h>
 #include <string.h>
+#include <err.h>
 
 #include "apps.h"
 
@@ -86,12 +87,9 @@ genpkey_main(int argc, char **argv)
 
 	int do_param = 0;
 
-	if (single_execution) {
-		if (pledge("stdio rpath wpath cpath tty", NULL) == -1) {
-			perror("pledge");
-			exit(1);
-		}
-	}
+	if (single_execution)
+		if (pledge("stdio rpath wpath cpath tty", NULL) == -1)
+			err(1, "pledge");
 
 	outformat = FORMAT_PEM;
 
Index: genrsa.c
===================================================================
RCS file: /cvs/src/usr.bin/openssl/genrsa.c,v
retrieving revision 1.8
diff -u -p -r1.8 genrsa.c
--- genrsa.c	17 Oct 2015 15:00:11 -0000	1.8
+++ genrsa.c	4 Apr 2016 21:59:10 -0000
@@ -70,6 +70,7 @@
 
 #include <stdio.h>
 #include <string.h>
+#include <err.h>
 
 #include "apps.h"
 
@@ -100,12 +101,9 @@ genrsa_main(int argc, char **argv)
 	BIGNUM *bn = BN_new();
 	RSA *rsa = NULL;
 
-	if (single_execution) {
-		if (pledge("stdio rpath wpath cpath tty", NULL) == -1) {
-			perror("pledge");
-			exit(1);
-		}
-	}
+	if (single_execution)
+		if (pledge("stdio rpath wpath cpath tty", NULL) == -1)
+			err(1, "pledge");
 
 	if (!bn)
 		goto err;
Index: nseq.c
===================================================================
RCS file: /cvs/src/usr.bin/openssl/nseq.c,v
retrieving revision 1.6
diff -u -p -r1.6 nseq.c
--- nseq.c	17 Oct 2015 15:00:11 -0000	1.6
+++ nseq.c	4 Apr 2016 21:59:10 -0000
@@ -58,6 +58,7 @@
 
 #include <stdio.h>
 #include <string.h>
+#include <err.h>
 
 #include "apps.h"
 
@@ -109,12 +110,9 @@ nseq_main(int argc, char **argv)
 	NETSCAPE_CERT_SEQUENCE *seq = NULL;
 	int i, ret = 1;
 
-	if (single_execution) {
-		if (pledge("stdio rpath wpath cpath", NULL) == -1) {
-			perror("pledge");
-			exit(1);
-		}
-	}
+	if (single_execution)
+		if (pledge("stdio rpath wpath cpath", NULL) == -1)
+			err(1, "pledge");
 
 	memset(&nseq_config, 0, sizeof(nseq_config));
 
Index: ocsp.c
===================================================================
RCS file: /cvs/src/usr.bin/openssl/ocsp.c,v
retrieving revision 1.7
diff -u -p -r1.7 ocsp.c
--- ocsp.c	17 Oct 2015 15:00:11 -0000	1.7
+++ ocsp.c	4 Apr 2016 21:59:10 -0000
@@ -65,6 +65,7 @@
 #include <string.h>
 #include <poll.h>
 #include <time.h>
+#include <err.h>
 
 /* Needs to be included before the openssl headers! */
 #include "apps.h"
@@ -146,12 +147,9 @@ ocsp_main(int argc, char **argv)
 	const EVP_MD *cert_id_md = NULL;
 	const char *errstr = NULL;
 
-	if (single_execution) {
-		if (pledge("stdio inet rpath wpath cpath", NULL) == -1) {
-			perror("pledge");
-			exit(1);
-		}
-	}
+	if (single_execution)
+		if (pledge("stdio inet rpath wpath cpath", NULL) == -1)
+			err(1, "pledge");
 
 	args = argv + 1;
 	reqnames = sk_OPENSSL_STRING_new_null();
Index: passwd.c
===================================================================
RCS file: /cvs/src/usr.bin/openssl/passwd.c,v
retrieving revision 1.7
diff -u -p -r1.7 passwd.c
--- passwd.c	17 Oct 2015 15:00:11 -0000	1.7
+++ passwd.c	4 Apr 2016 21:59:10 -0000
@@ -8,6 +8,7 @@
 
 #include <assert.h>
 #include <string.h>
+#include <err.h>
 
 #include "apps.h"
 
@@ -145,12 +146,9 @@ passwd_main(int argc, char **argv)
 	int argsused;
 	int ret = 1;
 
-	if (single_execution) {
-		if (pledge("stdio rpath wpath cpath tty", NULL) == -1) {
-			perror("pledge");
-			exit(1);
-		}
-	}
+	if (single_execution)
+		if (pledge("stdio rpath wpath cpath tty", NULL) == -1)
+			err(1, "pledge");
 
 	memset(&passwd_config, 0, sizeof(passwd_config));
 
Index: pkcs12.c
===================================================================
RCS file: /cvs/src/usr.bin/openssl/pkcs12.c,v
retrieving revision 1.7
diff -u -p -r1.7 pkcs12.c
--- pkcs12.c	17 Oct 2015 15:00:11 -0000	1.7
+++ pkcs12.c	4 Apr 2016 21:59:10 -0000
@@ -63,6 +63,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <err.h>
 
 #include "apps.h"
 
@@ -124,12 +125,9 @@ pkcs12_main(int argc, char **argv)
 	char *macalg = NULL;
 	char *CApath = NULL, *CAfile = NULL;
 
-	if (single_execution) {
-		if (pledge("stdio rpath wpath cpath tty", NULL) == -1) {
-			perror("pledge");
-			exit(1);
-		}
-	}
+	if (single_execution)
+		if (pledge("stdio rpath wpath cpath tty", NULL) == -1) 
+			err(1, "pledge");
 
 	cert_pbe = NID_pbe_WithSHA1And40BitRC2_CBC;
 
Index: pkcs7.c
===================================================================
RCS file: /cvs/src/usr.bin/openssl/pkcs7.c,v
retrieving revision 1.8
diff -u -p -r1.8 pkcs7.c
--- pkcs7.c	17 Oct 2015 15:00:11 -0000	1.8
+++ pkcs7.c	4 Apr 2016 21:59:10 -0000
@@ -60,6 +60,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
+#include <err.h>
 
 #include "apps.h"
 
@@ -154,12 +155,9 @@ pkcs7_main(int argc, char **argv)
 	int ret = 1;
 	int i;
 
-	if (single_execution) {
-		if (pledge("stdio rpath wpath cpath", NULL) == -1) {
-			perror("pledge");
-			exit(1);
-		}
-	}
+	if (single_execution)
+		if (pledge("stdio rpath wpath cpath", NULL) == -1)
+			err(1, "pledge");
 
 	memset(&pkcs7_config, 0, sizeof(pkcs7_config));
 
Index: pkcs8.c
===================================================================
RCS file: /cvs/src/usr.bin/openssl/pkcs8.c,v
retrieving revision 1.9
diff -u -p -r1.9 pkcs8.c
--- pkcs8.c	17 Oct 2015 15:00:11 -0000	1.9
+++ pkcs8.c	4 Apr 2016 21:59:11 -0000
@@ -58,6 +58,7 @@
 
 #include <stdio.h>
 #include <string.h>
+#include <err.h>
 
 #include "apps.h"
 #include "progs.h"
@@ -226,12 +227,9 @@ pkcs8_main(int argc, char **argv)
 	char pass[50], *passin = NULL, *passout = NULL, *p8pass = NULL;
 	int ret = 1;
 
-	if (single_execution) {
-		if (pledge("stdio rpath wpath cpath tty", NULL) == -1) {
-			perror("pledge");
-			exit(1);
-		}
-	}
+	if (single_execution)
+		if (pledge("stdio rpath wpath cpath tty", NULL) == -1)
+			err(1, "pledge");
 
 	memset(&pkcs8_config, 0, sizeof(pkcs8_config));
 
Index: pkey.c
===================================================================
RCS file: /cvs/src/usr.bin/openssl/pkey.c,v
retrieving revision 1.8
diff -u -p -r1.8 pkey.c
--- pkey.c	17 Oct 2015 15:00:11 -0000	1.8
+++ pkey.c	4 Apr 2016 21:59:11 -0000
@@ -58,6 +58,7 @@
 
 #include <stdio.h>
 #include <string.h>
+#include <err.h>
 
 #include "apps.h"
 
@@ -79,12 +80,9 @@ pkey_main(int argc, char **argv)
 	int badarg = 0;
 	int ret = 1;
 
-	if (single_execution) {
-		if (pledge("stdio rpath wpath cpath tty", NULL) == -1) {
-			perror("pledge");
-			exit(1);
-		}
-	}
+	if (single_execution)
+		if (pledge("stdio rpath wpath cpath tty", NULL) == -1)
+			err(1, "pledge");
 
 	informat = FORMAT_PEM;
 	outformat = FORMAT_PEM;
Index: pkeyparam.c
===================================================================
RCS file: /cvs/src/usr.bin/openssl/pkeyparam.c,v
retrieving revision 1.9
diff -u -p -r1.9 pkeyparam.c
--- pkeyparam.c	17 Oct 2015 15:00:11 -0000	1.9
+++ pkeyparam.c	4 Apr 2016 21:59:11 -0000
@@ -58,6 +58,7 @@
 
 #include <stdio.h>
 #include <string.h>
+#include <err.h>
 
 #include "apps.h"
 
@@ -118,12 +119,9 @@ pkeyparam_main(int argc, char **argv)
 	EVP_PKEY *pkey = NULL;
 	int ret = 1;
 
-	if (single_execution) {
-		if (pledge("stdio rpath wpath cpath", NULL) == -1) {
-			perror("pledge");
-			exit(1);
-		}
-	}
+	if (single_execution)
+		if (pledge("stdio rpath wpath cpath", NULL) == -1)
+			err(1, "pledge");
 
 	memset(&pkeyparam_config, 0, sizeof(pkeyparam_config));
 
Index: pkeyutl.c
===================================================================
RCS file: /cvs/src/usr.bin/openssl/pkeyutl.c,v
retrieving revision 1.10
diff -u -p -r1.10 pkeyutl.c
--- pkeyutl.c	17 Oct 2015 15:00:11 -0000	1.10
+++ pkeyutl.c	4 Apr 2016 21:59:11 -0000
@@ -57,6 +57,7 @@
  */
 
 #include <string.h>
+#include <err.h>
 
 #include "apps.h"
 
@@ -100,13 +101,9 @@ pkeyutl_main(int argc, char **argv)
 
 	int ret = 1, rv = -1;
 
-	if (single_execution) {
-		if (pledge("stdio rpath wpath cpath tty", NULL) == -1) {
-			perror("pledge");
-			exit(1);
-		}
-	}
-
+	if (single_execution) 
+		if (pledge("stdio rpath wpath cpath tty", NULL) == -1)
+			err(1, "pledge");
 	argc--;
 	argv++;
 
Index: prime.c
===================================================================
RCS file: /cvs/src/usr.bin/openssl/prime.c,v
retrieving revision 1.10
diff -u -p -r1.10 prime.c
--- prime.c	17 Oct 2015 15:00:11 -0000	1.10
+++ prime.c	4 Apr 2016 21:59:11 -0000
@@ -50,6 +50,7 @@
 
 #include <string.h>
 #include <limits.h>
+#include <err.h>
 
 #include "apps.h"
 
@@ -118,12 +119,9 @@ prime_main(int argc, char **argv)
 	char *s;
 	int ret = 1;
 
-	if (single_execution) {
-		if (pledge("stdio rpath", NULL) == -1) {
-			perror("pledge");
-			exit(1);
-		}
-	}
+	if (single_execution)
+		if (pledge("stdio rpath", NULL) == -1)
+			err(1, "pledge");
 
 	memset(&prime_config, 0, sizeof(prime_config));
 
Index: rand.c
===================================================================
RCS file: /cvs/src/usr.bin/openssl/rand.c,v
retrieving revision 1.10
diff -u -p -r1.10 rand.c
--- rand.c	17 Oct 2015 15:00:11 -0000	1.10
+++ rand.c	4 Apr 2016 21:59:11 -0000
@@ -56,6 +56,7 @@
 #include <ctype.h>
 #include <stdio.h>
 #include <string.h>
+#include <err.h>
 
 #include "apps.h"
 
@@ -109,12 +110,9 @@ rand_main(int argc, char **argv)
 	int i, r;
 	BIO *out = NULL;
 
-	if (single_execution) {
-		if (pledge("stdio rpath wpath cpath", NULL) == -1) {
-			perror("pledge");
-			exit(1);
-		}
-	}
+	if (single_execution)
+		if (pledge("stdio rpath wpath cpath", NULL) == -1)
+			err(1, "pledge");
 
 	memset(&rand_config, 0, sizeof(rand_config));
 
Index: req.c
===================================================================
RCS file: /cvs/src/usr.bin/openssl/req.c,v
retrieving revision 1.13
diff -u -p -r1.13 req.c
--- req.c	14 Nov 2015 14:53:14 -0000	1.13
+++ req.c	4 Apr 2016 21:59:11 -0000
@@ -67,6 +67,7 @@
 #include <limits.h>
 #include <string.h>
 #include <time.h>
+#include <err.h>
 
 #include "apps.h"
 
@@ -176,12 +177,9 @@ req_main(int argc, char **argv)
 	const EVP_MD *md_alg = NULL, *digest = NULL;
 	unsigned long chtype = MBSTRING_ASC;
 
-	if (single_execution) {
-		if (pledge("stdio rpath wpath cpath tty", NULL) == -1) {
-			perror("pledge");
-			exit(1);
-		}
-	}
+	if (single_execution)
+		if (pledge("stdio rpath wpath cpath tty", NULL) == -1)
+			err(1, "pledge");
 
 	req_conf = NULL;
 	cipher = EVP_aes_256_cbc();
Index: rsa.c
===================================================================
RCS file: /cvs/src/usr.bin/openssl/rsa.c,v
retrieving revision 1.8
diff -u -p -r1.8 rsa.c
--- rsa.c	17 Oct 2015 15:00:11 -0000	1.8
+++ rsa.c	4 Apr 2016 21:59:11 -0000
@@ -62,6 +62,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
+#include <err.h>
 
 #include "apps.h"
 #include "progs.h"
@@ -268,14 +269,12 @@ rsa_main(int argc, char **argv)
 	BIO *out = NULL;
 	char *passin = NULL, *passout = NULL;
 
-	if (single_execution) {
-		if (pledge("stdio rpath wpath cpath tty", NULL) == -1) {
-			perror("pledge");
-			exit(1);
-		}
-	}
+	if (single_execution)
+		if (pledge("stdio rpath wpath cpath tty", NULL) == -1)
+			err(1, "pledge");
 
 	memset(&rsa_config, 0, sizeof(rsa_config));
+	
 	rsa_config.pvk_encr = 2;
 	rsa_config.informat = FORMAT_PEM;
 	rsa_config.outformat = FORMAT_PEM;
Index: rsautl.c
===================================================================
RCS file: /cvs/src/usr.bin/openssl/rsautl.c,v
retrieving revision 1.10
diff -u -p -r1.10 rsautl.c
--- rsautl.c	17 Oct 2015 15:00:11 -0000	1.10
+++ rsautl.c	4 Apr 2016 21:59:11 -0000
@@ -60,6 +60,7 @@
 
 
 #include <string.h>
+#include <err.h>
 
 #include "apps.h"
 
@@ -98,13 +99,9 @@ rsautl_main(int argc, char **argv)
 
 	int ret = 1;
 
-	if (single_execution) {
-		if (pledge("stdio rpath wpath cpath tty", NULL) == -1) {
-			perror("pledge");
-			exit(1);
-		}
-	}
-
+	if (single_execution)
+		if (pledge("stdio rpath wpath cpath tty", NULL) == -1)
+			err(1, "pledge");
 	argc--;
 	argv++;
 
Index: s_client.c
===================================================================
RCS file: /cvs/src/usr.bin/openssl/s_client.c,v
retrieving revision 1.27
diff -u -p -r1.27 s_client.c
--- s_client.c	1 Dec 2015 12:01:56 -0000	1.27
+++ s_client.c	4 Apr 2016 21:59:12 -0000
@@ -149,6 +149,7 @@
 #include <string.h>
 #include <unistd.h>
 #include <poll.h>
+#include <err.h>
 
 #include "apps.h"
 
@@ -364,12 +365,9 @@ s_client_main(int argc, char **argv)
 	int enable_timeouts = 0;
 	long socket_mtu = 0;
 
-	if (single_execution) {
-		if (pledge("stdio inet dns rpath wpath cpath tty", NULL) == -1) {
-			perror("pledge");
-			exit(1);
-		}
-	}
+	if (single_execution)
+		if (pledge("stdio inet dns rpath wpath cpath tty", NULL) == -1)
+			err(1, "pledge");
 
 	meth = SSLv23_client_method();
 
Index: s_server.c
===================================================================
RCS file: /cvs/src/usr.bin/openssl/s_server.c,v
retrieving revision 1.24
diff -u -p -r1.24 s_server.c
--- s_server.c	23 Dec 2015 20:43:42 -0000	1.24
+++ s_server.c	4 Apr 2016 21:59:12 -0000
@@ -157,6 +157,7 @@
 #include <string.h>
 #include <unistd.h>
 #include <poll.h>
+#include <err.h>
 
 #include "apps.h"
 
@@ -604,12 +605,9 @@ s_server_main(int argc, char *argv[])
 	const char *alpn_in = NULL;
 	tlsextalpnctx alpn_ctx = { NULL, 0 };
 
-	if (single_execution) {
-		if (pledge("stdio inet dns rpath tty", NULL) == -1) {
-			perror("pledge");
-			exit(1);
-		}
-	}
+	if (single_execution)
+		if (pledge("stdio inet dns rpath tty", NULL) == -1)
+			err(1, "pledge");
 
 	meth = SSLv23_server_method();
 
Index: s_time.c
===================================================================
RCS file: /cvs/src/usr.bin/openssl/s_time.c,v
retrieving revision 1.14
diff -u -p -r1.14 s_time.c
--- s_time.c	17 Oct 2015 15:00:11 -0000	1.14
+++ s_time.c	4 Apr 2016 21:59:12 -0000
@@ -70,6 +70,7 @@
 #include <string.h>
 #include <unistd.h>
 #include <poll.h>
+#include <err.h>
 
 #include "apps.h"
 
@@ -258,12 +259,9 @@ s_time_main(int argc, char **argv)
 	char buf[1024 * 8];
 	int ver;
 
-	if (single_execution) {
-		if (pledge("stdio inet rpath", NULL) == -1) {
-			perror("pledge");
-			exit(1);
-		}
-	}
+	if (single_execution)
+		if (pledge("stdio inet rpath", NULL) == -1)
+			err(1, "pledge");
 
 	s_time_meth = SSLv23_client_method();
 
Index: sess_id.c
===================================================================
RCS file: /cvs/src/usr.bin/openssl/sess_id.c,v
retrieving revision 1.7
diff -u -p -r1.7 sess_id.c
--- sess_id.c	17 Oct 2015 15:00:11 -0000	1.7
+++ sess_id.c	4 Apr 2016 21:59:13 -0000
@@ -59,6 +59,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <err.h>
 
 #include "apps.h"
 #include "progs.h"
@@ -158,12 +159,9 @@ sess_id_main(int argc, char **argv)
 	int ret = 1, i;
 	BIO *out = NULL;
 
-	if (single_execution) {
-		if (pledge("stdio rpath wpath cpath", NULL) == -1) {
-			perror("pledge");
-			exit(1);
-		}
-	}
+	if (single_execution)
+		if (pledge("stdio rpath wpath cpath", NULL) == -1)
+			err(1, "pledge");
 
 	memset(&sess_id_config, 0, sizeof(sess_id_config));
 
Index: smime.c
===================================================================
RCS file: /cvs/src/usr.bin/openssl/smime.c,v
retrieving revision 1.7
diff -u -p -r1.7 smime.c
--- smime.c	17 Oct 2015 15:00:11 -0000	1.7
+++ smime.c	4 Apr 2016 21:59:13 -0000
@@ -60,6 +60,7 @@
 
 #include <stdio.h>
 #include <string.h>
+#include <err.h>
 
 #include "apps.h"
 
@@ -112,12 +113,9 @@ smime_main(int argc, char **argv)
 
 	X509_VERIFY_PARAM *vpm = NULL;
 
-	if (single_execution) {
-		if (pledge("stdio rpath wpath cpath tty", NULL) == -1) {
-			perror("pledge");
-			exit(1);
-		}
-	}
+	if (single_execution) 
+		if (pledge("stdio rpath wpath cpath tty", NULL) == -1)
+			err(1, "pledge");
 
 	args = argv + 1;
 	ret = 1;
Index: speed.c
===================================================================
RCS file: /cvs/src/usr.bin/openssl/speed.c,v
retrieving revision 1.18
diff -u -p -r1.18 speed.c
--- speed.c	17 Oct 2015 15:00:11 -0000	1.18
+++ speed.c	4 Apr 2016 21:59:13 -0000
@@ -89,6 +89,7 @@
 #include <limits.h>
 #include <string.h>
 #include <unistd.h>
+#include <err.h>
 
 #include "apps.h"
 
@@ -469,12 +470,9 @@ speed_main(int argc, char **argv)
 	int multi = 0;
 	const char *errstr = NULL;
 
-	if (single_execution) {
-		if (pledge("stdio proc", NULL) == -1) {
-			perror("pledge");
-			exit(1);
-		}
-	}
+	if (single_execution)
+		if (pledge("stdio proc", NULL) == -1) 
+			err(1, "pledge");
 
 	usertime = -1;
 
Index: spkac.c
===================================================================
RCS file: /cvs/src/usr.bin/openssl/spkac.c,v
retrieving revision 1.8
diff -u -p -r1.8 spkac.c
--- spkac.c	17 Oct 2015 15:00:11 -0000	1.8
+++ spkac.c	4 Apr 2016 21:59:13 -0000
@@ -61,6 +61,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
+#include <err.h>
 
 #include "apps.h"
 #include "progs.h"
@@ -181,12 +182,9 @@ spkac_main(int argc, char **argv)
 	NETSCAPE_SPKI *spki = NULL;
 	EVP_PKEY *pkey = NULL;
 
-	if (single_execution) {
-		if (pledge("stdio rpath wpath cpath tty", NULL) == -1) {
-			perror("pledge");
-			exit(1);
-		}
-	}
+	if (single_execution) 
+		if (pledge("stdio rpath wpath cpath tty", NULL) == -1)
+			err(1, "pledge");
 
 	memset(&spkac_config, 0, sizeof(spkac_config));
 	spkac_config.spkac = "SPKAC";
Index: ts.c
===================================================================
RCS file: /cvs/src/usr.bin/openssl/ts.c,v
retrieving revision 1.13
diff -u -p -r1.13 ts.c
--- ts.c	17 Oct 2015 15:00:11 -0000	1.13
+++ ts.c	4 Apr 2016 21:59:14 -0000
@@ -59,6 +59,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <err.h>
 
 #include "apps.h"
 
@@ -149,12 +150,9 @@ ts_main(int argc, char **argv)
 	/* Output is ContentInfo instead of TimeStampResp. */
 	int token_out = 0;
 
-	if (single_execution) {
-		if (pledge("stdio rpath wpath cpath tty", NULL) == -1) {
-			perror("pledge");
-			exit(1);
-		}
-	}
+	if (single_execution)
+		if (pledge("stdio rpath wpath cpath tty", NULL) == -1)
+			err(1, "pledge");
 
 	for (argc--, argv++; argc > 0; argc--, argv++) {
 		if (strcmp(*argv, "-config") == 0) {
Index: verify.c
===================================================================
RCS file: /cvs/src/usr.bin/openssl/verify.c,v
retrieving revision 1.6
diff -u -p -r1.6 verify.c
--- verify.c	17 Oct 2015 15:00:11 -0000	1.6
+++ verify.c	4 Apr 2016 21:59:14 -0000
@@ -59,6 +59,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <err.h>
 
 #include "apps.h"
 
@@ -85,12 +86,9 @@ verify_main(int argc, char **argv)
 	X509_LOOKUP *lookup = NULL;
 	X509_VERIFY_PARAM *vpm = NULL;
 
-	if (single_execution) {
-		if (pledge("stdio rpath", NULL) == -1) {
-			perror("pledge");
-			exit(1);
-		}
-	}
+	if (single_execution)
+		if (pledge("stdio rpath", NULL) == -1)
+			err(1, "pledge");
 
 	cert_ctx = X509_STORE_new();
 	if (cert_ctx == NULL)
Index: version.c
===================================================================
RCS file: /cvs/src/usr.bin/openssl/version.c,v
retrieving revision 1.8
diff -u -p -r1.8 version.c
--- version.c	17 Oct 2015 15:00:11 -0000	1.8
+++ version.c	4 Apr 2016 21:59:14 -0000
@@ -112,6 +112,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <err.h>
 
 #include "apps.h"
 
@@ -213,12 +214,9 @@ version_usage(void)
 int
 version_main(int argc, char **argv)
 {
-	if (single_execution) {
-		if (pledge("stdio", NULL) == -1) {
-			perror("pledge");
-			exit(1);
-		}
-	}
+	if (single_execution)
+		if (pledge("stdio", NULL) == -1)
+			err(1, "pledge");
 
 	memset(&version_config, 0, sizeof(version_config));
 
Index: x509.c
===================================================================
RCS file: /cvs/src/usr.bin/openssl/x509.c,v
retrieving revision 1.12
diff -u -p -r1.12 x509.c
--- x509.c	17 Oct 2015 15:00:11 -0000	1.12
+++ x509.c	4 Apr 2016 21:59:14 -0000
@@ -61,6 +61,7 @@
 #include <stdlib.h>
 #include <limits.h>
 #include <string.h>
+#include <err.h>
 
 #include "apps.h"
 
@@ -198,12 +199,9 @@ x509_main(int argc, char **argv)
 	unsigned long nmflag = 0, certflag = 0;
 	const char *errstr = NULL;
 
-	if (single_execution) {
-		if (pledge("stdio rpath wpath cpath tty", NULL) == -1) {
-			perror("pledge");
-			exit(1);
-		}
-	}
+	if (single_execution) 
+		if (pledge("stdio rpath wpath cpath tty", NULL) == -1) 
+			err(1, "pledge");
 
 	reqfile = 0;
 
