Douglas E. Warner wrote: > Douglas E. Warner wrote: >> Sorry this is taking me so long to get worked out; it looks like the >> PolicyKit >> rules I previously wrote don't work anymore (at least on my box). The udev >> rules are working fine, but I just can't get access to the device from a >> regular user. I'll try to figure out what's going on today. >> > > Okay, I think I have an updated gen_udev_support script that generates: > * udev rules (alias /dev/harmony* to the correct usb device) > * ConsoleKit perms (pre-PolicyKit that used pam_console to grant access to > devices) > * PolicyKit perms (includes a hal script to assign the correct keys to the hal > device as well as the PolicyKit policy) > > Fedora only currently supports PolicyKit (ConsoleKit was dropped in F9) but > since we had the rules I kept them in the script but just cleaned up the names > of variables. > > I'm packaging up things now to test and will post the updated script once I > know that's good. >
Here we go; attached gen_udev_support script. -Doug
#!/bin/bash # # vim:shiftwidth=2:tabstop=2:expandtab:textwidth=80:softtabstop=4:ai # # This script generates udev and/or policykit rules for Logitech Harmony # devices. # # This script is loosely-based on scripts by Douglas E. Warner # <silfr...@silfreed.net> # # GPLv2 # # Copyright 2009 Phil Dibowitz # UDEV_POLICY_TEMPLATE='ATTR{idVendor}=="%s", ATTR{idProduct}=="%s", SYMLINK+="harmony-%%k"' UDEV_NO_POLICY_TEMPLATE='SYSFS{idVendor}=="%s", SYSFS{idProduct}=="%s", MODE="0660", GROUP="dialout"' HAL_PRE_TEMPLATE=' <match key="usb_device.vendor_id" int="0x%s">' HAL_RULE_TEMPLATE=' <match key="usb_device.product_id" int="0x%s"> <append key="info.capabilities" type="strlist">access_control</append> <merge key="access_control.file" type="copy_property">linux.device_file</merge> <merge key="access_control.type" type="string">libconcord</merge> </match>' HAL_POST=' </match>' NATIONAL_VID=0400 NATIONAL_PID=c359 LOGITECH_VID=046d LOGITECH_MIN_PID=c110 LOGITECH_MAX_PID=c14f UDEV_FILE='99-libconcord.rules' HAL_POLICY_FILE='99-libconcord.fdi' POLICYKIT_FILE='org.freedesktop.hal.device-access.libconcord.policy' CONSOLEKIT_FILE='99-libconcord.perms' # # GENERAL FUNCTIONS # emit_for_all() { file="$1" template="$2" include_vid="$3" printf "$template\n" $NATIONAL_VID $NATIONAL_PID >>$file for pid in `seq 0x$LOGITECH_MIN_PID 0x$LOGITECH_MAX_PID`; do pid=`printf "%x" $pid` if [ "$include_vid" == 'yes' ] ; then printf "$template\n" $LOGITECH_VID $pid >>$file else printf "$template\n" $pid >>$file fi done } # # UDEV FUNCTIONS # emit_udev_header() { file="$1" cat >$file <<END # Neat trick so that non-harmony devices don't read through a million rules SUBSYSTEM=="usb_device", GOTO="harmony_usb_rules" SUBSYSTEM=="usb", GOTO="harmony_usb_rules" BUS!="usb", GOTO="harmony_rules_end" GOTO="harmony_rules_end" LABEL="harmony_usb_rules" END } emit_udev_footer() { file="$1" cat >>$file <<END GOTO="harmony_rules_end" LABEL="harmony_rules_end" END } emit_udev_rules() { file="$1" type="$2" if [ "$type" == 'policykit' ]; then template="$UDEV_POLICY_TEMPLATE" else template="$UDEV_NO_POLICY_TEMPLATE" fi emit_for_all $file "$template" 'yes' } create_udev_file() { mode=$1 echo -n "Creating udev file: $UDEV_FILE ... " emit_udev_header $UDEV_FILE emit_udev_rules $UDEV_FILE $mode emit_udev_footer $UDEV_FILE echo 'done' } # # HAL POLICY FUNCITONS # emit_hal_policy_header() { file="$1" cat >$file <<END <?xml version="1.0" encoding="UTF-8"?> <deviceinfo version="0.2"> <device> END printf "$HAL_PRE_TEMPLATE\n" $LOGITECH_VID >>$file } emit_hal_policy_footer() { printf "$HAL_POST\n" >>$file file="$1" cat >>$file <<END </device> </deviceinfo> END } emit_hal_policy_rules() { file="$1" emit_for_all $file "$HAL_RULE_TEMPLATE" } create_hal_policy_file() { echo -n "Creating hal policy file: $HAL_POLICY_FILE ... " emit_hal_policy_header $HAL_POLICY_FILE emit_hal_policy_rules $HAL_POLICY_FILE emit_hal_policy_footer $HAL_POLICY_FILE echo 'done' } # # POLICYKIT FUNCITONS # emit_policykit() { file="$1" cat >$file <<END <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE policyconfig PUBLIC "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN" "http://www.freedesktop.org/standards/PolicyKit/1.0/policyconfig.dtd"> <policyconfig> <action id="org.freedesktop.hal.device-access.libconcord"> <description>Directly access the Logitech Harmony remote</description> <message>System policy prevents access to the Logitech Harmony remote</message> <defaults> <allow_inactive>no</allow_inactive> <allow_active>yes</allow_active> </defaults> </action> </policyconfig> END } create_policykit_file() { echo -n "Creating PolicyKit file: $POLICYKIT_FILE ..." emit_policykit $POLICYKIT_FILE echo ' done' } # # CONSOLEKIT # emit_perms() { file="$1" cat >$file <<END <harmony>=/dev/harmony* <console> 0600 <harmony> 0600 root END } create_perms_file() { echo -n "Creating perms file: $CONSOLEKIT_FILE ..." emit_perms $CONSOLEKIT_FILE echo ' done' } # # OTHER FUNCTIONS # usage() { echo "Usage: $0 <-u|-p|-c>" } # # MAIN # while getopts upc opt; do case $opt in u) MODE='udev_only' ;; p) MODE='policykit' ;; c) MODE='consolekit' ;; *) usage exit 1 esac done if [ "$MODE" == '' ]; then usage exit 1 fi create_udev_file $MODE if [ "$MODE" == 'policykit' ]; then create_hal_policy_file create_policykit_file elif [ "$MODE" == 'consolekit' ]; then create_perms_file fi
signature.asc
Description: OpenPGP digital signature
------------------------------------------------------------------------------ Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H
_______________________________________________ concordance-devel mailing list concordance-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/concordance-devel