Bug 161254 - Scanner only recognized as Root
Scanner only recognized as Root
Status: CLOSED CURRENTRELEASE
Product: Fedora
Classification: Fedora
Component: udev (Show other bugs)
4
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Harald Hoyer
:
: 143313 (view as bug list)
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2005-06-21 15:21 EDT by Jerry Barrington
Modified: 2007-11-30 17:11 EST (History)
4 users (show)

See Also:
Fixed In Version: 095
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2007-01-13 14:47:02 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)

  None (edit)
Description Jerry Barrington 2005-06-21 15:21:38 EDT
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050513 Fedora/1.0.4-1.3.1 Firefox/1.0.4

Description of problem:
Logging in as Root, the Microtek E3 scanner in hardware browser and is recognized by sane-find-scanner. It is functional in OpenOffice and even in xsane with gimp.

Logged in as user, it is not recognized with sane-find-scanner and not usable in OpenOffice or xsane.

This same scanner works well in FC3.  All hardware is the same and no settings are changed.

Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
1.Log in as user
2.run sane-find-scanner
3.
  

Actual Results:  Sane-find scanner reports no scsi scanner found.

Expected Results:  Sane-find-scanner should report scanner found as sg0.

Additional info:

This computer runs multiple operating systems via swappable hard drive bay.
The scanner is a Microtek E3 - old but reliable - and scsi connected to an
Adaptec 2906 using the external connector.
Comment 1 Jerry Barrington 2005-06-22 00:04:43 EDT
Further testing and information:

I did a bad thing and inserted the following lines from
/etc/udev/permissions.d/50-udevpermissions
into /etc/udev/rules.d/50-udev.rules:

# scanner devices
scanner:root:root:0600
usb/scanner*:root:root:0600

I then have to boot up with the scanner power off to remove any reference to it.
Then shutdown the computer, turn on the scanner, boot up and log in as user.
sane-find-scanner then recognizes the scanner as device sg0.

These steps must be repeated with each boot up as the scanner is lost each shutdown.

Really confusing!!!
Comment 2 Jerry Barrington 2005-06-22 15:02:03 EDT
With further testing, I found that the three lines added to the file have no
effect and were removed.
However, the startup procedure stated above is required at every power on boot
up of restart of the system.
I guess I can live with that.  Now, if I could get the Num Lock to come on at
startup . . .
Comment 3 Harald Hoyer 2005-06-23 03:29:38 EDT
Try to load the "sg" module in e.g. rc.local..
Comment 4 Jerry Barrington 2005-06-23 10:30:06 EDT
Thanks, I tried that suggestion and no joy.  It still loses the scanner without
the special procedure.

The link /dev/scanner linked to /dev/sg0 is not created normally without that
procedure.  Creating /dev/scanner manually revives the scanner for both root and
user.

I am learning more about Linux than I ever thought I wanted to.
Comment 5 Harald Hoyer 2005-06-23 12:09:34 EDT
It seems that there is no hotplug event, if you switch on your scanner.
The scsi driver should send a hotplug event.
Try to set in /etc/sysconfig/hotplug:
DEBUG="yes"

and look in /var/log/messages for udev and hotplug messages, if you switch on
your scanner, while the system is up.
Comment 6 Jerry Barrington 2005-06-24 02:40:14 EDT
OK.  There is no file /etc/sysconfig/hotplug.  I found
/etc/hotplug/hotplug.functions with the line   # DEBUG="yes"   and unremmed that.
This generates the following sequence or similar many tines in /var/log/messages:

