LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   scanner root permissions (https://www.linuxquestions.org/questions/slackware-14/scanner-root-permissions-769050/)

icecubeflower 11-14-2009 01:13 AM

scanner root permissions
 
When i ran Slack 12.2 Kooka would only work for root. Then I fixed it so I could scan as user. But I forgot how I did it.

Now I am running Slack 13 and I am trying to use skanlite but same old problem. Root only.

I read part of this:
http://www.sane-project.org/man/sane.7.html

It says my device permissions are wrong. How do I fix this?

I tried
useradd -G scanner icecube
but that does nothing.

Then I tried
usermod -G scanner icecube
and that added icecube to the group, scanner.

But still I can only use skanlite as root. I don't know what to do.

Find scanner as icecube:
Code:

icecube@inferno:~$ sane-find-scanner

  # sane-find-scanner will now attempt to detect your scanner. If the
  # result is different from what you expected, first make sure your
  # scanner is powered up and properly connected to your computer.

  # No SCSI scanners found. If you expected something different, make sure that
  # you have loaded a kernel SCSI driver for your SCSI adapter.

  # No USB scanners found. If you expected something different, make sure that
  # you have loaded a kernel driver for your USB host controller and have setup
  # the USB system correctly. See man sane-usb for details.

  # Not checking for parallel port scanners.

  # Most Scanners connected to the parallel port or other proprietary ports
  # can't be detected by this program.

  # You may want to run this program as root to find all devices. Once you
  # found the scanner devices, be sure to adjust access permissions as
  # necessary.

Find scanner as root:
Code:

root@inferno:/home/icecube# sane-find-scanner

  # sane-find-scanner will now attempt to detect your scanner. If the
  # result is different from what you expected, first make sure your
  # scanner is powered up and properly connected to your computer.

  # No SCSI scanners found. If you expected something different, make sure that
  # you have loaded a kernel SCSI driver for your SCSI adapter.

found USB scanner (vendor=0x03f0 [HP], product=0x4811 [PSC 1600 series]) at libusb:003:002
  # Your USB scanner was (probably) detected. It may or may not be supported by
  # SANE. Try scanimage -L and read the backend's manpage.

  # Not checking for parallel port scanners.

  # Most Scanners connected to the parallel port or other proprietary ports
  # can't be detected by this program.
root@inferno:/home/icecube#


ponce 11-14-2009 01:32 AM

I think you should be in plugdev group too.
Code:

# gpasswd -a icecube plugdev
then relogin.

when you create a user with adduser, it asks you the default group and then the additional groups: you should press then the up arrow key to have a default set of additional groups useful if your user use the pc as a desktop.

icecubeflower 11-14-2009 01:42 AM

Ah! I think I did something stupid.

I did:
chown icecube.scanner /dev/usb/lp0

and now /dev/usb is gone!

Please tell me how to undo whatever damage I did.

icecubeflower 11-14-2009 01:48 AM

Okay I still need solution to problem I created in previous post. But I tried you thing and icecube is a member of plugdev and scanner. I logged in again. It still doesn't work. And as far as I can tell
# gpasswd -a icecube plugdev
# usermod -G scanner icecube
both do the same thing. I added to scanner one way and to plugdev the other way.

ponce 11-14-2009 01:49 AM

Quote:

Originally Posted by icecubeflower (Post 3756611)
Ah! I think I did something stupid.

I did:
chown icecube.scanner /dev/usb/lp0

and now /dev/usb is gone!

Please tell me how to undo whatever damage I did.

(i know it sounds ugly but) reboot

icecubeflower 11-14-2009 01:51 AM

lol

icecubeflower 11-14-2009 02:02 AM

I rebooted. /dev/usb is back, praise God.

And this happens:
Code:

root@inferno:/dev/usb# groups icecube
icecube : users plugdev scanner

And yet, I cannot use scanner as icecube. I know I fixed this before but I forgot what I did. Very irritating.

ponce 11-14-2009 02:05 AM

there's an interesting thread here about it

http://www.linuxquestions.org/questi...urrent-594071/

icecubeflower 11-14-2009 02:10 AM

I don't think that's it. I remember reading that last time. The solution is something really simple, a simple command like adding user to scanner.

Maybe I'm wrong. Piter Punk's link is dead. I don't have a "90-local.rules" file.

icecubeflower 11-14-2009 03:44 AM

I found this with "man sane-usb"

Code:

      The permissions for the device files used by  libusb  must  be  adjusted  for  user
      access.  Otherwise  only  root  can  use  SANE  devices. For Linux, the devices are
      located in /proc/bus/usb/ or in /dev/bus/usb, if you use udev. There  are  directo-
      ries named e.g. "001" (the bus name) containing files "001", "002" etc. (the device
      files). The right device files can be found out by running scanimage  -L  as  root.
      Setting  permissions  with  "chmod"  is  not permanent, however. They will be reset
      after reboot or replugging the scanner.

      Usually udev or for older distributions the hotplug utilities are used, which  sup-
      port  dynamic  setting  of  access  permissions.  SANE  comes with udev and hotplug
      scripts in the directory tools/udev and tools/hotplug. They can be used for setting
      permissions,  see /usr/doc/sane-1.0.19/README.linux, tools/README and the README in
      the tools/hotplug directory for more details.

I don't understand it yet. If I was going to do the quick fix and use chmod I'm not sure what I'm supposed to chmod.

icecubeflower 11-14-2009 03:50 AM

This is /usr/doc/sane-1.0.19/README.linux:
Code:

Information about USB scanners:
================================

With Linux 2.4.* you could either use the kernel scanner module or libusb to
access USB scanners.  In Linux 2.6.4 the kernel scanner module was removed.
Therefore with this and later kernels libusb must be used.

Permissions:
------------
While SANE automatically uses libusb when the library and its header file were
present during the build of sane-backends, setting permissions will require some
attention. So if scanimage -L lists your scanner as root but not as normal user
read on this text.

Most distributions support setting permissions without much manual
configuration. Usually you must just add the users that are allowed to access
the scanner to group "scanner". To make that change active, the user must login
again. For more details, see your distribution's documentation e.g. for Debian:
README.debian.gz. If this doesn't work you you want to know more, read on.

The device files used by libusb are located in /proc/bus/usb/
(e.g. /proc/bus/usb/001/003) or in /dev/bus/usb/ (e.g. /dev/bus/usb/001/003), if
you use udev.  The exact file name can be found out by running sane-find-scanner
which would print "libusb:001:003" in this case.  While setting permissions with
e.g. "chmod a+rw /proc/bus/usb/001/003" works, this change is not permanent.
The permissions will be reset when the scanner is replugged or Linux is
rebooted.

One solution to set permissions on-the-fly is Linux udev which comes with
current distributions. SANE comes with a udev rules file in the tools/udev
directory which may be used by distributions or can be copied to
/etc/udev/rules.d manually. The file format is explained on top of the file
itself. Either you need libusb 0.1.12 or newer or USB_DEVFS_PATH=/dev/bus/usb
must be exported as a system-wide environment variable.

Older distributions may use the Linux hot-plug tools (or hotplug-ng). Your
distribution should have set up the scripts to automatically change permissions
correctly. Look for "libsane.usermap" and "libusbscanner" in /etc/hotplug/usb.
If you build SANE from source you can use the hotplug script that comes with
SANE. See the tools/hotplug/ directory in the source distribution. Please refer
to the README in that directory for the details.

Gentoo information:
-------------------
Gentoo users: If your USB scanner is not detected at all check that USE=usb is
set when emerging.


Information about SCSI scanners:
================================

Under Linux, your kernel must have generic SCSI support (sg) as well as a
driver for your SCSI adapter. You may want to increase the SCSI buffer size
to increase scan speed. Details on all of the above can be found in
sane-scsi(5).

If your SCSI and sg driver are build as moduls you will need to load them
with modprobe:

# modprobe your-driver-name
# modprobe sg

You may find error messages in /var/log/messages. Look at the documentation
for your SCSI driver. Maybe you need to add options like the io port.

Now the SCSI adapter and your scanner should be visible at /proc/scsi/scsi.
Example:

# cat /proc/scsi/scsi
Host: scsi0 Channel: 00 Id: 06 Lun: 00
  Vendor: SCANNER  Model:                  Rev: 2.02
  Type:  Scanner                          ANSI SCSI revision: 01 CCS

In this case the real vendor and scanner name are not shown (Mustek
Scannexpress 12000SP) but SANE will detect it nevertheless.

If your scanner is supported by SANE, scanimage -L will list it now:

# scanimage -L
device mustek:/dev/scanner' is a Mustek ScanExpress 12000SP flatbed scanner

If this doesn't work you may have to add the right SCSI generic device name
to the configuration file. This should be documented in the man page for
your backend. To find out about the right SCSI device use sane-find-scanner:

# sane-find-scanner
found SCSI scanner "SCANNER  2.02" at /dev/scanner
found SCSI scanner "SCANNER  2.02" at /dev/sg0
found SCSI scanner "SCANNER  2.02" at /dev/sga

It may help to set a symbolic link /dev/scanner to the respective device if
automatic detection does not work.

If you need more information on the Linux SCSI subsystem, look at
http://www.torque.net/scsi/linux_scsi_24/index.html. Although this
documentation is about the 2.4 kernels, large parts are also valid for
older kernels. One important exception is the section on "Device Names
in devfs".

Adaptec 1542 SCSI adapter:
  Using buffer sizes of more than 32768 bytes with the aha1542 driver can
  lead to kernel panic with older kernels. To avoid this, run configure with
  the option --enable-scsibuffersize or set the environment variable
  SANE_SG_BUFFERSIZE to 32768 before running scanimage or another frontend,
  or download and install the SG driver 2.1.37 or newer from
  http://www.torque.net/sg.

idescsi:
  The Linux kernel "Emulation of a SCSI host adapter for IDE ATAPI
  devices" (idescsi) is reported to cause problems in connection with
  SANE. If your scanner isn't found or you encounter segmentation faults
  try to disable idescsi.

SCSI Direct IO: Recent versions of the Linux SG driver for the 2.4 kernels
  support direct IO, i.e., the SCSI adapter's DMA chip copies data directly
  to/from user memory. Direct IO reduces memory usage, but it can lead to
  access conflicts, if a backend uses shared memory. SANE does not use
  direct IO by default. If you want to use it, run

        configure --enable-scsi-directio=yes

Very old Linux distributions are missing the /usr/include/scsi directory.  In
such a case, it is necessary to copy the relevant files from the kernel
distribution.  Normally, the command:

  cp -a /usr/src/linux/include/scsi /usr/include

should fix this problem. Don't do this if you don't get compilation errors
about missing SCSI headers.


Other Information
=================

ld.so.conf configuration:
  "/usr/local/lib/sane" or "/usr/lib/sane" MUST NOT be listed in
  /etc/ld.so.conf. If your scanner is not detected or only Video for Linux
  devices are found, check for one of the above lines in ld.so.conf.
  A line "/usr/local/lib" or "/usr/lib" in ld.so.conf is ok, however.

Excessive warnings "pointer of type `void *' used in arithmetic":
  Some older versions of glibc generate these warnings not related to SANE
  source code. To suppress these warnings do

  export CFLAGS="-g -O2 -D__NO_STRING_INLINES"

  and rerun configure.

If you use DEC cc on Linux Alpha, you may need to set LDFLAGS="-N" to
  be able to build sane-backends.

The Intel C++ Compiler for IA32 and IA64 isn't supported yet. If you want
  to try nevertheless, you will experience undefined references to inb
  and outb functions. To avoid those replace #include <sys/io.h> with

  #if defined(__ICC) && __ICC >= 700
  # define __GNUC__ 2
  #endif
  #include <sys/io.h>
  #if defined(__ICC) && __ICC >= 700
  # undef __GNUC__
  #elif defined(__ICC) && defined(HAVE_ASM_IO_H)
  # include <asm/io.h>
  #endif

Maybe I've almost got it. It says adding icecube to scanner should probably work but that doesn't work so I guess I have to read on. I hope I didn't mess up the scanner group by using the useradd command. All that ever did was say "icecube exists" or something and it would never add me to the scanner group and I had to use usermod instead.

icecubeflower 11-14-2009 03:58 AM

Where is the tools/udev directory? What are they talking about?

icecubeflower 11-14-2009 04:09 AM

Hey I got the quick fix. Apparently I use udev. And by using sane-find-scanner as root I got the correct numbers and did this:
chmod a+rw /dev/bus/usb/003/002

And I can use skanlite as icecube!

But the man pages say I need to type that every time I boot unless I do the "permissions on the fly" thing with udev.

But I don't know what tools/udev directory they are talking about. At this point I'm considering it not worth the effort. I can just make a shellscript with an easy name with the chmod command in it and run the script as root whenever I want to scan which is pretty rare.

markush 11-14-2009 04:22 AM

Hello icecubeflower,

the trick is to add yourself to the lp-group (because its a psc-multifunctiondevice). You'll get access to this device only via being a member of the lp-group.

Markus

mlangdn 11-14-2009 07:33 AM

Quote:

Originally Posted by icecubeflower (Post 3756717)
Hey I got the quick fix. Apparently I use udev. And by using sane-find-scanner as root I got the correct numbers and did this:
chmod a+rw /dev/bus/usb/003/002

And I can use skanlite as icecube!

But the man pages say I need to type that every time I boot unless I do the "permissions on the fly" thing with udev.

But I don't know what tools/udev directory they are talking about. At this point I'm considering it not worth the effort. I can just make a shellscript with an easy name with the chmod command in it and run the script as root whenever I want to scan which is pretty rare.

I always get confused myself trying the "on the fly" method for udev. I just use that command in rc.local:

Code:

chmod a+rw /dev/bus/usb/003/002
Now I have access to my HP Scanner, Supplies, and any thing else I need.
Its not the right solution, but it works everytime.


All times are GMT -5. The time now is 04:24 AM.