Changeset 36755 in vbox for trunk/src/VBox/Additions/common
- Timestamp:
- Apr 20, 2011 2:38:32 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlExec.cpp
r36745 r36755 717 717 718 718 719 #ifdef VBOXSERVICE_TOOLBOX720 719 /** 721 720 * Constructs the argv command line by resolving environment variables … … 731 730 const char * const *papszArgs, char ***ppapszArgv) 732 731 { 733 AssertPtrReturn(pszArgv0, VERR_INVALID_PARAMETER);734 AssertPtrReturn(ppapszArgv, VERR_INVALID_PARAMETER);735 736 732 /** @todo RTGetOptArgvToString converts to MSC quoted string, while 737 733 * RTGetOptArgvFromString takes bourne shell according to the docs... 738 734 * Actually, converting to and from here is a very roundabout way of prepending 739 735 * an entry (pszFilename) to an array (*ppapszArgv). */ 740 char *pszArgs; 741 int rc = RTGetOptArgvToString(&pszArgs, papszArgs, 736 int rc = VINF_SUCCESS; 737 char *pszNewArgs = NULL; 738 if (pszArgv0) 739 rc = RTStrAAppend(&pszNewArgs, pszArgv0); 740 if ( RT_SUCCESS(rc) 741 && papszArgs) 742 743 { 744 char *pszArgs; 745 rc = RTGetOptArgvToString(&pszArgs, papszArgs, 742 746 RTGETOPTARGV_CNV_QUOTE_MS_CRT); /* RTGETOPTARGV_CNV_QUOTE_BOURNE_SH */ 743 if ( RT_SUCCESS(rc)744 && *pszArgs)745 {746 /*747 * Construct the new command line by appending the actual748 * tool name to new process' command line.749 */750 char szArgsExp[RTPATH_MAX];751 rc = VBoxServiceControlExecMakeFullPath(pszArgs, szArgsExp, sizeof(szArgsExp));752 747 if (RT_SUCCESS(rc)) 753 748 { 754 char *pszNewArgs; 755 if (RTStrAPrintf(&pszNewArgs, "%s %s", pszArgv0, szArgsExp)) 756 { 757 #ifdef DEBUG 758 VBoxServiceVerbose(3, "ControlExec: VBoxServiceControlExecPrepareArgv: %s\n", 759 pszNewArgs); 760 #endif 761 int iNumArgsIgnored; 762 rc = RTGetOptArgvFromString(ppapszArgv, &iNumArgsIgnored, 763 pszNewArgs, NULL /* Use standard separators. */); 764 RTStrFree(pszNewArgs); 765 } 766 } 767 RTStrFree(pszArgs); 768 } 769 else /* No arguments given, just use the resolved file name as argv[0]. */ 749 rc = RTStrAAppend(&pszNewArgs, " "); 750 if (RT_SUCCESS(rc)) 751 rc = RTStrAAppend(&pszNewArgs, pszArgs); 752 } 753 } 754 755 if (RT_SUCCESS(rc)) 770 756 { 771 757 int iNumArgsIgnored; 772 758 rc = RTGetOptArgvFromString(ppapszArgv, &iNumArgsIgnored, 773 pszArgv0, NULL /* Use standard separators. */); 774 } 775 return rc; 776 } 777 #endif 759 pszNewArgs ? pszNewArgs : "", NULL /* Use standard separators. */); 760 } 761 762 VBoxServiceVerbose(3, "args: %s\n", pszNewArgs); 763 764 if (pszNewArgs) 765 RTStrFree(pszNewArgs); 766 return rc; 767 } 778 768 779 769 … … 834 824 { 835 825 char **papszArgsExp; 836 rc = VBoxServiceControlExecPrepareArgv(szSysprepCmd /* argv0 */, &papszArgs[1], &papszArgsExp);826 rc = VBoxServiceControlExecPrepareArgv(szSysprepCmd /* argv0 */, papszArgs, &papszArgsExp); 837 827 if (RT_SUCCESS(rc)) 838 828 { … … 867 857 { 868 858 char **papszArgsExp; 869 rc = VBoxServiceControlExecPrepareArgv(papszArgs[0], &papszArgs[1], &papszArgsExp); 859 rc = VBoxServiceControlExecPrepareArgv(pszExec /* Always use the unmodified executable name as argv0. */, 860 papszArgs /* Append the rest of the argument vector (if any). */, &papszArgsExp); 870 861 if (RT_SUCCESS(rc)) 871 862 { … … 888 879 #ifdef DEBUG 889 880 VBoxServiceVerbose(3, "Command: %s\n", szExecExp); 890 for (size_t i = 0; papszArgs Exp[i]; i++)891 VBoxServiceVerbose(3, "\targv[%ld]: %s\n", i, papszArgs Exp[i]);881 for (size_t i = 0; papszArgs[i]; i++) 882 VBoxServiceVerbose(3, "\targv[%ld]: %s\n", i, papszArgs[i]); 892 883 #endif 884 885 VBoxServiceVerbose(3, "%p %p %p\n", papszArgs, papszArgs[0], papszArgs[1]); 886 893 887 /* Do normal execution. */ 894 888 rc = RTProcCreateEx(szExecExp, papszArgsExp, hEnv, uProcFlags,
Note:
See TracChangeset
for help on using the changeset viewer.