Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.

Bug 78651

Summary: Error in /etc/ntp.conf leads to run-time error in redhat-config-date
Product: [Retired] Red Hat Linux Reporter: Mark Harig <mharig>
Component: redhat-config-dateAssignee: Brent Fox <bfox>
Status: CLOSED RAWHIDE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 8.0CC: jgkneuer
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2002-12-13 16:37:49 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Mark Harig 2002-11-27 00:57:23 UTC
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 16:37:49 UTC
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 16:20:36 UTC
*** Bug 88642 has been marked as a duplicate of this bug. ***