Bugzilla will be upgraded to version 5.0. The upgrade date is tentatively scheduled for 2 December 2018, pending final testing and feedback.
Bug 74857 - Bad parsing of chkconfig output in servicemethods.py
Bad parsing of chkconfig output in servicemethods.py
Product: Red Hat Linux
Classification: Retired
Component: redhat-config-services (Show other bugs)
All Linux
medium Severity medium
: ---
: ---
Assigned To: Daniel Walsh
Depends On:
  Show dependency treegraph
Reported: 2002-10-02 06:54 EDT by Eli Barzilay
Modified: 2007-04-18 12:46 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2003-08-01 15:43:21 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Eli Barzilay 2002-10-02 06:54:07 EDT
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:

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 11:03:25 EDT
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 13:04:56 EDT
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.