Bug 218393

Summary: no scanner access permissions via HAL/resmgr
Product: [openSUSE] openSUSE 10.2 Reporter: Johannes Meixner <jsmeix>
Component: OtherAssignee: Ludwig Nussel <lnussel>
Status: RESOLVED FIXED QA Contact: E-mail List <qa-bugs>
Severity: Normal    
Priority: P5 - None CC: bugz57, meissner, public, silviu_marin-caea
Version: Beta 1   
Target Milestone: ---   
Hardware: x86-64   
OS: SUSE Other   
Whiteboard:
Found By: Development Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Bug Depends on: 239688    
Bug Blocks:    
Attachments: Output of "lshal"
Content of 70-scanner.fdi
Content of 80-scanner.fdi

Description Johannes Meixner 2006-11-06 15:20:39 UTC
See bug #160899 for the history and background information.

When the package "sane" is installed it runs via postinstall script
/usr/share/sane/create_hal_global_fdi_for_scanners
which creates /etc/hal/fdi/policy/10osvendor/70-scanner.fdi
with tons of entries like
-----------------------------------------------------------------------
<match key="info.category" string="usbraw">
  <match key="@info.parent:usb_device.vendor_id" int="0x04b8">
    <match key="@info.parent:usb_device.product_id" int="0x010b">
      <append key="info.capabilities" type="strlist">scanner</append>
    </match>
  </match>
