Bug 74857

Summary: Bad parsing of chkconfig output in servicemethods.py
Product: [Retired] Red Hat Linux Reporter: Eli Barzilay <eli>
Component: redhat-config-servicesAssignee: Daniel Walsh <dwalsh>
Status: CLOSED CURRENTRELEASE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 8.0   
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: 2003-08-01 19:43:21 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Eli Barzilay 2002-10-02 10:54:07 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.1) Gecko/20020830

Description of problem:
I have added my own "service script" but it didn't appear in the
GUI service configuration.  Following the problem, I got to
servicemethods.py -- it looks like the output from "chkconfig --list"
is unreliable: if there is a long enough name (I have 16 characters),
then in the output the name is followed by a tab, and the "parsing"
done by the Python code fails to recognize it as a service.

More info below.


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


How reproducible:
Always

Steps to Reproduce:
1. create a service with a 16 character file name
2. do chkconfig --add on the new service
3. run the service configuration tool

	

Actual Results:  The new service is missing from the GUI.


Expected Results:  No reason for it not to appear.


Additional info:

Tracing the program, I was quite horrifid by the fact that it is
very inefficient.  Some obvious places to improve are:
1. Use the "chkconfig --list" output to identify xinetd services,
   there is little point in running a process for each one.

The later parsing could use some major rewrite:
2. Splitting a string by a " " creates lots of empty strings, for
   example, try re.split(" ","x    y").  A much better regexp would
   by " +", or even better -- just take tabs on the way with
   "[ \t]+".  Even better -- use the \s and \S patterns.
3. There are several passes on the list which could really be just
   one, this saves a lot of time allocating temporary results.

The bottom line -- here is a much shorter, much faster, and much more
elegant code that gets you *all* services at one shot:

  chkconfig_list = getstatusoutput("LANG=C /sbin/chkconfig --list")[1]
  chkconfig_list = re.split('\n', chkconfig_list)
  chkconfig_list = [re.sub(r"^\s*(\S+?):?\s.*", "\\1", f) for f in chkconfig_list]

I hope that this code is clear enough to be useful.

Comment 1 Daniel Walsh 2002-10-02 15:03:25 UTC
This is fixed in redhat-config-services-0.8.3-1

I went through and changed to code to only exec chkconfig --list once.  It is a
lot faster.  This package will be in Raw Hide fairly soon.


Comment 2 Eli Barzilay 2002-10-13 17:04:56 UTC
Sorry for being ignorant, but why is the status left as MODIFIED if it is fixed?
Is there something I need to do?