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

Libusb cant initialize? #2

Open
bphermansson opened this issue Sep 25, 2018 · 16 comments
Open

Libusb cant initialize? #2

bphermansson opened this issue Sep 25, 2018 · 16 comments

Comments

@bphermansson
Copy link

Cant get the program to run on Peppermint OS:

sudo usb-reset -a
Unable to initialise libusb, exiting.

And then nothing more.

@ralight
Copy link
Owner

ralight commented Sep 25, 2018

That's a puzzler, it's about the first thing that is done. I've just pushed a change to this repository that attempts to print out the error from libusb, are you able to give it a try?

@bphermansson
Copy link
Author

Well it didn't compile:

gcc -c -Wall -O2 -ggdb -I/usr/include/libusb-1.0 -DVERSION="\"0.3\"" -o usb-reset.o usb-reset.c
usb-reset.c:24:10: fatal error: libusb.h: No such file or directory
 #include <libusb.h>
          ^~~~~~~~~~
compilation terminated.
Makefile:15: recipe for target 'usb-reset.o' failed
make: *** [usb-reset.o] Error 1

I took a shoot and installed libusb-dev and then it compiles and works. The version I first ran was a Snap, it still fails even though I installed the dev-lib.

@ralight
Copy link
Owner

ralight commented Sep 25, 2018

Ok... I wonder if there is a permission that isn't set on the snap that is required (or possibly Peppermint is doing something unusual).

If you're willing to do some more debugging, would you run the following commands to scan the snap security log for any issues related to usb-reset?

sudo snap install snappy-debug
sudo /snap/bin/snappy-debug.security scanlog usb-reset

The commands are from the bottom of this page: https://docs.snapcraft.io/build-snaps/debugging

@bphermansson
Copy link
Author

Ok, I tested that:

sudo /snap/bin/snappy-debug.security scanlog usb-reset
INFO: following '/var/log/syslog'. If have dropped messages, use:
INFO: $ sudo journalctl --output=short --follow --all | sudo snappy-debug.security scanlog
kernel.printk_ratelimit = 0

Then it just sits there.

@ralight
Copy link
Owner

ralight commented Sep 25, 2018

Hmm, ok. I thought that it scanned the old log messages but it might not - could you run the scanlog command, then try to run the usb-reset snap?

@bphermansson
Copy link
Author

Ok, I ran "sudo /snap/bin/snappy-debug.security scanlog" in one terminal, "sudo usb-reset -a" in another.
The scanlog then says:

 sudo /snap/bin/snappy-debug.security scanlog
INFO: following '/var/log/syslog'. If have dropped messages, use:
INFO: $ sudo journalctl --output=short --follow --all | sudo snappy-debug.security scanlog
kernel.printk_ratelimit = 0
= Seccomp =
Time: Sep 26 17:36:47
Log: auid=4294967295 uid=0 gid=0 ses=4294967295 pid=11810 comm="usb-reset" exe="/snap/usb-reset/7/usr/local/bin/usb-reset" sig=0 arch=c000003e 41(socket) compat=0 ip=0x7faf36b385a7 code=0x50000
Syscall: socket
Suggestions:
* add account-control (if using NETLINK_AUDIT)
* add bluetooth-control (if using AF_{ALG,BLUETOOTH})
* add firewall-control (if using NETLINK_{FIREWALL,IP6_FW,NETFILTER,NF_LOG,ROUTE})
* add hardware-observe (if using NETLINK_{GENERIC,KOBJECT_UEVENT})
* add netlink-audit (if using NETLINK_AUDIT)
* add netlink-connector (if using NETLINK_CONNECTOR)
* add network (if using AF_INET{,6}, NETLINK_ROUTE)
* add network-bind (if using AF_INET{,6}, NETLINK_ROUTE)
* add network-control (if using AF_{APPLETALK,BRIDGE,INET,INET6,IPX,PACKET,PPPOX,SNA}, NETLINK_{DNRTMSG,FIB_LOOKUP,GENERIC,INET_DIAG,ISCSI,KOBJECT_UEVENT,RDMA,ROUTE,XFRM})
* add network-observe (if using SOCK_RAW, AF_INET{,6}), NETLINK_{GENERIC,INET_DIAG,KOBJECT_UEVENT,ROUTE})
* add unity7 (if using NETLINK_KOBJECT_UEVENT)
* add x11 (if using NETLINK_KOBJECT_UEVENT)

