Bug#309629: ipmasq: watch for i - j substitution

2005-07-23 Thread Osamu Aoki
Hi,

On Tue, Jun 28, 2005 at 07:31:22PM +0200, Frederic LEHOBEY wrote:
...
 Please notice that in the file F31routes.rul I believe the variable i
 should be substituted to the j (see the patch below) for the latter
 `if' test to make sense.
 
 --
 diff -Naur /usr/share/doc/ipmasq/examples/routes/F31routes.rul 
 /tmp/ipmasq-309629/F31routes.rul
 --- /usr/share/doc/ipmasq/examples/routes/F31routes.rul   2004-07-27 
 21:37:24.0 +0200
 +++ /tmp/ipmasq-309629/F31routes.rul  2005-06-28 18:41:03.711288480 +0200
 @@ -1,10 +1,10 @@
  #: Forward packets among internal and routed networks
  if [ -n $ROUTES ]; then
  for route in $ROUTES; do
 - j=${$route%%:*}
 + j=${route%%:*}
   dest=${route##*:}
   for r in $ROUTES; do 
 - j=${$r%%:*}
 + i=${r%%:*}
   src=${r##*:}
  if [ $i != $j ]; then
  case $MASQMETHOD in
 --

This looks good. Thanks I will take this :-)

 Just for the record my alternative patch to A01routes.rul is also
 included below.
 
 --
 diff -Naur /usr/share/doc/ipmasq/examples/routes/A01routes.rul 
 /tmp/ipmasq-309629/A01routes.rul
 --- /usr/share/doc/ipmasq/examples/routes/A01routes.rul   2004-07-28 
 22:51:24.0 +0200
 +++ /tmp/ipmasq-309629/A01routes.rul  2005-06-28 18:41:03.711288480 +0200
 @@ -18,9 +18,11 @@
  return
  }
  
 -for route in `route -n | grep '^[1-9]'`; do
 +routelines=`route -n | grep '^[1-9]'`
 +for (( i=1 ; $i = `echo $routelines | wc -l` ; i++ )) do
 +route=`echo $routelines | head -n $i | tail -n 1`
  IFACE=$( echo $route | { read X X X X X X X Y ; echo $Y ; } )
 -if echo $INTERNAL | grep -q $IFACE; then
 +if `echo $INTERNAL | grep -q $IFACE -` ; then
  # $IFACE is in $INTERNAL
  NDEST=$( echo $route | { read Y X X X X X X X ; echo $Y ; } )
  NMASK=$( echo $route | { read X X Y X X X X X ; echo $Y ; } )
 --

Oops.  Yopu are right.  This could not work.  But I need to confirm few
things. I have question on this patch. 

 -if echo $INTERNAL | grep -q $IFACE; then
 +if `echo $INTERNAL | grep -q $IFACE -` ; then

First, I think grep do not need '-' as file name.  
My original script should work.  It is testing exit code of grep.

Can you tell me why this patch?

 Otherwise, I have the same typos for files I31routes.rul, M71masq.rul
 and O31routes.rul as original bug submitter (not included).

Give them to me.



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Bug#309629: ipmasq: watch for i - j substitution

2005-07-23 Thread Frederic Lehobey
Hi,

On Sat, Jul 23, 2005 at 03:04:50PM +0200, Osamu Aoki wrote:
 On Tue, Jun 28, 2005 at 07:31:22PM +0200, Frederic LEHOBEY wrote:

 Oops.  Yopu are right.  This could not work.  But I need to confirm few
 things. I have question on this patch. 
 
  -if echo $INTERNAL | grep -q $IFACE; then
  +if `echo $INTERNAL | grep -q $IFACE -` ; then
 
 First, I think grep do not need '-' as file name.  
 My original script should work.  It is testing exit code of grep.
 
 Can you tell me why this patch?

You are right.  It does not seem to be necessary anymore.  I used it
to get rid of the following error (from my notes, sorry, French
locale) I cannot reproduce anymore (weird, as I was already in stable
sarge):

# invoke-rc.d ipmasq restart
Initializing IP Masquerading...Usage: grep [OPTION]... PATRON [FICHIER]...
Pour en savoir davantage, faites: « grep --help ».
Usage: grep [OPTION]... PATRON [FICHIER]...
Pour en savoir davantage, faites: « grep --help ».
Usage: grep [OPTION]... PATRON [FICHIER]...
Pour en savoir davantage, faites: « grep --help ».
Usage: grep [OPTION]... PATRON [FICHIER]...
Pour en savoir davantage, faites: « grep --help ».
Usage: grep [OPTION]... PATRON [FICHIER]...
Pour en savoir davantage, faites: « grep --help ».
Usage: grep [OPTION]... PATRON [FICHIER]...
Pour en savoir davantage, faites: « grep --help ».
Usage: grep [OPTION]... PATRON [FICHIER]...
Pour en savoir davantage, faites: « grep --help ».
Usage: grep [OPTION]... PATRON [FICHIER]...
Pour en savoir davantage, faites: « grep --help ».
Usage: grep [OPTION]... PATRON [FICHIER]...
Pour en savoir davantage, faites: « grep --help ».
Usage: grep [OPTION]... PATRON [FICHIER]...
Pour en savoir davantage, faites: « grep --help ».
Usage: grep [OPTION]... PATRON [FICHIER]...
Pour en savoir davantage, faites: « grep --help ».
Usage: grep [OPTION]... PATRON [FICHIER]...
Pour en savoir davantage, faites: « grep --help ».
Usage: grep [OPTION]... PATRON [FICHIER]...
Pour en savoir davantage, faites: « grep --help ».
Usage: grep [OPTION]... PATRON [FICHIER]...
Pour en savoir davantage, faites: « grep --help ».
Usage: grep [OPTION]... PATRON [FICHIER]...
Pour en savoir davantage, faites: « grep --help ».
Usage: grep [OPTION]... PATRON [FICHIER]...
Pour en savoir davantage, faites: « grep --help ».
Usage: grep [OPTION]... PATRON [FICHIER]...
Pour en savoir davantage, faites: « grep --help ».
Usage: grep [OPTION]... PATRON [FICHIER]...
Pour en savoir davantage, faites: « grep --help ».
Usage: grep [OPTION]... PATRON [FICHIER]...
Pour en savoir davantage, faites: « grep --help ».
Usage: grep [OPTION]... PATRON [FICHIER]...
Pour en savoir davantage, faites: « grep --help ».
Usage: grep [OPTION]... PATRON [FICHIER]...
Pour en savoir davantage, faites: « grep --help ».
Usage: grep [OPTION]... PATRON [FICHIER]...
Pour en savoir davantage, faites: « grep --help ».
Usage: grep [OPTION]... PATRON [FICHIER]...
Pour en savoir davantage, faites: « grep --help ».
Usage: grep [OPTION]... PATRON [FICHIER]...
Pour en savoir davantage, faites: « grep --help ».
Usage: grep [OPTION]... PATRON [FICHIER]...
Pour en savoir davantage, faites: « grep --help ».
Usage: grep [OPTION]... PATRON [FICHIER]...
Pour en savoir davantage, faites: « grep --help ».
Usage: grep [OPTION]... PATRON [FICHIER]...
Pour en savoir davantage, faites: « grep --help ».
Usage: grep [OPTION]... PATRON [FICHIER]...
Pour en savoir davantage, faites: « grep --help ».
Usage: grep [OPTION]... PATRON [FICHIER]...
Pour en savoir davantage, faites: « grep --help ».
Usage: grep [OPTION]... PATRON [FICHIER]...
Pour en savoir davantage, faites: « grep --help ».
Usage: grep [OPTION]... PATRON [FICHIER]...
Pour en savoir davantage, faites: « grep --help ».
Usage: grep [OPTION]... PATRON [FICHIER]...
Pour en savoir davantage, faites: « grep --help ».
done.

Maybe they were only a consequence of the other typo (solved _after_
this change while investigating).

  Otherwise, I have the same typos for files I31routes.rul, M71masq.rul
  and O31routes.rul as original bug submitter (not included).
 
 Give them to me.

Here they are, in the attachment.

Best regards,
Frederic Lehobey
diff -Naur /usr/share/doc/ipmasq/examples/routes/A01routes.rul 
/tmp/ipmasq-309629/A01routes.rul
--- /usr/share/doc/ipmasq/examples/routes/A01routes.rul 2004-07-28 
22:51:24.0 +0200
+++ /tmp/ipmasq-309629/A01routes.rul2005-07-23 15:38:13.219017768 +0200
@@ -18,7 +18,9 @@
 return
 }
 
-for route in `route -n | grep '^[1-9]'`; do
+routelines=`route -n | grep '^[1-9]'`
+for (( i=1 ; $i = `echo $routelines | wc -l` ; i++ )) do
+route=`echo $routelines | head -n $i | tail -n 1`
 IFACE=$( echo $route | { read X X X X X X X Y ; echo $Y ; } )
 if echo $INTERNAL | grep -q $IFACE; then
 # $IFACE is in $INTERNAL
diff -Naur /usr/share/doc/ipmasq/examples/routes/F31routes.rul 
/tmp/ipmasq-309629/F31routes.rul
--- /usr/share/doc/ipmasq/examples/routes/F31routes.rul 2004-07-27 

Bug#309629: ipmasq: watch for i - j substitution

2005-06-28 Thread Frederic LEHOBEY
Package: ipmasq
Version: 4.0.2
Followup-For: Bug #309629

Hi,

I have experienced the same bug (it is therefore confirmed) and solved
it in almost the same way independently (I should have checked before
the BTS).

Please notice that in the file F31routes.rul I believe the variable i
should be substituted to the j (see the patch below) for the latter
`if' test to make sense.

