Bugzilla – Attachment 63261 Details for
Bug 142859
scanner access and resmgr
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
IDP Log In
|
Forgot Password
[patch]
patch to write fdi file
f (text/plain), 6.92 KB, created by
Ludwig Nussel
on 2006-01-13 13:01:13 UTC
(
hide
)
Description:
patch to write fdi file
Filename:
MIME Type:
Creator:
Ludwig Nussel
Created:
2006-01-13 13:01:13 UTC
Size:
6.92 KB
patch
obsolete
>Index: src/Scanner.ycp >=================================================================== >--- src/Scanner.ycp (Revision 27007) >+++ src/Scanner.ycp (Arbeitskopie) >@@ -496,15 +496,18 @@ > /** > * Search the autodetected_scanners list for USB scanners > * and if at least one USB scanner was found, >- * then create the file /etc/resmgr.conf.d/50-scanner.conf >+ * then create the file /etc/hal/fdi/policy/10osvendor/80-scanner.fdi > * with an entry for each autodetected USB scanner like > * ----------------------------------------------------------------------------------- >- * add usb:vendor=0x1234,product=0x5678 scanner >- * add usb:vendor=0x1a2b,product=0x3c4d scanner >+ * <match key="linux.subsystem" string="usb"> >+ * <match key="usb.vendor_id" int="0x12345"> >+ * <match key="usb.product_id" int="0x5678"> >+ * <merge key="resmgr.class" type="string">scanner</merge> >+ * </match> >+ * </match> >+ * </match> > * ----------------------------------------------------------------------------------- >- * and (re)-start and enable the service "resmgr" >- * otherwise remove the file /etc/resmgr.conf.d/50-scanner.conf >- * and (re)-start the service "resmgr". >+ * otherwise remove the file /etc/hal/fdi/policy/10osvendor/80-scanner.fdi > * Ignore whether or not an autodetected USB scanner appears in the active_scanners list > * (i.e. simply grant access to all autodetected USB scanners) > * because on x86_64 "scanimage -L" cannot find scanners using the 32-bit epkowa backend >@@ -515,28 +518,36 @@ > * @return true on success > */ > boolean SetUsbScannerAccessPermissions() >-{ string resmgr_scanner_config_file = "/etc/resmgr.conf.d/50-scanner.conf"; >+{ string resmgr_scanner_config_dir = "/etc/hal/fdi/policy/10osvendor"; >+ string resmgr_scanner_config_file = resmgr_scanner_config_dir + "/80-scanner.fdi"; > boolean autodetected_usb_scanner = false; > boolean autodetected_usb_scanner_with_missing_ids = false; >+ string content = ""; >+ SCR::Execute (.target.mkdir, resmgr_scanner_config_dir); > foreach( map< string, string > autodetected_scanner, > autodetected_scanners, > { if( "USB" == autodetected_scanner["connection"]:"unknown" ) > { // There is an autodetected USB scanner. > if( ! autodetected_usb_scanner ) >- { // Clear /etc/resmgr.conf.d/50-scanner.conf and write the header comment >+ { // Clear fdi file and write the header comment > // only for the first autodetected USB scanner > // (i.e. when autodetected_usb_scanner is still false): > y2milestone( "There is an autodetected USB scanner: Setting USB Scanner Access Permissions in %1 anew.", resmgr_scanner_config_file ); >- if( ExecuteBashCommand( "echo '# Use /usr/sbin/lsusb to create entries like:' >" + resmgr_scanner_config_file ) >- && ExecuteBashCommand( "echo '# add usb:vendor=0x1a2b,product=0x3c4d scanner' >>" + resmgr_scanner_config_file ) >- && ExecuteBashCommand( "echo '# to grant access to USB scanners:' >>" + resmgr_scanner_config_file ) >- ) >- { y2milestone( "(Re)-created %1", resmgr_scanner_config_file ); >- } >- else >- { y2milestone( "Failed to (re)-create %1", resmgr_scanner_config_file ); >- return false; >- } >+ content = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?> >+<!-- Use /usr/sbin/lsusb to create entries like: >+<match key=\"linux.subsystem\" string=\"usb\"> >+ <match key=\"usb.vendor_id\" int=\"0x1234\"> >+ <match key=\"usb.product_id\" int=\"0x5678\"> >+ <merge key=\"resmgr.class\" type=\"string\">scanner</merge> >+ </match> >+ </match> >+</match> >+ >+to grant access to USB scanners --> >+ >+<deviceinfo version=\"0.2\"> >+ <device> >+"; > } > autodetected_usb_scanner = true; > string usb_vendor_id = autodetected_scanner["usb_vendor_id"]:""; >@@ -551,49 +562,43 @@ > } > else > { // USB vendor ID and USB product ID exist: >- string resmgr_entry = "add usb:" + "vendor=" + usb_vendor_id + ",product=" + usb_product_id + " scanner"; >- if( ! ExecuteBashCommand( "echo '" + resmgr_entry + "' >>" + resmgr_scanner_config_file ) ) >- { y2milestone( "Failed to write '%1' into %2", resmgr_entry, resmgr_scanner_config_file ); >- return false; >- } >- else >- { y2milestone( "Wrote '%1' into %2", resmgr_entry, resmgr_scanner_config_file ); >- } >+ content = content + sformat(" >+ <match key=\"linux.subsystem\" string=\"usb\"> >+ <match key=\"usb.vendor_id\" int=\"%1\"> >+ <match key=\"usb.product_id\" int=\"%2\"> >+ <merge key=\"resmgr.class\" type=\"string\">scanner</merge> >+ </match> >+ </match> >+ </match> >+", usb_vendor_id, usb_product_id); > } > } > } > ); >- if( autodetected_usb_scanner ) >- { // If there is an autodetected USB scanner, >- // /etc/resmgr.conf.d/50-scanner.conf was (re)-created in any case >- // so that resmgr must be (re)-started and enabled: >- if( ! Service::Restart( "resmgr" ) ) >- { y2milestone( "Service::Restart('resmgr') failed." ); >- return false; >+ >+ if(content != "") >+ { >+ content = content + " </device>\n</deviceinfo>\n"; >+ if((boolean)SCR::Write(.target.string, resmgr_scanner_config_file, content)) >+ { >+ y2milestone( "(Re)-created %1", resmgr_scanner_config_file ); > } >- if( ! Service::Enable( "resmgr" ) ) >- { y2milestone( "Service::Enable('resmgr') failed." ); >+ else >+ { >+ y2milestone( "Failed to (re)-create %1", resmgr_scanner_config_file ); >+ // displayed in error dialog (%1 is a filename) >+ bash_result["stderr"] = sformat(_("can't write file %1"), resmgr_scanner_config_file); > return false; > } >- y2milestone( "Service resmgr (re)-started and enabled." ); >- if( autodetected_usb_scanner_with_missing_ids ) >- { return false; >- } >- return true; > } >- else >- { if( ! ExecuteBashCommand( "rm -f " + resmgr_scanner_config_file ) ) >- { y2milestone( "Failed to remove %1", resmgr_scanner_config_file ); >- return false; >- } >- y2milestone( "Removed %1 (using 'rm -f').", resmgr_scanner_config_file ); >- if( ! Service::Restart( "resmgr" ) ) >- { y2milestone( "Service::Restart('resmgr') failed." ); >- return false; >- } >- y2milestone( "Service resmgr (re)-started." ); >- return true; >+ if( !autodetected_usb_scanner && >+ (boolean)SCR::Execute(.target.remove, resmgr_scanner_config_file) != true ) >+ { y2milestone( "Failed to remove %1", resmgr_scanner_config_file ); >+ // displayed in error dialog (%1 is a filename) >+ bash_result["stderr"] = sformat(_("can't remove file %1"), resmgr_scanner_config_file); >+ return false; > } >+ return true; > } > > /** ># vim: syntax=diff
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
Actions:
View
|
Diff
Attachments on
bug 142859
:
63261
|
63291
|
63420
|
63460