VirtualBox

Changeset 40066 in vbox


Ignore:
Timestamp:
Feb 10, 2012 2:52:47 PM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
76200
Message:

hash the teleporter token.

Location:
trunk
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/settings.h

    r38873 r40066  
    10571057    void readStorageControllers(const xml::ElementNode &elmStorageControllers, Storage &strg);
    10581058    void readDVDAndFloppies_pre1_9(const xml::ElementNode &elmHardware, Storage &strg);
     1059    void readTeleporter(const xml::ElementNode *pElmTeleporter, MachineUserData *pUserData);
    10591060    void readSnapshot(const xml::ElementNode &elmSnapshot, Snapshot &snap);
    10601061    void convertOldOSType_pre1_5(com::Utf8Str &str);
  • trunk/src/VBox/Main/Makefile.kmk

    r39955 r40066  
    286286        src-all/EventImpl.cpp \
    287287        src-all/Global.cpp \
     288        src-all/HashedPw.cpp \
    288289        src-all/Logging.cpp \
    289290        src-all/PciDeviceAttachmentImpl.cpp \
     
    638639        src-all/EventImpl.cpp \
    639640        src-all/Global.cpp \
     641        src-all/HashedPw.cpp \
    640642        src-all/Logging.cpp \
    641643        src-all/PciDeviceAttachmentImpl.cpp \
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r39882 r40066  
    41694169        very basic measure to prevent simple hacks and operators accidentally
    41704170        beaming a virtual machine to the wrong place.
     4171
     4172        Note that you SET a plain text password while reading back a HASHED
     4173        password.  Setting a hashed password is currently not supported.
    41714174      </desc>
    41724175    </attribute>
  • trunk/src/VBox/Main/src-all/Global.cpp

    r40041 r40066  
    11/* $Id$ */
    22/** @file
    3  *
    43 * VirtualBox COM global definitions
    54 *
     
    87
    98/*
    10  * Copyright (C) 2008-2011 Oracle Corporation
     9 * Copyright (C) 2008-2012 Oracle Corporation
    1110 *
    1211 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    537536}
    538537
    539 
    540538/* vi: set tabstop=4 shiftwidth=4 expandtab: */
  • trunk/src/VBox/Main/src-client/ConsoleImplTeleporter.cpp

    r36041 r40066  
    2626#include "AutoCaller.h"
    2727#include "Logging.h"
     28#include "HashedPw.h"
    2829
    2930#include <iprt/asm.h>
     
    932933    CheckComArgOutPointerValid(aProgress);
    933934    CheckComArgStrNotEmptyOrNull(aHostname);
    934     CheckComArgStrNotEmptyOrNull(aHostname);
     935    CheckComArgStrNotEmptyOrNull(aPassword);
    935936    CheckComArgExprMsg(aPort, aPort > 0 && aPort <= 65535, ("is %u", aPort));
    936937    CheckComArgExprMsg(aMaxDowntime, aMaxDowntime > 0, ("is %u", aMaxDowntime));
     938
     939    Utf8Str strPassword(aPassword);
     940    if (!strPassword.isEmpty())
     941    {
     942        if (VBoxIsPasswordHashed(&strPassword))
     943            return setError(E_INVALIDARG, tr("The specified password resembles a hashed password, expected plain text"));
     944        VBoxHashPassword(&strPassword);
     945    }
    937946
    938947    AutoCaller autoCaller(this);
     
    971980
    972981    TeleporterStateSrc *pState = new TeleporterStateSrc(this, mpUVM, ptrProgress, mMachineState);
    973     pState->mstrPassword    = aPassword;
     982    pState->mstrPassword    = strPassword;
    974983    pState->mstrHostname    = aHostname;
    975984    pState->muPort          = aPort;
  • trunk/src/VBox/Main/src-server/MachineImpl.cpp

    r39926 r40066  
    6060
    6161#include "AutoCaller.h"
     62#include "HashedPw.h"
    6263#include "Performance.h"
    6364
     
    7071#include <iprt/cpp/utils.h>
    7172#include <iprt/cpp/xml.h>               /* xml::XmlFileWriter::s_psz*Suff. */
     73#include <iprt/sha.h>
    7274#include <iprt/string.h>
    7375
     
    26962698
    26972699    AutoCaller autoCaller(this);
    2698     if (FAILED(autoCaller.rc())) return autoCaller.rc();
    2699 
    2700     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    2701 
    2702     mUserData->s.strTeleporterPassword.cloneTo(aPassword);
    2703 
    2704     return S_OK;
     2700    HRESULT hrc = autoCaller.rc();
     2701    if (SUCCEEDED(hrc))
     2702    {
     2703        AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     2704        mUserData->s.strTeleporterPassword.cloneTo(aPassword);
     2705    }
     2706
     2707    return hrc;
    27052708}
    27062709
    27072710STDMETHODIMP Machine::COMSETTER(TeleporterPassword)(IN_BSTR aPassword)
    27082711{
    2709     AutoCaller autoCaller(this);
    2710     if (FAILED(autoCaller.rc())) return autoCaller.rc();
    2711 
    2712     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    2713 
    2714     HRESULT rc = checkStateDependency(MutableStateDep);
    2715     if (FAILED(rc)) return rc;
    2716 
    2717     setModified(IsModified_MachineData);
    2718     mUserData.backup();
    2719     mUserData->s.strTeleporterPassword = aPassword;
    2720 
    2721     return S_OK;
     2712    /*
     2713     * Hash the password first.
     2714     */
     2715    Utf8Str strPassword(aPassword);
     2716    if (!strPassword.isEmpty())
     2717    {
     2718        if (VBoxIsPasswordHashed(&strPassword))
     2719            return setError(E_INVALIDARG, tr("Cannot set an already hashed password, only plain text password please"));
     2720        VBoxHashPassword(&strPassword);
     2721    }
     2722
     2723    /*
     2724     * Do the update.
     2725     */
     2726    AutoCaller autoCaller(this);
     2727    HRESULT hrc = autoCaller.rc();
     2728    if (SUCCEEDED(hrc))
     2729    {
     2730        AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     2731        hrc = checkStateDependency(MutableStateDep);
     2732        if (SUCCEEDED(hrc))
     2733        {
     2734            setModified(IsModified_MachineData);
     2735            mUserData.backup();
     2736            mUserData->s.strTeleporterPassword = strPassword;
     2737        }
     2738    }
     2739
     2740    return hrc;
    27222741}
    27232742
  • trunk/src/VBox/Main/xml/Settings.cpp

    r38893 r40066  
    5252
    5353/*
    54  * Copyright (C) 2007-2011 Oracle Corporation
     54 * Copyright (C) 2007-2012 Oracle Corporation
    5555 *
    5656 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    7777
    7878#include "Logging.h"
     79#include "HashedPw.h"
    7980
    8081using namespace com;
     
    31433144
    31443145/**
     3146 * Called for reading the <Teleporter> element under <Machine>.
     3147 */
     3148void MachineConfigFile::readTeleporter(const xml::ElementNode *pElmTeleporter,
     3149                                       MachineUserData *pUserData)
     3150{
     3151    pElmTeleporter->getAttributeValue("enabled", pUserData->fTeleporterEnabled);
     3152    pElmTeleporter->getAttributeValue("port", pUserData->uTeleporterPort);
     3153    pElmTeleporter->getAttributeValue("address", pUserData->strTeleporterAddress);
     3154    pElmTeleporter->getAttributeValue("password", pUserData->strTeleporterPassword);
     3155
     3156    if (   pUserData->strTeleporterPassword.isNotEmpty()
     3157        && !VBoxIsPasswordHashed(&pUserData->strTeleporterPassword))
     3158        VBoxHashPassword(&pUserData->strTeleporterPassword);
     3159}
     3160
     3161/**
    31453162 * Called initially for the <Snapshot> element under <Machine>, if present,
    31463163 * to store the snapshot's data into the given Snapshot structure (which is
     
    33413358                machineUserData.strDescription = pelmMachineChild->getValue();
    33423359            else if (pelmMachineChild->nameEquals("Teleporter"))
    3343             {
    3344                 pelmMachineChild->getAttributeValue("enabled", machineUserData.fTeleporterEnabled);
    3345                 pelmMachineChild->getAttributeValue("port", machineUserData.uTeleporterPort);
    3346                 pelmMachineChild->getAttributeValue("address", machineUserData.strTeleporterAddress);
    3347                 pelmMachineChild->getAttributeValue("password", machineUserData.strTeleporterPassword);
    3348             }
     3360                readTeleporter(pelmMachineChild, &machineUserData);
    33493361            else if (pelmMachineChild->nameEquals("FaultTolerance"))
    33503362            {
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