Red Hat Bugzilla – Bug 74857
Bad parsing of chkconfig output in servicemethods.py
Last modified: 2007-04-18 12:46:59 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):
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.
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")
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.
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.
Sorry for being ignorant, but why is the status left as MODIFIED if it is fixed?
Is there something I need to do?