VirtualBox

Changeset 102534 in vbox


Ignore:
Timestamp:
Dec 8, 2023 11:06:41 AM (10 months ago)
Author:
vboxsync
Message:

Main/Unattended: Renamed the attribute "IUnattended::password" to "IUnattended::userPassword". Added new getter/setter attribute "IUnattended::adminPassword", to set a dedicated admin / root password. If not specified explicitly, the password from "IUnattended::userPassword" will be used. Extended testcases. bugref:10554

Location:
trunk/src/VBox/Main
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r102381 r102534  
    49624962  <interface
    49634963    name="IUnattended" extends="$unknown"
    4964     uuid="1136224d-0ba7-45d6-9aee-03b628da46b6"
     4964    uuid="a71e5822-365b-49ba-bd14-c8d616e6740d"
    49654965    wsmap="managed"
    49664966    rest="managed"
     
    50105010    <attribute name="user" type="wstring">
    50115011      <desc>
    5012         Assign an user login name.
    5013       </desc>
    5014     </attribute>
    5015 
    5016     <attribute name="password" type="wstring">
    5017       <desc>
    5018         Assign a password to the user. The password is the same for both
    5019         normal user and for Administrator / 'root' accounts.
     5012        Assigns an user login name.
     5013      </desc>
     5014    </attribute>
     5015
     5016    <attribute name="userPassword" type="wstring">
     5017      <desc>
     5018        Assigns a password to the user.
     5019      </desc>
     5020    </attribute>
     5021
     5022    <attribute name="adminPassword" type="wstring">
     5023      <desc>
     5024        Assigns a password to the Administrator / 'root' accounts.
     5025
     5026        If no Administrator / 'root' password is being set explicitly, the password set via <link to="IUnattended::userPassword"/>
     5027        will be used instead.
    50205028      </desc>
    50215029    </attribute>
  • trunk/src/VBox/Main/include/UnattendedImpl.h

    r102381 r102534  
    8080    Utf8Str const &i_getIsoPath() const;
    8181    Utf8Str const &i_getUser() const;
    82     Utf8Str const &i_getPassword() const;
     82    Utf8Str const &i_getUserPassword() const;
     83    Utf8Str const &i_getAdminPassword() const;
    8384    Utf8Str const &i_getFullUserName() const;
    8485    Utf8Str const &i_getProductKey() const;
     
    128129     * @{ */
    129130    Utf8Str         mStrUser;
    130     Utf8Str         mStrPassword;
     131    Utf8Str         mStrUserPassword;
     132    Utf8Str         mStrAdminPassword;
    131133    Utf8Str         mStrFullUserName;
    132134    Utf8Str         mStrProductKey;
     
    198200    HRESULT getUser(com::Utf8Str &user);
    199201    HRESULT setUser(const com::Utf8Str &user);
    200     HRESULT getPassword(com::Utf8Str &password);
    201     HRESULT setPassword(const com::Utf8Str &password);
     202    HRESULT getUserPassword(com::Utf8Str &password);
     203    HRESULT setUserPassword(const com::Utf8Str &password);
     204    HRESULT getAdminPassword(com::Utf8Str &password);
     205    HRESULT setAdminPassword(const com::Utf8Str &password);
    202206    HRESULT getFullUserName(com::Utf8Str &user);
    203207    HRESULT setFullUserName(const com::Utf8Str &user);
  • trunk/src/VBox/Main/src-server/UnattendedImpl.cpp

    r102417 r102534  
    315315    {
    316316        mStrUser                    = "vboxuser";
    317         mStrPassword                = "changeme";
     317        mStrUserPassword            = "changeme";
     318        /* Note: For mStrAdminPassword see Unattended::i_getAdminPassword(). */
    318319        mfInstallGuestAdditions     = false;
    319320        mfInstallTestExecService    = false;
     
    34623463}
    34633464
    3464 HRESULT Unattended::getPassword(com::Utf8Str &password)
     3465HRESULT Unattended::getUserPassword(com::Utf8Str &password)
    34653466{
    34663467    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    3467     password = mStrPassword;
    3468     return S_OK;
    3469 }
    3470 
    3471 HRESULT Unattended::setPassword(const com::Utf8Str &password)
     3468    password = mStrUserPassword;
     3469    return S_OK;
     3470}
     3471
     3472HRESULT Unattended::setUserPassword(const com::Utf8Str &password)
    34723473{
    34733474    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    34743475    AssertReturn(mpInstaller == NULL, setErrorBoth(E_FAIL, VERR_WRONG_ORDER, tr("Cannot change after prepare() has been called")));
    3475     mStrPassword = password;
     3476    mStrUserPassword = password;
     3477    return S_OK;
     3478}
     3479
     3480HRESULT Unattended::getAdminPassword(com::Utf8Str &password)
     3481{
     3482    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     3483    password = mStrAdminPassword;
     3484    return S_OK;
     3485}
     3486
     3487HRESULT Unattended::setAdminPassword(const com::Utf8Str &password)
     3488{
     3489    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     3490    AssertReturn(mpInstaller == NULL, setErrorBoth(E_FAIL, VERR_WRONG_ORDER, tr("Cannot change after prepare() has been called")));
     3491    mStrAdminPassword = password;
    34763492    return S_OK;
    34773493}
     
    41484164}
    41494165
    4150 Utf8Str const &Unattended::i_getPassword() const
     4166Utf8Str const &Unattended::i_getUserPassword() const
    41514167{
    41524168    Assert(isReadLockedOnCurrentThread());
    4153     return mStrPassword;
     4169    return mStrUserPassword;
     4170}
     4171
     4172Utf8Str const &Unattended::i_getAdminPassword() const
     4173{
     4174    Assert(isReadLockedOnCurrentThread());
     4175
     4176    /* If no Administrator / 'root' password is being set, the user password will be used instead.
     4177     * Also see API documentation. */
     4178    return mStrAdminPassword.isEmpty() ? mStrUserPassword : mStrAdminPassword;
    41544179}
    41554180
  • trunk/src/VBox/Main/src-server/UnattendedInstaller.cpp

    r102347 r102534  
    250250    if (mpParent->i_getUser().isEmpty())
    251251        return mpParent->setError(E_INVALIDARG, tr("Empty user name is not allowed"));
    252     if (mpParent->i_getPassword().isEmpty())
    253         return mpParent->setError(E_INVALIDARG, tr("Empty password is not allowed"));
     252    if (mpParent->i_getUserPassword().isEmpty())
     253        return mpParent->setError(E_INVALIDARG, tr("Empty user password is not allowed"));
     254    /* If admin password is empty, the user password will be used instead. */
    254255
    255256    LogRelFunc(("UnattendedInstaller::savePassedData(): \n"));
  • trunk/src/VBox/Main/src-server/UnattendedScript.cpp

    r102488 r102534  
    676676        pszValue = mpUnattended->i_getUser().c_str();
    677677    else if (IS_MATCH("USER_PASSWORD"))
    678         pszValue = mpUnattended->i_getPassword().c_str();
     678        pszValue = mpUnattended->i_getUserPassword().c_str();
    679679    else if (IS_MATCH("USER_PASSWORD_SHACRYPT512"))
    680         SHACRYPT_AND_ASSIGN(mpUnattended->i_getPassword().c_str(), RTCrShaCrypt512, RT_SHACRYPT_512_MAX_SIZE);
     680        SHACRYPT_AND_ASSIGN(mpUnattended->i_getUserPassword().c_str(), RTCrShaCrypt512, RT_SHACRYPT_512_MAX_SIZE);
    681681    else if (IS_MATCH("ROOT_PASSWORD"))
    682         pszValue = mpUnattended->i_getPassword().c_str();
     682        pszValue = mpUnattended->i_getAdminPassword().c_str();
    683683    else if (IS_MATCH("ROOT_PASSWORD_SHACRYPT512"))
    684         SHACRYPT_AND_ASSIGN(mpUnattended->i_getPassword().c_str(), RTCrShaCrypt512, RT_SHACRYPT_512_MAX_SIZE);
     684        SHACRYPT_AND_ASSIGN(mpUnattended->i_getAdminPassword().c_str(), RTCrShaCrypt512, RT_SHACRYPT_512_MAX_SIZE);
    685685    else if (IS_MATCH("USER_FULL_NAME"))
    686686        pszValue = mpUnattended->i_getFullUserName().c_str();
  • trunk/src/VBox/Main/testcase/tstUnattendedScript-1.expected

    r102416 r102534  
    313101=vboxuser
    323202=changeme
    33 03=changeme
     3303=adminpw
    343404=VBox & VBox;
    353505=911
     
    757501=vboxuser
    767602=changeme
    77 03=changeme
     7703=adminpw
    787804=VBox & VBox;
    797905=911
     
    11911901=vboxuser
    12012002=changeme
    121 03=changeme
     12103=adminpw
    12212204='VBox & VBox;'
    12312305=911
     
    16316301=vboxuser
    16416402=changeme
    165 03=changeme
     16503=adminpw
    16616604='VBox & VBox;'
    16716705=911
     
    20720701=vboxuser
    20820802=changeme
    209 03=changeme
     20903=adminpw
    21021004=VBox &amp; VBox;
    21121105=911
     
    25125101=vboxuser
    25225202=changeme
    253 03=changeme
     25303=adminpw
    25425404=VBox &amp; VBox;
    25525505=911
     
    29529501=vboxuser
    29629602=changeme
    297 03=changeme
     29703=adminpw
    29829804=VBox &amp; VBox;
    29929905=911
     
    33933901=vboxuser
    34034002=changeme
    341 03=changeme
     34103=adminpw
    34234204=VBox &amp; VBox;
    34334305=911
     
    384384
    385385/*
    386  * SHAcrypt 512. Contains the word "changeme" as hashed results.
     386 * SHAcrypt 512. Contains the word "changeme" (01) and "adminpw" (02) as hashed results.
    387387 * Note: This uses a fixed salt ("testcase123") within UnattendedScript.cpp, so that we can compare the outputs.
    388388 */
    38938901=$6$testcase123$AtdiLq2Dp.l/NRkh9/9Ai6Eapd6d0bGxCOmqErpuGa4unRjiohzK5YERWtLHKvAYx26X0YhIrgSFRimkaLToI1
    390 02=$6$testcase123$AtdiLq2Dp.l/NRkh9/9Ai6Eapd6d0bGxCOmqErpuGa4unRjiohzK5YERWtLHKvAYx26X0YhIrgSFRimkaLToI1
    391 
     39002=$6$testcase123$.ul/vC02q6oasrgQH/gqtOwHCo0jALPhIY63uypm0Mb2kJeDT0yedResX/mMNVZkm0fuMj24tpxs9gMAm7sEC0
     391
  • trunk/src/VBox/Main/testcase/tstUnattendedScript-1.template

    r102416 r102534  
    384384
    385385/*
    386  * SHAcrypt 512. Contains the word "changeme" as hashed results.
     386 * SHAcrypt 512. Contains the word "changeme" (01) and "adminpw" (02) as hashed results.
    387387 * Note: This uses a fixed salt ("testcase123") within UnattendedScript.cpp, so that we can compare the outputs.
    388388 */
  • trunk/src/VBox/Main/testcase/tstUnattendedScript.cpp

    r102381 r102534  
    5959{
    6060    mStrUser                            = "vboxuser";
    61     mStrPassword                        = "changeme";
     61    mStrUserPassword                    = "changeme";
     62    mStrAdminPassword                   = "adminpw";
    6263    mStrFullUserName                    = "VBox & VBox;";
    6364    mStrProductKey                      = "911";
     
    168169}
    169170
    170 HRESULT Unattended::getPassword(com::Utf8Str &password)
     171HRESULT Unattended::getUserPassword(com::Utf8Str &password)
    171172{
    172173    RT_NOREF(password);
     
    174175}
    175176
    176 HRESULT Unattended::setPassword(const com::Utf8Str &password)
     177HRESULT Unattended::setUserPassword(const com::Utf8Str &password)
     178{
     179    RT_NOREF(password);
     180    return E_NOTIMPL;
     181}
     182
     183HRESULT Unattended::getAdminPassword(com::Utf8Str &password)
     184{
     185    RT_NOREF(password);
     186    return E_NOTIMPL;
     187}
     188
     189HRESULT Unattended::setAdminPassword(const com::Utf8Str &password)
    177190{
    178191    RT_NOREF(password);
     
    544557}
    545558
    546 Utf8Str const &Unattended::i_getPassword() const
    547 {
    548     return mStrPassword;
     559Utf8Str const &Unattended::i_getUserPassword() const
     560{
     561    return mStrUserPassword;
     562}
     563
     564Utf8Str const &Unattended::i_getAdminPassword() const
     565{
     566    /* If no Administrator / 'root' password is being set, the user password will be used instead.
     567     * Also see API documentation. */
     568    return mStrAdminPassword.isEmpty() ? mStrUserPassword : mStrAdminPassword;
    549569}
    550570
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