Patch for locale problems (Turkish locale)

Discussions about Linux installation and configuration on Samsung laptops
Post Reply
keremhd
Newbie
Newbie
Posts: 1
Joined: 24 Dec 2012, 23:36

Patch for locale problems (Turkish locale)

Post by keremhd »

Hi,
Installed samsung tools on ubuntu 12.10, utf8 turkish laptop.

I had crashes both with system service and session service when the system locale was turkish, and when I change my system locale to english utf8, everything was ok.

I could trace the problem to reading of config files, the library that python provides changes keynames to lowercase. When reading config items, it fails to convert "BACKLIGHT_HOTKEY" text to lowercase resulting in "backlIght_hotkey" instead of "backlight_hotkey", and this causes problems. (In turkish, lowercase of I is a special unicode character, and uppercase of i is a special unicode character. In the code the strings used for keys are not unicode but ascii, so python lowercase method doesn't know how to represent those characters in ascii strings, and leaves them intact).

You can test the faulty behavior by setting system locale to utf8 turkish:

Code: Select all

# cat /etc/default/locale 
LANG="tr_TR.UTF-8"
You may need to have turkish utf8 locale support installed first. When the desktop starts, the session and system services would crash in a few minutes.


I fixed the problem by making both the session service and system service run in POSIX locale. Actually, the session/system services themselves do not set or use locale, and while it is not set, python lets them run in POSIX. Then, when the DBUS libraries are included, it sets the process locale according to environment variables, and this changes behavior of string.lower(), and this causes the mentioned problems.

/usr/lib/samsung-tools/session-service.py:

Code: Select all

if __name__ == '__main__':
        # UPDATED
        if os.getenv('LC_ALL') != 'POSIX':
                os.putenv('LC_ALL', 'POSIX')
                os.execvp(sys.argv[0], sys.argv)
        # UPDATED

        dbus.mainloop.glib.DBusGMainLoop(set_as_default = True)
/usr/lib/samsung-tools/system-service.py:

Code: Select all

if __name__ == '__main__':
        # UPDATED
        if os.getenv('LC_ALL') != 'POSIX':
                os.putenv('LC_ALL', 'POSIX')
                os.execvp(sys.argv[0], sys.argv)
        # UPDATED

        dbus.mainloop.glib.DBusGMainLoop(set_as_default = True)
What the patch does is; it checks if LC_ALL is set as POSIX, and if it's not, it sets it and replaces current process with a new instance, with all arguments intact. Thus, session and system services are always forced to run in POSIX locale.
User avatar
voria
Administrator
Administrator
Posts: 1383
Joined: 12 Feb 2009, 18:08
Location: Italy
Contact:

Re: Patch for locale problems (Turkish locale)

Post by voria »

The locale problem is fixed in Samsung Tools 2.2 ;)
Image
Please consider a little donation to keep the 'Linux On My Samsung' project up and running. Thank you!
Post Reply