On Tue, 27 Mar 2012, Phil Dibowitz wrote: > On 03/25/2012 06:45 PM, Scott Talbert wrote: >> @@ -22,11 +24,14 @@ check_nm() { >> if [ "$ACTION" = "add" ]; then >> check_nm >> if [ "$?" -eq 1 ]; then >> + echo "NetworkManager found running." >>$LOG > > tabs -> spaces, please.
Okay, here's a v2 with correction of the above. Adam, I'm still looking at firewalld... Fixes several problems relating to the udev rules and dhcpd script for usbnet remotes. Changes include: * The udev rule for usbnet remotes depends on the 75-net-description.rules. Moved the usbnet rule to a separate file so that it can occur later in rules processing and the other udev rules can stay where they are. * The start_concordance* files needed to be installed as executable. * On Fedora, there wasn't a path set when the start_concordance_dhcpd.sh script was run, so it couldn't find any of the programs. Added a path. * Added an iptables rule to allow the DHCPD to receive requests (it was blocked by default on Fedora). * Added debug statements to start_concordance_dhcpd.sh script. * The start_concordance_dhcpd.sh script could write to stderr, which caused it to hang up udev. Redirected output to /dev/null by default. Signed-off-by: Scott Talbert <s...@techie.net> Index: libconcord/Makefile.am =================================================================== RCS file: /cvsroot/concordance/concordance/libconcord/Makefile.am,v retrieving revision 1.11.2.5 diff -u -p -r1.11.2.5 Makefile.am --- libconcord/Makefile.am 22 Mar 2012 08:52:43 -0000 1.11.2.5 +++ libconcord/Makefile.am 29 Mar 2012 02:45:57 -0000 @@ -16,9 +16,11 @@ install_udev_generic: $(MKDIR_P) $(DESTDIR)$(libdir)/udev/rules.d $(install_sh_DATA) libconcord.rules \ $(DESTDIR)$(libdir)/udev/rules.d/60-libconcord.rules - $(install_sh_DATA) start_concordance_dhcpd.sh \ + $(install_sh_DATA) libconcord-usbnet.rules \ + $(DESTDIR)$(libdir)/udev/rules.d/80-libconcord-usbnet.rules + $(install_sh_SCRIPT) start_concordance_dhcpd.sh \ $(DESTDIR)$(libdir)/udev/ - $(install_sh_DATA) start_concordance_dhcpd_wrapper.sh \ + $(install_sh_SCRIPT) start_concordance_dhcpd_wrapper.sh \ $(DESTDIR)$(libdir)/udev/ install_udev: udev install_udev_generic Index: libconcord/gen_udev_support =================================================================== RCS file: /cvsroot/concordance/concordance/libconcord/gen_udev_support,v retrieving revision 1.1.2.2 diff -u -p -r1.1.2.2 gen_udev_support --- libconcord/gen_udev_support 22 Mar 2012 08:52:43 -0000 1.1.2.2 +++ libconcord/gen_udev_support 29 Mar 2012 02:45:57 -0000 @@ -34,6 +34,7 @@ LOGITECH_MIN_PID=c110 LOGITECH_MAX_PID=c14f UDEV_FILE='libconcord.rules' +UDEV_USBNET_FILE='libconcord-usbnet.rules' HAL_POLICY_FILE='libconcord.fdi' POLICYKIT_FILE='org.freedesktop.hal.device-access.libconcord.policy' CONSOLEKIT_FILE='libconcord.perms' @@ -84,7 +85,7 @@ END # Rule for the usbnet family of remotes to start a DHCP daemon upon detection. emit_udev_usbnet_rules() { file="$1" - cat >>$file <<END + cat >$file <<END SUBSYSTEM=="net", ENV{ID_VENDOR_ID}=="046d", ENV{ID_MODEL_ID}=="c11f", \ RUN+="start_concordance_dhcpd_wrapper.sh" END @@ -104,14 +105,17 @@ emit_udev_rules() { emit_for_all $file "$template" 'yes' } -create_udev_file() { +create_udev_files() { 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 - # USBNET rule needs to be outside the other rules since it is a net rule. - emit_udev_usbnet_rules $UDEV_FILE + echo 'done' + # USBNET rule needs to be in a separate file because it depends on + # 75-net-description.rules. + echo -n "Creating udev file: $UDEV_USBNET_FILE ... " + emit_udev_usbnet_rules $UDEV_USBNET_FILE echo 'done' } @@ -238,7 +242,7 @@ if [ "$MODE" == '' ]; then exit 1 fi -create_udev_file $MODE +create_udev_files $MODE if [ "$MODE" == 'policykit' ]; then create_hal_policy_file create_policykit_file Index: libconcord/start_concordance_dhcpd.sh =================================================================== RCS file: /cvsroot/concordance/concordance/libconcord/Attic/start_concordance_dhcpd.sh,v retrieving revision 1.1.2.1 diff -u -p -r1.1.2.1 start_concordance_dhcpd.sh --- libconcord/start_concordance_dhcpd.sh 22 Mar 2012 08:52:43 -0000 1.1.2.1 +++ libconcord/start_concordance_dhcpd.sh 29 Mar 2012 02:45:57 -0000 @@ -6,6 +6,8 @@ NM_WAIT_COUNT=3 LOCAL_IP="169.254.1.1" REMOTE_IP="169.254.1.2" NETMASK="255.255.0.0" +export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" +IPTABLES_RULE="INPUT -p udp -i $INTERFACE --dport 67 -j ACCEPT" NMCLI=$(which nmcli) check_nm() { @@ -22,11 +24,14 @@ check_nm() { if [ "$ACTION" = "add" ]; then check_nm if [ "$?" -eq 1 ]; then + echo "NetworkManager found running." >>$LOG COUNT=0 while [ "$COUNT" -lt "$NM_WAIT_COUNT" ]; do + echo "Waiting for NetworkManager." >>$LOG $NMCLI -t -f DEVICE,STATE dev \ | grep "^${INTERFACE}\:connecting" >>$LOG 2>&1 if [ "$?" = "0" ]; then + echo "Disconnecting $INTERFACE via NetworkManager." >>$LOG $NMCLI dev disconnect iface $INTERFACE >>$LOG 2>&1 break fi @@ -34,9 +39,14 @@ if [ "$ACTION" = "add" ]; then sleep 1 done fi + echo "Configuring $INTERFACE interface." >>$LOG ifconfig $INTERFACE $LOCAL_IP netmask $NETMASK >>$LOG 2>&1 + echo "Adding iptables rule." >>$LOG + iptables -I $IPTABLES_RULE >>$LOG 2>&1 dnsmasq --port=0 --interface=$INTERFACE --bind-interfaces --leasefile-ro \ --dhcp-range=$REMOTE_IP,$REMOTE_IP --pid-file=$PID_FILE else + echo "Stopping dnsmasq and removing iptables rule." >>$LOG kill $(cat $PID_FILE) + iptables -D $IPTABLES_RULE >>$LOG 2>&1 fi Index: libconcord/start_concordance_dhcpd_wrapper.sh =================================================================== RCS file: /cvsroot/concordance/concordance/libconcord/Attic/start_concordance_dhcpd_wrapper.sh,v retrieving revision 1.1.2.1 diff -u -p -r1.1.2.1 start_concordance_dhcpd_wrapper.sh --- libconcord/start_concordance_dhcpd_wrapper.sh 22 Mar 2012 08:52:43 -0000 1.1.2.1 +++ libconcord/start_concordance_dhcpd_wrapper.sh 29 Mar 2012 02:45:57 -0000 @@ -1,4 +1,4 @@ #!/bin/bash # Kicks off dhcpd startup in the background so udev can go about its work. -$(dirname $0)/start_concordance_dhcpd.sh & +$(dirname $0)/start_concordance_dhcpd.sh >/dev/null 2>&1 & ------------------------------------------------------------------------------ This SF email is sponsosred by: Try Windows Azure free for 90 days Click Here http://p.sf.net/sfu/sfd2d-msazure _______________________________________________ concordance-devel mailing list concordance-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/concordance-devel