Detecting DVD drive and USB scanner by programs run as regular users

I have recently installed FreeBSD 15 on my desktop. I am using XFCE. The system is working well on the whole, while some things aren't well polished. I have a CanonScan LiDE 120 scanner attached which I want to use through my non root account. I have installed
sane-backends and simple-scan. I have followed the instructions given here . My account now is part of wheel and usb groups. However, while if I start simple-scan as root everything works fine, if I start it as a regular user, simple-scan cannot detect any scanners.

Similarly, when I use dvdisaster as a regular user, it is unable to detect the DVD drive. If I run it as root, it works without any problem.

USB pendrives show up in thunar even as regular user.

What am I missing to get the programs detect the devices as regular users? Please advise on the changes to make.
Thanks
 
There are two options to grant normal users permission to the scanner:

Option 1 (best suited): set permission to the USB device nodes of the DVD drive and scanner the normal user can access

/etc/devfs.rules
Code:
[localrules=5]
add path 'usb/*' mode 0660 group usb

/etc/rc.conf
Code:
devfs_system_ruleset="localrules"

Restart devfs service:
Code:
service devfs restart

Add user to group "usb":
Code:
pw groupmod usb -m <user_name>
To take effect, log out and log in the user again, check user groups ( id), run simple-scan.

Option 2 (less recommended, it will grant permissions to only one specific USB scanner device, option one grants to all) : See pkg info -D sane-backends post-install message
 
Create (if not existing) the /usr/local/etc/devd/saned.conf file with the following details. "vendor" and "product" should match those seen in the device description above.
Did you follow those instructions? Unplug the device and plug it back in. These rules are applied when the device is attaching. Then check if the permissions have been properly applied to the corresponding ugen(4) device. If not, double-check the Vendor and Product IDs. Make sure they match your device.

Also, if you added your user to the usb group, log off and back in again. Group membership isn't dynamic, its determined at login. Common pitfall because tools like id(1) will tell you the user is a member, but if that user hasn't logged off and back in again they still won't have the group membership applied.
 
Thanks to your replies. I have managed to correct the problem.
There were no errors in saned.conf or devfs.rules.

ls -l /dev/usb showed the result below.

Code:
crw-------  1 root operator  0x2e Feb 26 09:13 0.1.0
crw-------  1 root operator  0x4c Feb 26 09:13 0.1.1
crw-rw----  1 cups saned     0x7c Feb 26 09:13 0.2.0
crw-------  1 root operator  0x7e Feb 26 09:13 0.2.1
crw-------  1 root operator  0x7f Feb 26 09:13 0.2.2

I added my account to the saned group and now the USB scanner is detected by the regular account.

However, I don't understand what has happened. Was it the sane-backends that added the saned group to the USB device at the time of its installation? If so, how does it change the ownership to another device if I plug the scanner to another port?

Can you point me to a resource which explains the difference between usb devices and ugen devices and the need for them both?

My CD drive is still not recognized by dvdisaster. But, I may have mislead you when I did not point out that it is a SATA drive. I had assumed that somehow I missed some permission setting of all devices and in my head the DVD Drive was "obviously" SATA. Should I start a separate forum thread for that issue?

Thanks
 
PKG-Message for K3B port may give you some answers

:/usr/ports/sysutils/k3b $ more pkg-message
[

1. The FreeBSD k3b port supports SCSI drives only. If you have IDE CD or DVD
drives, use them through the cam system. See Chapter 17.5.1 of the handbook
(http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/creating-cds.html)
2. k3b has to be started from a root console, which is not recommended.
Alternatively, do ALL of the following:
a. Every user must have read and write access to /dev/cdX:
- add to your /etc/devfs.rules under '[system=10]':
add path 'cd*' mode 666
- or if you prefer allow access for a group XXX only add instead:
add path 'cd*' mode 660 group XXX
- to enable it, add to your /etc/rc.conf
# sysrc devfs_system_ruleset="system"
b. Every user who should be able to use k3b must have read and write access
to all pass through devices connected with CD and DVD drives and to the
/dev/xpt0 device. Run 'camcontrol devlist' to identify those devices (seek
string 'passX' at the end of each line). Note, that this is a security
leak as well but that there is no alternative!
- add to your /etc/devfs.rules under '[system=10]':
add path 'pass*' mode 666
add path 'xpt0' mode 666
- or if you prefer allow access for a group XXX only add instead:
add path 'pass*' mode 660 group XXX
add path 'xpt0' mode 660 group XXX
- to enable it, add to your /etc/rc.conf
# sysrc devfs_system_ruleset="system"
- to apply these changes without reboot, run as root:
# service devfs restart
3. Create a directory on a partition, which has enough disk space to hold a CDs
or DVDs content (usually below /usr). Enter this directory in Settings->
Configure K3b...->Misc.
4. Last but not the least, you need to set cdrecord parameters in K3b's
"Settings --> Configure k3b... --> Programs --> User Parameters" to
match your device as seen by `cdrecord -scanbus' (e.g. dev=3,0,0)
EOM
 
Similar info from dvdisaster port documentation.


Useful hints for dvdisaster
===========================

Device access
-------------
dvdisaster tries to read /dev/pass* to list available optical drives,
so it will not detect any available drives if the user running
dvdisaster does not have permissions to read /dev/pass*.

The solution is to create the file /etc/devfs.rules, containing
something like the following.

[localrules=10]
add path 'pass*' mode 0775 group mygroup

You also need to add this line to /etc/rc.conf:

devfs_system_ruleset="localrules"

You can use anything you like for localrules, and the number does not have to be 10.
See devfs.rules(5) for more details.

If /etc/devfs.rules already exists, add the line starting add to the section for the ruleset
mentioned in /etc/rc.conf.

For this to take effect, either reboot, or issue the command:

# service devfs restart

as root.

Missing optical drives
----------------------

The most common problem encountered is that dvdisaster does not detect
optical drives on older versions of FreeBSD.

FreeBSD 9.x does not pre-install a uniform CD-ROM driver for SCSI and
ATAPI drives, thus it cannot use any ATAPI drives in an out-of-the-box
FreeBSD 9.x installation. Normally, this can be fixed by loading a
kernel module called atapicam.

### Loading the atapicam kernel module by hand

To manually load the required kernel module, issue the command:

# kldload atapicam

To see if any optical drives are available:

# camcontrol devlist
<NAME OF YOUR DRIVE> at scbus1 target 0 lun 0 (pass0,cd0)

### Loading the atapicam kernel module permanently

If the above step works, the module can be loaded automatically at boot time by adding
the line:

atapicam_load="YES"

to the file /boot/loader.conf.

### Building the atapicam module

If the atapicam kernel module is not available (check the contents
of /boot/kernel) you will need to recompile the kernel with the following
additional device line in the kernel configuration:

device atapicam

This will actually build the module into the kernel. To build it separately,
see `make.conf(5)`.

The devices ata, scbus, cd, and pass are also required, but are included by
default in FreeBSD 6.0 and later.
 
Back
Top