aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEugeni Dodonov <eugeni@mandriva.org>2009-06-30 11:22:48 +0000
committerEugeni Dodonov <eugeni@mandriva.org>2009-06-30 11:22:48 +0000
commitede53d74fee082930fe052950e32980c902f1fa1 (patch)
tree2ac126ad5d67b11b18614f664bb5d6163db593a1 /src
parent7e763b1685703cbb13d0d1f8d0cfa32fffa4436e (diff)
downloadmsec-ede53d74fee082930fe052950e32980c902f1fa1.tar
msec-ede53d74fee082930fe052950e32980c902f1fa1.tar.gz
msec-ede53d74fee082930fe052950e32980c902f1fa1.tar.bz2
msec-ede53d74fee082930fe052950e32980c902f1fa1.tar.xz
msec-ede53d74fee082930fe052950e32980c902f1fa1.zip
Correctly handling unicode messages (#50869).
Diffstat (limited to 'src')
-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 37880e7..74e4d08 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 9cd384a..56045be 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 b897d0b..7e9b5df 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