VirtualBox

Changeset 55590 in vbox


Ignore:
Timestamp:
May 1, 2015 8:24:07 PM (10 years ago)
Author:
vboxsync
Message:

Main: Removed IGuestSession::environmentClear because it duplicates the writable IGuestSession::environment attribute. Removed IGuestSession::environmentGet because it's not capable of returning empty value and variables scheduled for unsetting, and it could very easily mislead anyone into thinking you can use it to get useful thing like 'windir' and 'TEMP' from the guest.

Location:
trunk/src/VBox
Files:
4 edited

Legend:

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

    r55586 r55590  
    1078310783  <interface
    1078410784    name="IGuestSession" extends="$unknown"
    10785     uuid="c899776d-41f7-7aee-7056-4bac979d58b7"
     10785    uuid="e1fa83fe-437d-3e3a-9278-4297f1ca95dd"
    1078610786    wsmap="managed"
    1078710787    >
     
    1110711107      <param name="acl" type="wstring" dir="in">
    1110811108        <desc>Actual ACL string to set. Must comply with the guest OS.</desc>
    11109       </param>
    11110     </method>
    11111 
    11112 <!-- r=bird: Remove this it duplicates the 'environment' attribute. -->
    11113     <method name="environmentClear">
    11114       <desc>
    11115         Clears (deletes) all session environment variables.
    11116 
    11117         <result name="VBOX_E_IPRT_ERROR">
    11118 <!-- r=bird: No, it won't return this result, because you're just doing .clear() on a vector. -->
    11119           Error while clearing the session environment variables.
    11120         </result>
    11121       </desc>
    11122     </method>
    11123 
    11124     <method name="environmentGet">
    11125 <!-- r=bird: Remove this because the interface isn't suitable for returning
    11126 'unset' or empty values, and it can easily be misunderstood.  Besides there is
    11127 hardly a usecase for it as long as it just works on environment changes and
    11128 there is the 'environment' attribute. -->
    11129       <desc>
    11130         Gets the value of an environment variable scheduled to be set.
    11131 
    11132         <result name="VBOX_E_IPRT_ERROR">
    11133 <!-- r=bird: Would never return this, only invalid input or out of memory. -->
    11134           Error while getting the value of the session environment variable.
    11135         </result>
    11136       </desc>
    11137       <param name="name" type="wstring" dir="in">
    11138         <desc>Name of session environment variable to get the value for.</desc>
    11139       </param>
    11140       <param name="value" type="wstring" dir="return">
    11141         <desc>
    11142           Value of the session environment variable specified.  If this variable
    11143           does not exist an empty value will be returned.
    11144           <note>
    11145             An empty value will also be return for a variable with an value or
    11146             a unset-variable entry.
    11147           </note>
    11148         </desc>
    1114911109      </param>
    1115011110    </method>
  • trunk/src/VBox/Main/include/GuestSessionImpl.h

    r55588 r55590  
    312312    HRESULT directorySetACL(const com::Utf8Str &aPath,
    313313                             const com::Utf8Str &aAcl);
    314     HRESULT environmentClear();
    315     HRESULT environmentGet(const com::Utf8Str &aName,
    316                            com::Utf8Str &aValue);
    317314    HRESULT environmentSet(const com::Utf8Str &aName,
    318315                           const com::Utf8Str &aValue);
  • trunk/src/VBox/Main/src-client/GuestSessionImpl.cpp

    r55588 r55590  
    29042904}
    29052905
    2906 /** @todo remove this it duplicates the 'environment' attribute.   */
    2907 HRESULT GuestSession::environmentClear()
    2908 {
    2909 #ifndef VBOX_WITH_GUEST_CONTROL
    2910     ReturnComNotImplemented();
    2911 #else
    2912     LogFlowThisFuncEnter();
    2913 
    2914     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    2915 
    2916     mData.mEnvironment.reset();
    2917 
    2918     LogFlowThisFuncLeave();
    2919     return S_OK;
    2920 #endif /* VBOX_WITH_GUEST_CONTROL */
    2921 }
    2922 
    2923 /** @todo Remove this because the interface isn't suitable for returning 'unset'
    2924  *        or empty values, and it can easily be misunderstood.  Besides there
    2925  *        is hardly a usecase for it as long as it just works on
    2926  *        environment changes and there is the 'environment' attribute. */
    2927 HRESULT GuestSession::environmentGet(const com::Utf8Str &aName, com::Utf8Str &aValue)
    2928 {
    2929 #ifndef VBOX_WITH_GUEST_CONTROL
    2930     ReturnComNotImplemented();
    2931 #else
    2932     LogFlowThisFuncEnter();
    2933 
    2934     HRESULT hrc;
    2935     if (RT_LIKELY(aName.isNotEmpty()))
    2936     {
    2937         if (RT_LIKELY(strchr(aName.c_str(), '=') == NULL))
    2938         {
    2939             AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    2940 
    2941             mData.mEnvironment.getVariable(aName, &aValue);
    2942             hrc = S_OK;
    2943         }
    2944         else
    2945             hrc = setError(E_INVALIDARG, tr("The equal char is not allowed in environment variable names"));
    2946     }
    2947     else
    2948         hrc = setError(E_INVALIDARG, tr("No variable name specified"));
    2949 
    2950     LogFlowThisFuncLeave();
    2951     return hrc;
    2952 #endif /* VBOX_WITH_GUEST_CONTROL */
    2953 }
    2954 
    29552906HRESULT GuestSession::environmentSet(const com::Utf8Str &aName, const com::Utf8Str &aValue)
    29562907{
  • trunk/src/VBox/ValidationKit/tests/additions/tdAddGuestCtrl.py

    r55535 r55590  
    11341134                break;
    11351135            try:
    1136                 for (_, aEnv) in enumerate(curTest.aEnv): # Enumerate only will work with a sequence (e.g > 1 entries).
     1136                for (_, aEnv) in enumerate(curTest.aEnv):
    11371137                    aElems = aEnv.split('=');
    1138                     strKey = '';
     1138                    strKey = '';  ## @todo s/Key/Var/g
    11391139                    strValue = '';
    11401140                    if len(aElems) > 0:
     
    11421142                    if len(aElems) == 2:
    11431143                        strValue = aElems[1];
    1144                     reporter.log2('Test #%d: Single key="%s", value="%s" (%d) ...' \
     1144                    reporter.log2('Test #%d: Single var="%s", value="%s" (%d) ...' \
    11451145                                  % (i, strKey, strValue, len(aElems)));
    11461146                    try:
     
    11571157                        else:
    11581158                            reporter.log('Test #%d: API reported an error (single), good' % (i,));
    1159                     reporter.log2('Getting key="%s" ...' % (strKey,));
    1160                     try:
    1161                         strValue2 = curGuestSession.environmentGet(strKey);
    1162                         if      strKey.isalnum() \
    1163                             and strValue != strValue2:
    1164                             reporter.error('Test #%d failed: Got environment variable "%s", expected "%s" (key: "%s")' \
    1165                                            % (i, strValue2, strValue, strKey));
    1166                             fRc = False;
    1167                             break;
    1168                         # Getting back an empty value when specifying an invalid key is fine.
    1169                         reporter.log2('Got key "%s=%s"' % (strKey, strValue2));
    1170                     except UnicodeDecodeError: # Might happen on unusal values, fine.
    1171                         if strValue != strValue2:
    1172                             reporter.error('Test #%d failed: Got (undecoded) environment variable "%s", ' \
    1173                                            'expected "%s" (key: "%s")' \
    1174                                            % (i, strValue2, strValue, strKey));
    1175                             fRc = False;
    1176                             break;
    1177                     except:
    1178                         if     strKey == "" \
    1179                             or not strKey.isalnum():
    1180                             reporter.log('Test #%d: API reported an error (invalid key "%s"), good' % (i, strKey));
    1181                         else:
    1182                             reporter.errorXcpt('Test #%d failed: Getting environment variable:' % (i));
     1159                    ## @todo environmentGet() has been removed in 5.0 because it's not up to the task of returning all the
     1160                    ## putenv strings forms and gives the impression that the envrionment is something it isn't. This test
     1161                    ## should be rewritten using the attribute.  What's more, there should be an Unset test here, shouldn't
     1162                    ## there?
     1163                    #
     1164                    #reporter.log2('Getting key="%s" ...' % (strKey,));
     1165                    #try:
     1166                    #    strValue2 = curGuestSession.environmentGet(strKey);
     1167                    #    if      strKey.isalnum() \
     1168                    #        and strValue != strValue2:
     1169                    #        reporter.error('Test #%d failed: Got environment value "%s", expected "%s" (var: "%s")' \
     1170                    #                       % (i, strValue2, strValue, strKey));
     1171                    #        fRc = False;
     1172                    #        break;
     1173                    #    # Getting back an empty value when specifying an invalid key is fine.
     1174                    #    reporter.log2('Got key "%s=%s"' % (strKey, strValue2));
     1175                    #except UnicodeDecodeError: # Might happen on unusal values, fine.
     1176                    #    if strValue != strValue2:
     1177                    #        reporter.error('Test #%d failed: Got (undecoded) environment variable "%s", ' \
     1178                    #                       'expected "%s" (var: "%s")' \
     1179                    #                       % (i, strValue2, strValue, strKey));
     1180                    #        fRc = False;
     1181                    #        break;
     1182                    #except:
     1183                    #    if     strKey == "" \
     1184                    #        or not strKey.isalnum():
     1185                    #        reporter.log('Test #%d: API reported an error (invalid key "%s"), good' % (i, strKey));
     1186                    #    else:
     1187                    #        reporter.errorXcpt('Test #%d failed: Getting environment variable:' % (i));
    11831188                if fRc is False:
    11841189                    continue;
     
    12091214                    fRc = False;
    12101215                    break;
    1211                 curGuestSession.environmentClear(); # No return (e.g. boolean) value available thru wrapper.
     1216
     1217                self.oTstDrv.oVBoxMgr.setArray(curGuestSession, 'environment', []);
    12121218                curEnv = self.oTstDrv.oVBoxMgr.getArray(curGuestSession, 'environment');
    12131219                if len(curEnv) is not 0:
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