[rancid] "upgrade" to 3.1 breaks par?

heasley heas at shrubbery.net
Fri Sep 26 16:50:36 UTC 2014


Thu, Sep 25, 2014 at 11:07:07AM -0400, Dan Anderson:
> It's a Raspberry Pi running Raspian. I can get you access to the box if
> you'd like it.

This patch fixes the issue.  Thanks for the help, Dan.

Index: bin/hpuifilter.c
===================================================================
--- bin/hpuifilter.c	(revision 2872)
+++ bin/hpuifilter.c	(working copy)
@@ -109,6 +109,8 @@
 #include <termios.h>
 #if HAVE_UTIL_H
 # include <util.h>
+#elif HAVE_LIBUTIL_H
+# include <libutil.h>
 #endif
 
 #define	BUFSZ	(LINE_MAX * 2)
@@ -141,13 +143,13 @@
 {
     extern char		*optarg;
     extern int		optind;
-    char		ch,
-			hbuf[BUFSZ],		/* hlogin buffer */
+    char		hbuf[BUFSZ],		/* hlogin buffer */
 			ptyname[FILENAME_MAX + 1],
 			tbuf[BUFSZ],		/* telnet/ssh buffer */
 			tbufstr[5] = {ESC, '\x07', '\r', '\n', '\0'};
     int			bytes,			/* bytes read/written */
 			devnull,
+			i,
 			rval = EX_OK,
 			ptym,			/* master pty */
 			ptys;			/* slave pty */
@@ -167,8 +169,8 @@
     if (strrchr(progname, '.') != NULL)
 	*(strrchr(progname, '.')) = '\0';
 
-    while ((ch = getopt(argc, argv, "dhvt:")) != -1 )
-	switch (ch) {
+    while ((i = getopt(argc, argv, "dhvt:")) != -1 )
+	switch (i) {
 	case 'd':
 	    debug++;
 	    break;
Index: bin/par.c
===================================================================
--- bin/par.c	(revision 2872)
+++ bin/par.c	(working copy)
@@ -138,7 +138,6 @@
 {
     extern char		*optarg;
     extern int		optind;
-    char		ch;
     time_t		t;
     int			i,
 			line;
@@ -167,8 +166,8 @@
     } else
 	errfp = stderr;
 
-    while ((ch = getopt(argc, argv, "defhiqxvc:e:l:n:p:")) != -1 )
-	switch (ch) {
+    while ((i = getopt(argc, argv, "defhiqxvc:e:l:n:p:")) != -1 )
+	switch (i) {
 	case 'c':	/* command to run */
 	    c_opt = optarg;
 	    break;
@@ -912,7 +911,7 @@
 
     /* first line might be a command */
     if (*line == 1) {
-	switch ((buf[0] = fgetc(*F))) {
+	switch ((e = fgetc(*F))) {
 	case EOF:
 	    goto ERR;
 	    break;
@@ -933,7 +932,7 @@
 	    }
 	    break;
 	default:
-	    ungetc(buf[0], *F);
+	    ungetc(e, *F);
 	    if (*cmd == NULL && c_opt != NULL)
 		if ((e = line_split(c_opt, cmd))) {
 			/* XXX: is strerror(e) right? */
Index: bin/clogin.in
===================================================================
--- bin/clogin.in	(revision 2872)
+++ bin/clogin.in	(working copy)
@@ -656,7 +656,7 @@
     for {set i 0} {$i < $num_commands} { incr i} {
 	send -- "[subst -nocommands [lindex $commands $i]]\r"
 	expect {
-	    -re "\b+"				{ exp_continue }
+	    -re "^\b+"				{ exp_continue }
 	    -re "^\[^\n\r *]*$reprompt"		{ send_user -- "$expect_out(buffer)"
 						}
 	    -re "^\[^\n\r]*$reprompt."		{ send_user -- "$expect_out(buffer)"
Index: bin/fnlogin.in
===================================================================
--- bin/fnlogin.in	(revision 2872)
+++ bin/fnlogin.in	(working copy)
@@ -455,6 +455,10 @@
     expect -re $prompt; send -- "end\r"
     expect -re $prompt;
 
+# see http://www.shrubbery.net/pipermail/rancid-discuss/2011-July/005787.html
+    # this is the only way i see to get rid of more prompts in o/p..grrrrr
+    log_user 0
+
     set sep "\\1\u001"
     regsub -all {([^\\])\;} $command "$sep" esccommand
     set sep "\u001"
@@ -466,10 +470,12 @@
             -re "$prompt"			{ send "\r"
 						  sleep 0.5
 						}
-	    -gl "--More--"			{ send " "
+	    -gl "--More--\[^\n\r]*"		{ send " "
 						  exp_continue
-	    -re "\[\n\r]+"			{ exp_continue }
 						}
+	    -re "\[^\r\n]*\[\n\r]+"             { send_user -- "$expect_out(buffer)"
+						  exp_continue
+						}
 	}
      }
      expect {
@@ -586,8 +592,12 @@
 	}
     } elseif { $do_script } {
 	# Disable output paging.
+	send "config global\r"
+	expect -re $prompt	{}
 	send "config system console\r"
+	expect -re $prompt	{}
 	send "set output standard\r"
+	expect -re $prompt	{}
 	send "end\r"
 	expect -re $prompt	{}
 	source $sfile
Index: bin/hlogin.in
===================================================================
--- bin/hlogin.in	(revision 2872)
+++ bin/hlogin.in	(working copy)
@@ -565,6 +565,8 @@
 					  }
 					  exp_continue
 					}
+	    -re "^More: \[^\n\r]* line:" { catch {send " "}
+					  exp_continue }
 	    -re "^<-+ More -+>\[^\n\r]*" { catch {send " "}
 					  exp_continue }
 	    -re "^-+ MORE -+\[^\n\r]*"	{ catch {send " "}
Index: bin/jlogin.in
===================================================================
--- bin/jlogin.in	(revision 2872)
+++ bin/jlogin.in	(working copy)
@@ -301,6 +301,7 @@
 		send_user "\nError: telnet failed: $reason\n"
 		return 1
 	    }
+stty cols 132
 	} elseif ![string compare $prog "ssh"] {
 	    # ssh to the router & try to login with or without an identfile.
 	    # We use two calls to spawn since spawn does not seem to parse
@@ -318,6 +319,7 @@
 		send_user "\nError: $sshcmd failed: $reason\n"
 		return 1
 	    }
+stty cols 132
 	} elseif ![string compare $prog "rsh"] {
 	    send_error "\nError: unsupported method: rsh\n"
 	    if { $progs == 0 } {
Index: bin/nxrancid.in
===================================================================
--- bin/nxrancid.in	(revision 2872)
+++ bin/nxrancid.in	(working copy)
@@ -313,7 +313,17 @@
 
 	s/ +$//;	# Drop trailing ' '
 	next if (/Fan Zone Speed:/);
-	next if (/INTAKE/);
+	if (/(control temperature|monitor temperature)/i) {
+	    ProcessHistory("COMMENTS","","","!Env: $_");
+	    while (<INPUT>) {
+		if (/(.*\s+\d+\s+\d+\s+)(\d+)(.*$)/) {
+		    $_ = sprintf("%s%-". length($2)."s%s\n", $1, "", $3);
+		}
+		ProcessHistory("COMMENTS","","","!Env: $_");
+		last if (/^\s*$/);
+	    }
+	    next;
+	}
 	ProcessHistory("COMMENTS","","","!Env: $_");
     }
     ProcessHistory("COMMENTS","","","!\n");
@@ -334,6 +344,7 @@
 	return(-1) if (/\% Permission denied/);
 	return(-1) if (/command authorization failed/i);
 
+	s/ +$//;	# Drop trailing ' '
 # Cut out CurTemp - drop the 2nd to last field.
 #--------------------------------------------------------------------
 #Module   Sensor        MajorThresh   MinorThres   CurTemp     Status
@@ -340,10 +351,21 @@
 #                       (Celsius)     (Celsius)    (Celsius)         
 #5        Outlet1 (s1)    125             125         33         Ok
 #5        QEng1Sn1(s10)   115             105         39         Ok
-	s/^(.+\s)(\S+\s+)(\S+\s*)$/$1$3/;
-
-	s/ +$//;	# Drop trailing ' '
-	ProcessHistory("COMMENTS","","","!Env: $_");
+	if (/(control temperature|monitor temperature)/i) {
+	    ProcessHistory("COMMENTS","","","!Env: $_");
+	    while (<INPUT>) {
+		if (/(.*\s+\d+\s+\d+\s+)(\d+)(.*$)/) {
+		    $_ = sprintf("%s%-". length($2)."s%s\n", $1, "", $3);
+		}
+		ProcessHistory("COMMENTS","","","!Env: $_");
+		last if (/^\s*$/);
+	    }
+	    next;
+	} else {
+	    s/^(.+\s)(\S+\s+)(\S+\s*)$/$1$3/;
+	    s/ +$//;	# Drop trailing ' '
+	    ProcessHistory("COMMENTS","","","!Env: $_");
+	}
     }
     ProcessHistory("COMMENTS","","","!\n");
     return(0);



More information about the Rancid-discuss mailing list