Explorar el Código

remove outdated solana-ledger-udev binary (#2955)

* remove outdated solana-ledger-udev binary

Currently there exists a solana-ledger-udev binary which creates a
udev rules file in /etc/udev/rules.d/20-hw1.rules and reloads the
udev rules.

This might work on some systems and not on others (e.g., NixOS) and
makes unnecessary assumptions about the currently running system.

These rules are also outdated and we're probably better off
referencing the upstream repository rules maintained by Ledger
https://github.com/LedgerHQ/udev-rules
and encouraging people to integrate them into their system.

* remote-wallet: add README

Add a README to remote-wallet which explains why this library exists and
where to get ledger udev rules from.
Patrick Reich hace 1 año
padre
commit
2013eb6ebf
Se han modificado 3 ficheros con 10 adiciones y 54 borrados
  1. 0 4
      remote-wallet/Cargo.toml
  2. 10 0
      remote-wallet/README.md
  3. 0 50
      remote-wallet/src/bin/ledger-udev.rs

+ 0 - 4
remote-wallet/Cargo.toml

@@ -34,9 +34,5 @@ linux-shared-libusb = ["hidapi/linux-shared-libusb"]
 linux-static-hidraw = ["hidapi/linux-static-hidraw"]
 linux-static-libusb = ["hidapi/linux-static-libusb"]
 
-[[bin]]
-name = "solana-ledger-udev"
-path = "src/bin/ledger-udev.rs"
-
 [package.metadata.docs.rs]
 targets = ["x86_64-unknown-linux-gnu"]

+ 10 - 0
remote-wallet/README.md

@@ -0,0 +1,10 @@
+Solana Remote Wallet
+===
+
+Library for interacting with "remote" wallets, meaning any wallet where the private key bytes are not directly available,
+such as Ledger devices.
+
+## Ledger udev-rules
+
+In order to use a Ledger device on Linux machines, users must apply certain udev rules. These are available at the
+[udev-rules repository](https://github.com/LedgerHQ/udev-rules) maintained by the Ledger team.

+ 0 - 50
remote-wallet/src/bin/ledger-udev.rs

@@ -1,50 +0,0 @@
-/// Implements udev rules on Linux for supported Ledger devices
-/// This script must be run with sudo privileges
-use std::{
-    error,
-    fs::{File, OpenOptions},
-    io::{Read, Write},
-    path::Path,
-    process::Command,
-};
-
-const LEDGER_UDEV_RULES: &str = r#"# Nano S
-SUBSYSTEMS=="usb", ATTRS{idVendor}=="2c97", ATTRS{idProduct}=="0001|1000|1001|1002|1003|1004|1005|1006|1007|1008|1009|100a|100b|100c|100d|100e|100f|1010|1011|1012|1013|1014|1015|1016|1017|1018|1019|101a|101b|101c|101d|101e|101f", TAG+="uaccess", TAG+="udev-acl", MODE="0666"
-# Nano X
-SUBSYSTEMS=="usb", ATTRS{idVendor}=="2c97", ATTRS{idProduct}=="0004|4000|4001|4002|4003|4004|4005|4006|4007|4008|4009|400a|400b|400c|400d|400e|400f|4010|4011|4012|4013|4014|4015|4016|4017|4018|4019|401a|401b|401c|401d|401e|401f", TAG+="uaccess", TAG+="udev-acl", MODE="0666""#;
-
-const LEDGER_UDEV_RULES_LOCATION: &str = "/etc/udev/rules.d/20-hw1.rules";
-
-fn main() -> Result<(), Box<dyn error::Error>> {
-    if cfg!(target_os = "linux") {
-        let mut contents = String::new();
-        if Path::new("/etc/udev/rules.d/20-hw1.rules").exists() {
-            let mut file = File::open(LEDGER_UDEV_RULES_LOCATION)?;
-            file.read_to_string(&mut contents)?;
-        }
-        if !contents.contains(LEDGER_UDEV_RULES) {
-            let mut file = OpenOptions::new()
-                .append(true)
-                .create(true)
-                .open(LEDGER_UDEV_RULES_LOCATION)
-                .inspect_err(|_e| {
-                    println!("Could not write to file; this script requires sudo privileges");
-                })?;
-            file.write_all(LEDGER_UDEV_RULES.as_bytes())?;
-
-            Command::new("udevadm").arg("trigger").output().unwrap();
-
-            Command::new("udevadm")
-                .args(["control", "--reload-rules"])
-                .output()
-                .unwrap();
-
-            println!("Ledger udev rules written");
-        } else {
-            println!("Ledger udev rules already in place");
-        }
-    } else {
-        println!("Mismatched target_os; udev rules only required on linux os");
-    }
-    Ok(())
-}