]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Fix localization issue of vmware-vgauth-cmd
authorOliver Kurth <okurth@vmware.com>
Wed, 1 Apr 2020 18:31:35 +0000 (11:31 -0700)
committerOliver Kurth <okurth@vmware.com>
Wed, 1 Apr 2020 18:31:35 +0000 (11:31 -0700)
1. default msg catalog folder is wrong, add correct msgCatalog in
   vgauth.conf
2. rename vmsg file name to "VGAuthCli" since file name used in main
   is "VGAuthCli"
3. Move I18n init up to fix variable localization issue

open-vm-tools/vgauth/cli/Makefile.am
open-vm-tools/vgauth/cli/main.c
open-vm-tools/vgauth/service/Makefile.am
open-vm-tools/vgauth/service/vgauth.conf

index bea91390b8fd987d23c2346ce02e6da32878c51f..69bb10047da0b97eb1ef1021773477e678c9f788 100644 (file)
@@ -1,5 +1,5 @@
 ################################################################################
-### Copyright (C) 2014-2016 VMware, Inc.  All rights reserved.
+### Copyright (C) 2014-2016, 2020 VMware, Inc.  All rights reserved.
 ###
 ### This program is free software; you can redistribute it and/or modify
 ### it under the terms of version 2 of the GNU General Public License as
@@ -47,5 +47,6 @@ else
 endif
 
 # Message catalogs.
+# rename file name to "VGAuthCli" which used in main
 install-data-hook:
-       @INSTVMSG@ vmware-vgauth-cmd $(srcdir)/l10n $(DESTDIR)$(datadir)
+       @INSTVMSG@ VGAuthCli $(srcdir)/l10n $(DESTDIR)$(datadir)
\ No newline at end of file
index 25fbde7f2a6c59d60ad10ba4fde1fd5967bc180f..7561699a60a777718259d84f9e60dd70293c5e72 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 2011-2019 VMware, Inc. All rights reserved.
+ * Copyright (C) 2011-2020 VMware, Inc. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as published
@@ -380,6 +380,44 @@ CliListMapped(VGAuthContext *ctx)
 }
 
 
+/*
+ ******************************************************************************
+ * InitMsgCatalog --                                                     */ /**
+ *
+ * Initialize language setting according to machine locale
+ *
+ ******************************************************************************
+ */
+
+static void
+InitMsgCatalog(void)
+{
+   PrefHandle prefs;
+   gchar *msgCatalog;
+
+   /*
+    * Do this first, so any noise from the locale setup is properly filtered.
+    */
+   VGAuth_SetLogHandler(CliLog, NULL, 0, NULL);
+
+   /*
+    * Find the location of the i18n catalogs.
+    */
+   setlocale(LC_ALL, "");
+   prefs = Pref_Init(VGAUTH_PREF_CONFIG_FILENAME);
+   msgCatalog = Pref_GetString(prefs,
+                               VGAUTH_PREF_LOCALIZATION_DIR,
+                               VGAUTH_PREF_GROUP_NAME_LOCALIZATION,
+                               VGAUTH_PREF_DEFAULT_LOCALIZATION_CATALOG);
+
+   I18n_BindTextDomain(VMW_TEXT_DOMAIN,    // domain -- base name of vmsg files
+                       NULL,               // locale -- let it figure it out
+                       msgCatalog);        // path to message catalogs
+   g_free(msgCatalog);
+   Pref_Shutdown(prefs);
+}
+
+
 /*
  ******************************************************************************
  * mainRun --                                                            */ /**
@@ -422,14 +460,14 @@ mainRun(int argc,
    const gchar *lSubject = SU_(cmdline.summary.subject, "subject");
    const gchar *lPEMfile = SU_(cmdline.summary.pemfile, "PEM-file");
    const gchar *lComm = SU_(cmdline.summary.comm, "comment");
+
 #if (use_glib_parser == 0)
    int i;
    GOptionEntry *cmdOptions;
 #else
    GError *gErr = NULL;
 #endif
-   PrefHandle prefs;
-   gchar *msgCatalog = NULL;
+
    GOptionEntry listOptions[] = {
       { "username", 'u', 0, G_OPTION_ARG_STRING, &userName,
          SU_(listoptions.username,
@@ -479,26 +517,6 @@ mainRun(int argc,
    argcCopy = argc;
    argvCopy = argv;
 
-   /*
-    * Do this first, so any noise form the locale setup is properly filtered.
-    */
-   VGAuth_SetLogHandler(CliLog, NULL, 0, NULL);
-
-   /*
-    * Find the location of the i18n catalogs.
-    */
-   setlocale(LC_ALL, "");
-   prefs = Pref_Init(VGAUTH_PREF_CONFIG_FILENAME);
-   msgCatalog = Pref_GetString(prefs,
-                               VGAUTH_PREF_LOCALIZATION_DIR,
-                               VGAUTH_PREF_GROUP_NAME_LOCALIZATION,
-                               VGAUTH_PREF_DEFAULT_LOCALIZATION_CATALOG);
-
-   I18n_BindTextDomain(VMW_TEXT_DOMAIN,    // domain -- base name of vmsg files
-                       NULL,               // locale -- let it figure it out
-                       msgCatalog);        // path to message catalogs
-   g_free(msgCatalog);
-
    /*
     * Set up the option parser
     */
