Index: head/security/trezord/Makefile =================================================================== --- head/security/trezord/Makefile (revision 472180) +++ head/security/trezord/Makefile (revision 472181) @@ -1,42 +1,26 @@ # Created by: Alex Dupre # $FreeBSD$ PORTNAME= trezord -PORTVERSION= 1.2.1 -PORTREVISION= 2 +PORTVERSION= 2.0.14 CATEGORIES= security -MASTER_SITES= LOCAL/ale MAINTAINER= ale@FreeBSD.org COMMENT= TREZOR Communication Daemon aka TREZOR Bridge LICENSE= LGPL3 LICENSE_FILE= ${WRKSRC}/COPYING -BUILD_DEPENDS= protoc:devel/protobuf \ - boost-libs>=0:devel/boost-libs -LIB_DEPENDS= libcurl.so:ftp/curl \ - libjsoncpp.so:devel/jsoncpp \ - libmicrohttpd.so:www/libmicrohttpd - -USES= cmake compiler:c++11-lang pkgconfig - +USES= go USE_RC_SUBR= ${PORTNAME} +USE_GITHUB= yes +GH_ACCOUNT= trezor +GH_PROJECT= ${PORTNAME}-go +GH_TAGNAME= v${PORTVERSION} +GO_PKGNAME= github.com/${GH_ACCOUNT}/${GH_PROJECT} -CMAKE_ARGS+= -DJSONCPP_INCLUDE_DIR:STRING="${LOCALBASE}/include/jsoncpp" \ - -DJSONCPP_LIBRARY:STRING="-L${LOCALBASE}/lib -ljsoncpp" +PATCH_STRIP= -p1 -PLIST_FILES= sbin/${PORTNAME} - -post-extract: - ${CP} ${FILESDIR}/usb.hpp ${WRKSRC}/src/ - ${CP} ${FILESDIR}/config.proto ${WRKSRC}/src/config/ - -pre-build: - cd ${WRKSRC}/src/config && ${LOCALBASE}/bin/protoc \ - -I${LOCALBASE}/include -I. --cpp_out=. config.proto - -do-install: - ${INSTALL_PROGRAM} ${WRKSRC}/${PORTNAME} ${STAGEDIR}/${PREFIX}/sbin/ +PLIST_FILES= bin/${GH_PROJECT} .include Index: head/security/trezord/distinfo =================================================================== --- head/security/trezord/distinfo (revision 472180) +++ head/security/trezord/distinfo (revision 472181) @@ -1,3 +1,3 @@ -TIMESTAMP = 1514538815 -SHA256 (trezord-1.2.1.tar.gz) = aad7426ffd765977b6013d2efe675748027dd61b83dfc3a9ad28e4331fbc0d53 -SIZE (trezord-1.2.1.tar.gz) = 465139 +TIMESTAMP = 1528707476 +SHA256 (trezor-trezord-go-2.0.14-v2.0.14_GH0.tar.gz) = a28001afe130a717e5366fdb5ec16e10ca44d6bdd366694f844efda830a08f68 +SIZE (trezor-trezord-go-2.0.14-v2.0.14_GH0.tar.gz) = 859521 Index: head/security/trezord/files/patch-src_wire.hpp =================================================================== --- head/security/trezord/files/patch-src_wire.hpp (revision 472180) +++ head/security/trezord/files/patch-src_wire.hpp (nonexistent) @@ -1,114 +0,0 @@ ---- src/wire.hpp.orig 2017-12-02 14:37:41 UTC -+++ src/wire.hpp -@@ -57,13 +57,14 @@ device_info_list - enumerate_connected_devices(F filter) - { - device_info_list list; -- auto *infos = hid::enumerate(0x00, 0x00); -+ auto *infos = usb::enumerate(0x00, 0x00); - - for (auto i = infos; i != nullptr; i = i->next) { - // skip unsupported devices - if (!filter(i)) { - continue; - } -+#if 0 - // skip foreign interfaces - if (i->interface_number > 0) { - CLOG(DEBUG, "wire.enumerate") << "skipping, invalid device"; -@@ -79,6 +80,7 @@ enumerate_connected_devices(F filter) - CLOG(DEBUG, "wire.enumerate") << "skipping, fido interface"; - continue; - } -+#endif - list.emplace_back( - device_info{ - i->vendor_id, -@@ -86,7 +88,7 @@ enumerate_connected_devices(F filter) - i->path}); - } - -- hid::free_enumeration(infos); -+ usb::free_enumeration(infos); - return list; - } - -@@ -112,18 +114,19 @@ struct device - - device(char const *path) - { -- hid = hid::open_path(path); -+ hid = usb::open_path(path); - if (!hid) { - throw open_error("HID device open failed"); - } -- hid_version = try_hid_version(); -+ hid_version = 1; // no report with libusb try_hid_version(); - if (hid_version <= 0) { - throw open_error("Unknown HID version"); - } - } - -- ~device() { hid::close(hid); } -+ ~device() { usb::close(hid); } - -+#if 0 - // try writing packet that will be discarded to figure out hid version - int try_hid_version() { - int r; -@@ -133,7 +136,7 @@ struct device - report.fill(0xFF); - report[0] = 0x00; - report[1] = 0x3F; -- r = hid::write(hid, report.data(), 65); -+ r = usb::write(hid, report.data(), 65); - if (r == 65) { - return 2; - } -@@ -141,7 +144,7 @@ struct device - // try version 1 - report.fill(0xFF); - report[0] = 0x3F; -- r = hid::write(hid, report.data(), 64); -+ r = usb::write(hid, report.data(), 64); - if (r == 64) { - return 1; - } -@@ -149,6 +152,7 @@ struct device - // unknown version - return 0; - } -+#endif - - void - read_buffered(char_type *data, -@@ -210,7 +214,7 @@ private: - int r; - - do { -- r = hid::read_timeout(hid, report.data(), report.size(), 50); -+ r = usb::read(hid, report.data(), report.size()); - } while (r == 0); - - if (r < 0) { -@@ -251,7 +255,7 @@ private: - break; - } - -- int r = hid::write(hid, report.data(), report_size); -+ int r = usb::write(hid, report.data(), report_size); - if (r < 0) { - throw write_error{"HID device write failed"}; - } -@@ -263,9 +267,9 @@ private: - } - - typedef std::vector buffer_type; -- typedef std::array report_type; -+ typedef std::array report_type; - -- hid_device *hid; -+ libusb_device_handle *hid; - buffer_type read_buffer; - int hid_version; - }; Property changes on: head/security/trezord/files/patch-src_wire.hpp ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -on \ 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/patch-CMakeLists.txt =================================================================== --- head/security/trezord/files/patch-CMakeLists.txt (revision 472180) +++ head/security/trezord/files/patch-CMakeLists.txt (nonexistent) @@ -1,43 +0,0 @@ ---- CMakeLists.txt.orig 2017-12-02 14:37:41 UTC -+++ CMakeLists.txt -@@ -31,7 +31,6 @@ if (WIN32) - endif(WIN32) - - if (UNIX AND NOT APPLE) -- set (SRCS src/glibc_compat.c ${SRCS}) - endif(UNIX AND NOT APPLE) - - add_executable(trezord ${SRCS}) -@@ -49,7 +48,7 @@ else(WIN32) - if (APPLE) - set(OS_LIBRARIES pthread) - else(APPLE) -- set(OS_LIBRARIES pthread dl z) -+ set(OS_LIBRARIES pthread usb z) - endif(APPLE) - endif(WIN32) - -@@ -72,7 +71,6 @@ find_package(Protobuf 2.5.0 REQUIRED) - find_package(jsoncpp REQUIRED) - - # add vendored libs --add_subdirectory(vendor/hidapi) - add_subdirectory(vendor/trezor-crypto) - - include_directories( -@@ -81,7 +79,6 @@ include_directories( - ${PROTOBUF_INCLUDE_DIRS} - ${JSONCPP_INCLUDE_DIRS} - ${CURL_INCLUDE_DIRS} -- vendor/hidapi/hidapi - vendor/trezor-crypto - vendor/easyloggingpp) - -@@ -91,7 +88,6 @@ target_link_libraries(trezord - ${CURL_LIBRARIES} - ${PROTOBUF_LIBRARIES} - ${JSONCPP_LIBRARIES} -- hidapi - TrezorCrypto) - - if(BUILD_TESTS) Property changes on: head/security/trezord/files/patch-CMakeLists.txt ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -on \ 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/patch-src_main.cpp =================================================================== --- head/security/trezord/files/patch-src_main.cpp (revision 472180) +++ head/security/trezord/files/patch-src_main.cpp (nonexistent) @@ -1,26 +0,0 @@ ---- src/main.cpp.orig 2017-12-02 14:37:41 UTC -+++ src/main.cpp -@@ -33,7 +33,7 @@ - #include - - #include "utils.hpp" --#include "hid.hpp" -+#include "usb.hpp" - #include "wire.hpp" - #include "core.hpp" - #include "http_client.hpp" -@@ -163,14 +163,12 @@ main(int argc, char *argv[]) - return 1; - } - --#ifdef __linux__ - if (!vm.count("foreground")) { - if (daemon(0, 0) < 0) { - LOG(ERROR) << "could not daemonize"; - return 1; - } - } --#endif - - std::string cert_data; - std::string privkey_data; Property changes on: head/security/trezord/files/patch-src_main.cpp ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -on \ 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/config.proto =================================================================== --- head/security/trezord/files/config.proto (revision 472180) +++ head/security/trezord/files/config.proto (nonexistent) @@ -1,30 +0,0 @@ -/** - * Configuration format for TREZOR plugin - */ - -// Sugar for easier handling in Java -option java_package = "com.satoshilabs.trezor.lib.protobuf"; -option java_outer_classname = "TrezorConfig"; - -import "google/protobuf/descriptor.proto"; - -/** - * Device Descriptor used in Configuration - */ -message DeviceDescriptor { - optional uint32 vendor_id = 1; // USB vendor ID - optional uint32 product_id = 2; // USB product ID - optional string serial_number = 3; // USB serial number - optional string path = 4; // USB device path -} - -/** - * Plugin Configuration - */ -message Configuration { - repeated string whitelist_urls = 1; // allowed URLs for plugin - repeated string blacklist_urls = 2; // forbidden URLs for plugin - required google.protobuf.FileDescriptorSet wire_protocol = 3; // compiled specification of write protocol (serialized using "protoc -o") - repeated DeviceDescriptor known_devices = 4; // descriptors of allowed devices - optional uint32 valid_until = 5; // expiration timestamp -} Property changes on: head/security/trezord/files/config.proto ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -on \ 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/patch-src_core.hpp =================================================================== --- head/security/trezord/files/patch-src_core.hpp (revision 472180) +++ head/security/trezord/files/patch-src_core.hpp (nonexistent) @@ -1,33 +0,0 @@ ---- src/core.hpp.orig 2017-12-02 14:37:41 UTC -+++ src/core.hpp -@@ -195,12 +195,12 @@ public: - pb_wire_codec{new protobuf::wire_codec{pb_state.get()}}, - pb_json_codec{new protobuf::json_codec{pb_state.get()}} - { -- hid::init(); -+ usb::init(); - } - - ~kernel() - { -- hid::exit(); -+ usb::exit(); - } - - std::string -@@ -433,13 +433,13 @@ private: - enumerate_supported_devices() - { - return wire::enumerate_connected_devices( -- [&] (hid_device_info const *i) { -+ [&] (usb::usb_device_info const *i) { - return is_device_supported(i); - }); - } - - bool -- is_device_supported(hid_device_info const *info) -+ is_device_supported(usb::usb_device_info const *info) - { - return std::any_of( - config.c.known_devices().begin(), Property changes on: head/security/trezord/files/patch-src_core.hpp ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -on \ 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/usb.hpp =================================================================== --- head/security/trezord/files/usb.hpp (revision 472180) +++ head/security/trezord/files/usb.hpp (nonexistent) @@ -1,174 +0,0 @@ -/* - * This file is part of the TREZOR project. - * - * Copyright (C) 2014 SatoshiLabs - * - * This library is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library. If not, see . - */ - -#include -#include - -namespace trezord -{ -namespace usb -{ - -static std::unique_ptr< utils::async_executor > usb_executor; - -struct usb_device_info { - char path[10]; - uint16_t vendor_id; - uint16_t product_id; - - usb_device_info *next; -}; - -// Init/exit - -void -init() -{ - libusb_init(NULL); - usb_executor.reset(new utils::async_executor()); -} - -void -exit() -{ - libusb_exit(NULL); - usb_executor.reset(); -} - -// Enumeration - -usb_device_info * -enumerate(unsigned short vendor_id, unsigned short product_id) -{ - return usb_executor->await([=] { - libusb_device **devs = NULL; - libusb_device *dev = NULL; - struct usb_device_info *root = NULL; /* return object */ - struct usb_device_info *cur_dev = NULL; - int i = 0; - - libusb_get_device_list(NULL, &devs); - while ((dev = devs[i++]) != NULL) { - struct libusb_device_descriptor desc; - libusb_get_device_descriptor(dev, &desc); - if ((vendor_id == 0 || vendor_id == desc.idVendor) && (product_id == 0 || product_id == desc.idProduct)) { - struct usb_device_info *tmp; - tmp = (struct usb_device_info *) calloc(1, sizeof(struct usb_device_info)); - if (cur_dev) { - cur_dev->next = tmp; - } else { - root = tmp; - } - cur_dev = tmp; - - cur_dev->next = NULL; - snprintf(cur_dev->path, sizeof(cur_dev->path), "%04x:%04x", - libusb_get_bus_number(dev), - libusb_get_device_address(dev)); - - cur_dev->vendor_id = desc.idVendor; - cur_dev->product_id = desc.idProduct; - } - } - libusb_free_device_list(devs, 1); - return root; - }); -} - -void -free_enumeration(usb_device_info *devs) -{ - return usb_executor->await([=] { - struct usb_device_info *d = devs; - while (d) { - struct usb_device_info *next = d->next; - free(d); - d = next; - } - }); -} - -// Open/close - -libusb_device_handle * -open_path(char const *path) -{ - return usb_executor->await([=] { - libusb_device **devs = NULL; - libusb_device *dev = NULL; - libusb_device_handle *handle = NULL; - int i = 0; - - libusb_get_device_list(NULL, &devs); - while ((dev = devs[i++]) != NULL) { - char devpath[10]; - snprintf(devpath, sizeof(devpath), "%04x:%04x", - libusb_get_bus_number(dev), - libusb_get_device_address(dev)); - if (strncmp(devpath, path, sizeof(devpath)) == 0) { - if (libusb_open(dev, &handle) == 0) { -#if !defined(__FreeBSD__) || __FreeBSD_version >= 1100000 - libusb_set_auto_detach_kernel_driver(handle, 1); -#endif - if (libusb_claim_interface(handle, 0)) { - libusb_close(handle); - handle = NULL; - } - } - break; - } - } - libusb_free_device_list(devs, 1); - return handle; - }); -} - -void -close(libusb_device_handle *device) -{ - return usb_executor->await([=] { - libusb_release_interface(device, 0); - libusb_close(device); - }); -} - -// Communication - -int -write(libusb_device_handle *device, unsigned char *data, size_t length) -{ - return usb_executor->await([=] { - int xfer = -1; - libusb_interrupt_transfer(device, 0x01, data, length, &xfer, 0); - return xfer; - }); -} - -int -read(libusb_device_handle *device, unsigned char *data, size_t length) -{ - return usb_executor->await([=] { - int xfer = -1; - libusb_interrupt_transfer(device, 0x81, data, length, &xfer, 0); - return xfer; - }); -} - -} -} Property changes on: head/security/trezord/files/usb.hpp ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -on \ 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/patch-freebsd =================================================================== --- head/security/trezord/files/patch-freebsd (nonexistent) +++ head/security/trezord/files/patch-freebsd (revision 472181) @@ -0,0 +1,242 @@ +diff --git a/trezord.go b/trezord.go +index e1b7261..75b14bb 100644 +--- a/trezord.go ++++ b/trezord.go +@@ -6,6 +6,7 @@ import ( + "io" + "log" + "os" ++ "runtime" + "strconv" + + "github.com/trezor/trezord-go/memorywriter" +@@ -82,7 +83,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/webusb.go b/usb/webusb.go +index ee9c8d3..017fbf2 100644 +--- a/usb/webusb.go ++++ b/usb/webusb.go +@@ -3,6 +3,7 @@ package usb + import ( + "encoding/hex" + "fmt" ++ "runtime" + "strings" + "sync" + "sync/atomic" +@@ -188,7 +189,7 @@ func (b *WebUSB) match(dev usbhid.Device) bool { + } + return (c.BNumInterfaces > webIfaceNum && + c.Interface[webIfaceNum].Num_altsetting > webAltSetting && +- c.Interface[webIfaceNum].Altsetting[webAltSetting].BInterfaceClass == usbhid.CLASS_VENDOR_SPEC) ++ (c.Interface[webIfaceNum].Altsetting[webAltSetting].BInterfaceClass == usbhid.CLASS_VENDOR_SPEC || runtime.GOOS == "freebsd")) + } + + func (b *WebUSB) matchVidPid(vid uint16, pid uint16) bool { +@@ -198,13 +199,19 @@ func (b *WebUSB) matchVidPid(vid uint16, pid uint16) bool { + } + + func (b *WebUSB) identify(dev usbhid.Device) string { +- var ports [8]byte +- p, err := usbhid.Get_Port_Numbers(dev, ports[:]) +- if err != nil { +- b.mw.Println(fmt.Sprintf("webusb - identify - error getting port numbers %s", err.Error())) +- return "" ++ if runtime.GOOS != "freebsd" { ++ var ports [8]byte ++ p, err := usbhid.Get_Port_Numbers(dev, ports[:]) ++ if err != nil { ++ b.mw.Println(fmt.Sprintf("webusb - identify - error getting port numbers %s", err.Error())) ++ return "" ++ } ++ return webusbPrefix + hex.EncodeToString(p) ++ } else { ++ bn := usbhid.Get_Bus_Number(dev) ++ da := usbhid.Get_Device_Address(dev) ++ return fmt.Sprintf("%s%02x%02x", webusbPrefix, bn, da) + } +- return webusbPrefix + hex.EncodeToString(p) + } + + type WUD struct { +@@ -251,6 +258,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") +@@ -263,7 +276,7 @@ func (d *WUD) readWrite(buf []byte, endpoint uint8) (int, error) { + d.mw.Println("webusb - rw - lock transfer mutex") + d.transferMutex.Lock() + d.mw.Println("webusb - rw - actual interrupt transport") +- p, err := usbhid.Interrupt_Transfer(d.dev, endpoint, buf, usbTimeout) ++ p, err := usbhid.Interrupt_Transfer(d.dev, endpoint, buf, timeout) + d.transferMutex.Unlock() + d.mw.Println("webusb - rw - single transfer done") + +diff --git a/vendor/github.com/trezor/usbhid/hid.go b/vendor/github.com/trezor/usbhid/hid.go +index 114c1fe..4052529 100644 +--- a/vendor/github.com/trezor/usbhid/hid.go ++++ b/vendor/github.com/trezor/usbhid/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 usbhid + +@@ -15,6 +15,8 @@ package usbhid + + #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" +@@ -25,6 +27,8 @@ package usbhid + #include + + #include "os/threads_posix.c" ++#elif OS_FREEBSD ++ #include + #elif OS_DARWIN + #include + #include +@@ -38,17 +42,21 @@ package usbhid + #include + #endif + +-#include "libusbi.h" +-#include "libusb.h" +-#include "version.h" +-#include "version_nano.h" +-#include "core.c" +-#include "descriptor.c" +-#include "hotplug.h" +-#include "hotplug.c" +-#include "io.c" +-#include "strerror.c" +-#include "sync.c" ++#ifndef OS_FREEBSD ++ #include "libusbi.h" ++ #include "libusb.h" ++ #include "version.h" ++ #include "version_nano.h" ++ #include "core.c" ++ #include "descriptor.c" ++ #include "hotplug.h" ++ #include "hotplug.c" ++ #include "io.c" ++ #include "strerror.c" ++ #include "sync.c" ++#else ++ #include ++#endif + + #ifdef OS_LINUX + #include "os/poll_posix.h" +@@ -74,6 +82,8 @@ package usbhid + + #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/vendor/github.com/trezor/usbhid/libusb.go b/vendor/github.com/trezor/usbhid/libusb.go +index 13a2a66..b443102 100644 +--- a/vendor/github.com/trezor/usbhid/libusb.go ++++ b/vendor/github.com/trezor/usbhid/libusb.go +@@ -12,9 +12,15 @@ Copyright (c) 2017 Jason T. Harris + package usbhid + + /* +-// +build linux,cgo darwin,!ios,cgo windows,cgo ++// +build linux,cgo freebsd,cgo darwin,!ios,cgo windows,cgo + ++#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/vendor/github.com/trezor/usbhid/wchar.go b/vendor/github.com/trezor/usbhid/wchar.go +index 16941d1..e955fdd 100644 +--- a/vendor/github.com/trezor/usbhid/wchar.go ++++ b/vendor/github.com/trezor/usbhid/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 usbhid + Property changes on: head/security/trezord/files/patch-freebsd ___________________________________________________________________ Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/security/trezord/files/trezord.in =================================================================== --- head/security/trezord/files/trezord.in (revision 472180) +++ head/security/trezord/files/trezord.in (revision 472181) @@ -1,26 +1,41 @@ #!/bin/sh # $FreeBSD$ # # PROVIDE: trezord # REQUIRE: LOGIN # KEYWORD: shutdown # # Add these lines to /etc/rc.conf.local or /etc/rc.conf # to enable this service: # # trezord_enable (bool): Set to NO by default. # Set it to YES to enable trezord. . /etc/rc.subr name=trezord rcvar=trezord_enable load_rc_config $name : ${trezord_enable:="NO"} -command=%%PREFIX%%/sbin/${name} +command="%%PREFIX%%/bin/trezord-go" +command_args="-l /var/log/trezord.log" +daemon_command="/usr/sbin/daemon" +pidfile="/var/run/trezord.pid" +start_cmd="${name}_start" + +trezord_start() +{ + if [ -z "$rc_fast" -a -n "$rc_pid" ]; then + echo 1>&2 "${name} already running? (pid=$rc_pid)." + return 1 + fi + echo "Starting ${name}." + /usr/sbin/daemon -p $pidfile ${command} ${command_args} + _run_rc_postcmd +} run_rc_command "$1" Index: head/security/trezord/pkg-descr =================================================================== --- head/security/trezord/pkg-descr (revision 472180) +++ head/security/trezord/pkg-descr (revision 472181) @@ -1,4 +1,4 @@ trezord (short for TREZOR Daemon), or TREZOR Bridge, is a small piece of software, used for websites, to talk with TREZOR devices. -WWW: https://github.com/trezor/trezord +WWW: https://github.com/trezor/trezord-go