[arch-projects] [netctl][PATCH] Better detection of hex keys
Hex WEP keys are of even length, ASCII keys are of odd length. Using this information we make wifi-menu work better for WEP networks. Signed-off-by: Jouke Witteveen <j.witteveen@gmail.com> --- src/lib/wpa | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lib/wpa b/src/lib/wpa index d79fdbe..ff6d9ab 100644 --- a/src/lib/wpa +++ b/src/lib/wpa @@ -219,11 +219,15 @@ wpa_make_config_block() { wep) echo "key_mgmt=NONE" echo "wep_tx_keyidx=0" - echo "wep_key0=$(wpa_quote "$Key")" + if (( ${#Key} % 2 == 0 )) && [[ "$key" = +([[:xdigit:]]) ]]; then + echo "wep_key0=$Key" + else + echo "wep_key0=$(wpa_quote "$Key")" + fi ;; wpa) echo "proto=RSN WPA" - if [[ "${#Key}" -eq 64 ]]; then + if [[ "${#key}" -eq 64 && "$key" = +([[:xdigit:]]) ]]; then echo "psk=$Key" else echo "psk=$(wpa_quote "$Key")" -- 1.8.4.1
New timeout is 30 seconds, which equals the current dhcpcd default. Signed-off-by: Jouke Witteveen <j.witteveen@gmail.com> --- docs/netctl.profile.5.txt | 2 +- src/lib/ip | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/netctl.profile.5.txt b/docs/netctl.profile.5.txt index b1ccde1..17f0537 100644 --- a/docs/netctl.profile.5.txt +++ b/docs/netctl.profile.5.txt @@ -172,7 +172,7 @@ network. In particular, these connection types are +ethernet+, 'TimeoutDHCP=':: Maximum time, in seconds, to wait for DHCP to be successful. - Defaults to `++10++'. + Defaults to `++30++'. 'TimeoutDAD=':: Maximum time, in seconds, to wait for IPv6's Duplicate Address diff --git a/src/lib/ip b/src/lib/ip index d62ac0c..a93eaee 100644 --- a/src/lib/ip +++ b/src/lib/ip @@ -48,7 +48,7 @@ ip_set() { rm -f "/run/dhcpcd-$Interface".{pid,cache} # If using own dns, tell dhcpcd to NOT replace resolv.conf [[ $DNS ]] && DhcpcdOptions+=" -C resolv.conf" - do_debug dhcpcd -4qL -t "${TimeoutDHCP:-10}" $DhcpcdOptions "$Interface" |& report_debug "$(cat)" + do_debug dhcpcd -4qL -t "${TimeoutDHCP:-30}" $DhcpcdOptions "$Interface" |& report_debug "$(cat)" # The first array value of PIPESTATUS is the exit status of dhcpcd if (( PIPESTATUS != 0 )); then report_error "DHCP IP lease attempt failed on interface '$Interface'" @@ -57,7 +57,7 @@ ip_set() { ;; dhclient) rm -f "/run/dhclient-${Interface}.pid" - if ! do_debug dhclient -4 -q -e "TIMEOUT=${TimeoutDHCP:-10}" -pf "/run/dhclient-$Interface.pid" $DhclientOptions "$Interface"; then + if ! do_debug dhclient -4 -q -e "TIMEOUT=${TimeoutDHCP:-30}" -pf "/run/dhclient-$Interface.pid" $DhclientOptions "$Interface"; then report_error "DHCP IP lease attempt failed on interface '$Interface'" return 1 fi @@ -110,7 +110,7 @@ ip_set() { fi [[ $IP6 == "dhcp-noaddr" ]] && DhclientOptions6+=" -S" rm -f "/run/dhclient6-${Interface}.pid" - if ! do_debug dhclient -6 -q -e "TIMEOUT=${TimeoutDHCP:-10}" -pf "/run/dhclient6-${Interface}.pid" $DhclientOptions6 "$Interface"; then + if ! do_debug dhclient -6 -q -e "TIMEOUT=${TimeoutDHCP:-30}" -pf "/run/dhclient6-${Interface}.pid" $DhclientOptions6 "$Interface"; then report_error "DHCPv6 IP lease attempt failed on interface '$Interface'" return 1 fi -- 1.8.4.1
This is especially useful to enforce connecting in the 5 GHz band. Signed-off-by: Jouke Witteveen <j.witteveen@gmail.com> --- docs/netctl.profile.5.txt | 4 ++++ src/lib/wpa | 1 + 2 files changed, 5 insertions(+) diff --git a/docs/netctl.profile.5.txt b/docs/netctl.profile.5.txt index 17f0537..0eac7c3 100644 --- a/docs/netctl.profile.5.txt +++ b/docs/netctl.profile.5.txt @@ -235,6 +235,10 @@ of the `wireless' type: 'AdHoc=':: Whether or not to use ad-hoc mode. Defaults to `++no++'. +'ScanFrequencies=':: + A space-separated list of frequencies in MHz to scan when searching + for the network. Defaults to all available frequencies. + 'Priority=':: Priority group for the network. In case of automatic profile selection, the matched network with the highest priority will be diff --git a/src/lib/wpa b/src/lib/wpa index ff6d9ab..dea95d5 100644 --- a/src/lib/wpa +++ b/src/lib/wpa @@ -247,6 +247,7 @@ wpa_make_config_block() { [[ $AP ]] && echo "bssid=${AP,,}" is_yes "${Hidden:-no}" && echo "scan_ssid=1" is_yes "${AdHoc:-no}" && echo "mode=1" + [[ $ScanFrequencies ]] && echo "scan_freq=$ScanFrequencies" [[ $Priority ]] && echo "priority=$Priority" } -- 1.8.4.1
Netctl files can potentially contain passwords or execute code as root. Signed-off-by: Jouke Witteveen <j.witteveen@gmail.com> --- src/lib/globals | 2 ++ src/lib/wpa | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib/globals b/src/lib/globals index 5926472..a2a281f 100644 --- a/src/lib/globals +++ b/src/lib/globals @@ -5,6 +5,8 @@ CONN_DIR="$SUBR_DIR/connections" STATE_DIR="/run/network" STATE_FILE="${NETCTL_STATE_FILE:-/var/lib/netctl/netctl.state}" +umask 077 + ### Logging/Error reporting diff --git a/src/lib/wpa b/src/lib/wpa index dea95d5..6f21c0f 100644 --- a/src/lib/wpa +++ b/src/lib/wpa @@ -198,7 +198,6 @@ wpa_make_config_file() { report_debug "Could not create the configuration file '$config_file'" return 1 fi - chmod 600 "$config_file" echo "ctrl_interface=/run/wpa_supplicant" >> "$config_file" echo "ctrl_interface_group=${WPAGroup:-wheel}" >> "$config_file" -- 1.8.4.1
Also: tag error messages as systemd error messages when the messages are not directed to the terminal. Signed-off-by: Jouke Witteveen <j.witteveen@gmail.com> --- src/lib/globals | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lib/globals b/src/lib/globals index a2a281f..66f3cee 100644 --- a/src/lib/globals +++ b/src/lib/globals @@ -15,7 +15,11 @@ report_notice() { } report_error() { - echo "$*" + echo "$*" | if [[ -t 2 ]]; then + (tput bold; tput setaf 1; cat; tput sgr0) >&2 + else + systemd-cat -t "$(basename "$0")" -p err + fi } report_debug() { @@ -23,7 +27,7 @@ report_debug() { } exit_error() { - report_error "$@" >&2 + report_error "$@" exit 1 } -- 1.8.4.1
On Wed, Oct 23, 2013 at 02:06:49PM +0200, Jouke Witteveen wrote:
Also: tag error messages as systemd error messages when the messages are not directed to the terminal.
Signed-off-by: Jouke Witteveen <j.witteveen@gmail.com> --- src/lib/globals | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/lib/globals b/src/lib/globals index a2a281f..66f3cee 100644 --- a/src/lib/globals +++ b/src/lib/globals @@ -15,7 +15,11 @@ report_notice() { }
report_error() { - echo "$*" + echo "$*" | if [[ -t 2 ]]; then + (tput bold; tput setaf 1; cat; tput sgr0) >&2
Useless subshell. { cmd; cmd; } >&2 is what you want.
+ else + systemd-cat -t "$(basename "$0")" -p err
I don't really understand the need for this. If stderr isn't a terminal, isn't it reasonable to assume that this is being called by the daemon (which was already started by systemd?) You can just log to stderr and it'll be collected by the journal. Morever, logging in this manner will explicitly disconnect them from the daemon. The -t flag for systemd-cat just adds a SYSLOG_IDENTIFIER field. You can never find these messages with a _SYSTEMD_UNIT filter despite them having what *appears* to be a relationship to the caller.
+ fi }
report_debug() { @@ -23,7 +27,7 @@ report_debug() { }
exit_error() { - report_error "$@" >&2 + report_error "$@" exit 1 }
-- 1.8.4.1
On Wed, Oct 23, 2013 at 5:13 PM, Dave Reisner <d@falconindy.com> wrote:
On Wed, Oct 23, 2013 at 02:06:49PM +0200, Jouke Witteveen wrote:
Also: tag error messages as systemd error messages when the messages are not directed to the terminal.
Signed-off-by: Jouke Witteveen <j.witteveen@gmail.com> --- src/lib/globals | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/lib/globals b/src/lib/globals index a2a281f..66f3cee 100644 --- a/src/lib/globals +++ b/src/lib/globals @@ -15,7 +15,11 @@ report_notice() { }
report_error() { - echo "$*" + echo "$*" | if [[ -t 2 ]]; then + (tput bold; tput setaf 1; cat; tput sgr0) >&2
Useless subshell. { cmd; cmd; } >&2 is what you want.
Indeed, that's what was meant.
+ else + systemd-cat -t "$(basename "$0")" -p err
I don't really understand the need for this. If stderr isn't a terminal, isn't it reasonable to assume that this is being called by the daemon (which was already started by systemd?) You can just log to stderr and it'll be collected by the journal. Morever, logging in this manner will explicitly disconnect them from the daemon. The -t flag for systemd-cat just adds a SYSLOG_IDENTIFIER field. You can never find these messages with a _SYSTEMD_UNIT filter despite them having what *appears* to be a relationship to the caller.
Unfortunately, systemd does not classify output on stderr as errors. As a result, netctl errors are not formatted as such in the journal. Many problems people seem to be having with netctl are related to their inability to correctly parse the journal. I hoped to give some more guidance this way. Are there other ways to add the error identifier?
+ fi }
report_debug() { @@ -23,7 +27,7 @@ report_debug() { }
exit_error() { - report_error "$@" >&2 + report_error "$@" exit 1 }
-- 1.8.4.1
On Wed, Oct 23, 2013 at 5:18 PM, Jouke Witteveen <j.witteveen@gmail.com> wrote:
On Wed, Oct 23, 2013 at 5:13 PM, Dave Reisner <d@falconindy.com> wrote:
On Wed, Oct 23, 2013 at 02:06:49PM +0200, Jouke Witteveen wrote:
Also: tag error messages as systemd error messages when the messages are not directed to the terminal.
Signed-off-by: Jouke Witteveen <j.witteveen@gmail.com> --- src/lib/globals | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/lib/globals b/src/lib/globals index a2a281f..66f3cee 100644 --- a/src/lib/globals +++ b/src/lib/globals @@ -15,7 +15,11 @@ report_notice() { }
report_error() { - echo "$*" + echo "$*" | if [[ -t 2 ]]; then + (tput bold; tput setaf 1; cat; tput sgr0) >&2
Useless subshell. { cmd; cmd; } >&2 is what you want.
Indeed, that's what was meant.
+ else + systemd-cat -t "$(basename "$0")" -p err
I don't really understand the need for this. If stderr isn't a terminal, isn't it reasonable to assume that this is being called by the daemon (which was already started by systemd?) You can just log to stderr and it'll be collected by the journal. Morever, logging in this manner will explicitly disconnect them from the daemon. The -t flag for systemd-cat just adds a SYSLOG_IDENTIFIER field. You can never find these messages with a _SYSTEMD_UNIT filter despite them having what *appears* to be a relationship to the caller.
Unfortunately, systemd does not classify output on stderr as errors. As a result, netctl errors are not formatted as such in the journal. Many problems people seem to be having with netctl are related to their inability to correctly parse the journal. I hoped to give some more guidance this way. Are there other ways to add the error identifier?
Answering my own question. The answer was on http://0pointer.de/blog/projects/journal-submit.html which I somehow overlooked in my earlier searches. I will redo the patch to prefix '<3>' to error messages when not running interactively.
+ fi }
report_debug() { @@ -23,7 +27,7 @@ report_debug() { }
exit_error() { - report_error "$@" >&2 + report_error "$@" exit 1 }
-- 1.8.4.1
- Refactorization of option file generation - Introduction of optional additional pppd options file specification - Introduction of unit specification option for pppoe connections Signed-off-by: Jouke Witteveen <j.witteveen@gmail.com> --- docs/examples/mobile_ppp | 3 -- docs/netctl.profile.5.txt | 11 +++- src/lib/connections/mobile_ppp | 118 +++++++++++++---------------------------- src/lib/connections/pppoe | 90 +++++++++++++++---------------- 4 files changed, 89 insertions(+), 133 deletions(-) diff --git a/docs/examples/mobile_ppp b/docs/examples/mobile_ppp index f3b0b8a..383e000 100644 --- a/docs/examples/mobile_ppp +++ b/docs/examples/mobile_ppp @@ -2,9 +2,6 @@ Description='Example PPP mobile connection' Interface=ttyUSB0 Connection=mobile_ppp -# Debug pppd / chat output (separately from netctl) -#PPPDebug=true - # Use default route provided by the peer (default: true) #DefaultRoute=true # Use DNS provided by the peer (default: true) diff --git a/docs/netctl.profile.5.txt b/docs/netctl.profile.5.txt index 1f39361..74bbc6d 100644 --- a/docs/netctl.profile.5.txt +++ b/docs/netctl.profile.5.txt @@ -332,12 +332,18 @@ the `pppoe' type: Use the default route provided by the peer (defaults to `true') 'UsePeerDNS=':: - Use the DNS provided by the peer (defaults to `true') + Use the DNS provided by the peer (defaults to `true'). + +'PPPUnit=':: + Set the ppp unit number in the interface name (ppp0, ppp1, etc.). 'LCPEchoInterval=' and 'LCPEchoFailure=':: These options override default LCP parameters from `/etc/ppp/options'. +'OptionsFile=':: + A file to read additional pppd options from. + The following advanced options are also understood: 'PPPoEService=':: @@ -389,6 +395,9 @@ type: AT commands specific to certain Huawei modems; all other devices should use `None'. +'OptionsFile=':: + A file to read additional pppd options from. + OPTIONS FOR `tunnel' CONNECTIONS -------------------------------- diff --git a/src/lib/connections/mobile_ppp b/src/lib/connections/mobile_ppp index b966390..5006c6c 100644 --- a/src/lib/connections/mobile_ppp +++ b/src/lib/connections/mobile_ppp @@ -11,18 +11,14 @@ quote_word() { } mobile_ppp_up() { - local cfg - local chat - - mkdir -p "$STATE_DIR/mobile_ppp.${Interface}.${Profile}/" - chmod 700 "$STATE_DIR/mobile_ppp.${Interface}.${Profile}/" - cfg="$STATE_DIR/mobile_ppp.${Interface}.${Profile}/options" + local options chat + options="$STATE_DIR/mobile_ppp.${Interface}.${Profile}/options" chat="$STATE_DIR/mobile_ppp.${Interface}.${Profile}/modem.chat" - echo "linkname $(quote_word "${Profile}")" > "${cfg}" - chmod 600 "${cfg}" - cat >> "${cfg}" << EOF -${Interface} + mkdir -p "$(dirname "$options")" + cat >> "$options" << EOF +linkname $(quote_word "$Profile") +$(quote_word "$Interface") 921600 lock crtscts @@ -30,61 +26,19 @@ modem passive novj holdoff 10 -maxfail ${MaxFail:-5} -EOF - - # Debug pppd output separately from netctl - if is_yes "${PPPDebug:-yes}"; then - echo "debug" >> "${cfg}" - fi - - # Sets up route - if is_yes "${DefaultRoute:-yes}"; then - echo "defaultroute" >> "${cfg}" - else - echo "nodefaultroute" >> "${cfg}" - fi - if is_yes "${UsePeerDNS:-yes}"; then - echo "usepeerdns" >> "${cfg}" - fi - # Writes username and password - echo "noauth" >> "${cfg}" - echo "hide-password" >> ${cfg} - [[ -n ${User} ]] && echo "user $(quote_word "${User}")" >> "${cfg}" - [[ -n ${Password} ]] && echo "password $(quote_word "${Password}")" >> "${cfg}" - - #echo "'OK' @/etc/ppp/chatscripts/pin" >> "${chat}" - if [ -n "${Pin}" ]; then - PinStr="'OK' 'AT+CPIN=\"${Pin}\"'" - else - PinStr="'OK' 'AT'" - fi - report_debug echo $PinStr - - # Mode can be one of 3Gpref, 3Gonly, GPRSpref, GPRSonly, None - # Only works for Huawei modems - #echo "'OK' @/etc/ppp/chatscripts/mode" >> "${chat}" - case "${Mode}" in - 3Gonly) - ModeStr="'OK' 'AT\^SYSCFG=14,2,3fffffff,0,1'" - ;; - 3Gpref) - ModeStr="'OK' 'AT\^SYSCFG=2,2,3fffffff,0,1'" - ;; - GPRSonly) - ModeStr="'OK' 'AT\^SYSCFG=13,1,3fffffff,0,0'" - ;; - GPRSpref) - ModeStr="'OK' 'AT\^SYSCFG=2,1,3fffffff,0,0'" - ;; - *) - ModeStr="'OK' 'AT'" - ;; - esac +noauth +$(is_yes "${DefaultRoute:-yes}" || printf no)defaultroute +maxfail $(quote_word "${MaxFail:-5}") +$(is_yes "${UsePeerDNS:-yes}" && printf usepeerdns) +hide-password +${User:+user $(quote_word "$User")} +${Password:+password $(quote_word "$Password")} +connect $(quote_word "/usr/sbin/chat -v -t15 -f $(quote_word "$chat")") +${OptionsFile:+file $(quote_word "$OptionsFile")} +EOF - # Now that we’ve got the ppp configuration set up, write the chat script - cat >> "${chat}" << EOF + cat >> "$chat" << EOF ECHO ON ABORT 'BUSY' ABORT 'NO CARRIER' @@ -100,40 +54,40 @@ TIMEOUT 6 'OK-AT-OK' 'ATZ' TIMEOUT 3 'OK' 'AT+CFUN=1' -${PinStr} +'OK' 'AT${Pin:++CPIN=$(quote_word "$Pin")}' 'OK\d-AT-OK' 'ATI' 'OK' 'ATZ' 'OK' 'ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0' -${ModeStr} -'OK-AT-OK' 'AT+CGDCONT=1,"IP","${AccessPointName}"' +'OK' 'AT$(case $Mode in + 3Gonly) printf "\^SYSCFG=14,2,3fffffff,0,1";; + 3Gpref) printf "\^SYSCFG=2,2,3fffffff,0,1";; + GPRSonly) printf "\^SYSCFG=13,1,3fffffff,0,0";; + GPRSpref) printf "\^SYSCFG=2,1,3fffffff,0,0";; +esac)' +'OK-AT-OK' 'AT+CGDCONT=1,"IP",$(quote_word "$AccessPointName")' 'OK' 'ATDT*99#' TIMEOUT 30 CONNECT '' EOF - # Add the chat script line to the configuration - echo "connect \"/usr/sbin/chat -v -t15 -f ${chat}\"" >> "${cfg}" - - if ! $PPPD file "${cfg}"; then - rmdir "$STATE_DIR/mobile_ppp.${Interface}.${Profile}/" - report_error "Couldn't make pppd connection." + if ! $PPPD file "$options"; then + rm "$options" "$chat" + rmdir "$(dirname "$options")" + report_error "Could not establish a ppp connection for profile '$Profile'." return 1 fi } mobile_ppp_down() { - local cfg chat pidfile pid - cfg="$STATE_DIR/mobile_ppp.${Interface}.${Profile}/options" - chat="$STATE_DIR/mobile_ppp.${Interface}.${Profile}/modem.chat" - pidfile="/var/run/ppp-${Profile}.pid" + local options chat pidfile + options="$STATE_DIR/mobile_ppp.$Interface.$Profile/options" + chat="$STATE_DIR/mobile_ppp.$Interface.$Profile/modem.chat" + pidfile="/var/run/ppp-$Profile.pid" - if [[ -e $pidfile ]]; then - read pid < "$pidfile" - [[ "$pid" ]] && kill "$pid" - fi + [[ -r $pidfile ]] && kill "$(< "$pidfile")" - rm "${cfg}" "${chat}" - rmdir "$STATE_DIR/mobile_ppp.${Interface}.${Profile}/" + rm "$options" "$chat" + rmdir "$(dirname "$options")" } diff --git a/src/lib/connections/pppoe b/src/lib/connections/pppoe index 65fee79..78cc35f 100644 --- a/src/lib/connections/pppoe +++ b/src/lib/connections/pppoe @@ -8,7 +8,9 @@ quote_word() { } pppoe_up() { - local cfg + local options pidfile pppn + options="$STATE_DIR/pppoe.$Interface.$Profile/options" + pidfile="/var/run/ppp-$Profile.pid" if ! is_interface "$Interface"; then report_error "Interface '$Interface' does not exist" @@ -19,61 +21,55 @@ pppoe_up() { return 1 fi - mkdir -p "$STATE_DIR/pppoe.${Interface}.${Profile}/" - chmod 700 "$STATE_DIR/pppoe.${Interface}.${Profile}/" - cfg="$STATE_DIR/pppoe.${Interface}.${Profile}/options" - echo "linkname $(quote_word "${Profile}")" > "${cfg}" - chmod 600 "${cfg}" + mkdir -p "$(dirname "$options")" + cat >> "$options" << EOF +linkname $(quote_word "$Profile") +${PPPUnit:+unit $(quote_word "$PPPUnit")} +updetach +plugin rp-pppoe.so +nic-$Interface - echo "plugin rp-pppoe.so" >> "${cfg}" - echo "nic-${Interface}" >> "${cfg}" - echo "noauth" >> "${cfg}" - if is_yes "${DefaultRoute:-yes}"; then - echo "defaultroute" >> "${cfg}" - else - echo "nodefaultroute" >> "${cfg}" - fi - if is_yes "${UsePeerDNS:-yes}"; then - echo "usepeerdns" >> "${cfg}" - fi - echo "maxfail ${MaxFail:-5}" >> "${cfg}" - echo "updetach" >> "${cfg}" - if [[ ${ConnectionMode} == demand ]]; then - echo "demand" >> "${cfg}" - echo "idle ${IdleTimeout}" >> "${cfg}" - else - echo "persist" >> "${cfg}" - fi - echo "user $(quote_word "${User}")" >> "${cfg}" - echo "password $(quote_word "${Password}")" >> "${cfg}" - [[ -n ${LCPEchoInterval} ]] && echo "lcp-echo-interval ${LCPEchoInterval}" >> "${cfg}" - [[ -n ${LCPEchoFailure} ]] && echo "lcp-echo-failure ${LCPEchoFailure}" >> "${cfg}" - [[ -n ${PPPoEService} ]] && echo "rp_pppoe_service $(quote_word "${PPPoEService}")" >> "${cfg}" - [[ -n ${PPPoEAC} ]] && echo "rp_pppoe_ac $(quote_word "${PPPoEAC}")" >> "${cfg}" - [[ -n ${PPPoESession} ]] && echo "rp_pppoe_sess $(quote_word "${PPPoESession}")" >> "${cfg}" - [[ -n ${PPPoEMAC} ]] && echo "pppoe-mac $(quote_word "${PPPoEMAC}")" >> "${cfg}" - [[ ${PPPoEIP6} == yes ]] && echo "+ipv6" >> "${cfg}" +noauth +$(is_yes "${DefaultRoute:-yes}" || printf no)defaultroute +maxfail $(quote_word "${MaxFail:-5}") +$(is_yes "${UsePeerDNS:-yes}" && printf usepeerdns) +$(quote_word "${ConnectionMode:-persist}") +$([[ $ConnectionMode == demand ]] && printf "idle %s" "$(quote_word "$IdleTimeout")") +${LCPEchoInterval:+lcp-echo-interval $(quote_word "$LCPEchoInterval")} +${LCPEchoFailure:+lcp-echo-failure $(quote_word "$LCPEchoFailure")} +${PPPoEService:+rp_pppoe_service $(quote_word "$PPPoEService")} +${PPPoEAC:+rp_pppoe_ac $(quote_word "$PPPoEAC")} +${PPPoESession:+rp_pppoe_sess $(quote_word "$PPPoESession")} +${PPPoEMAC:+pppoe-mac $(quote_word "$PPPoEMAC")} +$(is_yes "${PPPoEIP6:-no}" && printf +ipv6) +$(is_yes "${PPPoEIP6:-yes}" || printf noipv6) - if ! $PPPD file "${cfg}"; then - rm "${cfg}" - rmdir "$STATE_DIR/pppoe.${Interface}.${Profile}/" - report_error "Couldn't make pppd connection." +user $(quote_word "$User") +password $(quote_word "$Password") +${OptionsFile:+file $(quote_word "$OptionsFile")} +EOF + + if ! $PPPD file "$options"; then + rm "$options" + rmdir "$(dirname "$options")" + report_error "Could not establish a ppp connection for profile '$Profile'." return 1 fi + + [[ -r $pidfile ]] || return 0 + pppn=$(grep -l "$(< "$pidfile")" /var/run/ppp[[:digit:]]*.pid) + report_notice "PPP unit for profile '$Profile': ${pppn:9:-4}" } pppoe_down() { - local cfg pidfile pid - cfg="$STATE_DIR/pppoe.${Interface}.${Profile}/options" - pidfile="/var/run/ppp-${Profile}.pid" + local options pidfile + options="$STATE_DIR/pppoe.$Interface.$Profile/options" + pidfile="/var/run/ppp-$Profile.pid" - if [[ -e $pidfile ]]; then - read pid < "$pidfile" - [[ "$pid" ]] && kill "$pid" - fi + [[ -r $pidfile ]] && kill "$(< "$pidfile")" - rm "${cfg}" - rmdir "$STATE_DIR/pppoe.${Interface}.${Profile}/" + rm "$options" + rmdir "$(dirname "$options")" bring_interface_down "$Interface" } -- 1.8.4.1
participants (2)
-
Dave Reisner
-
Jouke Witteveen