VirtualBox

Changeset 103411 in vbox for trunk/src


Ignore:
Timestamp:
Feb 19, 2024 7:12:34 AM (12 months ago)
Author:
vboxsync
Message:

FE/VBoxManage: Redo weird logic in handleRegisterVM to fix some parfait warnings, bugref:3409

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp

    r102540 r103411  
    7777{
    7878    HRESULT hrc;
    79     const char *VMName = NULL;
    80 
    81     Bstr bstrVMName;
    82     Bstr bstrPasswordFile;
     79
     80    const char *pszVmFile = NULL;
     81    const char *pszPasswordFile = NULL;
    8382
    8483    int c;
     
    9392        {
    9493            case 'p':   // --password
    95                 bstrPasswordFile = ValueUnion.psz;
     94                pszPasswordFile = ValueUnion.psz;
    9695                break;
    9796
    9897            case VINF_GETOPT_NOT_OPTION:
    99                 if (bstrVMName.isEmpty())
    100                     VMName = ValueUnion.psz;
     98                if (!pszVmFile)
     99                    pszVmFile = ValueUnion.psz;
    101100                else
    102101                    return errorSyntax(Misc::tr("Invalid parameter '%s'"), ValueUnion.psz);
     
    120119    Utf8Str strPassword;
    121120
    122     if (bstrPasswordFile.isNotEmpty())
    123     {
    124         if (bstrPasswordFile == "-")
     121    if (pszPasswordFile)
     122    {
     123        if (pszPasswordFile[0] == '-' && pszPasswordFile[1] == '\0')
    125124        {
    126125            /* Get password from console. */
     
    131130        else
    132131        {
    133             RTEXITCODE rcExit = readPasswordFile(a->argv[3], &strPassword);
     132            RTEXITCODE rcExit = readPasswordFile(pszPasswordFile, &strPassword);
    134133            if (rcExit == RTEXITCODE_FAILURE)
    135134                return RTMsgErrorExitFailure(Misc::tr("Failed to read password from file"));
     
    141140     * and the client's interpretation of relative paths. Remove after the API
    142141     * has been redesigned. */
    143     hrc = a->virtualBox->OpenMachine(Bstr(a->argv[0]).raw(),
     142    hrc = a->virtualBox->OpenMachine(Bstr(pszVmFile).raw(),
    144143                                     Bstr(strPassword).raw(),
    145144                                     machine.asOutParam());
    146     if (FAILED(hrc) && !RTPathStartsWithRoot(a->argv[0]))
     145    if (FAILED(hrc) && !RTPathStartsWithRoot(pszVmFile))
    147146    {
    148147        char szVMFileAbs[RTPATH_MAX] = "";
    149         int vrc = RTPathAbs(a->argv[0], szVMFileAbs, sizeof(szVMFileAbs));
     148        int vrc = RTPathAbs(pszVmFile, szVMFileAbs, sizeof(szVMFileAbs));
    150149        if (RT_FAILURE(vrc))
    151150            return RTMsgErrorExitFailure(Misc::tr("Failed to convert \"%s\" to an absolute path: %Rrc"),
    152                                          a->argv[0], vrc);
     151                                         pszVmFile, vrc);
    153152        CHECK_ERROR(a->virtualBox, OpenMachine(Bstr(szVMFileAbs).raw(),
    154153                                               Bstr(strPassword).raw(),
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette