Bug 78651 - Error in /etc/ntp.conf leads to run-time error in redhat-config-date
Error in /etc/ntp.conf leads to run-time error in redhat-config-date
Status: CLOSED RAWHIDE
Product: Red Hat Linux
Classification: Retired
Component: redhat-config-date (Show other bugs)
8.0
All Linux
medium Severity medium
: ---
: ---
Assigned To: Brent Fox
:
: 88642 (view as bug list)
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2002-11-26 19:57 EST by Mark Harig
Modified: 2008-05-01 11:38 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2002-12-13 11:37:49 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Mark Harig 2002-11-26 19:57:23 EST
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.1) Gecko/20021003

Description of problem:
If the user edits /etc/ntp.conf and deletes the text after the keyword
'server', then redhat-config-date either 1) fails silently (when invoked
via the main menu/GUI) or 2) fails with a run-time (Python) stack dump.

Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
1. Edit the default /etc/ntp.conf installed with ntp-4.1.1a-9.

2. Find the line with the text 'server  127.127.1.0  # local clock'

3. Delete the text after the keyword 'server', and then save the
   changes to the file.

4. Select the 'Date & Time' application from the 'System Settings' menu. 
Alternately, run 'redhat-config-date' from a shell prompt.
	

Actual Results:  When 'Date & Time' is run from the 'System Settings' menu, the
application fails to start and no error message is displayed.

When 'redhat-config-date' is run from a shell prompt, then the following Python
stack dump is displayed:

Traceback (most recent call last):
  File "/usr/share/redhat-config-date/redhat-config-date.py", line 35, in ?
    mainWindow.mainWindow().stand_alone()
  File "/usr/share/redhat-config-date/mainWindow.py", line 176, in __init__
    self.datePage = date_gui.datePage(self.dateBackend)
  File "/usr/share/redhat-config-date/date_gui.py", line 154, in __init__
    ntpServer = mainWindow.dateBackend.getNtpServer()
  File "/usr/share/redhat-config-date/dateBackend.py", line 184, in getNtpServer
   self.ntpServer = tokens[1]
IndexError: list index out of range


Expected Results:  Although this was clearly a user error -- the ntp.conf file
is invalid -- redhat-config-date should provide a useful error message.

Additional info:

The code in /usr/share/redhat-config-date/dateBackend.py, around line 184,
should likely be modified so that it does not assume that there is a second
token on any line that begins with the keyword 'server'.
Comment 1 Brent Fox 2002-12-13 11:37:49 EST
This bug was fixed on Nov 15, 2002.  The newest version in Rawhide should fix
this problem.  Thanks for your report.

Here's a cut-n-past of the cvs commit:

Update of /usr/local/CVS/redhat-config-date/src
In directory elvis.redhat.com:/tmp/cvs-serv27667

Modified Files:
        dateBackend.py 
Log Message:
handle empty server lines in ntp.conf

Index: dateBackend.py
===================================================================
RCS file: /usr/local/CVS/redhat-config-date/src/dateBackend.py,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- dateBackend.py      25 Oct 2002 15:27:40 -0000      1.20
+++ dateBackend.py      15 Nov 2002 20:19:09 -0000      1.21
@@ -198,10 +198,14 @@
                     tokens = string.split(line)
                     
                     if tokens[0][0] != "#" and tokens[0] == "server" and not
serverFound:
-                        self.ntpServer = tokens[1]
-                        serverFound = 1
+                        try:
+                            self.ntpServer = tokens[1]
+                            serverFound = 1
+                        except:
+                            #They have a server line in /etc/ntp.conf with no
server specified
+                            self.ntpServer = None
 
-            if self.ntpServer == "127.127.1.0":
+            if self.ntpServer == "127.127.1.0" or self.ntpServer == None:
                 return None
             else:
                 return self.ntpServer
Comment 2 Brent Fox 2003-04-14 12:20:36 EDT
*** Bug 88642 has been marked as a duplicate of this bug. ***

Note You need to log in before you can comment on or make changes to this bug.