Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

internal/usbid: allow path override of usb.ids path #610

Merged
merged 2 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/.wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ hotplug
hotplugged
hotplugging
HTTPS
hwdata
ICMP
idmap
idmapped
Expand Down
1 change: 1 addition & 0 deletions doc/environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ Name | Description
`INCUS_OVMF_PATH` | Path to an OVMF build including `OVMF_CODE.fd` and `OVMF_VARS.ms.fd`
`INCUS_SECURITY_APPARMOR` | If set to `false`, forces AppArmor off
`INCUS_UI` | Path to the web UI to serve through the web server
`INCUS_USBIDS_PATH` | Path to the hwdata `usb.ids` file
7 changes: 6 additions & 1 deletion internal/usbid/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ var (

// Load reads the USB database from disk.
func Load() {
usbids, err := os.Open("/usr/share/misc/usb.ids")
usbidFile := os.Getenv("INCUS_USBIDS_PATH")
adamcstephens marked this conversation as resolved.
Show resolved Hide resolved
if usbidFile == "" {
usbidFile = "/usr/share/misc/usb.ids"
}

usbids, err := os.Open(usbidFile)
if err != nil {
if !os.IsNotExist(err) {
log.Printf("usbid: failed to load: %s", err)
Expand Down
Loading