</match>
-----------------------------------------------------------------------
based upon the known scanner USB IDs in the
/usr/share/sane/descriptions*/*.desc files

Additionally the YaST scanner config runs
/usr/lib/YaST2/bin/test_and_set_scanner_access_permissions
which tests if the actually configured scanners are present in
/etc/hal/fdi/policy/10osvendor/70-scanner.fdi
and for those devices which are not present, it creates
/etc/hal/fdi/policy/10osvendor/80-scanner.fdi
with the same kind of entries.

Nevertheless there is no user-access for any scanner.

Neither after new login on local console nor via XDM/KDM.

Not after unplug and re-plug the scanner to the USB.

Also not after reboot.


Furthermore it does no longer work to enforce resmgr access via
# /sbin/resmgr add /dev/bus/usb/001/004 scanner usb
status code 500
server message follows:
command no longer supported


How is the HAL/resmgr stuff supposed to work for openSUSE 10.2?
Comment 1 Johannes Meixner 2006-11-07 07:06:36 UTC
HAL seems to work correctly because my scanners are listed
as expected in in lshal:
---------------------------------------------------------------------------
caps:~ # sane-find-scanner -q
found USB scanner (vendor=0x04b8 [EPSON], product=0x010b [Perfection1240])
 at libusb:001:004
found USB scanner (vendor=0x04b8 [EPSON], product=0x0121 [EPSON Scanner])
 at libusb:001:003

caps:~ # lshal | grep -B20 'info.capabilities.*scanner' \
 | egrep 'linux.device_file|info.capabilities'
  linux.device_file = '/dev/bus/usb/001/004'  (string)
  info.capabilities = {'usbraw', 'scanner'} (string list)
  linux.device_file = '/dev/bus/usb/001/003'  (string)
  info.capabilities = {'usbraw', 'scanner'} (string list)
----------------------------------------------------------------------------
Comment 2 Marcus Meissner 2006-11-09 14:16:32 UTC
is this beta1 or beta1plus or beta2?
Comment 3 Johannes Meixner 2006-11-09 14:20:57 UTC
Beta1 (as shown in the "Version" entry).
Comment 4 Marcus Meissner 2006-11-09 14:23:11 UTC
please attach "lshal" output to the bug ;)

ludwig is back on monday.
Comment 5 Johannes Meixner 2006-11-09 14:28:35 UTC
Right now I updated to remgr from STABLE
and restarted the resmgr service.

caps:~ # rpm -q resmgr
resmgr-1.1.0_SVNr123-4

But I don't see any difference.
When I log in as normal user "johannes" on text console
I don't have scanner access and "/sbin/resmgr list" doesn't
show any devices (only "no devices available").
Even when I unplug and re-plug a scanner there is no difference.
The same after graphical login.
Comment 6 Marcus Meissner 2006-11-09 14:32:03 UTC
use
/usr/sbin/hal-resmgr --list

in 10.2. this will show the active devices.
Comment 7 Johannes Meixner 2006-11-09 14:43:31 UTC
caps:~ # ls /usr/sbin/hal-resmgr
/bin/ls: cannot access /usr/sbin/hal-resmgr: No such file or directory

caps:~ # rpm -q hal-resmgr
package hal-resmgr is not installed

Ahhh!

It seems it was simply not installed by default in the standard
installation for beta1.
According to
/mounts/dist/install/stable-x86/suse/setup/descr/*.pat
it seems to be now in the "base" patterns.

Nevertheless, after installing it and restarting hal and resmgr
it still doesn't work.

According to
/usr/share/doc/packages/hal-resmgr/README
I write the wrong entries into /etc/hal/fdi/policy/10osvendor/70-scanner.fdi
and /etc/hal/fdi/policy/10osvendor/80-scanner.fdi but I do it as
discussed in bug #160899 (I assume there is only the documentation
outdated).
Comment 8 Johannes Meixner 2006-11-09 14:44:32 UTC
Created attachment 104490 [details]
Output of "lshal"
Comment 9 Johannes Meixner 2006-11-09 14:44:55 UTC
Created attachment 104491 [details]
Content of 70-scanner.fdi
Comment 10 Johannes Meixner 2006-11-09 14:45:48 UTC
Created attachment 104492 [details]
Content of 80-scanner.fdi
Comment 11 Johannes Meixner 2006-11-09 14:53:26 UTC
Tried it even with an old-style entry in 80-scanner.fdi
according to /usr/share/doc/packages/hal-resmgr/README
------------------------------------------------------------------------------
    <match key="info.category" string="usbraw">
      <match key="@info.parent:usb_device.vendor_id" int="0x04b8">
        <match key="@info.parent:usb_device.product_id" int="0x010b">
          <merge key="resmgr.class" type="string">scanner</merge>
        </match>
      </match>
    </match>
------------------------------------------------------------------------------
and restart of resmgr and hal but again no scanner access as normal user.
Comment 12 Ludwig Nussel 2006-11-13 15:31:32 UTC
the file from #11 should work. Problem with the other method is that hal reads files from /etc after the ones in /usr and the fdi file that matches for scanners is in /usr ... I moved all resmgr files to /etc now.
Comment 13 Johannes Meixner 2006-11-14 08:20:32 UTC
I do not understand what I must do because of comment #12.

My questions:

1.
Must I change back from
  <append key="info.capabilities" type="strlist">scanner</append>
to
  <merge key="resmgr.class" type="string">scanner</merge>
?

2.
I don't know about a fdi file for scanners in /usr/
I write only to /etc/
Which file for scanners in /usr/ do you mean?
Comment 14 Ludwig Nussel 2006-11-14 08:28:20 UTC
you don't need to do anything, the fix/workaround is in hal-resmgr. setting info.capabilities is fine.
Comment 15 Johannes Meixner 2006-11-15 08:36:10 UTC
Updated hal-resmgr to version hal-resmgr-0.1_SVNr122-9 and it works.
But I had to re-plug two of my scanners to the USB.
One model worked without re-plug - strange magic.
Comment 16 Marcus Meissner 2006-11-16 16:38:47 UTC
*** Bug 221650 has been marked as a duplicate of this bug. ***
Comment 17 Johannes Meixner 2006-11-17 08:01:37 UTC
It works perfectly for all my scanners with openSUSE beta2plus.
Comment 18 Marcus Meissner 2006-11-21 12:02:02 UTC
*** Bug 222913 has been marked as a duplicate of this bug. ***
Comment 19 Johannes Meixner 2006-11-23 15:13:24 UTC
For your information:

It works somehow but does not work nice.

Meanwhile I have openSUSE 10.2 RC1 installed.
I configured my scanners with YaST which had to install
the package sane (because it was not installed by default).
I got no user access until I did a reboot.

My scanners are listed in
/etc/hal/fdi/policy/10osvendor/70-scanner.fdi
which is created when the package sane gets installed
(see comment #0).

Perhaps the HAL/hal-resmgr machinery is not triggered when
/etc/hal/fdi/policy/10osvendor/70-scanner.fdi
is created?

I tried to re-plug a scanner to the USB but this had no effect.
I did a reboot and now I have user access for my scanners.
It seems we have (at least in some cases) Windows behaviour.
Comment 20 Ludwig Nussel 2006-11-27 08:23:35 UTC
looks like hal has some fdi file caching now and doesn't notice changes
Comment 21 Johannes Meixner 2006-11-27 11:27:54 UTC
For your information:

User access works perfectly for another new connected scanner
which is also listed in /etc/hal/fdi/policy/10osvendor/70-scanner.fdi
This file is never changed after it was created.
YaST writes only to 80-scanner.fdi, see comment #0.

I.e. the crucial difference seems to be whether or not the fdi file exists
during startup of the HAL machinery and according to comment #19 this means
to do a reboot when only one scanner is connected (which is the normal case).
Comment 22 Johannes Meixner 2006-11-30 13:45:45 UTC
The problem described since comment #19 should be avoided
because a scanner user frontend (which requires the package sane)
is now installed by default on all normal systems, see bug #224411
Comment 23 Johannes Meixner 2006-11-30 14:58:10 UTC
It works perfectly for me using openSUSE 10.2 RC4
default installation with Gnome.
Comment 24 Johannes Meixner 2006-12-01 14:18:52 UTC
More precisely:
It works perfectly only for those devices which are already listed in
/etc/hal/fdi/policy/10osvendor/70-scanner.fdi
The problem decribed in comment #19 still exists for devices which are
added by YaST to 80-scanner.fdi (i.e. which are not listed in 70-scanner.fdi).
Comment 25 Volker Kuhlmann 2006-12-03 08:12:16 UTC
I have this case fail in 10.2RC1:
Boot computer. Turn on SCSI scanner (HP 4P). Run rescan-scsi-bus.sh (nothing ever worked without this). Start yast to configure scanner - no problem with yast, auto-detection is fine, sane is correctly configured. No user access to this scanner is possible because /dev/sg* didn't get adjusted.
sane-find-scanner lists the scanner when run as root, but not otherwise.

This situation is very common, I don't think anyone has their SCSI scanners on 24/7. I didn't check whether a reboot will fix it because having to reboot for each scanner use isn't the done thing with Linux ;)

Is turning on a SCSI scanner after booting supposed to work somehow? Because it does with sane-dev, although I often have to run it twice on <=10.1.

While one can argue that an HP 4P belongs on the scrap heap, the same problem exists with film scanners, which on professional level have used SCSI until rather recently. At the cost of those devices I imagine people prefer them to work :)

I have yast logs but don't want to open a new bug before getting your opinion. Thanks!
Comment 26 Johannes Meixner 2006-12-04 09:00:20 UTC
Some more background info:

sane-dev still exists in the package sane as /usr/share/sane/sane-dev
so that it can be re-enabled if this works better than the current
HAL-based stuff. To re-enable sane-dev do
cp -p /usr/share/sane/sane-dev /etc/init.d/sane-dev
ln -s /etc/init.d/sane-dev /usr/sbin/rcsane-dev
insserv sane-dev
rcsane-dev start

By the way:
Right now I also had to do "rcsane-dev start" twice until my
SCSI processor "HP C6270A 3846" at /dev/sg0 (sane-find-scanner output)
was recognized and /dev/sg0 got appropriate permissions.
I know that this models falls asleep and needs a very long time
to wake up - perhaps this is the reason?

HP SCSI scanners are a bit special bcause (at least some of them)
do not show up as SCSI device with type "scanner" but with
type "processor" - see the sane-find-scanner output.
(As far as I know this is because those devices do not support
the standard SCSI command set for SCSI scanners).
Therefore the default entry for SCSI scanners in
/etc/hal/fdi/policy/10osvendor/70-scanner.fdi
----------------------------------------------------------------------
    <match key="info.category" string="scsi_generic">
      <match key="@info.parent:scsi.type" string="scanner">
        <append key="info.capabilities" type="strlist">scanner</append>
      </match>
    </match>
----------------------------------------------------------------------
does not apply for SCSI processors and therefore YaST writes an
additonal special entry to
/etc/hal/fdi/policy/10osvendor/80-scanner.fdi
--------------------------------------------------------------------------
    <match key="info.category" string="scsi_generic">
      <match key="@info.parent:scsi.type" string="processor">
        <match key="@info.parent:scsi.vendor" string="HP">
          <append key="info.capabilities" type="strlist">scanner</append>
        </match>
      </match>
    </match>
--------------------------------------------------------------------------
which works at least for me (using openSUSE RC4) with the fixed
/usr/lib/YaST2/bin/test_and_set_scanner_access_permissions
according to https://bugzilla.novell.com/show_bug.cgi?id=223875#c6
but after the setup with YaST I had to reboot the system once.

I don't know if turning on a SCSI scanner after booting is supposed
to work. I hope HAL may notice the new appearing SCSI device and
then via the HAL fdi files /usr/sbin/hal-resmgr would be triggered
to set up an appropriate ACL for the device node - use for example
  getfacl /dev/sg0
to see the ACL for /dev/sg0.
I didn't test it because my "HP C6270A 3846" has no off/on switch and
I don't dare to re-plug its power supply while the system is running.
Comment 27 Ludwig Nussel 2006-12-04 09:27:47 UTC
I have an umax scsi scanner at home. It has no power switch itself either, I power cycle it via a switch at the power socket since years. Didn't hurt so far.
Comment 28 Johannes Meixner 2006-12-04 09:29:10 UTC
For the log:

Regarding the problem described since comment #19:

I asked our HAL expert:
-------------------------------------------------------------------------
according to
https://bugzilla.novell.com/show_bug.cgi?id=218393#c19
and the subsequent comments, it seems HAL does not notice
when fdi files are changed during runtime.

For example the YaST scanner configuration adds entries to
/etc/hal/fdi/policy/10osvendor/80-scanner.fdi
to grant normal user access to scanners (via hal-resmgr).

How can I trigger HAL to notice a changed fdi file
or how can I let HAL re-process a particular fdi file?

Note that unplug and replug of the device is not possible
for SCSI scanners during runtime (and even for USB scanners
it would be not nice when the YaST scanner configuration
would have to tell the user that he must unplug and replug
the device to the USB).
-------------------------------------------------------------------------

His answer:
---------------------------------------------------------------------------
IIRC: there is currently no mechanism in HAL to detect a change in a
fdi-file  while HAL is running and apply this changes to a related
device which is already processed.

You can do this:
- remove and readd the device, hal should read the new fdi-file 

or:

- you can try to call (replace $device_UDI with the udi of your device):
  dbus-send --system --print-reply --dest=org.freedesktop.Hal \
  $device_UDI org.freedesktop.Hal.Device.Rescan

IMO some automatic magic would be not the best idea, because you can't say 
which device is effected by a change in a fdi-file and hence HAL need to 
reprocess _all_ devices. A restart of HAL or a manually triggered rescan 
should be much better in this case.
---------------------------------------------------------------------------

I will have a look at the "dbus-send" stuff - perhaps this may
lead to a solution for the next openSUSE version?
Comment 29 Johannes Meixner 2006-12-05 13:45:02 UTC
meanwhile I got a SCSI scanner (i.e. with SCSI type "scanner")
which is not recognized by HAL, see bug #226044
and therefore there cannot be resmgr access via hal-resmgr
for this device (after "chmod a+rw /dev/sg0" it works fine).
Comment 30 Johannes Meixner 2006-12-14 14:09:06 UTC
More information form the HAL expert:
----------------------------------------------------------------------------
HAL will apply the same fdi information it has read on startup.
There is currently no way of applying new fdi information
without restarting HAL. 

Watching the directories with Inotify is the way to go, yes.
Udev and D-Bus are already doing that for a long time.
----------------------------------------------------------------------------