VirtualBox

Changeset 92880 in vbox for trunk/src/VBox/Main/src-client


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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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    {
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