diff options
Diffstat (limited to 'www/firefox/patches')
10 files changed, 8 insertions, 561 deletions
diff --git a/www/firefox/patches/patch-config_makefiles_rust.mk b/www/firefox/patches/patch-config_makefiles_rust.mk index bc272c08ae7..d4fbf77c350 100644 --- a/www/firefox/patches/patch-config_makefiles_rust.mk +++ b/www/firefox/patches/patch-config_makefiles_rust.mk @@ -1,12 +1,6 @@ -$NetBSD: patch-config_makefiles_rust.mk,v 1.2 2020/08/07 08:29:42 maya Exp $ +$NetBSD: patch-config_makefiles_rust.mk,v 1.3 2020/08/25 14:35:24 ryoon Exp $ -NetBSD doesn't get along with parallel rust builds (it causes issues -with ld.so) which are the default. Force -j1. - -Set -Cembed-bitcode=yes when using LTO to fix build with rust >= 1.45. -Upstream bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1640982 - ---- config/makefiles/rust.mk.orig 2020-04-03 19:34:34.000000000 +0000 +--- config/makefiles/rust.mk.orig 2020-08-19 02:08:50.000000000 +0000 +++ config/makefiles/rust.mk @@ -52,6 +52,9 @@ endif ifeq (1,$(MOZ_PARALLEL_BUILD)) @@ -18,15 +12,15 @@ Upstream bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1640982 # These flags are passed via `cargo rustc` and only apply to the final rustc # invocation (i.e., only the top-level crate, not its dependencies). -@@ -62,6 +65,11 @@ ifndef MOZ_DEBUG_RUST - # gkrust_gtest. - ifeq (,$(findstring gkrust_gtest,$(RUST_LIBRARY_FILE))) - cargo_rustc_flags += -Clto -+endif +@@ -68,6 +71,11 @@ endif + ifeq (,$(filter 1.38.% 1.39.% 1.40.% 1.41.% 1.42.% 1.43.% 1.44.%,$(RUSTC_VERSION))) + RUSTFLAGS += -Cembed-bitcode=yes + endif +# Versions of rust >= 1.45 need -Cembed-bitcode=yes for all crates when +# using -Clto. +ifeq (,$(filter 1.38.% 1.39.% 1.40.% 1.41.% 1.42.% 1.43.% 1.44.%,$(RUSTC_VERSION))) +RUSTFLAGS += -Cembed-bitcode=yes ++endif endif endif - endif + diff --git a/www/firefox/patches/patch-media_libvorbis_lib_vorbis__info.c b/www/firefox/patches/patch-media_libvorbis_lib_vorbis__info.c deleted file mode 100644 index 6c59d1ca20b..00000000000 --- a/www/firefox/patches/patch-media_libvorbis_lib_vorbis__info.c +++ /dev/null @@ -1,19 +0,0 @@ -$NetBSD: patch-media_libvorbis_lib_vorbis__info.c,v 1.1 2020/05/30 08:02:52 rillig Exp $ - -Fix undefined behavior when calling <ctype.h> functions with illegal values. - -media/libvorbis/lib/vorbis_info.c:81:8: error: array subscript is of type 'char' [-Werror,-Wchar-subscripts] - -https://bugzilla.mozilla.org/show_bug.cgi?id=1642081 - ---- media/libvorbis/lib/vorbis_info.c.orig 2020-05-07 18:34:46.000000000 +0000 -+++ media/libvorbis/lib/vorbis_info.c -@@ -78,7 +78,7 @@ void vorbis_comment_add_tag(vorbis_comme - static int tagcompare(const char *s1, const char *s2, int n){ - int c=0; - while(c < n){ -- if(toupper(s1[c]) != toupper(s2[c])) -+ if(toupper((unsigned char) s1[c]) != toupper((unsigned char) s2[c])) - return !0; - c++; - } diff --git a/www/firefox/patches/patch-third__party_rust_authenticator_.cargo-checksum.json b/www/firefox/patches/patch-third__party_rust_authenticator_.cargo-checksum.json deleted file mode 100644 index dfcb6e7de0b..00000000000 --- a/www/firefox/patches/patch-third__party_rust_authenticator_.cargo-checksum.json +++ /dev/null @@ -1,15 +0,0 @@ -$NetBSD: patch-third__party_rust_authenticator_.cargo-checksum.json,v 1.2 2020/07/16 14:46:56 riastradh Exp $ - -Add NetBSD support for U2F. - -Submitted upstream: - -https://github.com/mozilla/authenticator-rs/pull/116 - ---- third_party/rust/authenticator/.cargo-checksum.json.orig 2020-07-08 21:55:03.000000000 +0000 -+++ third_party/rust/authenticator/.cargo-checksum.json -@@ -1 +1 @@ --{"files":{"Cargo.lock":"4e90be1a6ead1f94b74ab22da0ad669e69bb7c112849d0e43e8942b83ca5ba7b","Cargo.toml":"31b25c3aadc79a147603253dee37c7fcd74e1a20bb62dd3d3b506e097b555fa2","LICENSE":"e866c8f5864d4cacfe403820e722e9dc03fe3c7565efa5e4dad9051d827bb92a","README.md":"f7b1f971632873f3d3c322c2f5cf980fbcd0116786efb580b89fe6ddac07fc07","build.rs":"bc308b771ae9741d775370e3efe45e9cca166fd1d0335f4214b00497042ccc55","examples/main.rs":"7af9e288b1836fb9362589b6bf54c1f1d277bdf64df60c1caccef98c1bfe792c","rustfmt.toml":"de4e1daab481c1572805aed3e51e72c5dc1b3e5af757bc675e1717b251c6e922","src/capi.rs":"99f0d0742bf102451698c7e32db0fc4941b8ac10bec2fb309f41e7e5d99b05bd","src/consts.rs":"4c34980f94d1017e5e75e29b26750c1678e0609c9227296951ffbb9e180a5adf","src/freebsd/device.rs":"914ac446ff24cc3fc050732372e286e1fedf8341a8d4754e392bc9f38393b142","src/freebsd/mod.rs":"42dcb57fbeb00140003a8ad39acac9b547062b8f281a3fa5deb5f92a6169dde6","src/freebsd/monitor.rs":"3683370931b15f05403d240a788a87b1bea801284ee74b849e1f330a4a231dd0","src/freebsd/transaction.rs":"e3615cfdd7f23e9a80a53c32e0fa2a5ae290a432b009bed2b2e74e0df77f8266","src/freebsd/uhid.rs":"d19ade6e808e63981ba5f93d482d676ffa9dff29cb2b7011486591f69ddbbdcd","src/hidproto.rs":"9de8d86509d706e3a0ade2b5a57eec7730afd4073d9cdd99aa8ca1376be37f83","src/lib.rs":"4b43ad18b4eae9356ba6d7954542a38f3015ab8a72ab1fde28169aaf343721d8","src/linux/device.rs":"2271fbb8d176ec01f83a899c0c8194a954465fdd8670a9b136ab88baaba2ee48","src/linux/hidraw.rs":"0d5804d1cd99e7c30c8bde3089f8ed98d7d683d3cd487821e29b133b1ee90228","src/linux/hidwrapper.h":"72785db3a9b27ea72b6cf13a958fee032af54304522d002f56322473978a20f9","src/linux/hidwrapper.rs":"4be65676cf3220929700bf4906938dcbd1538ba53d40c60b08f9ba8890c910f6","src/linux/ioctl_aarch64le.rs":"f482a967c8006d0c34c03e9f2aeca4c4f426c5c27f7f930f3230129caf176060","src/linux/ioctl_armle.rs":"f482a967c8006d0c34c03e9f2aeca4c4f426c5c27f7f930f3230129caf176060","src/linux/ioctl_mips64le.rs":"fbda309934ad8bda689cd4fb5c0ca696fe26dedb493fe9d5a5322c3047d474fd","src/linux/ioctl_powerpc64be.rs":"fbda309934ad8bda689cd4fb5c0ca696fe26dedb493fe9d5a5322c3047d474fd","src/linux/ioctl_powerpc64le.rs":"0d50afd0bf094b5146d65d263544cba141ff248e487d90d6c03559e9b3c2fd55","src/linux/ioctl_powerpcbe.rs":"0d50afd0bf094b5146d65d263544cba141ff248e487d90d6c03559e9b3c2fd55","src/linux/ioctl_s390xbe.rs":"2d8b265cd39a9f46816f83d5a5df0701c13eb842bc609325bad42ce50add3bf0","src/linux/ioctl_x86.rs":"f482a967c8006d0c34c03e9f2aeca4c4f426c5c27f7f930f3230129caf176060","src/linux/ioctl_x86_64.rs":"f482a967c8006d0c34c03e9f2aeca4c4f426c5c27f7f930f3230129caf176060","src/linux/mod.rs":"446e435126d2a58f167f648dd95cba28e8ac9c17f1f799e1eaeab80ea800fc57","src/linux/monitor.rs":"57890c5f000829c5c0f44032fe5364126e60451605d517c79ba4d4fe4fd6c94b","src/linux/transaction.rs":"92b47d064c1fa5fe2674f65d06c519601480fc1c2b03667ade19a186a6ec9d13","src/macos/device.rs":"29863c88f851a957ec754f16aae6f789b300b00fcfe9a6c198a7cdcf1c9fcfe4","src/macos/iokit.rs":"a0fd818224718e96ad5d106dfc235f4bc9218a59f5114b9f9825abe3ee62bce7","src/macos/mod.rs":"333e561554fc901d4f6092f6e4c85823e2b0c4ff31c9188d0e6d542b71a0a07c","src/macos/monitor.rs":"d3a1dadfbfb5bfd665d75493d72bfbca3da9c43692262230f10d5feadb928e62","src/macos/transaction.rs":"cf2e67530401b0ef18e978557f470aa2661b3a5f4ef64cd3053d6e11f2f19b2b","src/manager.rs":"7428fc23038b004841936d8f27f8dc33234d5c06361efa75b73c7a5c035dae75","src/openbsd/device.rs":"b5de51a8b3ae0e542373a2064cff1ae6e1f91ac78e1406805d9ca8a05ce758c9","src/openbsd/mod.rs":"514274d414042ff84b3667a41a736e78581e22fda87ccc97c2bc05617e381a30","src/openbsd/monitor.rs":"953800ab8fd6adf5d70633059b20d2cf0f5a2701d92e58a06d1ec33208983bc4","src/openbsd/transaction.rs":"10be1ce983c72513fec57baaa6869ef02b9cdbd8ea66bb2dfe24d857faf054f5","src/statemachine.rs":"28477fba601f5086b85e911da1e4f04af3f0060329e6e0e1172b960f9c52fd41","src/stub/device.rs":"32e134fc8826667d16b02fe32831fc29f4d52d0a7a065d7d649c4a1c5faa0dcc","src/stub/mod.rs":"6a7fec504a52d403b0241b18cd8b95088a31807571f4c0a67e4055afc74f4453","src/stub/transaction.rs":"8655bc37b69c318ff0bc69a62fcb31820eb6ad7921a53e0cecffa15e80d97630","src/u2fhid-capi.h":"fc2575f720ab8f6bc0c523c57310f35c464576bd5150c3c2b1873d3abde5909b","src/u2fprotocol.rs":"77b6d5005d8b3d98cd96e480013c1e97155da5df3cf5e19819ee82ac8e3b6c7d","src/u2ftypes.rs":"cf972d805b15a95f4c18d556aa01660ce451f1d3bce1516b0ce73d17e73199aa","src/util.rs":"c517750c9bf00f44fb63cada8c40d0227a4d3765488499a1f4d3c0f01daa67a7","src/windows/device.rs":"86a6ecc239608977a963f375336780746e90e95c3eb9ff303347beb983c40ab6","src/windows/mod.rs":"218e7f2fe91ecb390c12bba5a5ffdad2c1f0b22861c937f4d386262e5b3dd617","src/windows/monitor.rs":"d8e8316e5bd9fc6ebed737bd8d6e0713c99287aca04f392f6319cdfd8576f754","src/windows/transaction.rs":"1b9a5af866048911ccaec8c94b698b28ae1b80e3d4842f9d6ed38462f459c796","src/windows/winapi.rs":"a4286fd5e8dcb178e37df512ba7752b2a3c38fe30e1176022767d2c05c242bf8"},"package":"ff593fb4dd388fe452c5e63d4d668699466bd46b571c4b852dfbca4bac8f0706"} -\ No newline at end of file -+{"files":{},"package":"ff593fb4dd388fe452c5e63d4d668699466bd46b571c4b852dfbca4bac8f0706"} -\ No newline at end of file diff --git a/www/firefox/patches/patch-third__party_rust_authenticator_src_lib.rs b/www/firefox/patches/patch-third__party_rust_authenticator_src_lib.rs deleted file mode 100644 index dd6807f9f28..00000000000 --- a/www/firefox/patches/patch-third__party_rust_authenticator_src_lib.rs +++ /dev/null @@ -1,38 +0,0 @@ -$NetBSD: patch-third__party_rust_authenticator_src_lib.rs,v 1.2 2020/07/16 14:46:56 riastradh Exp $ - -Add NetBSD support for U2F. - -Submitted upstream: - -https://github.com/mozilla/authenticator-rs/pull/116 - ---- third_party/rust/authenticator/src/lib.rs.orig 2020-07-08 19:27:16.000000000 +0000 -+++ third_party/rust/authenticator/src/lib.rs -@@ -5,7 +5,7 @@ - #[macro_use] - mod util; - --#[cfg(any(target_os = "linux", target_os = "freebsd"))] -+#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "netbsd"))] - pub mod hidproto; - - #[cfg(any(target_os = "linux"))] -@@ -22,6 +22,10 @@ extern crate devd_rs; - #[path = "freebsd/mod.rs"] - pub mod platform; - -+#[cfg(any(target_os = "netbsd"))] -+#[path = "netbsd/mod.rs"] -+pub mod platform; -+ - #[cfg(any(target_os = "openbsd"))] - #[path = "openbsd/mod.rs"] - pub mod platform; -@@ -41,6 +45,7 @@ pub mod platform; - target_os = "linux", - target_os = "freebsd", - target_os = "openbsd", -+ target_os = "netbsd", - target_os = "macos", - target_os = "windows" - )))] diff --git a/www/firefox/patches/patch-third__party_rust_authenticator_src_netbsd_device.rs b/www/firefox/patches/patch-third__party_rust_authenticator_src_netbsd_device.rs deleted file mode 100644 index 978bc74204b..00000000000 --- a/www/firefox/patches/patch-third__party_rust_authenticator_src_netbsd_device.rs +++ /dev/null @@ -1,145 +0,0 @@ -$NetBSD: patch-third__party_rust_authenticator_src_netbsd_device.rs,v 1.2 2020/07/16 14:46:56 riastradh Exp $ - -Add NetBSD support for U2F. - -Submitted upstream: - -https://github.com/mozilla/authenticator-rs/pull/116 - ---- third_party/rust/authenticator/src/netbsd/device.rs.orig 2020-07-15 16:29:34.208835297 +0000 -+++ third_party/rust/authenticator/src/netbsd/device.rs -@@ -0,0 +1,134 @@ -+/* This Source Code Form is subject to the terms of the Mozilla Public -+ * License, v. 2.0. If a copy of the MPL was not distributed with this -+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -+ -+extern crate libc; -+ -+use std::mem; -+use std::io::Read; -+use std::io::Write; -+use std::io; -+ -+use consts::CID_BROADCAST; -+use consts::HID_RPT_SIZE; -+use platform::fd::Fd; -+use platform::uhid; -+use u2ftypes::U2FDevice; -+use util::io_err; -+ -+#[derive(Debug)] -+pub struct Device { -+ fd: Fd, -+ cid: [u8; 4], -+} -+ -+impl Device { -+ pub fn new(fd: Fd) -> io::Result<Self> { -+ Ok(Self { fd, cid: CID_BROADCAST }) -+ } -+ -+ pub fn is_u2f(&mut self) -> bool { -+ if !uhid::is_u2f_device(&self.fd) { -+ return false; -+ } -+ // This step is not strictly necessary -- NetBSD puts fido -+ // devices into raw mode automatically by default, but in -+ // principle that might change, and this serves as a test to -+ // verify that we're running on a kernel with support for raw -+ // mode at all so we don't get confused issuing writes that try -+ // to set the report descriptor rather than transfer data on -+ // the output interrupt pipe as we need. -+ match uhid::hid_set_raw(&self.fd, true) { -+ Ok(_) => (), -+ Err(_) => return false, -+ } -+ if let Err(_) = self.ping() { -+ return false; -+ } -+ true -+ } -+ -+ fn ping(&mut self) -> io::Result<()> { -+ for i in 0..10 { -+ let mut buf = vec![0u8; 1 + HID_RPT_SIZE]; -+ -+ buf[0] = 0; // report number -+ buf[1] = 0xff; // CID_BROADCAST -+ buf[2] = 0xff; -+ buf[3] = 0xff; -+ buf[4] = 0xff; -+ buf[5] = 0x81; // ping -+ buf[6] = 0; -+ buf[7] = 1; // one byte -+ -+ self.write(&buf[..])?; -+ -+ // Wait for response -+ let mut pfd: libc::pollfd = unsafe { mem::zeroed() }; -+ pfd.fd = self.fd.fileno; -+ pfd.events = libc::POLLIN; -+ let nfds = unsafe { libc::poll(&mut pfd, 1, 100) }; -+ if nfds == -1 { -+ return Err(io::Error::last_os_error()); -+ } -+ if nfds == 0 { -+ debug!("device timeout {}", i); -+ continue; -+ } -+ -+ // Read response -+ self.read(&mut buf[..])?; -+ -+ return Ok(()); -+ } -+ -+ Err(io_err("no response from device")) -+ } -+} -+ -+impl PartialEq for Device { -+ fn eq(&self, other: &Device) -> bool { -+ self.fd == other.fd -+ } -+} -+ -+impl Read for Device { -+ fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> { -+ let bufp = buf.as_mut_ptr() as *mut libc::c_void; -+ let nread = unsafe { libc::read(self.fd.fileno, bufp, buf.len()) }; -+ if nread == -1 { -+ return Err(io::Error::last_os_error()); -+ } -+ Ok(nread as usize) -+ } -+} -+ -+impl Write for Device { -+ fn write(&mut self, buf: &[u8]) -> io::Result<usize> { -+ // Always skip the first byte (report number) -+ let data = &buf[1..]; -+ let data_ptr = data.as_ptr() as *const libc::c_void; -+ let nwrit = unsafe { -+ libc::write(self.fd.fileno, data_ptr, data.len()) -+ }; -+ if nwrit == -1 { -+ return Err(io::Error::last_os_error()); -+ } -+ // Pretend we wrote the report number byte -+ Ok(nwrit as usize + 1) -+ } -+ -+ fn flush(&mut self) -> io::Result<()> { -+ Ok(()) -+ } -+} -+ -+impl U2FDevice for Device { -+ fn get_cid<'a>(&'a self) -> &'a [u8; 4] { -+ &self.cid -+ } -+ -+ fn set_cid(&mut self, cid: [u8; 4]) { -+ self.cid = cid; -+ } -+} diff --git a/www/firefox/patches/patch-third__party_rust_authenticator_src_netbsd_fd.rs b/www/firefox/patches/patch-third__party_rust_authenticator_src_netbsd_fd.rs deleted file mode 100644 index 933566f645f..00000000000 --- a/www/firefox/patches/patch-third__party_rust_authenticator_src_netbsd_fd.rs +++ /dev/null @@ -1,58 +0,0 @@ -$NetBSD: patch-third__party_rust_authenticator_src_netbsd_fd.rs,v 1.2 2020/07/16 14:46:56 riastradh Exp $ - -Add NetBSD support for U2F. - -Submitted upstream: - -https://github.com/mozilla/authenticator-rs/pull/116 - ---- third_party/rust/authenticator/src/netbsd/fd.rs.orig 2020-07-15 16:29:34.209237373 +0000 -+++ third_party/rust/authenticator/src/netbsd/fd.rs -@@ -0,0 +1,47 @@ -+/* This Source Code Form is subject to the terms of the Mozilla Public -+ * License, v. 2.0. If a copy of the MPL was not distributed with this -+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -+ -+extern crate libc; -+ -+use std::ffi::CString; -+use std::io; -+use std::mem; -+use std::os::raw::c_int; -+use std::os::unix::io::RawFd; -+ -+#[derive(Debug)] -+pub struct Fd { -+ pub fileno: RawFd, -+} -+ -+impl Fd { -+ pub fn open(path: &str, flags: c_int) -> io::Result<Fd> { -+ let cpath = CString::new(path.as_bytes())?; -+ let rv = unsafe { libc::open(cpath.as_ptr(), flags) }; -+ if rv == -1 { -+ return Err(io::Error::last_os_error()); -+ } -+ Ok(Fd { fileno: rv }) -+ } -+} -+ -+impl Drop for Fd { -+ fn drop(&mut self) { -+ unsafe { libc::close(self.fileno) }; -+ } -+} -+ -+impl PartialEq for Fd { -+ fn eq(&self, other: &Fd) -> bool { -+ let mut st: libc::stat = unsafe { mem::zeroed() }; -+ let mut sto: libc::stat = unsafe { mem::zeroed() }; -+ if unsafe { libc::fstat(self.fileno, &mut st) } == -1 { -+ return false; -+ } -+ if unsafe { libc::fstat(other.fileno, &mut sto) } == -1 { -+ return false; -+ } -+ (st.st_dev == sto.st_dev) & (st.st_ino == sto.st_ino) -+ } -+} diff --git a/www/firefox/patches/patch-third__party_rust_authenticator_src_netbsd_mod.rs b/www/firefox/patches/patch-third__party_rust_authenticator_src_netbsd_mod.rs deleted file mode 100644 index 05b6f9bfe0d..00000000000 --- a/www/firefox/patches/patch-third__party_rust_authenticator_src_netbsd_mod.rs +++ /dev/null @@ -1,21 +0,0 @@ -$NetBSD: patch-third__party_rust_authenticator_src_netbsd_mod.rs,v 1.2 2020/07/16 14:46:56 riastradh Exp $ - -Add NetBSD support for U2F. - -Submitted upstream: - -https://github.com/mozilla/authenticator-rs/pull/116 - ---- third_party/rust/authenticator/src/netbsd/mod.rs.orig 2020-07-15 16:29:34.210141360 +0000 -+++ third_party/rust/authenticator/src/netbsd/mod.rs -@@ -0,0 +1,10 @@ -+/* This Source Code Form is subject to the terms of the Mozilla Public -+ * License, v. 2.0. If a copy of the MPL was not distributed with this -+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -+ -+pub mod device; -+pub mod transaction; -+ -+mod fd; -+mod monitor; -+mod uhid; diff --git a/www/firefox/patches/patch-third__party_rust_authenticator_src_netbsd_monitor.rs b/www/firefox/patches/patch-third__party_rust_authenticator_src_netbsd_monitor.rs deleted file mode 100644 index 69fb11e1020..00000000000 --- a/www/firefox/patches/patch-third__party_rust_authenticator_src_netbsd_monitor.rs +++ /dev/null @@ -1,100 +0,0 @@ -$NetBSD: patch-third__party_rust_authenticator_src_netbsd_monitor.rs,v 1.2 2020/07/16 14:46:56 riastradh Exp $ - -Add NetBSD support for U2F. - -Submitted upstream: - -https://github.com/mozilla/authenticator-rs/pull/116 - ---- third_party/rust/authenticator/src/netbsd/monitor.rs.orig 2020-07-15 16:29:34.210607689 +0000 -+++ third_party/rust/authenticator/src/netbsd/monitor.rs -@@ -0,0 +1,89 @@ -+/* This Source Code Form is subject to the terms of the Mozilla Public -+ * License, v. 2.0. If a copy of the MPL was not distributed with this -+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -+ -+use std::collections::HashMap; -+use std::ffi::OsString; -+use std::io; -+use std::sync::Arc; -+use std::thread; -+use std::time::Duration; -+ -+use runloop::RunLoop; -+ -+use platform::fd::Fd; -+ -+// XXX Should use drvctl, but it doesn't do pubsub properly yet so -+// DRVGETEVENT requires write access to /dev/drvctl. Instead, for now, -+// just poll every 500ms. -+const POLL_TIMEOUT: u64 = 500; -+ -+pub struct Monitor<F> -+where -+ F: Fn(Fd, &dyn Fn() -> bool) + Send + Sync + 'static, -+{ -+ runloops: HashMap<OsString, RunLoop>, -+ new_device_cb: Arc<F>, -+} -+ -+impl<F> Monitor<F> -+where -+ F: Fn(Fd, &dyn Fn() -> bool) + Send + Sync + 'static, -+{ -+ pub fn new(new_device_cb: F) -> Self { -+ Self { -+ runloops: HashMap::new(), -+ new_device_cb: Arc::new(new_device_cb), -+ } -+ } -+ -+ pub fn run(&mut self, alive: &dyn Fn() -> bool) -> io::Result<()> { -+ while alive() { -+ for n in 0..100 { -+ let uhidpath = format!("/dev/uhid{}", n); -+ match Fd::open(&uhidpath, libc::O_RDWR | libc::O_CLOEXEC) { -+ Ok(uhid) => { -+ self.add_device(uhid, OsString::from(&uhidpath)); -+ }, -+ Err(ref err) => { -+ match err.raw_os_error() { -+ Some(libc::EBUSY) => continue, -+ Some(libc::ENOENT) => break, -+ _ => self.remove_device(OsString::from(&uhidpath)), -+ } -+ }, -+ } -+ } -+ thread::sleep(Duration::from_millis(POLL_TIMEOUT)); -+ } -+ self.remove_all_devices(); -+ Ok(()) -+ } -+ -+ fn add_device(&mut self, fd: Fd, path: OsString) { -+ let f = self.new_device_cb.clone(); -+ -+ let runloop = RunLoop::new(move |alive| { -+ if alive() { -+ f(fd, alive); -+ } -+ }); -+ -+ if let Ok(runloop) = runloop { -+ self.runloops.insert(path.clone(), runloop); -+ } -+ } -+ -+ fn remove_device(&mut self, path: OsString) { -+ if let Some(runloop) = self.runloops.remove(&path) { -+ runloop.cancel(); -+ } -+ } -+ -+ fn remove_all_devices(&mut self) { -+ while !self.runloops.is_empty() { -+ let path = self.runloops.keys().next().unwrap().clone(); -+ self.remove_device(path); -+ } -+ } -+} diff --git a/www/firefox/patches/patch-third__party_rust_authenticator_src_netbsd_transaction.rs b/www/firefox/patches/patch-third__party_rust_authenticator_src_netbsd_transaction.rs deleted file mode 100644 index 8e31a59bd52..00000000000 --- a/www/firefox/patches/patch-third__party_rust_authenticator_src_netbsd_transaction.rs +++ /dev/null @@ -1,61 +0,0 @@ -$NetBSD: patch-third__party_rust_authenticator_src_netbsd_transaction.rs,v 1.2 2020/07/16 14:46:56 riastradh Exp $ - -Add NetBSD support for U2F. - -Submitted upstream: - -https://github.com/mozilla/authenticator-rs/pull/116 - ---- third_party/rust/authenticator/src/netbsd/transaction.rs.orig 2020-07-15 16:29:34.212621486 +0000 -+++ third_party/rust/authenticator/src/netbsd/transaction.rs -@@ -0,0 +1,50 @@ -+/* This Source Code Form is subject to the terms of the Mozilla Public -+ * License, v. 2.0. If a copy of the MPL was not distributed with this -+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -+ -+use runloop::RunLoop; -+use util::OnceCallback; -+ -+use platform::fd::Fd; -+use platform::monitor::Monitor; -+ -+pub struct Transaction { -+ // Handle to the thread loop. -+ thread: Option<RunLoop>, -+} -+ -+impl Transaction { -+ pub fn new<F, T>( -+ timeout: u64, -+ callback: OnceCallback<T>, -+ new_device_cb: F, -+ ) -> Result<Self, ::Error> -+ where -+ F: Fn(Fd, &dyn Fn() -> bool) + Sync + Send + 'static, -+ T: 'static, -+ { -+ let thread = RunLoop::new_with_timeout( -+ move |alive| { -+ // Create a new device monitor. -+ let mut monitor = Monitor::new(new_device_cb); -+ -+ // Start polling for new devices. -+ try_or!(monitor.run(alive), |_| callback.call(Err(::Error::Unknown))); -+ -+ // Send an error, if the callback wasn't called already. -+ callback.call(Err(::Error::NotAllowed)); -+ }, -+ timeout, -+ ) -+ .map_err(|_| ::Error::Unknown)?; -+ -+ Ok(Self { -+ thread: Some(thread), -+ }) -+ } -+ -+ pub fn cancel(&mut self) { -+ // This must never be None. -+ self.thread.take().unwrap().cancel(); -+ } -+} diff --git a/www/firefox/patches/patch-third__party_rust_authenticator_src_netbsd_uhid.rs b/www/firefox/patches/patch-third__party_rust_authenticator_src_netbsd_uhid.rs deleted file mode 100644 index 2128ad86dc2..00000000000 --- a/www/firefox/patches/patch-third__party_rust_authenticator_src_netbsd_uhid.rs +++ /dev/null @@ -1,90 +0,0 @@ -$NetBSD: patch-third__party_rust_authenticator_src_netbsd_uhid.rs,v 1.2 2020/07/16 14:46:56 riastradh Exp $ - -Add NetBSD support for U2F. - -Submitted upstream: - -https://github.com/mozilla/authenticator-rs/pull/116 - ---- third_party/rust/authenticator/src/netbsd/uhid.rs.orig 2020-07-15 16:29:34.213005315 +0000 -+++ third_party/rust/authenticator/src/netbsd/uhid.rs -@@ -0,0 +1,79 @@ -+/* This Source Code Form is subject to the terms of the Mozilla Public -+ * License, v. 2.0. If a copy of the MPL was not distributed with this -+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -+ -+extern crate libc; -+ -+use std::io; -+use std::mem; -+use std::os::raw::c_int; -+use std::os::raw::c_uchar; -+ -+use hidproto::ReportDescriptor; -+use hidproto::has_fido_usage; -+use platform::fd::Fd; -+use util::io_err; -+ -+/* sys/ioccom.h */ -+ -+const IOCPARM_MASK: u32 = 0x1fff; -+const IOCPARM_SHIFT: u32 = 16; -+const IOCGROUP_SHIFT: u32 = 8; -+ -+//const IOC_VOID: u32 = 0x20000000; -+const IOC_OUT: u32 = 0x40000000; -+const IOC_IN: u32 = 0x80000000; -+//const IOC_INOUT: u32 = IOC_IN|IOC_OUT; -+ -+macro_rules! ioctl { -+ ($dir:expr, $name:ident, $group:expr, $nr:expr, $ty:ty) => { -+ unsafe fn $name(fd: libc::c_int, val: *mut $ty) -+ -> io::Result<libc::c_int> { -+ let ioc = ($dir as u32) -+ | ((mem::size_of::<$ty>() as u32 & IOCPARM_MASK) -+ << IOCPARM_SHIFT) -+ | (($group as u32) << IOCGROUP_SHIFT) -+ | ($nr as u32); -+ let rv = libc::ioctl(fd, ioc as libc::c_ulong, val); -+ if rv == -1 { -+ return Err(io::Error::last_os_error()); -+ } -+ Ok(rv) -+ } -+ }; -+} -+ -+#[allow(non_camel_case_types)] -+#[repr(C)] -+struct usb_ctl_report_desc { -+ ucrd_size: c_int, -+ ucrd_data: [c_uchar; 1024], -+} -+ -+ioctl!(IOC_OUT, usb_get_report_desc, b'U', 21, usb_ctl_report_desc); -+ -+fn read_report_descriptor(fd: &Fd) -> io::Result<ReportDescriptor> { -+ let mut desc = unsafe { mem::zeroed() }; -+ unsafe { usb_get_report_desc(fd.fileno, &mut desc) }?; -+ if desc.ucrd_size < 0 { -+ return Err(io_err("negative report descriptor size")); -+ } -+ let size = desc.ucrd_size as usize; -+ let value = Vec::from(&desc.ucrd_data[..size]); -+ Ok(ReportDescriptor { value }) -+} -+ -+pub fn is_u2f_device(fd: &Fd) -> bool { -+ match read_report_descriptor(fd) { -+ Ok(desc) => has_fido_usage(desc), -+ Err(_) => false, -+ } -+} -+ -+ioctl!(IOC_IN, usb_hid_set_raw_ioctl, b'h', 2, c_int); -+ -+pub fn hid_set_raw(fd: &Fd, raw: bool) -> io::Result<()> { -+ let mut raw_int: c_int = if raw { 1 } else { 0 }; -+ unsafe { usb_hid_set_raw_ioctl(fd.fileno, &mut raw_int) }?; -+ Ok(()) -+} |