@@ -660,7 +678,6 @@ next:
    }
 
    VGAuth_Shutdown(ctx);
-   Pref_Shutdown(prefs);
    g_free(appName);
    return (err == VGAUTH_E_OK) ? 0 : -1;
 }
@@ -696,6 +713,8 @@ wmain(int argc,
       CHK_UTF16_TO_UTF8(argvUtf8[i], argv[i], goto end);
    }
 
+   InitMsgCatalog();
+
    retval = mainRun(argc, argvUtf8);
 
 end:
@@ -731,6 +750,7 @@ int
 main(int argc,
      char *argv[])
 {
+   InitMsgCatalog();
    return mainRun(argc, argv);
 }
 
index 774808e1c121e7b9fcd330415c6d13a3f702f800..240f73eb5fd6f63b4905605efe9d76ff9f15b1cb 100644 (file)
@@ -1,5 +1,5 @@
 ################################################################################
-### Copyright (C) 2014-2019 VMware, Inc.  All rights reserved.
+### Copyright (C) 2014-2020 VMware, Inc.  All rights reserved.
 ###
 ### This program is free software; you can redistribute it and/or modify
 ### it under the terms of version 2 of the GNU General Public License as
@@ -102,7 +102,10 @@ else
    VGAuthService_LINK = $(LINK)
 endif
 
+VGAuthMsgDir = $(datadir)/open-vm-tools
+
 # Message catalogs.
 install-data-hook:
        @INSTVMSG@ VGAuthService $(srcdir)/l10n $(DESTDIR)$(datadir)
-       cat vgauth.conf | sed -e"s!@@VGAUTHSCHEMADIR@@!$(VGAuthServicedir)!" > $(DESTDIR)/etc/vmware-tools/vgauth.conf
+       cat vgauth.conf | sed -e"s!@@VGAUTHSCHEMADIR@@!$(VGAuthServicedir)!" \
+                   |  sed -e"s!@@VGAUTHMSGDIR@@!$(VGAuthMsgDir)!" > $(DESTDIR)/etc/vmware-tools/vgauth.conf
index 3c758873bcf848bab211561b3df6f1d322079c56..c79f9f9bf5b65e16492b3f757664c0cfc539fb62 100644 (file)
@@ -1,3 +1,5 @@
 [service]
 samlSchemaDir = @@VGAUTHSCHEMADIR@@
 
+[localization]
+msgCatalog = @@VGAUTHMSGDIR@@