]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Check the RPC return value in timesync enable/disable commands.
authorOliver Kurth <okurth@vmware.com>
Fri, 15 Sep 2017 18:23:25 +0000 (11:23 -0700)
committerOliver Kurth <okurth@vmware.com>
Fri, 15 Sep 2017 18:23:25 +0000 (11:23 -0700)
toolbox-cmd timesync enable/disable commands always return success
even when the command failed. Added a check for the return value of
the RPC call and also print the error message using a generic
message which required renaming existing "disk.wiper.error" key.

open-vm-tools/toolbox/l10n/de.vmsg
open-vm-tools/toolbox/l10n/ja.vmsg
open-vm-tools/toolbox/l10n/ko.vmsg
open-vm-tools/toolbox/l10n/zh_CN.vmsg
open-vm-tools/toolbox/toolboxcmd-shrink.c
open-vm-tools/toolbox/toolboxcmd-time.c

index a2f2f7bbf7d3d5e06136cb745473e91fd33639d4..f5e3b4e6fb5d8d69a021284c18c8dbc38beb9cbb 100644 (file)
@@ -1,5 +1,5 @@
 ##########################################################
-# Copyright (C) 2010-2016 VMware, Inc. All rights reserved.
+# Copyright (C) 2010-2017 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
@@ -76,12 +76,12 @@ disk.shrink.ignoreFreeSpaceWarnings = "Ignorieren Sie während des Verkleinerung
 
 disk.wipe.ignoreFreeSpaceWarnings = "Ignorieren Sie während des Wiper-Vorgangs etwaige Warnungen bezüglich des Speicherplatzes.\n"
 
-disk.wiper.error = "Fehler: %1$s"
-
 disk.wiper.file.error = "Fehler, Erstellen der Wiper-Datei nicht möglich.\n"
 
 disk.wiper.progress = "\rProgress: %1$d"
 
+error.message = "Fehler: %1$s\n"
+
 error.missing = "%1$s: %2$s fehlt\n"
 
 error.noadmin.posix = "%1$s: Sie müssen root-Benutzer sein, um die %2$s-Vorgänge auszuführen.\n"
index c9927d4f829554491c22db86305533e11c05bcb9..ea7256f9b235eb9f4be6d8782d56cb4920fc6782 100644 (file)
@@ -1,5 +1,5 @@
 ##########################################################
-# Copyright (C) 2010-2016 VMware, Inc. All rights reserved.
+# Copyright (C) 2010-2017 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
@@ -76,12 +76,12 @@ disk.shrink.ignoreFreeSpaceWarnings = "圧縮プロセス中に表示される
 
 disk.wipe.ignoreFreeSpaceWarnings = "ワイプ プロセス中に表示されるディスク領域に関する警告はすべて無視してください。\n"
 
-disk.wiper.error = "エラー: %1$s"
-
 disk.wiper.file.error = "エラー。ワイパー ファイルを作成できません。\n"
 
 disk.wiper.progress = "\r進行状況: %1$d"
 
+error.message = "エラー: %1$s\n"
+
 error.missing = "%1$s: %2$s が見つかりません\n"
 
 error.noadmin.posix = "%1$s: %2$s 操作を実行するには、root ユーザーである必要があります。\n"
index 25aedee5b7c1d606534c9176c1395dd795dfd8c1..ac8897dbaeed26882a826a20c21018f8bd6210b0 100644 (file)
@@ -1,5 +1,5 @@
 ##########################################################
-# Copyright (C) 2010-2016 VMware, Inc. All rights reserved.
+# Copyright (C) 2010-2017 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
@@ -76,12 +76,12 @@ disk.shrink.ignoreFreeSpaceWarnings = "축소 프로세스가 실행되는 동
 
 disk.wipe.ignoreFreeSpaceWarnings = "지우기 프로세스가 실행되는 동안에는 디스크 공간에 대한 주의를 무시하십시오.\n"
 
-disk.wiper.error = "오류: %1$s"
-
 disk.wiper.file.error = "오류. 와이퍼 파일을 생성할 수 없습니다.\n"
 
 disk.wiper.progress = "\r진행률: %1$d"
 
+error.message = "오류: %1$s\n"
+
 error.missing = "%1$s: %2$s이(가) 없음\n"
 
 error.noadmin.posix = "%1$s: %2$s 작업은 루트 사용자만 수행할 수 있습니다.\n"
index ec187b9503fd866a9a4fe6a913523c3318aad7f1..82e3253ebf5cb6e8e1c81461ef9beec307610704 100644 (file)
@@ -1,5 +1,5 @@
 ##########################################################
-# Copyright (C) 2010-2016 VMware, Inc. All rights reserved.
+# Copyright (C) 2010-2017 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
@@ -76,12 +76,12 @@ disk.shrink.ignoreFreeSpaceWarnings = "请忽略压缩过程期间有关磁盘
 
 disk.wipe.ignoreFreeSpaceWarnings = "请忽略擦除过程期间有关磁盘空间的任何警告。\n"
 
