aboutsummaryrefslogtreecommitdiffstats
path: root/security
diff options
context:
space:
mode:
authorale <ale@FreeBSD.org>2018-06-11 18:08:10 +0800
committerale <ale@FreeBSD.org>2018-06-11 18:08:10 +0800
commit1ff3d6e893a8ce39646d3cac67e43f054664c0bf (patch)
tree533cfae61271bb4163dd0d5736f2af14c3522d47 /security
parentd2183049c9446062d29650d5ee00ec4188ac3b86 (diff)
downloadfreebsd-ports-gnome-1ff3d6e893a8ce39646d3cac67e43f054664c0bf.tar.gz
freebsd-ports-gnome-1ff3d6e893a8ce39646d3cac67e43f054664c0bf.tar.zst
freebsd-ports-gnome-1ff3d6e893a8ce39646d3cac67e43f054664c0bf.zip
Update to 2.0.14 release.
Switch from deprecated C++ version to supported Go version.
Diffstat (limited to 'security')
-rw-r--r--security/trezord/Makefile34
-rw-r--r--security/trezord/distinfo6
-rw-r--r--security/trezord/files/config.proto30
-rw-r--r--security/trezord/files/patch-CMakeLists.txt43
-rw-r--r--security/trezord/files/patch-freebsd242
-rw-r--r--security/trezord/files/patch-src_core.hpp33
-rw-r--r--security/trezord/files/patch-src_main.cpp26
-rw-r--r--security/trezord/files/patch-src_wire.hpp114
-rw-r--r--security/trezord/files/trezord.in17
-rw-r--r--security/trezord/files/usb.hpp174
-rw-r--r--security/trezord/pkg-descr2
11 files changed, 271 insertions, 450 deletions
diff --git a/security/trezord/Makefile b/security/trezord/Makefile
index 62d8314ab1be..f9a0a9621033 100644
--- a/security/trezord/Makefile
+++ b/security/trezord/Makefile
@@ -2,10 +2,8 @@
# $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
@@ -13,30 +11,16 @@ 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"
-
-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
+PATCH_STRIP= -p1
-do-install:
- ${INSTALL_PROGRAM} ${WRKSRC}/${PORTNAME} ${STAGEDIR}/${PREFIX}/sbin/
+PLIST_FILES= bin/${GH_PROJECT}
.include <bsd.port.mk>
diff --git a/security/trezord/distinfo b/security/trezord/distinfo
index 39230f9002ce..f2db48449e24 100644
--- a/security/trezord/distinfo
+++ b/security/trezord/distinfo
@@ -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
diff --git a/security/trezord/files/config.proto b/security/trezord/files/config.proto
deleted file mode 100644
index b7ffedd85157..000000000000
--- a/security/trezord/files/config.proto
+++ /dev/null
@@ -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
-}
diff --git a/security/trezord/files/patch-CMakeLists.txt b/security/trezord/files/patch-CMakeLists.txt
deleted file mode 100644
index 15b142f09c03..000000000000
--- a/security/trezord/files/patch-CMakeLists.txt
+++ /dev/null
@@ -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)
diff --git a/security/trezord/files/patch-freebsd b/security/trezord/files/patch-freebsd
new file mode 100644
index 000000000000..7e9ed9d63f63
--- /dev/null
+++ b/security/trezord/files/patch-freebsd
@@ -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 <sys/poll.h>
+
+ #include "os/threads_posix.c"
++#elif OS_FREEBSD
++ #include <stdlib.h>
+ #elif OS_DARWIN
+ #include <pthread.h>
+ #include <sys/poll.h>
+@@ -38,17 +42,21 @@ package usbhid
+ #include <oledlg.h>
+ #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 <libusb.h>
++#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 <libusb.h>
++#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
+
diff --git a/security/trezord/files/patch-src_core.hpp b/security/trezord/files/patch-src_core.hpp
deleted file mode 100644
index a802caee336d..000000000000
--- a/security/trezord/files/patch-src_core.hpp
+++ /dev/null
@@ -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(),
diff --git a/security/trezord/files/patch-src_main.cpp b/security/trezord/files/patch-src_main.cpp
deleted file mode 100644
index d865a29fcd91..000000000000
--- a/security/trezord/files/patch-src_main.cpp
+++ /dev/null
@@ -1,26 +0,0 @@
---- src/main.cpp.orig 2017-12-02 14:37:41 UTC
-+++ src/main.cpp
-@@ -33,7 +33,7 @@
- #include <easylogging++.h>
-
- #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;
diff --git a/security/trezord/files/patch-src_wire.hpp b/security/trezord/files/patch-src_wire.hpp
deleted file mode 100644
index 6af8f2253f81..000000000000
--- a/security/trezord/files/patch-src_wire.hpp
+++ /dev/null
@@ -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<char_type> buffer_type;
-- typedef std::array<char_type, 65> report_type;
-+ typedef std::array<char_type, 64> report_type;
-
-- hid_device *hid;
-+ libusb_device_handle *hid;
- buffer_type read_buffer;
- int hid_version;
- };
diff --git a/security/trezord/files/trezord.in b/security/trezord/files/trezord.in
index 5fdd0a6dd6fc..960d21d9b5cd 100644
--- a/security/trezord/files/trezord.in
+++ b/security/trezord/files/trezord.in
@@ -21,6 +21,21 @@ 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"
diff --git a/security/trezord/files/usb.hpp b/security/trezord/files/usb.hpp
deleted file mode 100644
index 24bca83840f4..000000000000
--- a/security/trezord/files/usb.hpp
+++ /dev/null
@@ -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 <http://www.gnu.org/licenses/>.
- */
-
-#include <stdio.h>
-#include <libusb.h>
-
-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;
- });
-}
-
-}
-}
diff --git a/security/trezord/pkg-descr b/security/trezord/pkg-descr
index 3a82010656a7..01d01b37b1b3 100644
--- a/security/trezord/pkg-descr
+++ b/security/trezord/pkg-descr
@@ -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