VirtualBox

Changeset 105016 in vbox for trunk/src/VBox/Main/src-all


Ignore:
Timestamp:
Jun 25, 2024 10:28:21 AM (11 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
163634
Message:

doc/manual,include/VBox,Frontends/VBoxManage,HostServices/SharedFolders,
Main/{include,SharedFolder,Console,Machine,VirtualBox.xidl}: Add a
new attribute to ISharedFolder for specifying a symbolic link creation
policy to restrict the source pathname when creating symbolic links
within a guest. The symbolic link policies are represented by a new
enumeration of type SymlinkPolicy_T which includes values for no
restrictions ('any'), symlink sources only within the subtree of the
share ('subtree'), symlink sources as any relative path ('relative'),
and no symlinks allowed ('forbidden'). The symlink policy can only be
applied to permanent shared folders at this stage. bugref:10619

Location:
trunk/src/VBox/Main/src-all
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-all/ConsoleSharedFolderImpl.cpp

    r98342 r105016  
    4444    Data()
    4545    : fWritable(false),
    46       fAutoMount(false)
     46      fAutoMount(false),
     47      enmSymlinkPolicy(SymlinkPolicy_None)
    4748    { }
    4849
     
    5354    const Utf8Str   strAutoMountPoint;
    5455    Utf8Str         strLastAccessError;
     56    SymlinkPolicy_T enmSymlinkPolicy;
    5557};
    5658
     
    305307}
    306308
     309HRESULT ConsoleSharedFolder::getSymlinkPolicy(SymlinkPolicy_T *aSymlinkPolicy)
     310{
     311    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     312    *aSymlinkPolicy = m->enmSymlinkPolicy;
     313    return S_OK;
     314}
     315
     316HRESULT ConsoleSharedFolder::setSymlinkPolicy(SymlinkPolicy_T aSymlinkPolicy)
     317{
     318    RT_NOREF(aSymlinkPolicy);
     319    return E_NOTIMPL;
     320}
    307321
    308322const Utf8Str& ConsoleSharedFolder::i_getName() const
     
    331345}
    332346
     347const SymlinkPolicy_T ConsoleSharedFolder::i_getSymlinkPolicy() const
     348{
     349    return m->enmSymlinkPolicy;
     350}
     351
    333352/* vi: set tabstop=4 shiftwidth=4 expandtab: */
  • trunk/src/VBox/Main/src-all/SharedFolderImpl.cpp

    r98341 r105016  
    4646    Data()
    4747    : fWritable(false),
    48       fAutoMount(false)
     48      fAutoMount(false),
     49      enmSymlinkPolicy(SymlinkPolicy_None)
    4950    { }
    5051
     
    5556    const Utf8Str   strAutoMountPoint;
    5657    Utf8Str         strLastAccessError;
     58    SymlinkPolicy_T enmSymlinkPolicy;
    5759};
    5860
     
    109111                           bool aAutoMount,
    110112                           const Utf8Str &aAutoMountPoint,
    111                            bool fFailOnError)
     113                           bool fFailOnError,
     114                           SymlinkPolicy_T enmSymlinkPolicy)
    112115{
    113116    /* Enclose the state transition NotReady->InInit->Ready */
     
    117120    unconst(mMachine) = aMachine;
    118121
    119     HRESULT hrc = i_protectedInit(aMachine, aName, aHostPath, aWritable, aAutoMount, aAutoMountPoint, fFailOnError);
     122    HRESULT hrc = i_protectedInit(aMachine, aName, aHostPath, aWritable, aAutoMount, aAutoMountPoint, fFailOnError,
     123                                  enmSymlinkPolicy);
    120124
    121125    /* Confirm a successful initialization when it's the case */
     
    152156                                  aThat->m->fAutoMount,
    153157                                  aThat->m->strAutoMountPoint,
    154                                   false /* fFailOnError */ );
     158                                  false /* fFailOnError */,
     159                                  aThat->m->enmSymlinkPolicy);
    155160
    156161    /* Confirm a successful initialization when it's the case */
     
    214219                                      bool aAutoMount,
    215220                                      const Utf8Str &aAutoMountPoint,
    216                                       bool fFailOnError)
    217 {
    218     LogFlowThisFunc(("aName={%s}, aHostPath={%s}, aWritable={%d}, aAutoMount={%d}\n",
    219                       aName.c_str(), aHostPath.c_str(), aWritable, aAutoMount));
     221                                      bool fFailOnError,
     222                                      SymlinkPolicy_T enmSymlinkPolicy)
     223{
     224    LogFlowThisFunc(("aName={%s}, aHostPath={%s}, aWritable={%d}, aAutoMount={%d} enmSymlinkPolicy={%d}\n",
     225                      aName.c_str(), aHostPath.c_str(), aWritable, aAutoMount, enmSymlinkPolicy));
    220226
    221227    ComAssertRet(aParent && aName.isNotEmpty() && aHostPath.isNotEmpty(), E_INVALIDARG);
     
    271277    m->fAutoMount = aAutoMount;
    272278    unconst(m->strAutoMountPoint) = aAutoMountPoint;
     279    m->enmSymlinkPolicy = enmSymlinkPolicy;
    273280
    274281    return S_OK;
     
    385392}
    386393
     394HRESULT SharedFolder::getSymlinkPolicy(SymlinkPolicy_T *aSymlinkPolicy)
     395{
     396    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     397    *aSymlinkPolicy = m->enmSymlinkPolicy;
     398    return S_OK;
     399}
     400
     401HRESULT SharedFolder::setSymlinkPolicy(SymlinkPolicy_T aSymlinkPolicy)
     402{
     403    switch (aSymlinkPolicy)
     404    {
     405        case SymlinkPolicy_AllowedToAnyTarget:
     406        case SymlinkPolicy_AllowedInShareSubtree:
     407        case SymlinkPolicy_AllowedToRelativeTargets:
     408        case SymlinkPolicy_Forbidden:
     409            break;
     410        default:
     411            return setError(E_INVALIDARG, tr("The symbolic link policy specified (%d) is invalid."), aSymlinkPolicy);
     412    }
     413
     414    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     415    m->enmSymlinkPolicy = aSymlinkPolicy;
     416    return S_OK;
     417}
    387418
    388419const Utf8Str& SharedFolder::i_getName() const
     
    411442}
    412443
     444const SymlinkPolicy_T SharedFolder::i_getSymlinkPolicy() const
     445{
     446    return m->enmSymlinkPolicy;
     447}
     448
    413449/* vi: set tabstop=4 shiftwidth=4 expandtab: */
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