# skanlite need root



## Alain De Vos (Nov 30, 2020)

Skanlite only find my usb scanner when started as root user.
What is the solution to start the application as a regular user


----------



## richardtoohey2 (Nov 30, 2020)

Would it be permissions on the scanner device?  Might be a complete red herring!

EDIT - section 7.7.3 in here?  Maybe?









						Chapter 8. Multimedia
					

FreeBSD supports a wide variety of sound cards, allowing users to enjoy high fidelity output from a FreeBSD system




					www.freebsd.org


----------



## a6h (Nov 30, 2020)

*Some thoughts:*
/etc/rc.conf

```
devfs_system_ruleset="localrules"
```
/etc/devfs.rules

```
[localrules=5]
add path 'usb/*' mode 0666 group operator
add path 'ugen[0-9]*' mode 0666 group operator
```
*Extra:*
Are you a member of operator?


----------



## Alain De Vos (Dec 1, 2020)

I am member of operator
/etc/group :

```
operator:*:5:root,x,toot,toor
```
In /etc/rc.conf:

```
devfs_rulesets="/etc/defaults/devfs.rules /etc/devfs.rules" # Files containing devfs(8) rules.
devfs_system_ruleset="localrules" # The name (NOT number) of a ruleset to apply to /dev
devfs_set_rulesets=""   # A list of /mount/dev=ruleset_name settings to apply (must be mounted already, i.e. fstab(5))
devfs_load_rulesets="YES"  # Enable to always load the default rulesets
```
And /etc/devfs.rules

```
[localrules=10]
add path 'ad*'    mode 0666 group operator
add path 'da*'    mode 0666 group operator
add path 'acd*'   mode 0666 group operator
add path 'cd*'    mode 0666 group operator
add path 'mmcsd*' mode 0666 group operator
add path 'pass*'  mode 0666 group operator
add path 'xpt*'   mode 0666 group operator
add path 'ugen*'  mode 0666 group operator
add path 'usbctl' mode 0666 group operator
add path 'usb*'   mode 0666 group operator
add path 'lpt*'   mode 0666 group operator
add path 'ulpt*'  mode 0666 group operator
add path 'unlpt*' mode 0666 group operator
add path 'fd*'    mode 0666 group operator
add path 'uscan*' mode 0666 group operator
add path 'video*' mode 0666 group operator
add path 'dvb/*'  mode 0666 group operator
add path 'tuner*' mode 0666 group operator
add path 'xpt*'   mode 0666 group operator
add path 'usb/*'  mode 0660 group operator
```

Still skanlite needs root otherwise sane finds no devices


----------



## T-Daemon (Dec 1, 2020)

Have a look at the graphics/sane-backends post-install message ( `pkg info -D sane-backends` ). Excerpt:


```
...
If you are using a USB scanner, you should create
%%PREFIX%%/etc/devd/saned.conf to allow saned access permissions.
Currently, devfs.rules(5) has no support for USB specific filters
such as vendor, product and serial number.
...
```


----------



## Alain De Vos (Dec 1, 2020)

#usbconfig -d 0.8 dump_device_desc

```
ugen0.8: <SEIKO EPSON USB MFP> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (2mA)
  bLength = 0x0012
  bDescriptorType = 0x0001
  bcdUSB = 0x0110
  bDeviceClass = 0x0000  <Probed by interface class>
  bDeviceSubClass = 0x0000
  bDeviceProtocol = 0x0000
  bMaxPacketSize0 = 0x0040
  idVendor = 0x04b8
  idProduct = 0x084d
  bcdDevice = 0x0100
  iManufacturer = 0x0001  <SEIKO EPSON>
  iProduct = 0x0002  <USB MFP>
  iSerialNumber = 0x0003  <LK4Z448730>
  bNumConfigurations = 0x0001
```

I edited saned.conf:

```
notify 100 {
        match "system" "USB";
        match "subsystem" "INTERFACE";
        match "type" "ATTACH";
        match "cdev" "ugen0.8";
        match "vendor" "0x04b8";
        match "product" "0x084d";
        action "chown -L cups:saned /dev/$cdev && chmod -L 660 /dev/$cdev";
};
```
Issued
/etc/rc.d/devd restart
But skanlite still does not find scanners as regular user

ls -al /dev/usb | grep 0.8.0 shows
crw-rw----   1 root  cups      0x11a Dec  1 16:15 0.8.0
It does not belong to group operator.

ls -al /dev has no files belonging to cups:saned


----------



## T-Daemon (Dec 1, 2020)

Alain De Vos said:


> ls -al /dev/usb | grep 0.8.0 shows
> crw-rw---- 1 root cups 0x11a Dec 1 16:15 0.8.0
> It does not belong to group operator.
> 
> ls -al /dev has no files belonging to cups:saned


Put the user in the `cups` group.

Also it's not a good idea to set `match "cdev" "ugen0.8";` . If the device is unplugged and other devices plugged in, the USB bus number will change if plugged in back, better set `match "cdev" "ugen[0-9].[0-9]";` , as in the post-install message given as example.



Alain De Vos said:


> In /etc/rc.conf:
> Code:
> devfs_rulesets="/etc/defaults/devfs.rules /etc/devfs.rules" # Files containing devfs(8) rules.
> ...
> ...


Furthermore the above settings in /etc/rc.conf are superfluous, they are already set as default in /etc/defaults/rc.conf. In /etc/rc.conf those options only need to be specified to override the defaults.


----------



## Alain De Vos (Dec 1, 2020)

I tried setuid of skanlite,xsane,gscan2pdf but none work. 
So I just rely on going to root as it doesn't work in my case.
It would be nice to hear if it works for other people.


----------



## T-Daemon (Dec 1, 2020)

Alain De Vos said:


> So I just rely on going to root as it doesn't work in my case.
> It would be nice to hear if it works for other people.


Have you tried adding the user to the `cups` group?

Apparently there is no need of a /usr/local/etc/devd/saned.conf if print/cups is installed, tested on my system. /usr/local/etc/devd/cups.conf takes care of the scanner, multi-functional (all-in-one) in my case. Only the user has to be specified in the `cups` group.

/usr/local/etc/devd/cups.conf

```
# Allow members of group cups to access generic USB printer devices

notify 100 {
    match "system"        "USB";
    match "subsystem"    "INTERFACE";
    match "type"        "ATTACH";
    match "intclass"    "0x07";
    match "intsubclass"    "0x01";
    match "intprotocol"    "(0x01|0x02|0x03)";
    action "chgrp cups /dev/$cdev; chmod g+rw /dev/$cdev";
};
```


----------



## Alain De Vos (Dec 1, 2020)

I did a 
#chmod a+x /dev/usb
now it works.


----------



## a6h (Dec 1, 2020)

`a+x on /dev/*`:
Isn't a little too much? Just asking, I'm curious.


----------



## Alain De Vos (Dec 1, 2020)

chmod ug+x /dev/usb
is enough


----------

