VirtualBox

Changeset 92880 in vbox


Ignore:
Timestamp:
Dec 13, 2021 11:16:44 AM (3 years ago)
Author:
vboxsync
Message:

Guest Control/Main: Resolved @todo: Implemented mode handling and secure bit of GuestSession::directoryCreateTemp(), added testcases.

Location:
trunk/src/VBox
Files:
4 edited

Legend:

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

    r92853 r92880  
    1436914369          OS.
    1437014370
    14371           This parameter is ignore if the @a secure parameter is set to @c true.
     14371          This parameter is ignored if the @a secure parameter is set to @c true.
    1437214372          <note>It is strongly recommended to use 0700.</note>
    1437314373        </desc>
  • trunk/src/VBox/Main/include/GuestSessionImpl.h

    r92878 r92880  
    303303    int                     i_fileQuerySize(const Utf8Str &strPath, bool fFollowSymlinks, int64_t *pllSize, int *pGuestRc);
    304304    int                     i_fsCreateTemp(const Utf8Str &strTemplate, const Utf8Str &strPath, bool fDirectory,
    305                                            Utf8Str &strName, int *pGuestRc);
     305                                           Utf8Str &strName, uint32_t fMode, bool fSecure, int *pGuestRc);
    306306    int                     i_fsQueryInfo(const Utf8Str &strPath, bool fFollowSymlinks, GuestFsObjData &objData, int *pGuestRc);
    307307    const GuestCredentials &i_getCredentials(void);
  • trunk/src/VBox/Main/src-client/GuestSessionImpl.cpp

    r92879 r92880  
    10821082}
    10831083
     1084/**
     1085 * Creates a temporary directory / file on the guest.
     1086 *
     1087 * @returns VBox status code.
     1088 * @returns VERR_GSTCTL_GUEST_ERROR on received guest error.
     1089 * @param   strTemplate         Name template to use.
     1090 *                              \sa RTDirCreateTemp / RTDirCreateTempSecure.
     1091 * @param   strPath             Path where to create the temporary directory / file.
     1092 * @param   fDirectory          Whether to create a temporary directory or file.
     1093 * @param   strName             Where to return the created temporary name on success.
     1094 * @param   fMode               File mode to use for creation (octal).
     1095 * @param   fSecure             Whether to perform a secure creation or not.
     1096 * @param   prcGuest            Guest rc, when returning VERR_GSTCTL_GUEST_ERROR.
     1097 */
    10841098int GuestSession::i_fsCreateTemp(const Utf8Str &strTemplate, const Utf8Str &strPath, bool fDirectory, Utf8Str &strName,
    1085                                  int *prcGuest)
     1099                                 uint32_t fMode, bool fSecure, int *prcGuest)
    10861100{
    10871101    AssertPtrReturn(prcGuest, VERR_INVALID_POINTER);
    10881102
    1089     LogFlowThisFunc(("strTemplate=%s, strPath=%s, fDirectory=%RTbool\n",
    1090                      strTemplate.c_str(), strPath.c_str(), fDirectory));
     1103    LogFlowThisFunc(("strTemplate=%s, strPath=%s, fDirectory=%RTbool, fMode=%o, fSecure=%RTbool\n",
     1104                     strTemplate.c_str(), strPath.c_str(), fDirectory, fMode, fSecure));
    10911105
    10921106    GuestProcessStartupInfo procInfo;
     
    11031117            procInfo.mArguments.push_back(Utf8Str("-t"));
    11041118            procInfo.mArguments.push_back(strPath);
     1119        }
     1120        /* Note: Secure flag and mode cannot be specified at the same time. */
     1121        if (fSecure)
     1122        {
     1123            procInfo.mArguments.push_back(Utf8Str("--secure"));
     1124        }
     1125        else
     1126        {
     1127            procInfo.mArguments.push_back(Utf8Str("--mode"));
     1128            procInfo.mArguments.push_back(Utf8Str("%o", fMode)); /* Octal mode. */
    11051129        }
    11061130        procInfo.mArguments.push_back("--"); /* strTemplate could be '--help'. */
     
    34373461                                          BOOL aSecure, com::Utf8Str &aDirectory)
    34383462{
    3439     RT_NOREF(aMode, aSecure); /** @todo r=bird: WTF? */
    3440 
    34413463    if (RT_UNLIKELY((aTemplateName.c_str()) == NULL || *(aTemplateName.c_str()) == '\0'))
    34423464        return setError(E_INVALIDARG, tr("No template specified"));
    34433465    if (RT_UNLIKELY((aPath.c_str()) == NULL || *(aPath.c_str()) == '\0'))
    34443466        return setError(E_INVALIDARG, tr("No directory name specified"));
     3467    if (!aSecure) /* Ignore what mode is specified when a secure temp thing needs to be created. */
     3468        if (RT_UNLIKELY(!(aMode & ~07777)))
     3469            return setError(E_INVALIDARG, tr("Mode invalid (must be specified in octal mode)"));
    34453470
    34463471    HRESULT hrc = i_isStartedExternal();
     
    34513476
    34523477    int rcGuest = VERR_IPE_UNINITIALIZED_STATUS;
    3453     int vrc = i_fsCreateTemp(aTemplateName, aPath, true /* Directory */, aDirectory, &rcGuest);
     3478    int vrc = i_fsCreateTemp(aTemplateName, aPath, true /* Directory */, aDirectory, aMode, RT_BOOL(aSecure), &rcGuest);
    34543479    if (!RT_SUCCESS(vrc))
    34553480    {
  • trunk/src/VBox/ValidationKit/tests/additions/tdAddGuestCtrl.py

    r92877 r92880  
    35423542              tdTestResultFailure() ],
    35433543            [ tdTestDirCreateTemp(sTemplate = 'tmpXXXtst', sDirectory = self.oTstDrv.getGuestTempDir(oTestVm)),
    3544                tdTestResultFailure() ],
    3545             ## @todo test fSecure and pass weird fMode values once these parameters are implemented in the API.
     3544              tdTestResultFailure() ],
    35463545        ];
     3546
     3547        if self.oTstDrv.fpApiVer >= 7.0:
     3548            # Weird mode set.
     3549            atTests.extend([
     3550                [ tdTestDirCreateTemp(sTemplate = 'XXX', sDirectory = self.oTstDrv.getGuestTempDir(oTestVm), fMode = 0o42333),
     3551                  tdTestResultFailure() ]
     3552            ]);
     3553            # Same as working stuff above, but with a different mode set.
     3554            atTests.extend([
     3555                [ tdTestDirCreateTemp(sTemplate = 'X', sDirectory = self.oTstDrv.getGuestTempDir(oTestVm), fMode = 0o777),
     3556                  tdTestResultFailure() ],
     3557                [ tdTestDirCreateTemp(sTemplate = 'XX', sDirectory = self.oTstDrv.getGuestTempDir(oTestVm), fMode = 0o777),
     3558                  tdTestResultFailure() ],
     3559                [ tdTestDirCreateTemp(sTemplate = 'XXX', sDirectory = self.oTstDrv.getGuestTempDir(oTestVm), fMode = 0o777),
     3560                  tdTestResultFailure() ],
     3561                [ tdTestDirCreateTemp(sTemplate = 'XXXXXXX', sDirectory = self.oTstDrv.getGuestTempDir(oTestVm), fMode = 0o777),
     3562                  tdTestResultFailure() ],
     3563                [ tdTestDirCreateTemp(sTemplate = 'tmpXXXtst', sDirectory = self.oTstDrv.getGuestTempDir(oTestVm), fMode = 0o777),
     3564                  tdTestResultFailure() ],
     3565                [ tdTestDirCreateTemp(sTemplate = 'tmpXXXtst', sDirectory = self.oTstDrv.getGuestTempDir(oTestVm), fMode = 0o777),
     3566                  tdTestResultFailure() ],
     3567                [ tdTestDirCreateTemp(sTemplate = 'tmpXXXtst', sDirectory = self.oTstDrv.getGuestTempDir(oTestVm), fMode = 0o777),
     3568                  tdTestResultFailure() ]
     3569            ]);
     3570            # Same as working stuff above, but with secure mode set.
     3571            atTests.extend([
     3572                [ tdTestDirCreateTemp(sTemplate = 'X', sDirectory = self.oTstDrv.getGuestTempDir(oTestVm), fSecure = True),
     3573                  tdTestResultFailure() ],
     3574                [ tdTestDirCreateTemp(sTemplate = 'XX', sDirectory = self.oTstDrv.getGuestTempDir(oTestVm), fSecure = True),
     3575                  tdTestResultFailure() ],
     3576                [ tdTestDirCreateTemp(sTemplate = 'XXX', sDirectory = self.oTstDrv.getGuestTempDir(oTestVm), fSecure = True),
     3577                  tdTestResultFailure() ],
     3578                [ tdTestDirCreateTemp(sTemplate = 'XXXXXXX', sDirectory = self.oTstDrv.getGuestTempDir(oTestVm), fSecure = True),
     3579                  tdTestResultFailure() ],
     3580                [ tdTestDirCreateTemp(sTemplate = 'tmpXXXtst', sDirectory = self.oTstDrv.getGuestTempDir(oTestVm),
     3581                                      fSecure = True),
     3582                  tdTestResultFailure() ],
     3583                [ tdTestDirCreateTemp(sTemplate = 'tmpXXXtst', sDirectory = self.oTstDrv.getGuestTempDir(oTestVm),
     3584                                      fSecure = True),
     3585                  tdTestResultFailure() ],
     3586                [ tdTestDirCreateTemp(sTemplate = 'tmpXXXtst', sDirectory = self.oTstDrv.getGuestTempDir(oTestVm),
     3587                                      fSecure = True),
     3588                  tdTestResultFailure() ]
     3589            ]);
    35473590
    35483591        fRc = True;
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