diff -Naur ../ori/netcfg-2.1.3/src/netcfg ./src/netcfg --- ../ori/netcfg-2.1.3/src/netcfg 2009-03-01 10:13:48.000000000 +0100 +++ ./src/netcfg 2009-04-11 23:23:18.691163577 +0200 @@ -59,7 +59,7 @@ killall dhcpcd ;; -d|down) - profile_down $2;; + profile_down "$2";; -i|iface-down) interface_down $2;; -a|all-down) @@ -72,7 +72,7 @@ usage;; *) if [ -n "$1" ]; then - profile_up $1 + profile_up "$1" else usage fi diff -Naur ../ori/netcfg-2.1.3/src/network.subr ./src/network.subr --- ../ori/netcfg-2.1.3/src/network.subr 2009-03-01 10:13:48.000000000 +0100 +++ ./src/network.subr 2009-04-11 23:23:15.290780426 +0200 @@ -19,19 +19,19 @@ # load_profile profile # source the profile load_profile() { - validate_profile $1 || return 1 - . $PROFILE_DIR/$1 + validate_profile "$1" || return 1 + . "$PROFILE_DIR/$1" } # validate_profile profile # check whether profile exists and is usable validate_profile() { [[ -z "$1" ]] && return 1 - if [[ ! -f $PROFILE_DIR/$1 ]]; then + if [[ ! -f "$PROFILE_DIR/$1" ]]; then err "Profile \"$1\" does not exist" return 1 fi - . $PROFILE_DIR/$1 + . "$PROFILE_DIR/$1" if [[ -z "$INTERFACE" ]]; then err "Profile missing an interface to configure" return 1 @@ -50,7 +50,7 @@ all_down() { ls -1 $STATE_DIR/profiles/ | while read prof; do - profile_down $prof + profile_down "$prof" done rm_daemon net-profiles } @@ -75,7 +75,7 @@ all_resume() { ls -1 $STATE_DIR/suspend/ | while read prof; do - profile_up $prof + profile_up "$prof" rm $STATE_DIR/suspend/$prof done } @@ -85,12 +85,11 @@ # profile_up() { - [[ ! -d $STATE_DIR ]] && mkdir -p $STATE_DIR/{interfaces,profiles} - load_profile $1 || return 1 + load_profile "$1" || return 1 - check_profile $1 && err "$1 already connected" && return 1 + check_profile "$1" && err "$1 already connected" && return 1 # NETWORKS_EXCLUSIVE, rc.conf: Profiles are globally mutually exclusive # EXCLUSIVE, network.d/profile: Individual profile is mutually exclusive @@ -106,7 +105,7 @@ stat_fail && return 1 else interface_down $INTERFACE || return 1 - load_profile $1 + load_profile "$1" fi fi @@ -114,14 +113,14 @@ eval $PRE_UP || return 1 . $SUBR_DIR/${CONNECTION}.subr - if ! ${CONNECTION}_up $1; then + if ! ${CONNECTION}_up "$1"; then stat_fail return 1 fi eval $POST_UP || return 1 - set_profile up $1 + set_profile up "$1" ${CONNECTION}_clean_scope unset EXCLUSIVE @@ -137,9 +136,9 @@ [[ ! -d $STATE_DIR ]] && mkdir -p $STATE_DIR/{interfaces,profiles} - load_profile $1 || return 1 + load_profile "$1" || return 1 - if ! check_profile $1; then + if ! check_profile "$1"; then err "Profile not connected" return 1 fi @@ -154,14 +153,14 @@ eval $PRE_DOWN || return 1 . $SUBR_DIR/${CONNECTION}.subr - if ! ${CONNECTION}_down $1; then + if ! ${CONNECTION}_down "$1"; then stat_fail return 1 fi eval $POST_DOWN || return 1 - set_profile down $1 + set_profile down "$1" ${CONNECTION}_clean_scope stat_done } @@ -189,8 +188,8 @@ # interface_down() { - local prof=$(get_iface_prof $1) - profile_down $prof + local prof="$(get_iface_prof $1)" + profile_down "$prof" return $? } @@ -230,7 +229,7 @@ # Return 1 if profile down # check_profile() { - [[ -f $STATE_DIR/profiles/$1 ]] && return 0 + [[ -f "$STATE_DIR/profiles/$1" ]] && return 0 return 1 } @@ -241,15 +240,15 @@ # set_profile() { if [[ "$1" == "up" ]]; then - . $PROFILE_DIR/$2 - cp $PROFILE_DIR/$2 $STATE_DIR/profiles/ - echo $2 > $STATE_DIR/last_profile - set_iface up $INTERFACE $2 + . "$PROFILE_DIR/$2" + cp "$PROFILE_DIR/$2" $STATE_DIR/profiles/ + echo "$2" > $STATE_DIR/last_profile + set_iface up $INTERFACE "$2" elif [[ "$1" == "down" ]]; then - . $STATE_DIR/profiles/$2 - rm $STATE_DIR/profiles/$2 - set_iface down $INTERFACE $2 + . "$STATE_DIR/profiles/$2" + rm "$STATE_DIR/profiles/$2" + set_iface down $INTERFACE "$2" fi } @@ -258,10 +257,10 @@ # optionally link it to a profile. # set_iface() { - PROFILE=$3 + PROFILE="$3" [[ -z "$PROFILE" ]] && PROFILE=external if [[ "$1" == "up" ]]; then - echo "PROFILE=$PROFILE" > $STATE_DIR/interfaces/$2 + echo "PROFILE=\"$PROFILE\"" > $STATE_DIR/interfaces/$2 elif [[ "$1" == "down" ]]; then rm $STATE_DIR/interfaces/$2 fi diff -Naur ../ori/netcfg-2.1.3/src/wireless.subr ./src/wireless.subr --- ../ori/netcfg-2.1.3/src/wireless.subr 2009-03-01 10:13:48.000000000 +0100 +++ ./src/wireless.subr 2009-04-11 23:23:12.704497815 +0200 @@ -99,7 +99,7 @@ wireless_up() { - load_profile $1 + load_profile "$1" if [[ ! -d /sys/class/net/$INTERFACE/wireless ]]; then err_append "Interface $INTERFACE is not a wireless interface" @@ -165,6 +165,7 @@ quirk "wpaessid" && eval iwconfig $INTERFACE essid "\"$ESSID\"" # Create a random file to store configuration, make it root only. + touch $WPA_CONF chmod 600 $WPA_CONF echo "ctrl_interface=/var/run/wpa_supplicant" >> $WPA_CONF echo "ctrl_interface_group=0" >> $WPA_CONF @@ -190,17 +191,17 @@ esac . $SUBR_DIR/ethernet.subr - if ! ethernet_up $1; then - wireless_down $1 YES + if ! ethernet_up "$1"; then + wireless_down "$1" YES return 1 fi } wireless_down() { - PROFILE=$1 NOETHERNETDOWN=$2 + PROFILE="$1" NOETHERNETDOWN=$2 if ! checkyesno $2; then . $SUBR_DIR/ethernet.subr - ethernet_down $1 + ethernet_down "$1" fi wpa_cli terminate &> /dev/null