Skip to contentSkip to conversation

policycoreutils: audit2* - ignore setlocale errors

PATCH Applied Petr Lautrbach 2 participants 2 messages Aug 25, 2015 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 policycoreutils: audit2* - ignore setlocale errors

When a user has invalid locales set, audit2allow and audit2why fail with a traceback. This could be safely ignored as it will stay with 'C' locale.

Fixes:
Traceback (most recent call last):
File "policycoreutils/audit2allow/audit2allow", line 35, in <module>
locale.setlocale(locale.LC_ALL, '')
File "/usr/lib64/python2.7/locale.py", line 579, in setlocale
return _setlocale(category, locale)
locale.Error: unsupported locale setting

---
 policycoreutils/audit2allow/audit2allow | 5 ++++-
 policycoreutils/audit2allow/audit2why   | 5 ++++-
 2 files changed, 8 insertions(+), 2 deletions(-)
policycoreutils/audit2allow/audit2allow +4 -1
index 6bbab40..e23e418 100644
@@ -32,7 +32,10 @@ import sepolgen.module as module
 from sepolgen.sepolgeni18n import _
 import selinux.audit2why as audit2why
 import locale
-locale.setlocale(locale.LC_ALL, '')
+try:
+    locale.setlocale(locale.LC_ALL, '')
+except:
+    pass
 
 
 class AuditToPolicy:
policycoreutils/audit2allow/audit2why +4 -1
index 3909b97..b1489ed 100644
@@ -32,7 +32,10 @@ import sepolgen.module as module
 from sepolgen.sepolgeni18n import _
 import selinux.audit2why as audit2why
 import locale
-locale.setlocale(locale.LC_ALL, '')
+try:
+    locale.setlocale(locale.LC_ALL, '')
+except:
+    pass
 
 
 class AuditToPolicy:
Signature · 1 line
2.5.0
#1 lore raw
Quoted 12 lines · Petr Lautrbach

When a user has invalid locales set, audit2allow and audit2why fail with a traceback. This could be safely ignored as it will stay with 'C' locale.

Fixes:
Traceback (most recent call last):
File "policycoreutils/audit2allow/audit2allow", line 35, in <module>
locale.setlocale(locale.LC_ALL, '')
File "/usr/lib64/python2.7/locale.py", line 579, in setlocale
return _setlocale(category, locale)
locale.Error: unsupported locale setting

Quoted 1 line

Thanks, applied.

Quoted 38 lines
---
 policycoreutils/audit2allow/audit2allow | 5 ++++-
 policycoreutils/audit2allow/audit2why   | 5 ++++-
 2 files changed, 8 insertions(+), 2 deletions(-)
policycoreutils/audit2allow/audit2allow +4 -1
index 6bbab40..e23e418 100644
@@ -32,7 +32,10 @@ import sepolgen.module as module
 from sepolgen.sepolgeni18n import _
 import selinux.audit2why as audit2why
 import locale
-locale.setlocale(locale.LC_ALL, '')
+try:
+    locale.setlocale(locale.LC_ALL, '')
+except:
+    pass
 
 
 class AuditToPolicy:
policycoreutils/audit2allow/audit2why +4 -1
index 3909b97..b1489ed 100644
@@ -32,7 +32,10 @@ import sepolgen.module as module
 from sepolgen.sepolgeni18n import _
 import selinux.audit2why as audit2why
 import locale
-locale.setlocale(locale.LC_ALL, '')
+try:
+    locale.setlocale(locale.LC_ALL, '')
+except:
+    pass
 
 
 class AuditToPolicy: