VirtualBox

Ignore:
Timestamp:
Sep 3, 2019 2:34:21 PM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
133086
Message:

Main: bugref:9341: Added VM autostart during boot support for windows host

Location:
trunk/src/VBox/Frontends/VBoxHeadless
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxHeadless/Makefile.kmk

    r76553 r80569  
    4646VBoxHeadless_TEMPLATE  := $(if $(VBOX_WITH_HARDENING),VBOXMAINCLIENTDLL,VBOXMAINCLIENTEXE)
    4747VBoxHeadless_DEFS      += $(if $(VBOX_WITH_RECORDING),VBOX_WITH_RECORDING,)
    48 VBoxHeadless_INCS      = $(VBOX_GRAPHICS_INCS)
    49 VBoxHeadless_SOURCES    = VBoxHeadless.cpp
     48VBoxHeadless_INCS      = \
     49        $(VBOX_GRAPHICS_INCS) \
     50        ../Common
     51VBoxHeadless_SOURCES    = \
     52        VBoxHeadless.cpp \
     53        ../Common/PasswordInput.cpp
    5054ifdef VBOX_WITH_GUEST_PROPS
    5155 VBoxHeadless_DEFS     += VBOX_WITH_GUEST_PROPS
  • trunk/src/VBox/Frontends/VBoxHeadless/VBoxHeadless.cpp

    r76553 r80569  
    6060#include <signal.h>
    6161#endif
     62
     63#include "PasswordInput.h"
    6264
    6365////////////////////////////////////////////////////////////////////////////////
     
    525527}
    526528#endif /* VBOX_WITH_RECORDING defined */
    527 
    528 static RTEXITCODE readPasswordFile(const char *pszFilename, com::Utf8Str *pPasswd)
    529 {
    530     size_t cbFile;
    531     char szPasswd[512];
    532     int vrc = VINF_SUCCESS;
    533     RTEXITCODE rcExit = RTEXITCODE_SUCCESS;
    534     bool fStdIn = !strcmp(pszFilename, "stdin");
    535     PRTSTREAM pStrm;
    536     if (!fStdIn)
    537         vrc = RTStrmOpen(pszFilename, "r", &pStrm);
    538     else
    539         pStrm = g_pStdIn;
    540     if (RT_SUCCESS(vrc))
    541     {
    542         vrc = RTStrmReadEx(pStrm, szPasswd, sizeof(szPasswd)-1, &cbFile);
    543         if (RT_SUCCESS(vrc))
    544         {
    545             if (cbFile >= sizeof(szPasswd)-1)
    546             {
    547                 RTPrintf("Provided password in file '%s' is too long\n", pszFilename);
    548                 rcExit = RTEXITCODE_FAILURE;
    549             }
    550             else
    551             {
    552                 unsigned i;
    553                 for (i = 0; i < cbFile && !RT_C_IS_CNTRL(szPasswd[i]); i++)
    554                     ;
    555                 szPasswd[i] = '\0';
    556                 *pPasswd = szPasswd;
    557             }
    558         }
    559         else
    560         {
    561             RTPrintf("Cannot read password from file '%s': %Rrc\n", pszFilename, vrc);
    562             rcExit = RTEXITCODE_FAILURE;
    563         }
    564         if (!fStdIn)
    565             RTStrmClose(pStrm);
    566     }
    567     else
    568     {
    569         RTPrintf("Cannot open password file '%s' (%Rrc)\n", pszFilename, vrc);
    570         rcExit = RTEXITCODE_FAILURE;
    571     }
    572 
    573     return rcExit;
    574 }
    575 
    576 static RTEXITCODE settingsPasswordFile(ComPtr<IVirtualBox> virtualBox, const char *pszFilename)
    577 {
    578     com::Utf8Str passwd;
    579     RTEXITCODE rcExit = readPasswordFile(pszFilename, &passwd);
    580     if (rcExit == RTEXITCODE_SUCCESS)
    581     {
    582         int rc;
    583         CHECK_ERROR(virtualBox, SetSettingsSecret(com::Bstr(passwd).raw()));
    584         if (FAILED(rc))
    585             rcExit = RTEXITCODE_FAILURE;
    586     }
    587 
    588     return rcExit;
    589 }
    590 
    591529
    592530#ifdef RT_OS_DARWIN
Note: See TracChangeset for help on using the changeset viewer.

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