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

Bug#371876: pppoeconf: more robust handling of /etc/network/interfaces



Package: pppoeconf
Version: 1.10
Severity: wishlist
Tags: patch

#334361 caused pppoeconf to make an invalid /etc/network/interfaces in
certain cases. I submitted two patches, one fixing the bug, and one to
take precautions against similar bugs being reintroduced, or even
already existing. The first patch was the applied, so I suggest applying the other patch I am attaching, though only after review.
--- /usr/sbin/pppoeconf	2006-06-02 21:20:03.000000000 -0400
+++ pppoeconf	2006-06-07 22:21:27.000000000 -0400
@@ -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
@@ -82,23 +82,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.
 
@@ -188,6 +171,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
@@ -408,7 +408,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: