Bug 74857 - Bad parsing of chkconfig output in servicemethods.py
Summary: Bad parsing of chkconfig output in servicemethods.py
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: redhat-config-services
Version: 8.0
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Daniel Walsh
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2002-10-02 10:54 UTC by Eli Barzilay
Modified: 2007-04-18 16:46 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2003-08-01 19:43:21 UTC
Embargoed:


Attachments (Terms of Use)

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?



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