From: Oliver Kurth Date: Mon, 17 Jun 2019 18:41:38 +0000 (-0700) Subject: linuxDeployment.c: Suppress the telinit error if the first telinit commands X-Git-Tag: stable-11.0.0~37 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=680c9d4a412a099efde6382a0a4e5f300bc4fc4e;p=thirdparty%2Fopen-vm-tools.git linuxDeployment.c: Suppress the telinit error if the first telinit commands has made VM reboot. The code executes '/sbin/telinit 6' repeatedly to reboot VM. VM will be rebooting if the telinit command executed successfully(exitcode==0). Observed the repeated telinit command might get error(exitcode==1) on some GOSes, ex: Ubuntu18.04, RHEL7.4/7.5 and Fedora 29. Observed no such error on older GOSes, ex: Ubuntu14.04, RHEL6.6 The error telinit log is confusing, actually it does NOT mean customization failed. This change does NOT log telinit error, and returns deployPkg status to make sure the log is consistent with customization result when the first 'telinit 6' succeeded but one of the following 'telinit 6' command failed. The following actions are unchanged with or without this change: 1. log telinit error, stop loop and exit 127 if the first 'telinit 6' fails. 2. repeatedly execute 'telinit 6' if previous one executed successfully (exitcode==0). --- diff --git a/open-vm-tools/libDeployPkg/linuxDeployment.c b/open-vm-tools/libDeployPkg/linuxDeployment.c index 1127502fa..1af08936e 100644 --- a/open-vm-tools/libDeployPkg/linuxDeployment.c +++ b/open-vm-tools/libDeployPkg/linuxDeployment.c @@ -1408,15 +1408,27 @@ Deploy(const char* packageName) // Repeatedly try to reboot to workaround PR 530641 where // telinit 6 is overwritten by a telinit 2 - int rebootComandResult = 0; + int rebootCommandResult; + bool isRebooting = false; + sLog(log_info, "Trigger reboot.\n"); do { - sLog(log_info, "Rebooting.\n"); - rebootComandResult = ForkExecAndWaitCommand("/sbin/telinit 6", false); + if (isRebooting) { + sLog(log_info, "Rebooting.\n"); + } + rebootCommandResult = + ForkExecAndWaitCommand("/sbin/telinit 6", false); + isRebooting = (rebootCommandResult == 0) ? + true : isRebooting; sleep(1); - } while (rebootComandResult == 0); - sLog(log_error, "telinit returned error %d.\n", rebootComandResult); - - exit (127); + } while (rebootCommandResult == 0); + if (!isRebooting) { + sLog(log_error, + "Failed to reboot, telinit returned error %d.\n", + rebootCommandResult); + exit (127); + } else { + sLog(log_info, "Reboot has been triggered.\n"); + } } }