pkgsrc-WIP-changes archive

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

usbutil: Fail to build with RELRO



Module Name:	pkgsrc-wip
Committed By:	Michael Baeuerle <michael.baeuerle%stz-e.de@localhost>
Pushed By:	micha
Date:		Tue Jul 16 18:23:08 2019 +0200
Changeset:	ced1ed32a6341071764dfc1e02d6b8423875731d

Added Files:
	usbutil/COMMIT_MSG
	usbutil/DESCR
	usbutil/Makefile
	usbutil/PLIST
	usbutil/TODO
	usbutil/distinfo
	usbutil/patches/patch-Makefile
	usbutil/patches/patch-aa
	usbutil/patches/patch-ab
	usbutil/patches/patch-ac
	usbutil/patches/patch-ad

Log Message:
usbutil: Fail to build with RELRO

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

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

diffstat:
 usbutil/COMMIT_MSG             |   4 +
 usbutil/DESCR                  |  10 ++
 usbutil/Makefile               |  17 ++++
 usbutil/PLIST                  |   6 ++
 usbutil/TODO                   |   3 +
 usbutil/distinfo               |  11 +++
 usbutil/patches/patch-Makefile |  33 +++++++
 usbutil/patches/patch-aa       |  29 ++++++
 usbutil/patches/patch-ab       | 209 +++++++++++++++++++++++++++++++++++++++++
 usbutil/patches/patch-ac       |  21 +++++
 usbutil/patches/patch-ad       |  21 +++++
 11 files changed, 364 insertions(+)

