1=head1 NAME
2
3Device::USB::FAQ - Frequently Asked Questions for Device::USB
4
5=head1 SYNOPSIS
6
7perldoc Device::USB::FAQ
8
9=head1 DESCRIPTION
10
11This is an attempt to answer some of the frequently asked questions about
12the Device::USB module
13
14=head1 QUESTIONS
15
16=head2 Which platforms does Device::USB support?
17
18C<Device:USB> supports any platform that C<libusb> supports. This list
19currently includes Linux, FreeBSD, NetBSD, OpenBSD, Darwin, and MacOS X.
20
21There is a port of the C<libusb> library to the Windows environment called
22C<LibUsb-Win32>. Because I don't have a development environment for testing
23this library, C<Device::USB> does not yet support this library.
24
25=head2 Do I have to use Device::USB as root?
26
27By default, access to the USB devices on a Unix-based system appear to be
28limited to the root account. This usually causes access to most of the
29C<libusb> features to fail with a permission error.
30
31Using the C<Device::USB> module as root avoids this feature, but is not
32very satisfying from a security standpoint. (See the next question for
33more options.)
34
35=head2 How do I enable use of Device::USB as a non-root user?
36
37Some of the attributes of USB devices are available to non-root users, but
38accessing many of the more interesting features require special privileges.
39According to the libusb source, the C<open()> function requires either device
40nodes to be present or the usbfs file system to be mounted in specific
41locations. Those places in order are:
42
43=over 4
44
45=item 1)
46
47F</dev/bus/usb>  - pre-2.6.11: via devfs / post-2.6.11: via udev
48
49=item 2)
50
51F</proc/bus/usb> - usbfs
52
53=back
54
55Look in both locations on your system for which of these two methods your
56libusb will use.
57
58No matter which method your system uses, you will probably want to create a
59separate group to control access. Run this command to add a system group:
60
61  addgroup --system usb
62
63or
64
65  groupadd --system usb
66
67You can then add users to that group to allow access to your usb devices.
68
69=head3 DEVFS / HOTPLUG
70
71TODO
72
73=head3 UDEV
74
75If you use Debian/Ubuntu, look in the F</etc/udev/permissions.rules> file.
76If you want to allow global access to all usb devices, make this change:
77
78Change this:
79  SUBSYSTEM=="usb_device", MODE="0664"
80
81To this:
82  SUBSYSTEM=="usb_device", MODE="0664", GROUP="usb"
83
84After you reboot, all usb devices will inherit the mode and group specified.
85
86If you want to only change permissions for certain devices, you can add this
87on one line and adjust the product and vendor IDs:
88
89  SUBSYSTEM=="usb_device", GROUP="usb", \
90    SYSFS{idVendor}=="1234", SYSFS{idProduct}=="1234"
91
92=head3 USBFS
93
94The usbfs defaults to root as the user and group. This can be changed in the
95F</etc/fstab> by adding the following on one line:
96
97  none /proc/bus/usb usbfs noauto,\
98      listuid=0,listgid=118,listmode=0664,\
99      busuid=0,busgid=118,busmode=0775,\
100      devuid=0,devgid=118,devmode=0664\
101      0 0
102
103The value C<118> in the above should be replaced with the group id of
104your usb group (created above). The list* values are to allow listing
105devices, the bus* is to control access to the bus directories and the
106dev* values control access to the device files. This approach does not
107allow the kind of granular permission that the udev approach gives, so
108it is all or nothing unless permissions are changed programmatically.
109
110If your F</etc/fstab> file already has a line for F</proc/bus/usb>, add the
111options above to the line that is already there rather than adding the
112new line. For example, you would change
113
114  usbfs   /proc/bus/usb   usbfs   noauto  0 0
115
116to
117
118  usbfs   /proc/bus/usb   usbfs  noauto,\
119      listuid=0,listgid=118,listmode=0664,\
120      busuid=0,busgid=118,busmode=0775,\
121      devuid=0,devgid=118,devmode=0664\
122      0 0
123
124Once again, this needs to be all on one line with the C<\> characters
125removed.
126
127=head1 SEE ALSO
128
129Device::USB and the C<libusb> library site at
130L<http://libusb.sourceforge.net/>.
131
132=head1 AUTHOR
133
134G. Wade Johnson (wade at anomaly dot org)
135Paul Archer (paul at paularcher dot org)
136
137Houston Perl Mongers Group
138
139=head1 ACKNOWLEDGEMENTS
140
141Thanks go to various users who submitted questions and answers for the
142list. In particular, Anthony L. Awtrey who contributed the first FAQ answer.
143
144=head1 COPYRIGHT & LICENSE
145
146Copyright 2006 Houston Perl Mongers
147
148This document is free software; you can redistribute it and/or modify it
149under the same terms as Perl itself.
150
151=cut
152