]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
powerOps: fix handling non-ascii power scripts on Ubuntu/Suse
authorVMware, Inc <>
Wed, 26 Jan 2011 02:05:25 +0000 (18:05 -0800)
committerMarcelo Vanzin <mvanzin@vmware.com>
Wed, 26 Jan 2011 02:05:25 +0000 (18:05 -0800)
If conversion of script name to current locale fails try using
original string (which should be UTF-8) and hope that shell
will understand it.

Note that conversions to system locale succeed on Fedora and RHEL
(which set G_BROKEN_FILENAMES=1) and fail on Open SUSE and Ubuntu
which expect everything to be pure UTF-8. Also Ubuntu is quite
funky because when I switched system language to Russian LANG in
terminals still was set as en_US.UTF-8; /etc/default/locale has
to be edited manually.

Signed-off-by: Marcelo Vanzin <mvanzin@vmware.com>
open-vm-tools/services/plugins/powerOps/powerOps.c

index 24704fb4c78a3f809263289eb0c50482ffb9ad29..735a3ac0edaf53ec11995523a8f9206ba3fc5834 100644 (file)
@@ -351,7 +351,12 @@ PowerOpsRunScript(PowerOpState *state,
 
    argv[0] = g_locale_from_utf8(script, -1, NULL, NULL, &err);
    if (err != NULL) {
-      g_error("Conversion error: %s\n", err->message);
+      g_debug("Conversion error: %s\n", err->message);
+      /*
+       * If we could not convert to current locate let's hope that
+       * what we have is a useable script name and use it directly.
+       */
+      argv[0] = g_strdup(script);
    }
    argv[1] = NULL;