diffs:
diff --git a/usbutil/COMMIT_MSG b/usbutil/COMMIT_MSG
new file mode 100644
index 0000000000..676d9d53f9
--- /dev/null
+++ b/usbutil/COMMIT_MSG
@@ -0,0 +1,4 @@
+Failed to build with RELRO option
+
+- Honor LDFLAGS
+- Bump PKGREVISION
diff --git a/usbutil/DESCR b/usbutil/DESCR
new file mode 100644
index 0000000000..4ee73dc424
--- /dev/null
+++ b/usbutil/DESCR
@@ -0,0 +1,10 @@
+USB developer utilities:
+usbctl
+	Dump information about devices on a USB bus.
+usbdebug
+	Set the kernel debugging flag.
+usbgen
+	Dump descriptors of a generic device.
+	usbgen -f ugenN -v -D
+usbstats
+	Gives statistics for a USB host contrller.
diff --git a/usbutil/Makefile b/usbutil/Makefile
new file mode 100644
index 0000000000..d445a0e586
--- /dev/null
+++ b/usbutil/Makefile
@@ -0,0 +1,17 @@
+# $NetBSD$
+#
+
+DISTNAME=	usbutil-0.5
+PKGREVISION=	6
+CATEGORIES=	sysutils
+MASTER_SITES=	ftp://ftp.augustsson.net/pub/netbsd/
+
+MAINTAINER=	lennart%augustsson.net@localhost
+COMMENT=	USB developer utilities
+
+post-install:
+	${INSTALL_MAN_DIR} ${DESTDIR}${PREFIX}/${PKGMANDIR}/man8
+	${INSTALL_MAN} ${WRKSRC}/usbgen.8 \
+		${DESTDIR}${PREFIX}/${PKGMANDIR}/man8/usbgen.8
+
+.include "../../mk/bsd.pkg.mk"
diff --git a/usbutil/PLIST b/usbutil/PLIST
new file mode 100644
index 0000000000..9db0b42dfc
--- /dev/null
+++ b/usbutil/PLIST
@@ -0,0 +1,6 @@
+@comment $NetBSD$
+man/man8/usbgen.8
+sbin/usbctl
+sbin/usbdebug
+sbin/usbgen
+sbin/usbstats
diff --git a/usbutil/TODO b/usbutil/TODO
new file mode 100644
index 0000000000..49e3fa656a
--- /dev/null
+++ b/usbutil/TODO
@@ -0,0 +1,3 @@
+[ ] pkglint complains about missing license
+[ ] Homepage looks dead
+    => Try whether maintainer email address still works
diff --git a/usbutil/distinfo b/usbutil/distinfo
new file mode 100644
index 0000000000..8a515b65b4
--- /dev/null
+++ b/usbutil/distinfo
@@ -0,0 +1,11 @@
+$NetBSD$
+
+SHA1 (usbutil-0.5.tar.gz) = 4c9abc6f370ab561bd2748b1792802d1e959c599
+RMD160 (usbutil-0.5.tar.gz) = 48c6bedeed8daf50a760feedef3575db021066f8
+SHA512 (usbutil-0.5.tar.gz) = 7bede70e32b185123f7297ccfe49f28ec7724a83ae018d9fce69e4aad6211a18571e177249da4d20cee3c7db3362011a4b13d6044a5f858bdc3951a247498dd8
+Size (usbutil-0.5.tar.gz) = 11508 bytes
+SHA1 (patch-Makefile) = dace3011ddd427f40e676099d9ff11726ff6679a
+SHA1 (patch-aa) = 8db548f99befd76839b8b31caa2de0861c6d708b
+SHA1 (patch-ab) = b470a91102e8ea4fbb592b4a0f5978ed11196969
+SHA1 (patch-ac) = 0c1c7e67c84c1a6db1ad0144803977bee7c61ceb
+SHA1 (patch-ad) = a98c2a46c6eb860416ff631c62361f5b0282def8
diff --git a/usbutil/patches/patch-Makefile b/usbutil/patches/patch-Makefile
new file mode 100644
index 0000000000..b8aba2af63
--- /dev/null
+++ b/usbutil/patches/patch-Makefile
@@ -0,0 +1,33 @@
+$NetBSD$
+
+Honor LDFLAGS.
+Use DESTDIR.
+
+--- Makefile.orig	1999-05-19 21:05:31.000000000 +0000
++++ Makefile
+@@ -7,19 +7,20 @@ man:	usbgen.8
+ 	nroff -mandoc usbgen.8 > usbgen.0
+ 
+ usbctl:		usbctl.c
+-	cc $(CFLAGS) usbctl.c -o usbctl
++	$(CC) $(CFLAGS) $(LDFLAGS) usbctl.c -o usbctl
+ 
+ usbdebug:	usbdebug.c
+-	cc $(CFLAGS) usbdebug.c -o usbdebug
++	$(CC) $(CFLAGS) $(LDFLAGS) usbdebug.c -o usbdebug
+ 
+ usbstats:	usbstats.c
+-	cc $(CFLAGS) usbstats.c -o usbstats
++	$(CC) $(CFLAGS) $(LDFLAGS) usbstats.c -o usbstats
+ 
+ usbgen:		usbgen.c
+-	cc $(CFLAGS) usbgen.c -o usbgen
++	$(CC) $(CFLAGS) $(LDFLAGS) usbgen.c -o usbgen
+ 
+ install: $(PROGS)
+-	install usbctl usbdebug usbstats usbgen $(PREFIX)/sbin
++	${BSD_INSTALL_PROGRAM_DIR} ${DESTDIR}${PREFIX}/sbin
++	install usbctl usbdebug usbstats usbgen ${DESTDIR}$(PREFIX)/sbin
+ 
+ clean:
+ 	rm -f $(PROGS)
diff --git a/usbutil/patches/patch-aa b/usbutil/patches/patch-aa
new file mode 100644
index 0000000000..497f978997
--- /dev/null
+++ b/usbutil/patches/patch-aa
@@ -0,0 +1,29 @@
+$NetBSD$
+
+--- usbgen.c.orig	2002-02-25 00:55:12.000000000 +0000
++++ usbgen.c
+@@ -27,11 +27,16 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <sys/types.h>
++#include <sys/ioctl.h>
+ #include <fcntl.h>
+ #include <unistd.h>
+ #include <string.h>
+ #include <err.h>
++#ifdef __DragonFly__
++#include <bus/usb/usb.h>
++#else
+ #include <dev/usb/usb.h>
++#endif
+ 
+ /* Backwards compatibility */
+ #ifndef UE_GET_DIR
+@@ -54,6 +59,7 @@
+ #define ucd_desc desc
+ #define uai_config_index config_index
+ #define uai_interface_index interface_index
++#define uai_alt_no	alt_no
+ #define udi_product product
+ #define udi_vendor vendor
+ #define udi_addr addr
diff --git a/usbutil/patches/patch-ab b/usbutil/patches/patch-ab
new file mode 100644
index 0000000000..97d658eb72
--- /dev/null
+++ b/usbutil/patches/patch-ab
@@ -0,0 +1,209 @@
+$NetBSD$
+
+--- usbctl.c.orig	2002-02-24 19:50:55.000000000 -0500
++++ usbctl.c	2011-07-24 09:56:59.000000000 -0400
+@@ -27,12 +27,18 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <sys/types.h>
++#include <sys/ioctl.h>
+ #include <fcntl.h>
+ #include <unistd.h>
+ #include <err.h>
+ #include <errno.h>
++#ifdef __DragonFly__
++#include <bus/usb/usb.h>
++#include <bus/usb/usbhid.h>
++#else
+ #include <dev/usb/usb.h>
+ #include <dev/usb/usbhid.h>
++#endif
+ 
+ #ifndef USB_STACK_VERSION
+ #define ucr_addr addr
+@@ -52,6 +58,21 @@
+ #define UICLASS_HUB UCLASS_HUB
+ #endif
+ 
++#ifndef UDESC_INTERFACE_ASSOC
++#define UDESC_INTERFACE_ASSOC 0x0b
++typedef struct {
++	uByte		bLength;
++	uByte		bDescriptorType;
++	uByte		bFirstInterface;
++	uByte		bInterfaceCount;
++	uByte		bFunctionClass;
++	uByte		bFunctionSubClass;
++	uByte		bFunctionProtocol;
++	uByte		iFunction
++} UPACKED usb_interface_assoc_descriptor_t;
++#define USB_INTERFACE_ASSOC_DESCRIPTOR_SIZE 8
++#endif
++
+ #define USBDEV "/dev/usb0"
+ 
+ /* Backwards compatibility */
+@@ -62,6 +83,7 @@
+ #endif
+ 
+ #define NSTRINGS
++#define STRINGLANG
+ 
+ int num = 0;
+ 
+@@ -80,17 +102,43 @@ getstring(int si, char *s)
+ 	int r, i, n;
+ 	u_int16_t c;
+ 	usb_string_descriptor_t us;
++	int lang = 0;
+ 
+ 	if (si == 0 || num) {
+ 		*s = 0;
+ 		return;
+ 	}
++
++#ifdef STRINGLANG
+ 	req.ucr_addr = usbaddr;
+ 	req.ucr_request.bmRequestType = UT_READ_DEVICE;
+ 	req.ucr_request.bRequest = UR_GET_DESCRIPTOR;
+ 	req.ucr_data = &us;
+-	USETW2(req.ucr_request.wValue, UDESC_STRING, si);
++	USETW2(req.ucr_request.wValue, UDESC_STRING, 0);
+ 	USETW(req.ucr_request.wIndex, 0);
++	USETW(req.ucr_request.wLength, sizeof(usb_string_descriptor_t));
++	req.ucr_flags = USBD_SHORT_XFER_OK;
++	r = ioctl(usbf, USB_REQUEST, &req);
++	if (r < 0) {
++		fprintf(stderr, "get lang tbl failed (error=%d)\n", errno);
++		*s = 0;
++		return;
++	}
++	if (req.ucr_actlen > 0 && us.bLength >= 4) {
++		lang = UGETW(us.bString[0]);
++#if 0
++		printf("getstring: %d langs, using %d\n",
++		       (us.bLength - 2) / 2, lang);
++#endif
++	}
++#endif
++
++	req.ucr_addr = usbaddr;
++	req.ucr_request.bmRequestType = UT_READ_DEVICE;
++	req.ucr_request.bRequest = UR_GET_DESCRIPTOR;
++	req.ucr_data = &us;
++	USETW2(req.ucr_request.wValue, UDESC_STRING, si);
++	USETW(req.ucr_request.wIndex, lang);
+ #ifdef NSTRINGS
+ 	USETW(req.ucr_request.wLength, sizeof(usb_string_descriptor_t));
+ 	req.ucr_flags = USBD_SHORT_XFER_OK;
+@@ -154,6 +202,7 @@ descTypeName(int t)
+ 	case UDESC_STRING: p = "string"; break;
+ 	case UDESC_INTERFACE: p = "interface"; break;
+ 	case UDESC_ENDPOINT: p = "endpoint"; break;
++	case UDESC_INTERFACE_ASSOC: p = "iad"; break;
+ 	case 0x20: p = "cs_undefined"; break;
+ 	case UDESC_CS_DEVICE: p = "cs_device"; break;
+ 	case UDESC_CS_CONFIG: p = "cs_config"; break;
+@@ -278,6 +327,21 @@ bInterfaceProtocol=%d iInterface=%d(%s)\
+ 	       d->iInterface, ifc);
+ }
+ 
++void
++priad(usb_interface_assoc_descriptor_t *d)
++{
++	char func[MAXSTR];
++	getstring(d->iFunction, func);
++	if (d->bDescriptorType != UDESC_INTERFACE_ASSOC) printf("weird descriptorType, should be %d\n", UDESC_INTERFACE_ASSOC);
++	printf("\
++bLength=%d bDescriptorType=%s bFirstInterface=%d bInterfaceCount=%d\n\
++bFunctionClass=%d bFunctionSubClass=%d bFunctionProtocol=%d\n\
++iFunction=%d(%s)\n",
++	    d->bLength, descTypeName(d->bDescriptorType), d->bFirstInterface,
++	    d->bInterfaceCount, d->bFunctionClass, d->bFunctionSubClass,
++	    d->bFunctionProtocol, d->iFunction, func);
++}
++
+ char *xfernames[] = { "control", "isochronous", "bulk", "interrupt" };
+ char *xfertypes[] = { "", "-async", "-adaptive", "-sync" };
+ 
+@@ -384,7 +448,7 @@ struct usb_cdc_union_descriptor {
+ };
+ 
+ void
+-prcdcd(usb_descriptor_t *ud)
++prcdcd(struct usb_cdc_header_descriptor *ud)
+ {
+ 	if (ud->bDescriptorType != UDESC_CS_INTERFACE)
+ 		printf("prcdcd: strange bDescriptorType=%d\n", 
+@@ -630,7 +694,7 @@ gethubdesc(int f, usb_hub_descriptor_t *
+ 	req.ucr_addr = addr;
+ 	req.ucr_request.bmRequestType = UT_READ_CLASS_DEVICE;
+ 	req.ucr_request.bRequest = UR_GET_DESCRIPTOR;
+-	USETW(req.ucr_request.wValue, 0);
++	USETW2(req.ucr_request.wValue, UDESC_HUB, 0);
+ 	USETW(req.ucr_request.wIndex, 0);
+ 	USETW(req.ucr_request.wLength, USB_HUB_DESCRIPTOR_SIZE);
+ 	req.ucr_data = d;
+@@ -1145,6 +1209,11 @@ prdesc(void *p, int *class, int *subclas
+ 		prhubd(p);
+ 		break;
+ #endif
++	case UDESC_INTERFACE_ASSOC:
++		printf("INTERFACE ASSOCIATION descriptor:\n");
++		priad(p);
++		break;
++		break;
+ 	case UDESC_CS_DEVICE:
+ 		if (*class == UICLASS_HID) {
+ 			usb_hid_descriptor_t *hid = p;
+@@ -1155,10 +1224,14 @@ prdesc(void *p, int *class, int *subclas
+ 			printf("\n");
+ 			for(k = 0; k < hid->bNumDescriptors; k++) {
+ 				int type, len;
+-				u_char buf[256];
++				u_char *buf;
+ 
+ 				type = hid->descrs[k].bDescriptorType;
+ 				len = UGETW(hid->descrs[k].wDescriptorLength);
++				buf = malloc(len);
++				if (buf == NULL) {
++					errx(1, "malloc failed (size=%d)\n", len);
++				}
+ 				if (type == UDESC_REPORT) {
+ 					getreportdesc(globf, *iface, k, buf, len, globaddr);
+ 					printf("Report descriptor\n");
+@@ -1169,6 +1242,7 @@ prdesc(void *p, int *class, int *subclas
+ 					printf("Unknown HID descriptor type %d\n", type);
+ 				}
+ 				printf("\n");
++				free(buf);
+ 			}
+ 		} else
+ 			goto def;
+@@ -1243,8 +1317,8 @@ prdesc(void *p, int *class, int *subclas
+ 	default:
+ 	def:
+ 		printf("Unknown descriptor (class %d/%d):\n", *class, *subclass);
+-		printf("bLength=%d bDescriptorType=%d bDescriptorSubtype=%d ...\n", d->bLength, 
+-		       d->bDescriptorType, d->bDescriptorSubtype
++		printf("bLength=%d bDescriptorType=%d ...\n", d->bLength, 
++		       d->bDescriptorType
+ 		       );
+ 		break;
+ 	}
+@@ -1321,6 +1395,7 @@ main(int argc, char **argv)
+ 
+ 	if (!doaddr)
+ 		prunits(f);
++#ifndef __NetBSD__
+ 	if (!nodisc) {
+ 		r = ioctl(f, USB_DISCOVER);
+ 		if (r < 0)
+@@ -1329,6 +1404,7 @@ main(int argc, char **argv)
+ 		if (disconly)
+ 			exit(0);
+ 	}
++#endif
+ 
+ 	for(addr = 0; addr < USB_MAX_DEVICES; addr++) {
+ 		if (doaddr != -1 && addr != doaddr)
diff --git a/usbutil/patches/patch-ac b/usbutil/patches/patch-ac
new file mode 100644
index 0000000000..88652e085a
--- /dev/null
+++ b/usbutil/patches/patch-ac
@@ -0,0 +1,21 @@
+$NetBSD$
+
+--- usbdebug.c.orig	1999-05-18 23:47:45.000000000 +0000
++++ usbdebug.c
+@@ -26,11 +26,16 @@
+ 
+ #include <stdio.h>
+ #include <sys/types.h>
++#include <sys/ioctl.h>
+ #include <fcntl.h>
+ #include <unistd.h>
+ #include <stdlib.h>
+ #include <err.h>
++#ifdef __DragonFly__
++#include <bus/usb/usb.h>
++#else
+ #include <dev/usb/usb.h>
++#endif
+ 
+ #define USBDEV "/dev/usb0"
+ 
diff --git a/usbutil/patches/patch-ad b/usbutil/patches/patch-ad
new file mode 100644
index 0000000000..6f34aa3297
--- /dev/null
+++ b/usbutil/patches/patch-ad
@@ -0,0 +1,21 @@
+$NetBSD$
+
+--- usbstats.c.orig	2002-02-25 01:55:56.000000000 +0100
++++ usbstats.c
+@@ -26,10 +26,16 @@
+ 
+ #include <stdio.h>
+ #include <sys/types.h>
++#include <sys/ioctl.h>
+ #include <fcntl.h>
++#include <stdlib.h>
+ #include <unistd.h>
+ #include <err.h>
++#ifdef __DragonFly__
++#include <bus/usb/usb.h>
++#else
+ #include <dev/usb/usb.h>
++#endif
+ 
+ #ifndef USB_STACK_VERSION
+ #define uds_requests requests


Home | Main Index | Thread Index | Old Index