[rancid] clogin commenting script commands following multiple blanks lines

heasley heas at shrubbery.net
Wed Oct 24 17:28:39 UTC 2018


Sat, Sep 29, 2018 at 03:19:00PM -0700, Erik Muller:
> So here's an odd thing I just ran across.  Running clogin with a script with multiple blank lines has some very unexpected behaviour.  It looks like it's turning \n\n into \n;, with the net effect of commenting out any command that follows two blank lines.  Reproducible on ubuntu 12.04 and OSX 10.13 with stock 3.8 source.  Works as expected in 2.3.8 ubuntu packages.
> 
> The culprit is definitely in the "# handle escaped ;s in commands, and ;; and ^;" section of clogin (rolling that block back to what was in 2.3.8 fixes it), but trying to grok that in expect language to provide a real fix makes my head hurt, so I'll leave this as a bug report.  Examples below.
> 
> thanks,
> -e

I believe that patch addresses this bug.

Index: bin/clogin.in
===================================================================
--- bin/clogin.in	(revision 3909)
+++ bin/clogin.in	(working copy)
@@ -76,12 +76,12 @@
 	    }
 
 	    # handle escaped ;s in commands, and ;; and ^;
-	    regsub -all {([^\\]);;} $command "\\1;\u002;" esccommand
-	    regsub {^;} $esccommand "\u002;" command
-	    set sep "\\1\u001"
-	    regsub -all {([^\\])\;} $command "$sep" esccommand
-	    set sep "\u001"
-	    set commands [split $esccommand $sep]
+	    regsub -all {([^\\]);} $command "\\1\u002;" esccommand
+	    regsub -all {([^\\]);;} $esccommand "\\1;\u002;" command
+	    regsub {^;} $command "\u002;" esccommand
+	    regsub -all {[\\];} $esccommand ";" command
+	    set sep "\u002;"
+	    set commands [split $command $sep]
 	    set num_commands [llength $commands]
 	    set rshfail 0
 	    for {set i 0} {$i < $num_commands && !$rshfail} { incr i} {
@@ -373,12 +373,12 @@
     log_user 0
 
     # handle escaped ;s in commands, and ;; and ^;
-    regsub -all {([^\\]);;} $command "\\1;\u002;" esccommand
-    regsub {^;} $esccommand "\u002;" command
-    set sep "\\1\u001"
-    regsub -all {([^\\])\;} $command "$sep" esccommand
-    set sep "\u001"
-    set commands [split $esccommand $sep]
+    regsub -all {([^\\]);} $command "\\1\u002;" esccommand
+    regsub -all {([^\\]);;} $esccommand "\\1;\u002;" command
+    regsub {^;} $command "\u002;" esccommand
+    regsub -all {[\\];} $esccommand ";" command
+    set sep "\u002;"
+    set commands [split $command $sep]
     set num_commands [llength $commands]
     # the pager can not be turned off on the PIX, so we have to look
     # for the "More" prompt.  the extreme is equally obnoxious in pre-12.3 XOS,



More information about the Rancid-discuss mailing list