Closed AbigailBuccaneer closed 6 years ago
Thanks, Abigail! I added your udev file at the end of the README to start. Maybe it makes sense to have it as a make option. My only hesitation is that even this super-simple Makefile is already not portable across Linux distros (it does not work on Fedora, for example). I prefer not to include distro-specific stuff.
Thanks, Bill
On Mon, Feb 8, 2016 at 3:44 AM, Abigail notifications@github.com wrote:
software/README talks about running as a daemon, and using rngd to add entropy from a FIFO to /dev/random. However, it's possible to use udev to start the daemon whenever the infnoise is plugged in, as so:
$ cat /etc/udev/rules.d/75-infnoise.rules ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6015", RUN+="/usr/local/bin/infnoise --dev-random --daemon"
Many similar software packages for hardware will ship udev rules in the repository with instructions on how to add the rules and check that they're working. I think this would be useful for infnoise, as it provides the lowest-friction way to use the infnoise.
If you think this would be useful in the repository, I can make a pull request with a rules file and instructions on how to use it (and maybe even make rules to install infnoise and the rules).
— Reply to this email directly or view it on GitHub https://github.com/waywardgeek/infnoise/issues/12.
Hi there,
I have some problems running infnoise with this method. When I run it from the command line everything runs smoothly and I can generate random nums for hours with gpg. But when the same command (i.e /usr/local/bin/infnoise --dev-random --daemon) is executed by the udev rule above it crash after a while (generally a few seconds).
Here is what strace says:
select(5, NULL, [4], NULL, {0, 1000}) = 1 (out [4], left {0, 982}) ioctl(4, USBDEVFS_REAPURBNDELAY, 0x7fff171a38f8) = 0 ioctl(4, USBDEVFS_SUBMITURB, 0x7fff171a3930) = 0 ioctl(4, USBDEVFS_REAPURBNDELAY, 0x7fff171a38f8) = -1 EAGAIN (Resource temporarily unavailable) select(5, NULL, [4], NULL, {0, 1000}) = 1 (out [4], left {0, 993}) ioctl(4, USBDEVFS_REAPURBNDELAY, 0x7fff171a38f8) = 0 ioctl(3, RNDGETENTCNT, 0x7fff171a3a8c) = 0 poll([{fd=3, events=POLLOUT}], 1, 1000) = 0 (Timeout) ioctl(3, RNDADDENTROPY, 0x11b9010) = 0 ioctl(4, USBDEVFS_SUBMITURB, 0x7fff171a3960) = -1 EBUSY (Device or resource busy) write(2, "USB write failed\n", 17) = -1 EPIPE (Broken pipe) --- SIGPIPE {si_signo=SIGPIPE, si_code=SI_USER, si_pid=2527, si_uid=0} --- exit_group(-1) = ? +++ exited with 255 +++
So I guess it has something to do with ftdi_write_data. Any idea why it works fine when executed from command line and not from udev rule ?
And BTW there seems to be a zombie process just after plugin-in the device:
asusport ~ # ps faux|grep infnoise
root 1002 0.0 0.0 0 0 ? Z 16:43 0:00 [infnoise]
Hello,
This method doe's not work on Debian Jessie.
Here is relevant dmesg output on device insertion:
[83350.556035] usb 2-4: new full-speed USB device number 18 using ohci-pci [83350.787052] usb 2-4: New USB device found, idVendor=0403, idProduct=6015 [83350.792483] usb 2-4: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [83350.797963] usb 2-4: Product: FT240X USB FIFO [83350.803363] usb 2-4: Manufacturer: FTDI [83350.808681] usb 2-4: SerialNumber: DN004WRD [83350.822111] ftdi_sio 2-4:1.0: FTDI USB Serial Device converter detected [83350.828454] usb 2-4: Detected FT-X [83350.833961] usb 2-4: Number of endpoints 2 [83350.839446] usb 2-4: Endpoint 1 MaxPacketSize 64 [83350.844883] usb 2-4: Endpoint 2 MaxPacketSize 64 [83350.850146] usb 2-4: Setting MaxPacketSize 64 [83350.863116] usb 2-4: FTDI USB Serial Device converter now attached to ttyUSB0 [83351.068409] ftdi_sio ttyUSB0: FTDI USB Serial Device converter now disconnected from ttyUSB0 [83351.074254] ftdi_sio 2-4:1.0: device disconnected [83382.640061] usb 2-4: usbfs: process 6260 (infnoise) did not claim interface 0 before use
Here is relevant journalctl output:
<...> same as above <...> Aug 17 16:17:33 homeserv kernel: ftdi_sio ttyUSB0: FTDI USB Serial Device converter now disconnected from ttyUSB0 Aug 17 16:17:33 homeserv kernel: ftdi_sio 2-4:1.0: device disconnected Aug 17 16:18:03 homeserv systemd-udevd[6258]: timeout '/usr/local/bin/infnoise --dev-random --daemon' Aug 17 16:18:04 homeserv kernel: usb 2-4: usbfs: process 6260 (infnoise) did not claim interface 0 before use Aug 17 16:18:34 homeserv systemd-udevd[6258]: timeout '/usr/local/bin/infnoise --dev-random --daemon'
If started by user from console runs as expected.
Actually, using udev to run a program is not allowed, but we can start a daemon or even better, systemd service!
I also had trouble with the driver being killed and constantly restarted.
Changed the udev rule to the following:
ACTION=="add", SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6015", TAG+="systemd", ENV{SYSTEMD_WANTS}="infnoise.service"
This starts the systemd service whenever the Infinite Noise TRNG is attached! Added pull request #18
Another improvement to stop the service when the device is unplugged is in pull request #21
Is everything working OK with udev now? If so, I'll close this issue.
On Ubuntu (17.04) and Raspbian (8.0) it works great.
A thing to be noticed is that the driver will not get restarted if it should ever stop or crash. Using the Restart=always in the unit file will also continue restarting after the device was unplugged...
Instead of restarting, I'd prefer to add some logging first so the reason for failure can be found in that case. (even if it should not happen)
EDIT: With pull request #36 the service will now be disabled if the device is removed. Restart=always makes no problems this way.
software/README
talks about running as a daemon, and usingrngd
to add entropy from a FIFO to/dev/random
. However, it's possible to useudev
to start the daemon whenever the infnoise is plugged in, as so:Many similar software packages for hardware will ship udev rules in the repository with instructions on how to add the rules and check that they're working. I think this would be useful for infnoise, as it provides the lowest-friction way to use the infnoise.
If you think this would be useful in the repository, I can make a pull request with a rules file and instructions on how to use it (and maybe even
make
rules to install infnoise and the rules).