@ralight
Copy link
Owner

ralight commented Sep 26, 2018

Ok, we're making progress! In the suggestions list it says "add network" - this should already be the case, so let's check if it has worked. Could you run:

snap interfaces usb-reset

This should give you an output like this:

Slot      Plug
:network  chromium,telegram-desktop,usb-reset
-         usb-reset:raw-usb

The important point here is that the network line exists, and that usb-reset is present. If it isn't present, then I don't know what has happened, it should be automatic.

@ralight
Copy link
Owner

ralight commented Sep 26, 2018

To fix:

sudo snap connect usb-reset:network core:network

@bphermansson
Copy link
Author

Well it's there:

snap interfaces usb-reset
Slot      Plug
:network  spotify,usb-reset
-         usb-reset:raw-usb

@ralight
Copy link
Owner

ralight commented Sep 27, 2018

Thanks for your help, I've got to the bottom of the problem - a change in recent versions of snapd of what interface is needed for observing hardware.

If you run "snap refresh" you should get the updated version that works.

@bphermansson
Copy link
Author

$snap refresh
All snaps up to date.
$sudo usb-reset -a
[sudo] password for patrik: 
Unable to initialise libusb, exiting.
usb-reset is installed as a snap. To allow it to function correctly you may need to run:
	sudo snap connect usb-reset:hardware-observe core:hardware-observe
	sudo snap connect usb-reset:raw-usb core:raw-usb

$sudo snap connect usb-reset:hardware-observe core:hardware-observe
$sudo snap connect usb-reset:raw-usb core:raw-usb
$sudo usb-reset -a
Unable to open device 10c4:ea60, are you root?
usb-reset is installed as a snap. To allow it to function correctly you may need to run:
	sudo snap connect usb-reset:hardware-observe core:hardware-observe
	sudo snap connect usb-reset:raw-usb core:raw-usb

@bphermansson
Copy link
Author

This problem still exists, I can't use the software.

@ralight
Copy link
Owner

ralight commented Oct 23, 2018

Could you retry the steps in #2 (comment) please?

@bphermansson
Copy link
Author

Like this?

sudo /snap/bin/snappy-debug.security scanlog
INFO: following '/var/log/syslog'. If have dropped messages, use:
INFO: $ sudo journalctl --output=short --follow --all | sudo snappy-debug.security scanlog
kernel.printk_ratelimit = 0
^C
kernel.printk_ratelimit = 5

patrik@PeppermintAthlon ~/Downloads $ sudo journalctl --output=short --follow --all | sudo snappy-debug.security scanlog
= AppArmor =
Time: okt 25 13:10:30
Log: apparmor="DENIED" operation="capable" profile="snap.snappy-debug.security" pid=28980 comm="python3" capability=2  capname="dac_read_search"

@ralight
Copy link
Owner

ralight commented Oct 25, 2018

Nearly :)

In one terminal run:

sudo /snap/bin/snappy-debug.security scanlog

In another terminal run:

sudo usb-reset -a

Then report back the output from the first terminal.

@bphermansson
Copy link
Author

Ok

sudo /snap/bin/snappy-debug.security scanlog
[sudo] password for patrik: 
INFO: following '/var/log/syslog'. If have dropped messages, use:
INFO: $ sudo journalctl --output=short --follow --all | sudo snappy-debug.security scanlog
kernel.printk_ratelimit = 0


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants