VirtualBox

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


Ignore:
Timestamp:
Jul 1, 2024 11:27:59 PM (10 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
163708
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

    r105018 r105087  
    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

    r105018 r105087  
    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
     
    100102 *  @param aAutoMountPoint Where the guest should try auto mount it.
    101103 *  @param fFailOnError Whether to fail with an error if the shared folder path is bad.
     104 *  @param enmSymlinkPolicy The symbolic link creation policy to apply.
    102105 *
    103106 *  @return          COM result indicator
     
    109112                           bool aAutoMount,
    110113                           const Utf8Str &aAutoMountPoint,
    111                            bool fFailOnError)
     114                           bool fFailOnError,
     115                           SymlinkPolicy_T enmSymlinkPolicy)
    112116{
    113117    /* Enclose the state transition NotReady->InInit->Ready */
     
    117121    unconst(mMachine) = aMachine;
    118122
    119     HRESULT hrc = i_protectedInit(aMachine, aName, aHostPath, aWritable, aAutoMount, aAutoMountPoint, fFailOnError);
     123    HRESULT hrc = i_protectedInit(aMachine, aName, aHostPath, aWritable, aAutoMount, aAutoMountPoint, fFailOnError,
     124                                  enmSymlinkPolicy);
    120125
    121126    /* Confirm a successful initialization when it's the case */
     
    152157                                  aThat->m->fAutoMount,
    153158                                  aThat->m->strAutoMountPoint,
    154                                   false /* fFailOnError */ );
     159                                  false /* fFailOnError */,
     160                                  aThat->m->enmSymlinkPolicy);
    155161
    156162    /* Confirm a successful initialization when it's the case */
     
    214220                                      bool aAutoMount,
    215221                                      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));
     222                                      bool fFailOnError,
     223                                      SymlinkPolicy_T enmSymlinkPolicy)
     224{
     225    LogFlowThisFunc(("aName={%s}, aHostPath={%s}, aWritable={%d}, aAutoMount={%d} enmSymlinkPolicy={%d}\n",
     226                      aName.c_str(), aHostPath.c_str(), aWritable, aAutoMount, enmSymlinkPolicy));
    220227
    221228    ComAssertRet(aParent && aName.isNotEmpty() && aHostPath.isNotEmpty(), E_INVALIDARG);
     
    271278    m->fAutoMount = aAutoMount;
    272279    unconst(m->strAutoMountPoint) = aAutoMountPoint;
     280    m->enmSymlinkPolicy = enmSymlinkPolicy;
    273281
    274282    return S_OK;
     
    385393}
    386394
     395HRESULT SharedFolder::getSymlinkPolicy(SymlinkPolicy_T *aSymlinkPolicy)
     396{
     397    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     398    *aSymlinkPolicy = m->enmSymlinkPolicy;
     399    return S_OK;
     400}
     401
     402HRESULT SharedFolder::setSymlinkPolicy(SymlinkPolicy_T aSymlinkPolicy)
     403{
     404    switch (aSymlinkPolicy)
     405    {
     406        case SymlinkPolicy_AllowedToAnyTarget:
     407        case SymlinkPolicy_AllowedInShareSubtree:
     408        case SymlinkPolicy_AllowedToRelativeTargets:
     409        case SymlinkPolicy_Forbidden:
     410            break;
     411        default:
     412            return setError(E_INVALIDARG, tr("The symbolic link policy specified (%d) is invalid."), aSymlinkPolicy);
     413    }
     414
     415    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     416    m->enmSymlinkPolicy = aSymlinkPolicy;
     417    return S_OK;
     418}
    387419
    388420const Utf8Str& SharedFolder::i_getName() const
     
    411443}
    412444
     445const SymlinkPolicy_T SharedFolder::i_getSymlinkPolicy() const
     446{
     447    return m->enmSymlinkPolicy;
     448}
     449
    413450/* 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