Changeset 80569 in vbox for trunk/src/VBox/Frontends/VBoxHeadless
- Timestamp:
- Sep 3, 2019 2:34:21 PM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 133086
- Location:
- trunk/src/VBox/Frontends/VBoxHeadless
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxHeadless/Makefile.kmk
r76553 r80569 46 46 VBoxHeadless_TEMPLATE := $(if $(VBOX_WITH_HARDENING),VBOXMAINCLIENTDLL,VBOXMAINCLIENTEXE) 47 47 VBoxHeadless_DEFS += $(if $(VBOX_WITH_RECORDING),VBOX_WITH_RECORDING,) 48 VBoxHeadless_INCS = $(VBOX_GRAPHICS_INCS) 49 VBoxHeadless_SOURCES = VBoxHeadless.cpp 48 VBoxHeadless_INCS = \ 49 $(VBOX_GRAPHICS_INCS) \ 50 ../Common 51 VBoxHeadless_SOURCES = \ 52 VBoxHeadless.cpp \ 53 ../Common/PasswordInput.cpp 50 54 ifdef VBOX_WITH_GUEST_PROPS 51 55 VBoxHeadless_DEFS += VBOX_WITH_GUEST_PROPS -
trunk/src/VBox/Frontends/VBoxHeadless/VBoxHeadless.cpp
r76553 r80569 60 60 #include <signal.h> 61 61 #endif 62 63 #include "PasswordInput.h" 62 64 63 65 //////////////////////////////////////////////////////////////////////////////// … … 525 527 } 526 528 #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 else539 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 else551 {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 else560 {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 else568 {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 591 529 592 530 #ifdef RT_OS_DARWIN
Note:
See TracChangeset
for help on using the changeset viewer.