pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

bsdec2-image-upload: Import bsdec2-image-upload-1.3.1 as wip/bsdec2-image-upload



Module Name:	pkgsrc-wip
Committed By:	Leonardo Taccari <leot%NetBSD.org@localhost>
Pushed By:	leot
Date:		Mon Feb 1 22:20:34 2021 +0100
Changeset:	5088a6e854fee2f2c89620ddd61937e04c766308

Added Files:
	bsdec2-image-upload/DESCR
	bsdec2-image-upload/Makefile
	bsdec2-image-upload/PLIST
	bsdec2-image-upload/distinfo
	bsdec2-image-upload/patches/patch-lib_util_sslreq.c
	bsdec2-image-upload/patches/patch-main.c

Log Message:
bsdec2-image-upload: Import bsdec2-image-upload-1.3.1 as wip/bsdec2-image-upload

Tool for uploading disk images into Amazon EC2 and creating Amazon Machine
Images from them.

From sysutils/bsdec2-image-upload and intended to update bsdec2-image-upload.

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=5088a6e854fee2f2c89620ddd61937e04c766308

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 bsdec2-image-upload/DESCR                          |   2 +
 bsdec2-image-upload/Makefile                       |  31 +++
 bsdec2-image-upload/PLIST                          |   2 +
 bsdec2-image-upload/distinfo                       |   8 +
 .../patches/patch-lib_util_sslreq.c                |  26 +++
 bsdec2-image-upload/patches/patch-main.c           | 238 +++++++++++++++++++++
 6 files changed, 307 insertions(+)

diffs:
diff --git a/bsdec2-image-upload/DESCR b/bsdec2-image-upload/DESCR
new file mode 100644
index 0000000000..a3535857d9
--- /dev/null
+++ b/bsdec2-image-upload/DESCR
@@ -0,0 +1,2 @@
+Tool for uploading disk images into Amazon EC2 and creating Amazon Machine
+Images from them.
diff --git a/bsdec2-image-upload/Makefile b/bsdec2-image-upload/Makefile
new file mode 100644
index 0000000000..c3e85ee504
--- /dev/null
+++ b/bsdec2-image-upload/Makefile
@@ -0,0 +1,31 @@
+# $NetBSD: Makefile,v 1.4 2020/01/18 21:50:52 jperkin Exp $
+
+DISTNAME=	bsdec2-image-upload-1.3.1
+CATEGORIES=	sysutils
+MASTER_SITES=	${MASTER_SITE_GITHUB:=cperciva/}
+
+MAINTAINER=	jmcneill%NetBSD.org@localhost
+HOMEPAGE=	https://github.com/cperciva/bsdec2-image-upload/
+COMMENT=	Tool for creating Amazon EC2 AMIs
+LICENSE=	2-clause-bsd
+
+.include "../../mk/compiler.mk"
+.if !empty(PKGSRC_COMPILER:Mgcc)
+CFLAGS+=	-Wno-error=pointer-sign \
+		-Wno-error=maybe-uninitialized \
+		-Wno-error=discarded-qualifiers \
+		-Wno-error=cast-qual \
+		-Wno-error=clobbered
+.elif !empty(PKGSRC_COMPILER:Mclang)
+CFLAGS+=	-Wno-unknown-warning-option -Wno-pointer-sign \
+		-Wno-incompatible-pointer-types-discards-qualifiers
+.endif
+BUILDLINK_TRANSFORM+=	rm:-Wno-error=\#warnings
+
+INSTALLATION_DIRS+=	bin
+
+do-install:
+	${INSTALL_PROGRAM} ${WRKSRC}/bsdec2-image-upload ${DESTDIR}${PREFIX}/bin
+
+.include "../../security/openssl/buildlink3.mk"
+.include "../../mk/bsd.pkg.mk"
diff --git a/bsdec2-image-upload/PLIST b/bsdec2-image-upload/PLIST
new file mode 100644
index 0000000000..ca95532232
--- /dev/null
+++ b/bsdec2-image-upload/PLIST
@@ -0,0 +1,2 @@
+@comment $NetBSD: PLIST,v 1.1 2019/05/22 08:45:10 jmcneill Exp $
+bin/bsdec2-image-upload
diff --git a/bsdec2-image-upload/distinfo b/bsdec2-image-upload/distinfo
new file mode 100644
index 0000000000..4cab11e182
--- /dev/null
+++ b/bsdec2-image-upload/distinfo
@@ -0,0 +1,8 @@
+$NetBSD: distinfo,v 1.1 2019/05/22 08:45:10 jmcneill Exp $
+
+SHA1 (bsdec2-image-upload-1.3.1.tar.gz) = f45ace71aa8ab71898ebc3e9360cb8cb48eaa633
+RMD160 (bsdec2-image-upload-1.3.1.tar.gz) = 02b442602ef773a8057a0a563b55cc9b30644d65
+SHA512 (bsdec2-image-upload-1.3.1.tar.gz) = b03d14b489a12a5f589c759acf3b4c57fc65520768be224613577c0778500d40a66ff154f0ab558ba6e6e81ff251defadb66a8c1c96edfc3b21abdcf75e5b4fe
+Size (bsdec2-image-upload-1.3.1.tar.gz) = 32890 bytes
+SHA1 (patch-lib_util_sslreq.c) = 8a5d8404f85a2ac340572d786b4ab1d643eb57de
+SHA1 (patch-main.c) = 4ce281161d7fae3e657e1d54b5cb33f4534d848a
diff --git a/bsdec2-image-upload/patches/patch-lib_util_sslreq.c b/bsdec2-image-upload/patches/patch-lib_util_sslreq.c
new file mode 100644
index 0000000000..bb7345eacc
--- /dev/null
+++ b/bsdec2-image-upload/patches/patch-lib_util_sslreq.c
@@ -0,0 +1,26 @@
+$NetBSD$
+
+Ignore SIGPIPE globally, backported from upstream commit
+5935505d197620010be9366d6e6e84162a39e90c.
+
+--- lib/util/sslreq.c.orig	2020-04-10 22:53:40.000000000 +0000
++++ lib/util/sslreq.c
+@@ -120,7 +120,6 @@ sslreq2(const char * host, const char * 
+ 	SSL * ssl;
+ 	int readlen;
+ 	size_t resppos;
+-	int on = 1;
+ 
+ 	/* Create resolver hints structure. */
+ 	memset(&hints, 0, sizeof(hints));
+@@ -153,10 +152,6 @@ sslreq2(const char * host, const char * 
+ 	if (r == NULL)
+ 		return "Could not connect";
+ 
+-	/* Disable SIGPIPE on this socket. */
+-	if (setsockopt(s, SOL_SOCKET, SO_NOSIGPIPE, &on, sizeof(on)))
+-		return "Could not disable SIGPIPE";
+-
+ 	/* Launch SSL. */
+ 	if (!SSL_library_init())
+ 		return "Could not initialize SSL";
diff --git a/bsdec2-image-upload/patches/patch-main.c b/bsdec2-image-upload/patches/patch-main.c
new file mode 100644
index 0000000000..28e2732fe0
--- /dev/null
+++ b/bsdec2-image-upload/patches/patch-main.c
@@ -0,0 +1,238 @@
+$NetBSD$
+
+- Ignore SIGPIPE globally, backported from upstream commit
+  5935505d197620010be9366d6e6e84162a39e90c.
+- Add casts betweeh char * and uint8_t * (to avoid warnings), backported from upstream
+  commit 28235699f040cd0fa41f2d0e6d38328c0fe79579.
+- Don't map files MAP_NOCORE if that's not defined, backported from upstream
+  commit c8713c2f66eb42c5a3fcb7d16ae64997f7a9a33a.
+
+--- main.c.orig	2021-01-30 11:25:00.884762293 +0000
++++ main.c
+@@ -4,6 +4,7 @@
+ 
+ #include <errno.h>
+ #include <inttypes.h>
++#include <signal.h>
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+@@ -117,7 +118,7 @@ s3_put(const char * key_id, const char *
+ 		goto err3;
+ 
+ 	/* Send the request. */
+-	if ((errstr = sslreq2(host, "443", CERTFILE, headers, len,
++	if ((errstr = sslreq2(host, "443", CERTFILE, (uint8_t *)headers, len,
+ 	    buf, buflen, resp, &resplen)) != NULL) {
+ 		warnp("SSL request failed: %s", errstr);
+ 		goto err4;
+@@ -127,11 +128,11 @@ s3_put(const char * key_id, const char *
+ 	resp[resplen] = '\0';
+ 
+         /* Find the end of the first line. */
+-        pos = strcspn(resp, "\r\n");
++        pos = strcspn((char *)resp, "\r\n");
+ 
+         /* Look for a "200" status on the first line. */
+-        if ((strstr(resp, " 200 ") == NULL) ||
+-            (strstr(resp, " 200 ") > (char *)&resp[pos])) {
++        if ((strstr((char *)resp, " 200 ") == NULL) ||
++            (strstr((char *)resp, " 200 ") > (char *)&resp[pos])) {
+ 		warnp("S3 request failed:\n%s\n", resp);
+ 		goto err4;
+ 	}
+@@ -386,7 +387,8 @@ uploadvolume(const char * fname, const c
+ 		free(s);
+ 		goto err2;
+ 	}
+-	if (s3_put_loop(key_id, key_secret, region, bucket, path, s, len)) {
++	if (s3_put_loop(key_id, key_secret, region, bucket, path,
++	    (uint8_t *)s, len)) {
+ 		free(path);
+ 		free(s);
+ 		goto err2;
+@@ -433,11 +435,11 @@ ec2_apicall(const char * key_id, const c
+ 	uint8_t * resp;
+ 	size_t resplen;
+ 	size_t pos;
+-	uint8_t * body;
++	char * body;
+ 
+ 	/* Sign request. */
+-	if (aws_sign_ec2_headers(key_id, key_secret, region, s, strlen(s),
+-	    &x_amz_content_sha256, &x_amz_date, &authorization)) {
++	if (aws_sign_ec2_headers(key_id, key_secret, region, (uint8_t *)s,
++	    strlen(s), &x_amz_content_sha256, &x_amz_date, &authorization)) {
+ 		warnp("Failed to sign EC2 POST request");
+ 		goto err0;
+ 	}
+@@ -468,8 +470,8 @@ ec2_apicall(const char * key_id, const c
+ 		goto err3;
+ 
+ 	/* Send the request. */
+-	if ((errstr = sslreq(host, "443", CERTFILE, req, len, resp, &resplen))
+-	    != NULL) {
++	if ((errstr = sslreq(host, "443", CERTFILE, (uint8_t *)req, len,
++	    resp, &resplen)) != NULL) {
+ 		warnp("SSL request failed: %s", errstr);
+ 		goto err4;
+ 	}
+@@ -478,23 +480,23 @@ ec2_apicall(const char * key_id, const c
+ 	resp[resplen] = '\0';
+ 
+ 	/* EC2 API responses should not contain NUL bytes. */
+-	if (strlen(resp) != resplen) {
++	if (strlen((char *)resp) != resplen) {
+ 		warnp("NUL byte in EC2 API response");
+ 		goto err4;
+ 	}
+ 
+         /* Find the end of the first line. */
+-        pos = strcspn(resp, "\r\n");
++        pos = strcspn((char *)resp, "\r\n");
+ 
+         /* Look for a "200" status on the first line. */
+-        if ((strstr(resp, " 200 ") == NULL) ||
+-            (strstr(resp, " 200 ") > (char *)&resp[pos])) {
++        if ((strstr((char *)resp, " 200 ") == NULL) ||
++            (strstr((char *)resp, " 200 ") > (char *)&resp[pos])) {
+ 		warnp("EC2 API request failed:\n%s\n", resp);
+ 		goto err4;
+ 	}
+ 
+ 	/* Find the end of the headers. */
+-	if ((body = strstr(resp, "\r\n\r\n")) == NULL) {
++	if ((body = strstr((char *)resp, "\r\n\r\n")) == NULL) {
+ 		warnp("Bad EC2 API response received:\n%s\n", resp);
+ 		goto err4;
+ 	}
+@@ -1257,8 +1259,11 @@ uploadsnap(const char * fname, const cha
+ 	len = sb.st_size;
+ 
+ 	/* Map the file. */
+-	if ((p = mmap(NULL, len, PROT_READ, MAP_PRIVATE | MAP_NOCORE,
+-	    fileno(f), 0)) == MAP_FAILED) {
++	if ((p = mmap(NULL, len, PROT_READ, MAP_PRIVATE
++#ifdef MAP_NOCORE
++		| MAP_NOCORE
++#endif
++	    , fileno(f), 0)) == MAP_FAILED) {
+ 		warnp("Could not map disk image");
+ 		goto err1;
+ 	}
+@@ -1660,7 +1665,8 @@ ssm_store(const char * key_id, const cha
+ 
+ 	/* Sign request. */
+ 	if (aws_sign_ssm_headers(key_id, key_secret, region, "PutParameter",
+-	    s, strlen(s), &x_amz_content_sha256, &x_amz_date, &authorization)) {
++	    (uint8_t *)s, strlen(s), &x_amz_content_sha256, &x_amz_date,
++	    &authorization)) {
+ 		warnp("Failed to sign SSM PutParameter request");
+ 		goto err1;
+ 	}
+@@ -1693,8 +1699,8 @@ ssm_store(const char * key_id, const cha
+ 		goto err4;
+ 
+ 	/* Send the request. */
+-	if ((errstr = sslreq(host, "443", CERTFILE, req, len, resp, &resplen))
+-	    != NULL) {
++	if ((errstr = sslreq(host, "443", CERTFILE, (uint8_t *)req, len,
++	    resp, &resplen)) != NULL) {
+ 		warnp("SSL request failed: %s", errstr);
+ 		goto err5;
+ 	}
+@@ -1703,17 +1709,17 @@ ssm_store(const char * key_id, const cha
+ 	resp[resplen] = '\0';
+ 
+ 	/* EC2 API responses should not contain NUL bytes. */
+-	if (strlen(resp) != resplen) {
++	if (strlen((char *)resp) != resplen) {
+ 		warnp("NUL byte in SSM API response");
+ 		goto err5;
+ 	}
+ 
+         /* Find the end of the first line. */
+-        pos = strcspn(resp, "\r\n");
++        pos = strcspn((char *)resp, "\r\n");
+ 
+         /* Look for a "200" status on the first line. */
+-        if ((strstr(resp, " 200 ") == NULL) ||
+-            (strstr(resp, " 200 ") > (char *)&resp[pos])) {
++        if ((strstr((char *)resp, " 200 ") == NULL) ||
++            (strstr((char *)resp, " 200 ") > (char *)&resp[pos])) {
+ 		warnp("SSM API request failed:\n%s\n", resp);
+ 		goto err5;
+ 	}
+@@ -1774,7 +1780,7 @@ sns_publish(const char * key_id, const c
+ 	uint8_t * resp;
+ 	size_t resplen;
+ 	size_t pos;
+-	uint8_t * body;
++	char * body;
+ 
+ 	/* Construct message subject. */
+ 	if (asprintf(&msg_subject, "New %s AMIs", releaseversion) == -1)
+@@ -1850,8 +1856,8 @@ sns_publish(const char * key_id, const c
+ 	region[strcspn(region, ":")] = '\0';
+ 
+ 	/* Sign request. */
+-	if (aws_sign_sns_headers(key_id, key_secret, region, s, strlen(s),
+-	    &x_amz_content_sha256, &x_amz_date, &authorization)) {
++	if (aws_sign_sns_headers(key_id, key_secret, region, (uint8_t *)s,
++	    strlen(s), &x_amz_content_sha256, &x_amz_date, &authorization)) {
+ 		warnp("Failed to sign SNS POST request");
+ 		goto err5;
+ 	}
+@@ -1883,8 +1889,8 @@ sns_publish(const char * key_id, const c
+ 		goto err8;
+ 
+ 	/* Send the request. */
+-	if ((errstr = sslreq(host, "443", CERTFILE, req, len, resp, &resplen))
+-	    != NULL) {
++	if ((errstr = sslreq(host, "443", CERTFILE, (uint8_t *)req, len,
++	    resp, &resplen)) != NULL) {
+ 		warnp("SSL request failed: %s", errstr);
+ 		goto err9;
+ 	}
+@@ -1893,23 +1899,23 @@ sns_publish(const char * key_id, const c
+ 	resp[resplen] = '\0';
+ 
+ 	/* SNS API responses should not contain NUL bytes. */
+-	if (strlen(resp) != resplen) {
++	if (strlen((char *)resp) != resplen) {
+ 		warnp("NUL byte in SNS API response");
+ 		goto err9;
+ 	}
+ 
+         /* Find the end of the first line. */
+-        pos = strcspn(resp, "\r\n");
++        pos = strcspn((char *)resp, "\r\n");
+ 
+         /* Look for a "200" status on the first line. */
+-        if ((strstr(resp, " 200 ") == NULL) ||
+-            (strstr(resp, " 200 ") > (char *)&resp[pos])) {
++        if ((strstr((char *)resp, " 200 ") == NULL) ||
++            (strstr((char *)resp, " 200 ") > (char *)&resp[pos])) {
+ 		warnp("SNS API request failed:\n%s\n", resp);
+ 		goto err9;
+ 	}
+ 
+ 	/* Find the end of the headers. */
+-	if ((body = strstr(resp, "\r\n\r\n")) == NULL) {
++	if ((body = strstr((char *)resp, "\r\n\r\n")) == NULL) {
+ 		warnp("Bad SNS API response received:\n%s\n", resp);
+ 		goto err9;
+ 	}
+@@ -2082,6 +2088,12 @@ main(int argc, char * argv[])
+ 		exit(1);
+ 	}
+ 
++	/* Ignore SIGPIPE. */
++	if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) {
++		warnp("signal(SIGPIPE)");
++		exit(1);
++	}
++
+ 	/* Get list of AWS regions. */
+ 	if (allregions) {
+ 		if (getregionlist(key_id, key_secret, region, &regions,


Home | Main Index | Thread Index | Old Index