--
diff -Naur /usr/share/doc/ipmasq/examples/routes/F31routes.rul 
/tmp/ipmasq-309629/F31routes.rul
--- /usr/share/doc/ipmasq/examples/routes/F31routes.rul 2004-07-27 
21:37:24.0 +0200
+++ /tmp/ipmasq-309629/F31routes.rul2005-06-28 18:41:03.711288480 +0200
@@ -1,10 +1,10 @@
 #: Forward packets among internal and routed networks
 if [ -n $ROUTES ]; then
 for route in $ROUTES; do
-   j=${$route%%:*}
+   j=${route%%:*}
dest=${route##*:}
for r in $ROUTES; do 
-   j=${$r%%:*}
+   i=${r%%:*}
src=${r##*:}
 if [ $i != $j ]; then
 case $MASQMETHOD in
--

Just for the record my alternative patch to A01routes.rul is also
included below.

--
diff -Naur /usr/share/doc/ipmasq/examples/routes/A01routes.rul 
/tmp/ipmasq-309629/A01routes.rul
--- /usr/share/doc/ipmasq/examples/routes/A01routes.rul 2004-07-28 
22:51:24.0 +0200
+++ /tmp/ipmasq-309629/A01routes.rul2005-06-28 18:41:03.711288480 +0200
@@ -18,9 +18,11 @@
 return
 }
 
-for route in `route -n | grep '^[1-9]'`; do
+routelines=`route -n | grep '^[1-9]'`
+for (( i=1 ; $i = `echo $routelines | wc -l` ; i++ )) do
+route=`echo $routelines | head -n $i | tail -n 1`
 IFACE=$( echo $route | { read X X X X X X X Y ; echo $Y ; } )
-if echo $INTERNAL | grep -q $IFACE; then
+if `echo $INTERNAL | grep -q $IFACE -` ; then
 # $IFACE is in $INTERNAL
 NDEST=$( echo $route | { read Y X X X X X X X ; echo $Y ; } )
 NMASK=$( echo $route | { read X X Y X X X X X ; echo $Y ; } )
--

Otherwise, I have the same typos for files I31routes.rul, M71masq.rul
and O31routes.rul as original bug submitter (not included).

Thanks for the works of both of you and best regards,
Frederic Lehobey

-- System Information:
Debian Release: 3.1
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: sparc (sparc64)
Kernel: Linux 2.6.8-2-sparc64
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)

Versions of packages ipmasq depends on:
ii  debconf   1.4.30.13  Debian configuration management sy
ii  ipchains  1.3.10-15  Network firewalling for Linux 2.2.
ii  iptables  1.2.11-10  Linux kernel 2.4+ iptables adminis

-- debconf information:
  ipmasq/ppp-turn-on:
* ipmasq/start: true
  ipmasq/move-ipmasq.rules: true
  ipmasq/external-rules-moved: true
* ipmasq/start-location: After network services have been started
  ipmasq/dpkg-conffiles:
* ipmasq/ppp-recompute: true
* ipmasq/ppp-turn-off:
  ipmasq/old-ipmasq.conf: true
  ipmasq/old-rc.boot-file: true


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]