[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#334361: pppoeconf: Explanation, patch



Package: pppoeconf
Version: 1.8
Followup-For: Bug #334361

First I'll clarify what David Fasani meant. By "erase the old "auto"
variable values", he thinks that auto is a variable and that the added
line #20 changes its value. Actually, #20 just declares new auto
interfaces, but since eth0 is already declared, the new interfaces file
is invalid. /etc/init.d/networking start fails and this explains why he
has to do stuff manually each time.

The cause of this breakage is either a broken regex introduced in 1.8
which greps for a literal "+", or the fact that the greps don't expect
auto lines to declare as auto several interfaces. Attached
pppoeconf_regex.patch fixes both problems in the two first lines. The
last line is a cosmetic fix.

Since pppoeconf isn't particularly robust, I've also attached
pppoeconf_1.8+regexfix_robustinterfaces.patch which attempts to make
sure that the generated interfaces is valid.
There are 2 reasons I created the last patch: in case a new similar bug
is introduced, and to learn sh scripting. Seriously, you should really
review the patch, I'm not assuming full responsability if it breaks
something.

Since this can break network and potentially let lo unconfigured, please consider bumping this to serious...or fixing soon ;)

-- System Information:
Debian Release: testing/unstable
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.12-1-386
Locale: LANG=fr_CA.UTF-8, LC_CTYPE=fr_CA.UTF-8 (charmap=UTF-8)

Versions of packages pppoeconf depends on:
ii  gettext-base                  0.14.5-2   GNU Internationalization utilities
ii  ppp                           2.4.4b1-1  Point-to-Point Protocol (PPP) daem
ii  sed                           4.1.2-8    The GNU sed stream editor
ii  whiptail [whiptail-provider]  0.51.6-31  Displays user-friendly dialog boxe

Versions of packages pppoeconf recommends:
ii  locales                       2.3.5-8    GNU C Library: National Language (

-- no debconf information
243c243
<   if ! grep -q "^auto\ +$iface" $INTFILE ; then
---
>   if ! grep -q "^[[:space:]]*auto[[:space:]][^#]*$iface" $INTFILE ; then
248c248
<   if ! grep -q "^\ *iface\ +$iface" $INTFILE ; then
---
>   if ! grep -q "^[[:space:]]*iface[[:space:]]\+$iface" $INTFILE ; then
250c250
<       echo "    iface $iface inet manual" >> $INTFILE
---
>       echo "iface $iface inet manual" >> $INTFILE
--- /root/pppoeconf.prerobust	2006-01-06 15:34:42.000000000 -0500
+++ pppoeconf	2006-01-07 08:53:15.000000000 -0500
@@ -7,7 +7,7 @@
 export TEXTDOMAINDIR="/usr/share/locale"
 export TEXTDOMAIN=pppoeconf
 export OPTSFILE="/etc/ppp/peers/dsl-provider"
-export INTFILE="/etc/network/interfaces"
+export REALINTFILE="/etc/network/interfaces"
 
 # IMPORTANT: Do not use gdialog unless it has been fixed!
 DIALOG=whiptail
@@ -77,23 +77,6 @@
 chmod 0640 $OPTSFILE
 chown root:dip $OPTSFILE
 
-if ! grep -q "dsl-provider" $INTFILE ; then
-   printf '\niface dsl-provider inet ppp\nprovider dsl-provider\n' >> $INTFILE
-fi
-
-# old crap, unreliable, does not work after reboot
-# if ! grep -q "line maintained by pppoeconf" $INTFILE ; then
-#    sed -i -e 's,provider dsl-provider$,     provider dsl-provider\n# please do not modify the following line\n     pre-up /sbin/ifconfig eth0 up # line maintained by pppoeconf\n,' $INTFILE
-# fi
-   
-umask 177
-# make a secure directory
-TMP="`mktemp -d -p /etc/ppp`"
-export TMP
-sectempfile="`mktemp -p $TMP`"
-export sectempfile
-trap "rm -rf '$TMP'" 0 HUP INT TRAP TERM
-
 gettext '
 Most providers send the needed login information per mail. Some providers describe it in odd ways, assuming the user to input the data in their "user-friendly" setup programs. But in fact, these applications generate usuall PPP user names and passwords from the entered data. You can find the real names too and input the correct data in the dialog box.
 
@@ -183,6 +166,23 @@
       exit 1
       ;;
    esac
+
+   INTFILE="`mktemp -t interfaces.pppoeconf.XXXXXX`" || exit 1
+   export INTFILE
+   cp $REALINTFILE $INTFILE
+
+   if ! grep -q "dsl-provider" $INTFILE ; then
+      printf '\niface dsl-provider inet ppp\nprovider dsl-provider\n' >> $INTFILE
+   fi
+
+   umask 177
+   # make a secure directory
+   TMP="`mktemp -d -p /etc/ppp`"
+   export TMP
+   sectempfile="`mktemp -p $TMP`"
+   export sectempfile
+   trap "rm -rf '$TMP'" 0 HUP INT TRAP TERM
+
    # now, execute an AC lookup on each interface
    for mmm in '' ' -U ' ; do
       for iface in $list; do
@@ -403,7 +403,24 @@
   
   # end of story
   rm -rf "$TMP"
-  
+  chmod --reference=$REALINTFILE $INTFILE
+  # check that final file is valid or original one was already invalid. otherwise ask what to do
+  ifup -nai $INTFILE 2>/dev/null
+  if test "$?" = "1" &&  (ifup -na 2>/dev/null; test "$?" = "0"); then
+    title='ERROR'
+    text="The interfaces file generated by pppoeconf appears to be invalid. This is probably because pppoeconf is unable to handle your original interfaces files. Should pppoeconf nevertheless change your interfaces file with the one that appears to be invalid?
+Answering Yes will probably break your network connectivity after rebooting, and cause some local problems if lo is down. Your original interfaces file will be moved to $REALINTFILE~ so you can restore it.
+Answering No means you will have to make sure that $iface is configured before starting your DSL connection and start the connection manually.
+
+Note that this situation is not expected and you should consider submitting a bug report against pppoeconf including your original interfaces files and the one generated by pppoeconf."
+    $DIALOG --title "$title" --clear --defaultno --yesno "$text" 20 75
+    if test "$?" = "0"; then
+      mv -b $INTFILE $REALINTFILE
+    fi
+  else
+    mv $INTFILE $REALINTFILE
+  fi
+
   title=$(gettext 'ESTABLISH A CONNECTION')
   text=$(gettext 'Now, you can make a DSL connection with "pon dsl-provider" and terminate it with "poff". Would you like to start the connection now?')
   $DIALOG --title "$title" --clear --yesno "$text" 15 60

Reply to: