diff --git a/cleaner.php b/cleaner.php index c870123..2b64220 100644 --- a/cleaner.php +++ b/cleaner.php @@ -1,5 +1,5 @@
-The Scanner udev Rule Maker is used to grant access to USB scanners that use libusb. It is a script that checks for libusb scanners and changes the permission on it so all users can access it and creates a configuration file so change will be persistent
+The Scanner udev Rule Maker is used to grant access to USB scanners that use libusb. It is a script that checks for libusb scanners and changes the permission on it so all users can access it and creates a configuration file so change will be persistent.
The file it creates is /etc/udev/rules.d/40-scanner.rules, if you already have this file it will give you a comparison of the rule(s) and let you do what you feel you need to (nothing, merge, append, etc.). Most likely it will create the file, if you run it twice it will tell you the file is up to date.
To use it simply extract the file and run the script as root in a terminal, you can safely delete the script after using it.
@@ -8,12 +8,69 @@
+Some scanners are not detected by the 'USB Scanner udev Rule Maker'. This tool is used to generate rules for the administrator to install manually.
+Select the scanners from this list of USB devices then click the 'Generate' button to get the necessary udev rules.
+To install these rules save the generated rules to /etc/udev/rules.d/40-scanner.rules
"; + foreach($_POST as $key => $val){ + foreach($usb as $dev){ + if(strpos($dev,$key)>-1){ + $dev=substr($dev,0,strpos($dev,':')); + $dev=explode(' ',$dev); + array_push($paths,$dev[1].'/'.$dev[3]); + break; + } + } + $key=explode(":",$key); + $vnd=$key[0]; + $itm=$key[1]; + echo html("# $val\n". + "SUBSYSTEMS==\"usb\", ATTRS{idVendor}==\"$vnd\", ATTRS{idProduct}==\"$itm\", ENV{libsane_matched}=\"yes\", $type=\"$group\"\n"); + } + echo "To apply these permissions without rebooting run these commands as root:
"; + foreach($paths as $val){ + echo 'chmod '.($type=="GROUP"?"root:$group":$group)." /dev/bus/usb/$val\n"; + } + echo "
If a scanner shows with scanimage -L
and is not detected by the server scanner the problem is permission.
To enable access jhansonxi has developed a application that will enable access a copy is included with the PHP Server Scanner.
To install it download the archive and extract it. Then move the script to /usr/local/bin/scanner-access-enabler
and set it for root:root ownership with rwxr-xr-x (0755) permissions.
-Then move the destop menu entry to the /usr/local/share/applications
directory with root:root ownership and rw-r--r-- (0644) permissions. The applicaion will now be under System -> Administration in Ubuntu.
+Then move the desktop menu entry to the /usr/local/share/applications
directory with root:root ownership and rw-r--r-- (0644) permissions. The application will now be under System -> Administration in Ubuntu.
Some scanners will need to have this done every time you boot.
If you have to run it every boot add /usr/local/bin/scanner-access-enabler -s
before exit 0
in /etc/rc.local
on its own line and you are good to go.
So you just want the terminal commands, I will assume you just opened a terminal and extracted the archive to your desktop
There is a problem with scanner device permissions on Ubuntu. Regular users (UID>999
) can access libsane applications like Xsane and Simple Scan without problems. PHP Scanner Server, which is running in Apache as www-data, can't access them without a chmod o+rw
on each scanner device. Nobody seems to know how the permissions work so this has to be fixed manually in a terminal. This is not n00b friendly so I created a GUI application that automatically changes the permissions of every scanner device.
The application relies on scanimage
and sane-find-scanner utilities to identify scanner device ports then simply does a chmod
against all of them. It supports USB, SCSI, and optionally parallel port (-p parameter) scanners and has been tested against the same ones I used for my LSS patch. It uses the same universal dialog code as webcam-server-dialog so it should work with almost any desktop environment.
To install first download the archive and extract the contents. Move the script to "/usr/local/bin/scanner-access-enabler
" and set it for root:root ownership with rwxr-xr-x
(0755) permissions. Copy the destop menu entry to the /usr/local/share/applications
directory with root:root
ownership and rw-r--r--
(0644) permissions. You may have to edit the desktop file as it uses gksudo by default. On KDE you may want to change the Exec entry to use kdesudo
instead. If you specify the -p option on the Exec line you may have to quote everything after gk/kdesudo. If you don't have one of the GUI dialoger utilities installed and plan on using dialog or whiptail then you need to set "Terminal=true" else you won't see anything.
On Ubuntu the menu item will be found under System > Administration. If you want users to be able to activate scanners without a password and admin group membership, you can add an exception to the end of "/etc/sudoers
" file. Simply run "sudo visudo" and enter the following:
The application relies on scanimage
and sane-find-scanner utilities to identify scanner device ports then simply does a chmod
against all of them. It supports USB, SCSI, and optionally parallel port (-p parameter) scanners and has been tested against the same ones I used for my LSS patch. It uses the same universal dialog code as webcam-server-dialog so it should work with almost any desktop environment.
To install first download the archive and extract the contents. Move the script to "/usr/local/bin/scanner-access-enabler
" and set it for root:root ownership with rwxr-xr-x
(0755) permissions. Copy the destop menu entry to the /usr/local/share/applications
directory with root:root
ownership and rw-r--r--
(0644) permissions. You may have to edit the desktop file as it uses gksudo by default. On KDE you may want to change the Exec entry to use kdesudo
instead. If you specify the -p option on the Exec line you may have to quote everything after gk/kdesudo. If you don't have one of the GUI dialogue utilities installed and plan on using dialog or whiptail then you need to set "Terminal=true" else you won't see anything.
On Ubuntu the menu item will be found under System > Administration. If you want users to be able to activate scanners without a password and admin group membership, you can add an exception to the end of "/etc/sudoers
" file. Simply run "sudo visudo" and enter the following:
# Allow any user to fix SCSI scanner port device permissions
ALL ALL=NOPASSWD: /usr/local/bin/scanner-access-enabler *
While you can use any editor as root to change the file, visudo checks for syntax errors before saving as a mistake can disable sudo and prevent you from fixing it easily. If you mess it up, you can reboot and use Ubuntu recovery mode or a LiveCD to fix it.
Update: I released v1.1 which adds filtering for "net:" devices from saned connections. This didn't affect the permission changes but made for a crowded dialog with both the raw and net devices shown.