aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEugeni Dodonov <eugeni@mandriva.org>2009-06-25 19:32:21 +0000
committerEugeni Dodonov <eugeni@mandriva.org>2009-06-25 19:32:21 +0000
commite0fb064bf52c9e18009573e900beb93b478fb2bb (patch)
tree648308120b9447f3794f385cd517ea7ced8e65ac
parent5f0f9cd16248a75d0a2e1fc52b8f8625fbbbff6a (diff)
downloadmsec-e0fb064bf52c9e18009573e900beb93b478fb2bb.tar
msec-e0fb064bf52c9e18009573e900beb93b478fb2bb.tar.gz
msec-e0fb064bf52c9e18009573e900beb93b478fb2bb.tar.bz2
msec-e0fb064bf52c9e18009573e900beb93b478fb2bb.tar.xz
msec-e0fb064bf52c9e18009573e900beb93b478fb2bb.zip
Correctly handling unicode messages (#50869).
-rw-r--r--src/msec/config.py3
-rwxr-xr-xsrc/msec/help_draksec.py6
-rwxr-xr-xsrc/msec/libmsec.py16
-rwxr-xr-xsrc/msec/msec.py3
-rwxr-xr-xsrc/msec/msecperms.py3
-rw-r--r--src/msec/plugins/pam.py3
6 files changed, 20 insertions, 14 deletions
diff --git a/src/msec/config.py b/src/msec/config.py
index 8342fa5..5646fb7 100644
--- a/src/msec/config.py
+++ b/src/msec/config.py
@@ -36,8 +36,7 @@ SECURITYLOG = '/var/log/msec.log'
# localization
try:
- cat = gettext.Catalog('msec')
- _ = cat.gettext
+ gettext.install('msec')
except IOError:
_ = str
diff --git a/src/msec/help_draksec.py b/src/msec/help_draksec.py
index 335ce77..1497fc6 100755
--- a/src/msec/help_draksec.py
+++ b/src/msec/help_draksec.py
@@ -31,8 +31,7 @@ import gettext
# localization
try:
- cat = gettext.Catalog('msec')
- _ = cat.gettext
+ gettext.install('msec')
except IOError:
_ = str
@@ -54,8 +53,7 @@ import gettext
# localization
try:
- cat = gettext.Catalog('msec')
- _ = cat.gettext
+ gettext.install('msec')
except IOError:
_ = str
diff --git a/src/msec/libmsec.py b/src/msec/libmsec.py
index d3f8d6e..4f520ae 100755
--- a/src/msec/libmsec.py
+++ b/src/msec/libmsec.py
@@ -56,8 +56,7 @@ import config
# localization
try:
- cat = gettext.Catalog('msec')
- _ = cat.gettext
+ gettext.install('msec')
except IOError:
_ = str
@@ -218,11 +217,20 @@ class Log:
self.logger.setLevel(log_level)
+ def trydecode(self, message):
+ """Attempts to decode a unicode message"""
+ try:
+ msg = message.decode('UTF-*')
+ except:
+ msg = message
+ return msg
+
def info(self, message):
"""Informative message (normal msec operation)"""
if self.quiet:
# skip informative messages in quiet mode
return
+ message = self.trydecode(message)
if self.buffer:
self.buffer["info"].append(message)
else:
@@ -230,6 +238,7 @@ class Log:
def error(self, message):
"""Error message (security has changed: authentication, passwords, etc)"""
+ message = self.trydecode(message)
if self.buffer:
self.buffer["error"].append(message)
else:
@@ -237,6 +246,7 @@ class Log:
def debug(self, message):
"""Debugging message"""
+ message = self.trydecode(message)
if self.buffer:
self.buffer["debug"].append(message)
else:
@@ -244,6 +254,7 @@ class Log:
def critical(self, message):
"""Critical message (big security risk, e.g., rootkit, etc)"""
+ message = self.trydecode(message)
if self.buffer:
self.buffer["critical"].append(message)
else:
@@ -254,6 +265,7 @@ class Log:
if self.quiet:
# skip warning messages in quiet mode
return
+ message = self.trydecode(message)
if self.buffer:
self.buffer["warn"].append(message)
else:
diff --git a/src/msec/msec.py b/src/msec/msec.py
index 0e8e5ce..9908db7 100755
--- a/src/msec/msec.py
+++ b/src/msec/msec.py
@@ -28,8 +28,7 @@ import logging
# localization
try:
- cat = gettext.Catalog('msec')
- _ = cat.gettext
+ gettext.install('msec')
except IOError:
_ = str
diff --git a/src/msec/msecperms.py b/src/msec/msecperms.py
index 5a948e2..328f804 100755
--- a/src/msec/msecperms.py
+++ b/src/msec/msecperms.py
@@ -18,8 +18,7 @@ import getopt
import gettext
try:
- cat = gettext.Catalog('msec')
- _ = cat.gettext
+ gettext.install('msec')
except IOError:
_ = str
diff --git a/src/msec/plugins/pam.py b/src/msec/plugins/pam.py
index 56eda83..bb04eff 100644
--- a/src/msec/plugins/pam.py
+++ b/src/msec/plugins/pam.py
@@ -14,8 +14,7 @@ import config
# localization
try:
- cat = gettext.Catalog('msec')
- _ = cat.gettext
+ gettext.install('msec')
except IOError:
_ = str