From: VMware, Inc <> Date: Thu, 24 Feb 2011 22:54:13 +0000 (-0800) Subject: toolbox-cmd: show full path to current scripts X-Git-Tag: 2011.02.23-368700~13 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d391e1df8c5f4d9a957500a36c6beadc61029f06;p=thirdparty%2Fopen-vm-tools.git toolbox-cmd: show full path to current scripts Let's show full path to scripts when executing vmware-toolbox-cmd script XXX current Scripts with relative paths are assumed to be under tools install dir. Signed-off-by: Marcelo Vanzin --- diff --git a/open-vm-tools/toolbox/toolboxcmd-scripts.c b/open-vm-tools/toolbox/toolboxcmd-scripts.c index da88bb303..d9e3f5bec 100644 --- a/open-vm-tools/toolbox/toolboxcmd-scripts.c +++ b/open-vm-tools/toolbox/toolboxcmd-scripts.c @@ -134,9 +134,10 @@ GetConfEntry(const char *progName, // IN: program name (argv[0]) const char *apm, // IN: apm name ScriptType type) // IN: Script type (default or current) { - gchar *entry = NULL; - GKeyFile *confDict = NULL; + gchar *entry; + GKeyFile *confDict; const char *confName; + int len; int ret; confName = GetConfName(apm); @@ -149,16 +150,42 @@ GetConfEntry(const char *progName, // IN: program name (argv[0]) confDict = LoadConfFile(); - if (type == Default) { - entry = g_strdup(GuestApp_GetDefaultScript(confName)); - } else if (type == Current) { + switch (type) { + case Current: entry = g_key_file_get_string(confDict, "powerops", confName, NULL); - if (entry == NULL) { - entry = g_strdup(GuestApp_GetDefaultScript(confName)); + if (entry) { + break; } + /* Fall through */ + + default: + entry = g_strdup(GuestApp_GetDefaultScript(confName)); + break; } - if (strlen(entry) > 0) { + len = strlen(entry); + if (len > 0) { + + /* If script path is not absolute, assume the Tools install path. */ + if (!g_path_is_absolute(entry)) { + char *defaultPath = GuestApp_GetInstallPath(); + char *tmp; + Bool quoted; + + ASSERT(defaultPath != NULL); + + /* Cope with old configs that added quotes around script paths. */ + quoted = (entry[0] == '"' && entry[len - 1] == '"'); + tmp = g_strdup_printf("%s%c%.*s", defaultPath, DIRSEPC, + quoted ? len - 2 : len, + quoted ? entry + 1 : entry); + + vm_free(defaultPath); + + g_free(entry); + entry = tmp; + } + g_print("%s\n", entry); ret = EXIT_SUCCESS; } else {