From: Oliver Kurth Date: Fri, 15 Sep 2017 18:23:25 +0000 (-0700) Subject: Check the RPC return value in timesync enable/disable commands. X-Git-Tag: stable-10.2.0~343 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d17b458c340f76112707ede1e277b575e6e4301b;p=thirdparty%2Fopen-vm-tools.git Check the RPC return value in timesync enable/disable commands. 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. --- diff --git a/open-vm-tools/toolbox/l10n/de.vmsg b/open-vm-tools/toolbox/l10n/de.vmsg index a2f2f7bbf..f5e3b4e6f 100644 --- a/open-vm-tools/toolbox/l10n/de.vmsg +++ b/open-vm-tools/toolbox/l10n/de.vmsg @@ -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" diff --git a/open-vm-tools/toolbox/l10n/ja.vmsg b/open-vm-tools/toolbox/l10n/ja.vmsg index c9927d4f8..ea7256f9b 100644 --- a/open-vm-tools/toolbox/l10n/ja.vmsg +++ b/open-vm-tools/toolbox/l10n/ja.vmsg @@ -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" diff --git a/open-vm-tools/toolbox/l10n/ko.vmsg b/open-vm-tools/toolbox/l10n/ko.vmsg index 25aedee5b..ac8897dba 100644 --- a/open-vm-tools/toolbox/l10n/ko.vmsg +++ b/open-vm-tools/toolbox/l10n/ko.vmsg @@ -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" diff --git a/open-vm-tools/toolbox/l10n/zh_CN.vmsg b/open-vm-tools/toolbox/l10n/zh_CN.vmsg index ec187b950..82e3253eb 100644 --- a/open-vm-tools/toolbox/l10n/zh_CN.vmsg +++ b/open-vm-tools/toolbox/l10n/zh_CN.vmsg @@ -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" diff --git a/open-vm-tools/toolbox/toolboxcmd-shrink.c b/open-vm-tools/toolbox/toolboxcmd-shrink.c index bf38f7be6..ef192ba03 100644 --- a/open-vm-tools/toolbox/toolboxcmd-shrink.c +++ b/open-vm-tools/toolbox/toolboxcmd-shrink.c @@ -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; diff --git a/open-vm-tools/toolbox/toolboxcmd-time.c b/open-vm-tools/toolbox/toolboxcmd-time.c index d6b7a9851..5c011d662 100644 --- a/open-vm-tools/toolbox/toolboxcmd-time.c +++ b/open-vm-tools/toolbox/toolboxcmd-time.c @@ -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; }