Ticket #1028 (closed enhancement: fixed)
Add support to LANG=es_ES in the chkconfig plugin
Reported by: | https://www.google.com/accounts/o8/id?id=AItOawlJa6QJcUnwqaUiOAgop4U4wANp_y0hDu4 | Owned by: | solj |
---|---|---|---|
Priority: | major | Milestone: | Bcfg2 1.2.0 Release |
Component: | bcfg2-client | Version: | 1.0 |
Keywords: | Cc: | [email protected]… |
Description
If I run the chkconfig command in a es_ES locale environment the status output is different from what the plugin wants and the service checks always fail:
ec4:~# chkconfig --list NetworkManager 0:desactivado 1:desactivado 2:desactivado 3:desactivado 4:desactivado 5:desactivado 6:desactivado acpid 0:desactivado 1:desactivado 2:activo 3:activo 4:activo 5:activo 6:desactivado
"on" == "activo" "off" == "desactivado"
Perhaps a solution could be unsetting the LANG environment variable before the chkconfig execution.
Attachments
Change History
comment:1 Changed 12 years ago by solj
- Cc [email protected]… added
- Owner changed from desai to solj
- Status changed from new to accepted
comment:2 Changed 12 years ago by https://www.google.com/accounts/o8/id?id=AItOawlJa6QJcUnwqaUiOAgop4U4wANp_y0hDu4
Yes, it's works.
Although I'm not sure what is best, unset the variable or set it to LANG=C. I think that is safer to set it to C instead of unsetting it (that is what I said at the beginning, sorry).
In http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap08.html#tag_08_02 this document I read the following: "If the LANG environment variable is not set or is set to the empty string, the implementation-defined default locale shall be used". So I suppose is better to set some value to LANG.
comment:3 Changed 12 years ago by solj
try #2
diff --git a/src/lib/Client/Tools/Chkconfig.py b/src/lib/Client/Tools/Chkconfig.py index 7bf176f..12d1a34 100644 --- a/src/lib/Client/Tools/Chkconfig.py +++ b/src/lib/Client/Tools/Chkconfig.py @@ -4,6 +4,8 @@ """This is chkconfig support.""" __revision__ = '$Revision$' +import os + import Bcfg2.Client.Tools import Bcfg2.Client.XML @@ -14,6 +16,7 @@ class Chkconfig(Bcfg2.Client.Tools.SvcTool): __execs__ = ['/sbin/chkconfig'] __handles__ = [('Service', 'chkconfig')] __req__ = {'Service': ['name', 'status']} + os.environ['LANG'] = 'C' def get_svc_command(self, service, action): return "/sbin/service %s %s" % (service.get('name'), action)
comment:4 Changed 12 years ago by https://www.google.com/accounts/o8/id?id=AItOawlJa6QJcUnwqaUiOAgop4U4wANp_y0hDu4
Yes, it works too.
comment:5 Changed 12 years ago by solj
- Status changed from accepted to closed
- Resolution set to fixed
Fixed in 063aa802aa50d2a1d9ab7c4c5bb0454db9dc41ed.
That's an interesting idea. So, does this work for you?