[Bug 864193] New: ntp-wait does not return / is useless / does not match description of associated ntpq
https://bugzilla.novell.com/show_bug.cgi?id=864193 https://bugzilla.novell.com/show_bug.cgi?id=864193#c0 Summary: ntp-wait does not return / is useless / does not match description of associated ntpq Classification: openSUSE Product: openSUSE 13.1 Version: Final Platform: All OS/Version: openSUSE 13.1 Status: NEW Severity: Normal Priority: P5 - None Component: Network AssignedTo: bnc-team-screening@forge.provo.novell.com ReportedBy: robert@rosaschulz.de QAContact: qa-bugs@suse.de Found By: --- Blocker: --- User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:27.0) Gecko/20100101 Firefox/27.0 openid ntp-wait is a perl-prog parsing output of ntpq. The current version of ntp-wait obvoiusly fails to parse the changed output of the corresponding ntpq program thus hangs forever. I Reproducible: Always Steps to Reproduce: 1. startntp demon 2. (optional) wait for ntp synced message in /var/log/messages 3. call /usr/sbin/ntp-wait Actual Results: hangs forever Expected Results: retunrs after ntp synched time successfully / returns immediately i paste a corrected /usr/sbin/ntp-wait script here with changed call to ntpq and adapted output parsing. worked for me. Also this version does more safely check whether the ntpq result is in an expected range ========== corrected /usr/sbin/ntp-wait script ========== #! /usr/bin/perl -w die "perl5 needed\n" unless ($] > 5); use Getopt::Std; $opt_h = 0; # Print help message $opt_f = 0; # 'Hard' failure if 'state' is unknown $opt_n = 1000; # How many tries before we give up? (10 min+) $opt_s = 6; # Seconds to sleep between tries (6s = 10/min) $opt_v = 0; # Be verbose? getopts('hfn:s:v'); $cmd = 'ntpq -c "rv"'; $| = 1; # Autoflush output. if( $opt_h ) { print "\nUsage: ntp-wait [ options ]\n\n". " -h Print this message\n". " -f 'Hard' failure if 'state' is unknown\n". " -n How many tries before we give up? Default 1000 (ca 10 min)\n". " -s Seconds to sleep between tries. Default 6.\n". " -v Be verbose\n\n"; exit 0; } print "Waiting for ntpd to synchronize... " if ($opt_v); for ($i = 0; $i < $opt_n; ++$i) { open(Q, $cmd." 2>&1 |") || die "Can't start ntpq: $!"; while(<Q>) { # second of 4 digits will be 0 if "not yet synchronized", so [1-9] if synchronized # Ref: http://www.eecis.udel.edu/~mills/ntp/html/decode.html#sys if (/\bstatus=[0-9][1-9][0-9][0-9]\b/) { print "\bOK!\n" if ($opt_v); exit 0; } if (/request variable was unknown/) { print "\bCan't tell!\nPerhaps you are running an old version of ntpd.\n" if ($opt_v); exit $opt_f; } if (/Connection refused/) { print "\bntpd is not running!\n" if ($opt_v); exit 1; } if ( ! /\bstatus=[0-9]0[0-9][0-9]\b/) { print "\bntpd output unexpected!\n" if ($opt_v); exit 1; } } close(Q); print "\b".substr("*+:.", $i % 4, 1) if ($opt_v); sleep($opt_s); } print "\bNo!\nntpd did not synchronize.\n" if ($opt_v); exit 1; ========== -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=864193
https://bugzilla.novell.com/show_bug.cgi?id=864193#c
zhang jiajun
https://bugzilla.novell.com/show_bug.cgi?id=864193
https://bugzilla.novell.com/show_bug.cgi?id=864193#c1
Dr. Werner Fink
https://bugzilla.novell.com/show_bug.cgi?id=864193
https://bugzilla.novell.com/show_bug.cgi?id=864193#c2
--- Comment #2 from Dr. Werner Fink
https://bugzilla.novell.com/show_bug.cgi?id=864193
https://bugzilla.novell.com/show_bug.cgi?id=864193#c3
Dr. Werner Fink
https://bugzilla.novell.com/show_bug.cgi?id=864193
https://bugzilla.novell.com/show_bug.cgi?id=864193#c4
--- Comment #4 from Bernhard Wiedemann
http://bugzilla.novell.com/show_bug.cgi?id=864193
http://bugzilla.novell.com/show_bug.cgi?id=864193#c7
Reinhard Max
participants (1)
-
bugzilla_noreply@novell.com