Index: head/security/trezord/Makefile =================================================================== --- head/security/trezord/Makefile (revision 480602) +++ head/security/trezord/Makefile (revision 480603) @@ -1,32 +1,31 @@ # Created by: Alex Dupre # $FreeBSD$ PORTNAME= trezord -PORTVERSION= 2.0.21 +PORTVERSION= 2.0.23 DISTVERSIONPREFIX= v CATEGORIES= security MAINTAINER= ale@FreeBSD.org COMMENT= TREZOR Communication Daemon aka TREZOR Bridge LICENSE= LGPL3 LICENSE_FILE= ${WRKSRC}/COPYING USES= go USE_RC_SUBR= ${PORTNAME} USE_GITHUB= yes GH_ACCOUNT= trezor GH_PROJECT= ${PORTNAME}-go GO_PKGNAME= github.com/${GH_ACCOUNT}/${GH_PROJECT} - -PATCH_STRIP= -p1 +GH_TAGNAME= 0e82873 PLIST_FILES= bin/${GH_PROJECT} .include .if ${OPSYS} == FreeBSD && ${OSVERSION} < 1102000 EXTRA_PATCHES+= ${FILESDIR}/extra-patch-usb_webusb.go .endif .include Index: head/security/trezord/distinfo =================================================================== --- head/security/trezord/distinfo (revision 480602) +++ head/security/trezord/distinfo (revision 480603) @@ -1,3 +1,3 @@ -TIMESTAMP = 1535444563 -SHA256 (trezor-trezord-go-v2.0.21_GH0.tar.gz) = e8987e2f998555d354297d0c00a79f0f3eb8343cff8e96241646638d7350f52a -SIZE (trezor-trezord-go-v2.0.21_GH0.tar.gz) = 953365 +TIMESTAMP = 1537790982 +SHA256 (trezor-trezord-go-v2.0.23-0e82873_GH0.tar.gz) = 87f359982952429d4f8303966ce750985fb1be484e3ee22ed636594b0dcc4345 +SIZE (trezor-trezord-go-v2.0.23-0e82873_GH0.tar.gz) = 954886 Index: head/security/trezord/files/patch-freebsd =================================================================== --- head/security/trezord/files/patch-freebsd (revision 480602) +++ head/security/trezord/files/patch-freebsd (nonexistent) @@ -1,192 +0,0 @@ -diff --git a/trezord.go b/trezord.go -index 91fb4b9..f8c545e 100644 ---- a/trezord.go -+++ b/trezord.go -@@ -6,6 +6,7 @@ import ( - "io" - "log" - "os" -+ "runtime" - "strconv" - - "github.com/trezor/trezord-go/core" -@@ -83,7 +84,11 @@ func main() { - if err != nil { - stderrLogger.Fatalf("hidapi: %s", err) - } -- bus = append(bus, w, h) -+ if runtime.GOOS != "freebsd" { -+ bus = append(bus, w, h) -+ } else { -+ bus = append(bus, w) -+ } - } - - longMemoryWriter.Println(fmt.Sprintf("UDP port count - %d", len(ports))) -diff --git a/usb/lowlevel/hid.go b/usb/lowlevel/hid.go -index 32ad167..c847c73 100644 ---- a/usb/lowlevel/hid.go -+++ b/usb/lowlevel/hid.go -@@ -6,7 +6,7 @@ - - // Package hid provides an interface for USB HID devices. - --// +build linux,cgo darwin,!ios,cgo windows,cgo -+// +build linux,cgo freebsd,cgo darwin,!ios,cgo windows,cgo - - package lowlevel - -@@ -21,6 +21,8 @@ extern void goLog(const char *s); - - #cgo linux CFLAGS: -DDEFAULT_VISIBILITY="" -DOS_LINUX -D_GNU_SOURCE -DPOLL_NFDS_TYPE=int - #cgo linux,!android LDFLAGS: -lrt -+#cgo freebsd CFLAGS: -DOS_FREEBSD -+#cgo freebsd LDFLAGS: -lusb - #cgo darwin CFLAGS: -DOS_DARWIN -DDEFAULT_VISIBILITY="" -DPOLL_NFDS_TYPE="unsigned int" - #cgo darwin LDFLAGS: -framework CoreFoundation -framework IOKit -lobjc - #cgo windows CFLAGS: -DOS_WINDOWS -DDEFAULT_VISIBILITY="" -DPOLL_NFDS_TYPE="unsigned int" -@@ -34,6 +36,8 @@ extern void goLog(const char *s); - #include "os/poll_posix.c" - #include "os/linux_usbfs.c" - #include "os/linux_netlink.c" -+#elif OS_FREEBSD -+ #include - #elif OS_DARWIN - #include - -@@ -50,15 +54,21 @@ extern void goLog(const char *s); - #include "os/threads_windows.c" - #endif - --#include "core.c" --#include "descriptor.c" --#include "hotplug.c" --#include "io.c" --#include "strerror.c" --#include "sync.c" -+#ifndef OS_FREEBSD -+ #include "core.c" -+ #include "descriptor.c" -+ #include "hotplug.c" -+ #include "io.c" -+ #include "strerror.c" -+ #include "sync.c" -+#else -+ #include -+#endif - - #ifdef OS_LINUX - #include "linux/hid.c" -+#elif OS_FREEBSD -+ #include "linux/hid.c" - #elif OS_DARWIN - #include "mac/hid.c" - #elif OS_WINDOWS -diff --git a/usb/lowlevel/libusb.go b/usb/lowlevel/libusb.go -index 454c95c..acda2c6 100644 ---- a/usb/lowlevel/libusb.go -+++ b/usb/lowlevel/libusb.go -@@ -1,4 +1,4 @@ --// +build linux,cgo darwin,!ios,cgo windows,cgo -+// +build linux,cgo freebsd,cgo darwin,!ios,cgo windows,cgo - - //----------------------------------------------------------------------------- - /* -@@ -14,7 +14,13 @@ Copyright (c) 2017 Jason T. Harris - package lowlevel - - /* -+#cgo freebsd LDFLAGS: -lusb -+ -+#ifndef __FreeBSD__ - #include "./c/libusb/libusb.h" -+#else -+#include -+#endif - - // When a C struct ends with a zero-sized field, but the struct itself is not zero-sized, - // Go code can no longer refer to the zero-sized field. Any such references will have to be rewritten. -@@ -921,9 +927,11 @@ func Get_Port_Numbers(dev Device, ports []byte) ([]byte, error) { - return ports[:rc], nil - } - -+/* - func Get_Parent(dev Device) Device { - return C.libusb_get_parent(dev) - } -+*/ - - func Get_Device_Address(dev Device) uint8 { - return uint8(C.libusb_get_device_address(dev)) -@@ -1066,10 +1074,12 @@ func Set_Auto_Detach_Kernel_Driver(hdl Device_Handle, enable bool) error { - //----------------------------------------------------------------------------- - // Miscellaneous - -+/* - func Has_Capability(capability uint32) bool { - rc := int(C.libusb_has_capability((C.uint32_t)(capability))) - return rc != 0 - } -+*/ - - func Error_Name(code int) string { - return C.GoString(C.libusb_error_name(C.int(code))) -@@ -1084,6 +1094,7 @@ func CPU_To_LE16(x uint16) uint16 { - return uint16(C.libusb_cpu_to_le16((C.uint16_t)(x))) - } - -+/* - func Setlocale(locale string) error { - cstr := C.CString(locale) - rc := int(C.libusb_setlocale(cstr)) -@@ -1092,6 +1103,7 @@ func Setlocale(locale string) error { - } - return nil - } -+*/ - - func Strerror(errcode int) string { - return C.GoString(C.libusb_strerror(int32(errcode))) -diff --git a/usb/lowlevel/wchar.go b/usb/lowlevel/wchar.go -index a85a143..8448510 100644 ---- a/usb/lowlevel/wchar.go -+++ b/usb/lowlevel/wchar.go -@@ -7,7 +7,7 @@ - // https://github.com/orofarne/gowchar/blob/master/LICENSE - - // +build !ios --// +build linux darwin windows -+// +build linux freebsd darwin windows - - package lowlevel - -diff --git a/usb/webusb.go b/usb/webusb.go -index eb8cadd..1366074 100644 ---- a/usb/webusb.go -+++ b/usb/webusb.go -@@ -3,6 +3,7 @@ package usb - import ( - "encoding/hex" - "fmt" -+ "runtime" - "strings" - "sync" - "sync/atomic" -@@ -214,9 +215,14 @@ func (b *WebUSB) match(dev lowlevel.Device) bool { - b.mw.Println("webusb - match - error getting config descriptor " + err.Error()) - return false - } -- return (c.BNumInterfaces > webIfaceNum && -- c.Interface[webIfaceNum].Num_altsetting > webAltSetting && -- c.Interface[webIfaceNum].Altsetting[webAltSetting].BInterfaceClass == lowlevel.CLASS_VENDOR_SPEC) -+ if runtime.GOOS != "freebsd" { -+ return (c.BNumInterfaces > webIfaceNum && -+ c.Interface[webIfaceNum].Num_altsetting > webAltSetting && -+ c.Interface[webIfaceNum].Altsetting[webAltSetting].BInterfaceClass == lowlevel.CLASS_VENDOR_SPEC) -+ } else { -+ return (c.BNumInterfaces > webIfaceNum && -+ c.Interface[webIfaceNum].Num_altsetting > webAltSetting) -+ } - } - - func (b *WebUSB) matchVidPid(vid uint16, pid uint16) bool { Property changes on: head/security/trezord/files/patch-freebsd ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -yes \ No newline at end of property Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/security/trezord/files/extra-patch-usb_webusb.go =================================================================== --- head/security/trezord/files/extra-patch-usb_webusb.go (revision 480602) +++ head/security/trezord/files/extra-patch-usb_webusb.go (revision 480603) @@ -1,54 +1,52 @@ -diff --git a/usb/webusb.go b/usb/webusb.go -index eb8cadd..1366074 100644 ---- a/usb/webusb.go -+++ b/usb/webusb.go -@@ -226,13 +232,21 @@ func (b *WebUSB) matchVidPid(vid uint16, pid uint16) bool { +--- usb/webusb.go.orig 2018-09-21 13:31:27 UTC ++++ usb/webusb.go +@@ -274,13 +274,21 @@ func (b *WebUSB) matchVidPid(vid uint16, } func (b *WebUSB) identify(dev lowlevel.Device) string { - var ports [8]byte - p, err := lowlevel.Get_Port_Numbers(dev, ports[:]) - if err != nil { - b.mw.Println(fmt.Sprintf("webusb - identify - error getting port numbers %s", err.Error())) - return "" + var path string + if runtime.GOOS != "freebsd" { + var ports [8]byte + p, err := lowlevel.Get_Port_Numbers(dev, ports[:]) + if err != nil { + b.mw.Println(fmt.Sprintf("webusb - identify - error getting port numbers %s", err.Error())) + return "" + } + path = hex.EncodeToString(p) + } else { + bn := lowlevel.Get_Bus_Number(dev) + da := lowlevel.Get_Device_Address(dev) + path = fmt.Sprintf("%02x%02x", bn, da) } - return webusbPrefix + hex.EncodeToString(p) + return webusbPrefix + path } type WUD struct { -@@ -279,6 +293,12 @@ func (d *WUD) finishReadQueue() { +@@ -331,6 +339,12 @@ func (d *WUD) finishReadQueue() { } func (d *WUD) readWrite(buf []byte, endpoint uint8) (int, error) { + var timeout uint + if runtime.GOOS != "freebsd" { + timeout = usbTimeout + } else { + timeout = 0 + } d.mw.Println("webusb - rw - start") for { d.mw.Println("webusb - rw - checking closed") -@@ -291,7 +311,7 @@ func (d *WUD) readWrite(buf []byte, endpoint uint8) (int, error) { +@@ -343,7 +357,7 @@ func (d *WUD) readWrite(buf []byte, endp d.mw.Println("webusb - rw - lock transfer mutex") d.transferMutex.Lock() d.mw.Println("webusb - rw - actual interrupt transport") - p, err := lowlevel.Interrupt_Transfer(d.dev, endpoint, buf, usbTimeout) + p, err := lowlevel.Interrupt_Transfer(d.dev, endpoint, buf, timeout) d.transferMutex.Unlock() d.mw.Println("webusb - rw - single transfer done")