-disk.wiper.error = "错误: %1$s"
-
 disk.wiper.file.error = "错误,无法创建擦除器文件。\n"
 
 disk.wiper.progress = "\r进度:%1$d"
 
+error.message = "错误: %1$s\n"
+
 error.missing = "%1$s: 缺失 %2$s\n"
 
 error.noadmin.posix = "%1$s: 您必须是 root 用户才能执行 %2$s 操作。\n"
index bf38f7be6e857d568e8e81ce7a87475377e7f717..ef192ba0344bb96090839a15eb413b96e0570730 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 2008-2016 VMware, Inc. All rights reserved.
+ * Copyright (C) 2008-2017 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
@@ -436,7 +436,7 @@ ShrinkDoWipeAndShrink(char *mountPoint,         // IN: mount point
                               SU_(disk.wiper.file.error,
                                   "Error, Unable to create wiper file.\n"));
          } else {
-            ToolsCmd_PrintErr(SU_(disk.wiper.error, "Error: %s"), err);
+            ToolsCmd_PrintErr(SU_(error.message, "Error: %s\n"), err);
          }
 
          rc = EX_TEMPFAIL;
index d6b7a9851508c0107c5a52aea9eb5e01ac34b3d1..5c011d662c730fb9b62fc47b755fff777b4ea556 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 2008-2016 VMware, Inc. All rights reserved.
+ * Copyright (C) 2008-2017 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
@@ -28,6 +28,7 @@
 #include "vmware/guestrpc/tclodefs.h"
 #include "vmware/guestrpc/timesync.h"
 #include "vmware/tools/i18n.h"
+#include "vmware/tools/utils.h"
 
 
 /*
@@ -73,14 +74,16 @@ TimeSyncGetOldOptions(void)
  *-----------------------------------------------------------------------------
  */
 
-static void
-TimeSyncSet(Bool enable) // IN: status
+static gboolean
+TimeSyncSet(Bool enable,      // IN:
+            char **reply,     // OUT:
+            size_t *replyLen) // OUT:
 {
    gchar *msg = g_strdup_printf("vmx.set_option %s %s %s",
                                 TOOLSOPTION_SYNCTIME,
                                 !enable ? "1" : "0",
                                 enable ? "1" : "0");
-   ToolsCmd_SendRPC(msg, strlen(msg) + 1, NULL, NULL);
+   return ToolsCmd_SendRPC(msg, strlen(msg) + 1, reply, replyLen);
 }
 
 
@@ -92,7 +95,7 @@ TimeSyncSet(Bool enable) // IN: status
  *      Enable time sync.
  *
  * Results:
- *      EXIT_SUCCESS
+ *      EXIT_SUCCESS on success, EXIT_FAILURE on failure.
  *
  * Side effects:
  *      Same as TimeSyncSet.
@@ -103,9 +106,19 @@ TimeSyncSet(Bool enable) // IN: status
 static int
 TimeSyncEnable(void)
 {
-   TimeSyncSet(TRUE);
-   ToolsCmd_Print("%s\n", SU_(option.enabled, "Enabled"));
-   return EXIT_SUCCESS;
+   int ret = EXIT_SUCCESS;
+   char *reply = NULL;
+   size_t replyLen;
+
+   if (TimeSyncSet(TRUE, &reply, &replyLen)) {
+      ToolsCmd_Print("%s\n", SU_(option.enabled, "Enabled"));
+   } else {
+      ToolsCmd_PrintErr(SU_(error.message, "Error: %s\n"), reply);
+      ret = EXIT_FAILURE;
+   }
+
+   vm_free(reply);
+   return ret;
 }
 
 
@@ -117,7 +130,7 @@ TimeSyncEnable(void)
  *      Disable time sync.
  *
  * Results:
- *      EXIT_SUCCESS
+ *      EXIT_SUCCESS on success, EXIT_FAILURE on failure.
  *
  * Side effects:
  *      Same as TimeSyncSet.
@@ -128,9 +141,19 @@ TimeSyncEnable(void)
 static int
 TimeSyncDisable(void)
 {
-   TimeSyncSet(FALSE);
-   ToolsCmd_Print("%s\n", SU_(option.disabled, "Disabled"));
-   return EXIT_SUCCESS;
+   int ret = EXIT_SUCCESS;
+   char *reply = NULL;
+   size_t replyLen;
+
+   if (TimeSyncSet(FALSE, &reply, &replyLen)) {
+      ToolsCmd_Print("%s\n", SU_(option.disabled, "Disabled"));
+   } else {
+      ToolsCmd_PrintErr(SU_(error.message, "Error: %s\n"), reply);
+      ret = EXIT_FAILURE;
+   }
+
+   vm_free(reply);
+   return ret;
 }