Jun 23 12:39:53 BeeHive default.hotplug[2668]: no runnable
/etc/hotplug/block.agent is installed
Jun 23 12:39:53 BeeHive default.hotplug[2677]: arguments (scsi_generic) env
(PHYSDEVPATH=/devices/platform/host1/target1:0:6/1:0:6:0 SUBSYSTEM=scsi_generic
OLDPWD=/ DEVPATH=/class/scsi_generic/sg1 MINOR=1
PATH=/bin:/sbin:/usr/sbin:/usr/bin ACTION=add PWD=/etc/hotplug UDEV_LOG=3
MAJOR=21 MANAGED_EVENT=1 UDEVD_EVENT=1 DEVNAME=/dev/sg1 SHLVL=1 HOME=/
PHYSDEVDRIVER=sd DEBUG=yes PHYSDEVBUS=scsi SEQNUM=454 _=/bin/env)
Jun 23 12:39:53 BeeHive default.hotplug[2705]: arguments (vc) env (SUBSYSTEM=vc
OLDPWD=/ DEVPATH=/class/vc/vcs2 MINOR=2 PATH=/bin:/sbin:/usr/sbin:/usr/bin
ACTION=add PWD=/etc/hotplug UDEV_LOG=3 MAJOR=7 MANAGED_EVENT=1 UDEVD_EVENT=1
DEVNAME=/dev/vcs2 SHLVL=1 HOME=/ DEBUG=yes SEQNUM=457 _=/bin/env)
Jun 23 12:39:54 BeeHive default.hotplug[2705]: no runnable /etc/hotplug/vc.agent
is installed

After following the bootup procedure to get the scanner recognized,
sane-find-scanner shows two lines:

Found SCSI Scanner "Scanner 1.80" at dev /dev/scanner
Found SCSI Scanner "Scanner 1.80" at dev /dev/sg0

Switching the scanner off removes both lines and switching on again returns them.

I have no USB devices connected.  Could something not be installed that is
needed for the SCSI scanner to be detected properly?

Comment 7 Harald Hoyer 2005-06-24 04:21:42 EDT
hmm... DEVNAME=/dev/sg1 .... maybe sane-find-scanner looks for /dev/sg0, and if
none found, gives up... and misses /dev/sg1 ...

Is this sg1 every time, you switch on your scanner, after booting up the PC?
Comment 8 Jerry Barrington 2005-06-26 12:14:54 EDT
/dev/sg0 and /dev/sg1 are present after each bootup or reboot if the scanner is
powered up at that time.  /dev/scanner is present only the first time but is
absent after reboot even if the scanner is left powered up.

I checked bug #143313 and got a clue there.  I created a new file named
/etc/udev/rules.d/20-scanner.rules:

# permissions for SCSI sg devices and scanner

KERNEL=="sg0", BUS=="scsi", 	SYMLINK="scanner%e"
# KERNEL=="sg[0-9]", BUS=="scsi", 	SYMLINK="scanner%e"

The first lines creates the /dev/scanner sym link at every reboot if the scanner
is on.  The second line unremmed creates /dev/scanner1 and /dev/scanner2.

This can instead be added to 50-udev.rules by inserting:


KERNEL=="device-mapper",	NAME="mapper/control"

# old compat symlinks with enumeration
KERNEL=="sr[0-9]*",		SYMLINK="cdrom%e"
KERNEL=="scd[0-9]*",		SYMLINK="cdrom%e"
KERNEL=="pcd[0-9]*",		SYMLINK="cdrom%e"
KERNEL=="fd[0-9]*",		SYMLINK="floppy%e"
KERNEL=="nst[0-9]", BUS=="scsi", 	SYMLINK="tape%e"
KERNEL=="nosst[0-9]", BUS=="scsi", 	SYMLINK="tape%e"

KERNEL=="sg[0-9]", BUS=="scsi", 	SYMLINK="scanner%e"

KERNEL=="umad*", 		NAME="infiniband/%k"
KERNEL=="issm*", 		NAME="infiniband/%k"

# Section for zaptel device

This solves the problem nicely.  The scanner can be switched off and on with no
problem.
Comment 9 Harald Hoyer 2005-06-27 03:43:20 EDT
we have to refine the rule, because "sg" could be "any scsi device"..
Does this rule work??
BUS=="scsi", KERNEL=="sg[0-9]*", SYSFS{type}=="6", NAME="%k",
SYMLINK="scanner%e", MODE="0660"
Comment 10 Jerry Barrington 2005-06-27 14:12:21 EDT
Great.  I now have /dev/sg0 and /dev/scanner only.  This is diffrent than the
suggestion in bug 143313, which didn't work.  I see the difference.  I guess the
one I did worked since the scanner is my only scsi device.

Thanks for the help.
Comment 11 D. Hugh Redelmeier 2005-08-14 11:06:26 EDT
[Please see the thread starting with
https://www.redhat.com/archives/fedora-list/2005-August/msg01668.html]

RED HAT: please add the lines suggested below to /etc/udev/rules.d/50-udev.rules

There seem to be two problems:
(1) getting /dev/sg0 (or whatever) owned by the userid logged into the console
so that that userid can access the scanner
(2) recognizing the scanner in the case that it is turned on after boot.

Problem (1) is partly handled by console.perms(5).  If there is a /dev/scannerN,
it will be chowned at login to the console userid.  How can we get /dev/scannerN
created?  See udev(8).  There need to be some additional rules in
/etc/udev/rules.d for scanners.  Here are two that I think should be standard
issue (i.e. done by Red Hat, not the end user).

BUS="scsi", SYSFS{vendor}="HP*", SYSFS{model}="C2520A*", SYMLINK="scanner%n"
BUS="scsi", SYSFS{vendor}="UMAX*", SYSFS{model}="Astra*", SYMLINK="scanner%n"

Problem (2) requires work that I haven't tried to figure out.  In my particular
setup, the following command, issued by the superuser, gets the system to notice
the scanner when it is turned on some time after boot:
      echo 'scsi add-single-device 0 0 5 0' >/proc/scsi/scsi
                                         ^ LUN
                                       ^ SCSI ID
                                     ^ host adapter channel
                                   ^ host adapter
This is not very elegant.  Contrary to the documentation in proc(5), this
command seems to rescan all scsi buses (including USB buses).
Comment 12 Harald Hoyer 2005-08-25 06:35:02 EDT
BUS=="scsi", KERNEL=="sg[0-9]*", SYSFS{type}=="6", NAME="%k",
SYMLINK="scanner%e", MODE="0660"

should cover your 2 lines.
Comment 13 D. Hugh Redelmeier 2005-08-27 22:22:22 EDT
The line from #12 seems to work and is much more general.

The MODE field does not seem to work as I'd expect:
lrwxrwxrwx  1 root root     3 Aug 27 21:52 /dev/scanner -> sg4
crw-------  1 hugh root 21, 4 Aug 27 21:52 /dev/sg4

I think that this comes from the following line in
/etc/security/console.perms.d/50-default.perms
<console>  0600 <scanner>    0600 root

The SYSFS{type}="6" is a bit magical.  Where is this 6 documented?  All I've
found is table 21 on page 35 of http://www.t10.org/ftp/t10/drafts/spc/spc-r11a.pdf
[SCSI-3 primary commands].  It would be good if there is documentation that can
easily be found starting from the udev(8) manpage.
Comment 14 Harald Hoyer 2005-08-29 07:17:43 EDT
$ fgrep TYPE_ /usr/include/scsi/scsi.h
#define TYPE_DISK           0x00
#define TYPE_TAPE           0x01
#define TYPE_PROCESSOR      0x03    /* HP scanners use this */
#define TYPE_WORM           0x04    /* Treated as ROM by our system */
#define TYPE_ROM            0x05
#define TYPE_SCANNER        0x06
#define TYPE_MOD            0x07    /* Magneto-optical disk -
                                     * - treated as TYPE_DISK */
#define TYPE_MEDIUM_CHANGER 0x08
#define TYPE_ENCLOSURE      0x0d    /* Enclosure Services Device */
#define TYPE_NO_LUN         0x7f


If you don't like the permissions in
/etc/security/console.perms.d/50-default.perms just define new ones in a
seperate file in /etc/security/console.perms.d/
Comment 15 Phil Cole 2005-09-21 19:30:11 EDT
Thanks to all that have contributed to this bug.  Very useful.  To get my Epson
Perfection 1200S (using the aic7xxx kernel module) working on FC4 I needed to
alter the line in comment #12 to include scsi type 3. i.e. 

BUS=="scsi", KERNEL=="sg[0-9]*", SYSFS{type}=="[36]", NAME="%k",
SYMLINK="scanner%e", MODE="0660"
Comment 16 John Thacker 2007-01-13 14:43:00 EST
*** Bug 143313 has been marked as a duplicate of this bug. ***
Comment 17 John Thacker 2007-01-13 14:47:02 EST
This is fixed in the current version of udev, as the line mentioned above is
correctly included.  Seems like this bug never got closed.  Closing now.

Note You need to log in before you can comment on or make changes to this bug.