VirtualBox

Changeset 40130 in vbox


Ignore:
Timestamp:
Feb 14, 2012 3:17:35 PM (13 years ago)
Author:
vboxsync
Message:

Main/webservice+doc/manual: Add SSL support to the webservice, and also add an optional parameter which ensures the authentication setting is correct. Update manual and SDK reference.

Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Config.kmk

    r39955 r40130  
    88
    99#
    10 # Copyright (C) 2006-2011 Oracle Corporation
     10# Copyright (C) 2006-2012 Oracle Corporation
    1111#
    1212# This file is part of VirtualBox Open Source Edition (OSE), as
     
    483483# The webservices api.
    484484VBOX_WITH_WEBSERVICES = 1
     485VBOX_WITH_WEBSERVICES_SSL = 1
    485486# The Qt 4 GUI.
    486487VBOX_WITH_QTGUI = 1
  • trunk/doc/manual/docbook2latex.xsl

    r37524 r40130  
    1919        by this XSLT (see below).
    2020
    21      Copyright (C) 2006-2010 Oracle Corporation
     21     Copyright (C) 2006-2012 Oracle Corporation
    2222
    2323     This file is part of VirtualBox Open Source Edition (OSE), as
     
    585585            <xsl:with-param name="text" select="$subst6" />
    586586            <xsl:with-param name="replace" select="'~'" />
    587             <xsl:with-param name="with" select="'\~'" />
     587            <xsl:with-param name="with" select="'\textasciitilde '" />
    588588            <xsl:with-param name="disable-output-escaping" select="no" />
    589589          </xsl:call-template>
     
    676676            <xsl:with-param name="text" select="$subst8" />
    677677            <xsl:with-param name="replace" select="'~'" />
    678             <xsl:with-param name="with" select="'\~'" />
     678            <xsl:with-param name="with" select="'\textasciitilde '" />
    679679            <xsl:with-param name="disable-output-escaping" select="no" />
    680680          </xsl:call-template>
  • trunk/doc/manual/en_US/SDKRef.xml

    r39852 r40130  
    293293          binary package for your specific platform. Since the SDK contains
    294294          only platform-independent text files and documentation, the binaries
    295           are instead shipped with the platform-specific packages.</para>
     295          are instead shipped with the platform-specific packages. For this
     296          reason the information how to run it as a service is included in the
     297          VirtualBox documentation.</para>
    296298        </note></para>
    297299
     
    340342            <computeroutput>-p</computeroutput>): This specifies which port to
    341343            bind to on the host and defaults to 18083.</para>
     344          </listitem>
     345
     346          <listitem>
     347            <para><computeroutput>--ssl</computeroutput> (or
     348            <computeroutput>-s</computeroutput>): This enables SSL support.</para>
     349          </listitem>
     350
     351          <listitem>
     352            <para><computeroutput>--keyfile</computeroutput> (or
     353            <computeroutput>-K</computeroutput>): This specifies the file name
     354            containing the server private key and the certificate. This is a
     355            mandatory parameter if SSL is enabled.</para>
     356          </listitem>
     357
     358          <listitem>
     359            <para><computeroutput>--passwordfile</computeroutput> (or
     360            <computeroutput>-a</computeroutput>): This specifies the file name
     361            containing the password for the server private key. If unspecified
     362            or an empty string is specified this is interpreted as an empty
     363            password (i.e. the private key is not protected by a password). If
     364            the file name <computeroutput>-</computeroutput> is specified then
     365            then the password is read from the standard input stream, otherwise
     366            from the specified file. The user is responsible for appropriate
     367            access rights to protect the confidential password.</para>
     368          </listitem>
     369
     370          <listitem>
     371            <para><computeroutput>--cacert</computeroutput> (or
     372            <computeroutput>-c</computeroutput>): This specifies the file name
     373            containing the CA certificate appropriate for the server
     374            certificate.</para>
     375          </listitem>
     376
     377          <listitem>
     378            <para><computeroutput>--capath</computeroutput> (or
     379            <computeroutput>-C</computeroutput>): This specifies the directory
     380            containing several CA certificates appropriate for the server
     381            certificate.</para>
     382          </listitem>
     383
     384          <listitem>
     385            <para><computeroutput>--dhfile</computeroutput> (or
     386            <computeroutput>-D</computeroutput>): This specifies the file name
     387            containing the DH key. Alternatively it can contain the number of
     388            bits of the DH key to generate. If left empty, RSA is used.</para>
     389          </listitem>
     390
     391          <listitem>
     392            <para><computeroutput>--randfile</computeroutput> (or
     393            <computeroutput>-r</computeroutput>): This specifies the file name
     394            containing the seed for the random number generator. If left empty,
     395            an operating system specific source of the seed.</para>
    342396          </listitem>
    343397
     
    370424
    371425          <listitem>
     426            <para><computeroutput>--threads</computeroutput> (or
     427            <computeroutput>-T</computeroutput>): This specifies the maximum
     428            number or worker threads, and defaults to 100. This normally does
     429            not need to be changed.</para>
     430          </listitem>
     431
     432          <listitem>
     433            <para><computeroutput>--keepalive</computeroutput> (or
     434            <computeroutput>-k</computeroutput>): This specifies the maximum
     435            number of requests which can be sent in one web service connection,
     436            and defaults to 100. This normally does not need to be changed.</para>
     437          </listitem>
     438
     439          <listitem>
     440            <para><computeroutput>--authentication</computeroutput> (or
     441            <computeroutput>-A</computeroutput>): This specifies the desired
     442            web service authentication method. If the parameter is not
     443            specified or the empty string is specified it does not change the
     444            authentication method, otherwise it is set to the specified value.
     445            Using this parameter is a good measure against accidental
     446            misconfiguration, as the web service ensures periodically that it
     447            isn't changed.</para>
     448          </listitem>
     449
     450          <listitem>
    372451            <para><computeroutput>--verbose</computeroutput> (or
    373452            <computeroutput>-v</computeroutput>): Normally, the web service
     
    377456            are mapped to internally, which can be useful for debugging client
    378457            programs.</para>
     458          </listitem>
     459
     460          <listitem>
     461            <para><computeroutput>--pidfile</computeroutput> (or
     462            <computeroutput>-P</computeroutput>): Name of the PID file which is
     463            created when the daemon was started.</para>
    379464          </listitem>
    380465
     
    389474            unattended and need to debug problems after they have
    390475            occurred.</para>
     476          </listitem>
     477
     478          <listitem>
     479            <para><computeroutput>--logrotate</computeroutput> (or
     480            <computeroutput>-R</computeroutput>): Number of old log files to
     481            keep, defaults to 10. Log rotation is disabled if set to 0.</para>
     482          </listitem>
     483
     484          <listitem>
     485            <para><computeroutput>--logsize</computeroutput> (or
     486            <computeroutput>-S</computeroutput>): Maximum size of log file in
     487            bytes, defaults to 100MB. Log rotation is triggered if the file
     488            grows beyond this limit.</para>
     489          </listitem>
     490
     491          <listitem>
     492            <para><computeroutput>--loginterval</computeroutput> (or
     493            <computeroutput>-I</computeroutput>): Maximum time interval to be
     494            put in a log file before rotation is triggered, in seconds, and
     495            defaults to one day.</para>
    391496          </listitem>
    392497        </itemizedlist>
     
    445550        use this variable carefully, and only if you fully understand what
    446551        you're doing.</para>
    447       </sect2>
    448 
    449       <sect2>
    450         <title>Solaris host: starting the web service via SMF</title>
    451 
    452         <para>On Solaris hosts, the VirtualBox web service daemon is
    453         integrated into the SMF framework. You can change the parameters, but
    454         don't have to if the defaults below already match your needs:<screen>svccfg -s svc:/application/virtualbox/webservice:default setprop config/host=localhost
    455 svccfg -s svc:/application/virtualbox/webservice:default setprop config/port=18083
    456 svccfg -s svc:/application/virtualbox/webservice:default setprop config/user=root</screen></para>
    457 
    458         <para>If you made any change, don't forget to run the following
    459         command to put the changes into effect immediately:<screen>svcadm refresh svc:/application/virtualbox/webservice:default</screen></para>
    460 
    461         <para>If you forget the above command then the previous settings will
    462         be used when enabling the service. Check the current property settings
    463         with:<screen>svcprop -p config svc:/application/virtualbox/webservice:default</screen></para>
    464 
    465         <para>When everything is configured correctly you can start the
    466         VirtualBox web service with the following command:<screen>svcadm enable svc:/application/virtualbox/webservice:default</screen></para>
    467 
    468         <para>For more information about SMF, please refer to the Solaris
    469         documentation.</para>
    470552      </sect2>
    471553    </sect1>
  • trunk/doc/manual/en_US/user_AdvancedTopics.xml

    r40019 r40130  
    860860        device. Read/write access is also later needed when using the image
    861861        from a virtual machine. On some host platforms (e.g. Windows Vista
    862         and later), raw disk access may be restricted and not permitted by
    863         the host OS in some situations.</para>
     862        and later), raw disk access may be restricted and not permitted by
     863        the host OS in some situations.</para>
    864864
    865865        <para>Just like with regular disk images, this does not automatically
     
    18771877    Development Kit (SDK); please see <xref linkend="VirtualBoxAPI" />. As the
    18781878    client base using this interface is growing, we added start scripts for
    1879     the various operation systems we support. The following describes how to
    1880     use them. Please be aware that the web service is never started automatically
    1881     as a result of a standard installation.<itemizedlist>
    1882         <listitem>
    1883           <para>On Mac OS X, launchd is used. An example configuration file
    1884           can be found in
    1885           <computeroutput>$HOME/Library/LaunchAgents/org.virtualbox.vboxwebsrv.plist</computeroutput>.
    1886           It can be enabled by changing the
    1887           <computeroutput>Disabled</computeroutput> key from
    1888           <computeroutput>true</computeroutput> to
    1889           <computeroutput>false</computeroutput>. To manually start the
    1890           service use the following command: <screen>launchctl load ~/Library/LaunchAgents/org.virtualbox.vboxwebsrv.plist</screen>
    1891           For additional information on how launchd services could be
    1892           configured see <literal><ulink
    1893           url="http://developer.apple.com/mac/library/documentation/MacOSX/Conceptual/BPSystemStartup/BPSystemStartup.html">http://developer.apple.com/mac/library/documentation/MacOSX/Conceptual/BPSystemStartup/BPSystemStartup.html</ulink></literal>.</para>
    1894         </listitem>
    1895         <listitem>
    1896           <para>On Linux, the web service can be automatically started during
    1897             host boot by adding appropriate parameters to the file /etc/default/virtualbox.
    1898             There is one mandatory parameter, VBOXWEB_USER which must be set to
    1899             the user which will later start the VMs.
    1900             <table>
    1901               <title>ignored</title>
    1902               <tgroup cols="2">
    1903                 <tbody>
    1904                   <row>
    1905                     <entry><emphasis role="bold">Parameter</emphasis></entry>
    1906                     <entry><emphasis role="bold">Description</emphasis></entry>
    1907                     <entry><emphasis role="bold">Default</emphasis></entry>
    1908                   </row>
    1909                   <row>
    1910                     <entry>VBOXWEB_HOST</entry>
    1911                     <entry>The host to bind the web service to</entry>
    1912                     <entry>localhost</entry>
    1913                   </row>
    1914                   <row>
    1915                     <entry>VBOXWEB_PORT</entry>
    1916                     <entry>The port to bind the web service to</entry>
    1917                     <entry>18083</entry>
    1918                   </row>
    1919                   <row>
    1920                     <entry>VBOXWEB_TIMEOUT</entry>
    1921                     <entry>Session timeout in seconds; 0 disables timeouts</entry>
    1922                     <entry>300</entry>
    1923                   </row>
    1924                   <row>
    1925                     <entry>VBOXWEB_ CHECK_INTERVAL</entry>
    1926                     <entry>Frequency of timeout checks in seconds</entry>
    1927                     <entry>5</entry>
    1928                   </row>
    1929                   <row>
    1930                     <entry>VBOXWEB_THREADS</entry>
    1931                     <entry>Maximum number of worker threads to run in parallel</entry>
    1932                     <entry>100</entry>
    1933                   </row>
    1934                   <row>
    1935                     <entry>VBOXWEB_KEEPALIVE</entry>
    1936                     <entry>Maximum number of requests before a socket will be closed</entry>
    1937                     <entry>100</entry>
    1938                   </row>
    1939                   <row>
    1940                     <entry>VBOXWEB_LOGFILE</entry>
    1941                     <entry>Name of file to write log to</entry>
    1942                     <entry><emphasis>no file</emphasis></entry>
    1943                   </row>
    1944                   <row>
    1945                     <entry>VBOXWEB_ROTATE</entry>
    1946                     <entry>Number of log files; 0 disables log rotation</entry>
    1947                     <entry>10</entry>
    1948                   </row>
    1949                   <row>
    1950                     <entry>VBOXWEB_LOGSIZE</entry>
    1951                     <entry>Maximum size of a log file in bytes to trigger rotation</entry>
    1952                     <entry>1MB</entry>
    1953                   </row>
    1954                   <row>
    1955                     <entry>VBOXWEB_LOGINTERVAL</entry>
    1956                     <entry>Maximum time interval in seconds to trigger log rotation</entry>
    1957                     <entry>1 day</entry>
    1958                   </row>
    1959                 </tbody>
    1960               </tgroup>
    1961             </table>
    1962           </para>
    1963         </listitem>
    1964       </itemizedlist></para>
     1879    the various operation systems we support. The following sections describe
     1880    how to use them. The VirtualBox web service is never started automatically
     1881    as a result of a standard installation.</para>
     1882
     1883    <sect2 id="vboxwebsrv-linux">
     1884      <title>Linux: starting the webservice via <computeroutput>init</computeroutput></title>
     1885
     1886      <para>On Linux, the web service can be automatically started during
     1887      host boot by adding appropriate parameters to the file
     1888      <computeroutput>/etc/default/virtualbox</computeroutput>.
     1889      There is one mandatory parameter, <computeroutput>VBOXWEB_USER</computeroutput>,
     1890      which must be set to the user which will later start the VMs. The
     1891      paramters in the table below all start with <computeroutput>VBOXWEB_</computeroutput>
     1892      (<computeroutput>VBOXWEB_HOST</computeroutput>,
     1893      <computeroutput>VBOXWEB_PORT</computeroutput> etc.):
     1894      <table>
     1895        <title>ignored</title>
     1896        <tgroup cols="3">
     1897          <tbody>
     1898            <row>
     1899              <entry><emphasis role="bold">Parameter</emphasis></entry>
     1900              <entry><emphasis role="bold">Description</emphasis></entry>
     1901              <entry><emphasis role="bold">Default</emphasis></entry>
     1902            </row>
     1903            <row>
     1904              <entry>USER</entry>
     1905              <entry>The user as which the web service runs</entry>
     1906              <entry></entry>
     1907            </row>
     1908            <row>
     1909              <entry>HOST</entry>
     1910              <entry>The host to bind the web service to</entry>
     1911              <entry>localhost</entry>
     1912            </row>
     1913            <row>
     1914              <entry>PORT</entry>
     1915              <entry>The port to bind the web service to</entry>
     1916              <entry>18083</entry>
     1917            </row>
     1918            <row>
     1919              <entry>SSL_KEYFILE</entry>
     1920              <entry>Server key and certificate file, PEM format</entry>
     1921              <entry></entry>
     1922            </row>
     1923            <row>
     1924              <entry>SSL_PASSWORDFILE</entry>
     1925              <entry>File name for password to server key</entry>
     1926              <entry></entry>
     1927            </row>
     1928            <row>
     1929              <entry>SSL_CACERT</entry>
     1930              <entry>CA certificate file, PEM format</entry>
     1931              <entry></entry>
     1932            </row>
     1933            <row>
     1934              <entry>SSL_CAPATH</entry>
     1935              <entry>CA certificate path</entry>
     1936              <entry></entry>
     1937            </row>
     1938            <row>
     1939              <entry>SSL_DHFILE</entry>
     1940              <entry>DH file name or DH key length in bits</entry>
     1941              <entry></entry>
     1942            </row>
     1943            <row>
     1944              <entry>SSL_RANDFILE</entry>
     1945              <entry>File containing seed for random number generator</entry>
     1946              <entry></entry>
     1947            </row>
     1948            <row>
     1949              <entry>TIMEOUT</entry>
     1950              <entry>Session timeout in seconds; 0 disables timeouts</entry>
     1951              <entry>300</entry>
     1952            </row>
     1953            <row>
     1954              <entry>CHECK_INTERVAL</entry>
     1955              <entry>Frequency of timeout checks in seconds</entry>
     1956              <entry>5</entry>
     1957            </row>
     1958            <row>
     1959              <entry>THREADS</entry>
     1960              <entry>Maximum number of worker threads to run in parallel</entry>
     1961              <entry>100</entry>
     1962            </row>
     1963            <row>
     1964              <entry>KEEPALIVE</entry>
     1965              <entry>Maximum number of requests before a socket will be closed</entry>
     1966              <entry>100</entry>
     1967            </row>
     1968            <row>
     1969              <entry>LOGFILE</entry>
     1970              <entry>Name of file to write log to</entry>
     1971              <entry></entry>
     1972            </row>
     1973            <row>
     1974              <entry>ROTATE</entry>
     1975              <entry>Number of log files; 0 disables log rotation</entry>
     1976              <entry>10</entry>
     1977            </row>
     1978            <row>
     1979              <entry>LOGSIZE</entry>
     1980              <entry>Maximum size of a log file in bytes to trigger rotation</entry>
     1981              <entry>1MB</entry>
     1982            </row>
     1983            <row>
     1984              <entry>LOGINTERVAL</entry>
     1985              <entry>Maximum time interval in seconds to trigger log rotation</entry>
     1986              <entry>1 day</entry>
     1987            </row>
     1988          </tbody>
     1989        </tgroup>
     1990      </table>
     1991      </para>
     1992
     1993      <para>Setting the parameter <computeroutput>SSL_KEYFILE</computeroutput>
     1994      enables the SSL/TLS support. Using encryption is strongly encouraged, as
     1995      otherwise everything (including passwords) is transferred in clear
     1996      text.</para>
     1997    </sect2>
     1998
     1999    <sect2 id="vboxwebsrv-solaris">
     2000      <title>Solaris: starting the web service via SMF</title>
     2001
     2002      <para>On Solaris hosts, the VirtualBox web service daemon is
     2003      integrated into the SMF framework. You can change the parameters, but
     2004      don't have to if the defaults below already match your needs:<screen>svccfg -s svc:/application/virtualbox/webservice:default setprop config/host=localhost
     2005svccfg -s svc:/application/virtualbox/webservice:default setprop config/port=18083
     2006svccfg -s svc:/application/virtualbox/webservice:default setprop config/user=root</screen></para>
     2007
     2008      <para>The table in the previous section showing the parameter names and
     2009      defaults also applies to Solaris. The parameter names must be changed
     2010      to lowercase and a prefix of <computeroutput>config/</computeroutput>
     2011      has to be added, e.g. <computeroutput>config/user</computeroutput> or
     2012      <computeroutput>config/ssl_keyfile</computeroutput>. If you made any
     2013      change, don't forget to run the following command to put the changes into
     2014      effect immediately:<screen>svcadm refresh svc:/application/virtualbox/webservice:default</screen></para>
     2015
     2016      <para>If you forget the above command then the previous settings will
     2017      be used when enabling the service. Check the current property settings
     2018      with:<screen>svcprop -p config svc:/application/virtualbox/webservice:default</screen></para>
     2019
     2020      <para>When everything is configured correctly you can start the
     2021      VirtualBox web service with the following command:<screen>svcadm enable svc:/application/virtualbox/webservice:default</screen></para>
     2022
     2023      <para>For more information about SMF, please refer to the Solaris
     2024      documentation.</para>
     2025    </sect2>
     2026
     2027    <sect2 id="vboxwebsrv-osx">
     2028      <title>Mac OS X: starting the webservice via launchd</title>
     2029
     2030      <para>On Mac OS X, launchd is used to start the VirtualBox webservice. An
     2031      example configuration file can be found in
     2032      <computeroutput>$HOME/Library/LaunchAgents/org.virtualbox.vboxwebsrv.plist</computeroutput>.
     2033      It can be enabled by changing the
     2034      <computeroutput>Disabled</computeroutput> key from
     2035      <computeroutput>true</computeroutput> to
     2036      <computeroutput>false</computeroutput>. To manually start the
     2037      service use the following command: <screen>launchctl load ~/Library/LaunchAgents/org.virtualbox.vboxwebsrv.plist</screen>
     2038      For additional information on how launchd services could be
     2039      configured see <literal><ulink
     2040      url="http://developer.apple.com/mac/library/documentation/MacOSX/Conceptual/BPSystemStartup/BPSystemStartup.html">http://developer.apple.com/mac/library/documentation/MacOSX/Conceptual/BPSystemStartup/BPSystemStartup.html</ulink></literal>.</para>
     2041    </sect2>
    19652042  </sect1>
    19662043
  • trunk/src/VBox/Installer/linux/vboxweb-service.sh.in

    r36480 r40130  
    33# VirtualBox web service API daemon init script.
    44#
    5 # Copyright (C) 2006-2011 Oracle Corporation
     5# Copyright (C) 2006-2012 Oracle Corporation
    66#
    77# This file is part of VirtualBox Open Source Edition (OSE), as
     
    293293        [ -n "$VBOXWEB_HOST" ]           && PARAMS="$PARAMS -H $VBOXWEB_HOST"
    294294        [ -n "$VBOXWEB_PORT" ]           && PARAMS="$PARAMS -p $VBOXWEB_PORT"
     295        [ -n "$VBOXWEB_SSL_KEYFILE" ]    && PARAMS="$PARAMS -s -K $VBOXWEB_SSL_KEYFILE"
     296        [ -n "$VBOXWEB_SSL_PASSWORDFILE" ] && PARAMS="$PARAMS -a $VBOXWEB_SSL_PASSWORDFILE"
     297        [ -n "$VBOXWEB_SSL_CACERT" ]     && PARAMS="$PARAMS -c $VBOXWEB_SSL_CACERT"
     298        [ -n "$VBOXWEB_SSL_CAPATH" ]     && PARAMS="$PARAMS -C $VBOXWEB_SSL_CAPATH"
     299        [ -n "$VBOXWEB_SSL_DHFILE" ]     && PARAMS="$PARAMS -D $VBOXWEB_SSL_DHFILE"
     300        [ -n "$VBOXWEB_SSL_RANDFILE" ]   && PARAMS="$PARAMS -r $VBOXWEB_SSL_RANDFILE"
    295301        [ -n "$VBOXWEB_TIMEOUT" ]        && PARAMS="$PARAMS -t $VBOXWEB_TIMEOUT"
    296302        [ -n "$VBOXWEB_CHECK_INTERVAL" ] && PARAMS="$PARAMS -i $VBOXWEB_CHECK_INTERVAL"
    297303        [ -n "$VBOXWEB_THREADS" ]        && PARAMS="$PARAMS -T $VBOXWEB_THREADS"
    298304        [ -n "$VBOXWEB_KEEPALIVE" ]      && PARAMS="$PARAMS -k $VBOXWEB_KEEPALIVE"
     305        [ -n "$VBOXWEB_AUTHENTICATION" ] && PARAMS="$PARAMS -A $VBOXWEB_AUTHENTICATION"
    299306        [ -n "$VBOXWEB_LOGFILE" ]        && PARAMS="$PARAMS -F $VBOXWEB_LOGFILE"
    300307        [ -n "$VBOXWEB_ROTATE" ]         && PARAMS="$PARAMS -R $VBOXWEB_ROTATE"
  • trunk/src/VBox/Installer/solaris/smf-vboxwebsrv.sh

    r36748 r40130  
    22# $Id$
    33
    4 # Copyright (C) 2008-2011 Oracle Corporation
     4# Copyright (C) 2008-2012 Oracle Corporation
    55#
    66# This file is part of VirtualBox Open Source Edition (OSE), as
     
    4242        VW_PORT=`/usr/bin/svcprop -p config/port $SMF_FMRI 2>/dev/null`
    4343        [ $? != 0 ] && VW_PORT=
     44        VW_SSL_KEYFILE=`/usr/bin/svcprop -p config/ssl_keyfile $SMF_FMRI 2>/dev/null`
     45        [ $? != 0 ] && VW_SSL_KEYFILE=
     46        VW_SSL_PASSWORDFILE=`/usr/bin/svcprop -p config/ssl_passwordfile $SMF_FMRI 2>/dev/null`
     47        [ $? != 0 ] && VW_SSL_PASSWORDFILE=
     48        VW_SSL_CACERT=`/usr/bin/svcprop -p config/ssl_cacert $SMF_FMRI 2>/dev/null`
     49        [ $? != 0 ] && VW_SSL_CACERT=
     50        VW_SSL_CAPATH=`/usr/bin/svcprop -p config/ssl_capath $SMF_FMRI 2>/dev/null`
     51        [ $? != 0 ] && VW_SSL_CAPATH=
     52        VW_SSL_DHFILE=`/usr/bin/svcprop -p config/ssl_dhfile $SMF_FMRI 2>/dev/null`
     53        [ $? != 0 ] && VW_SSL_DHFILE=
     54        VW_SSL_RANDFILE=`/usr/bin/svcprop -p config/ssl_randfile $SMF_FMRI 2>/dev/null`
     55        [ $? != 0 ] && VW_SSL_RANDFILE=
    4456        VW_TIMEOUT=`/usr/bin/svcprop -p config/timeout $SMF_FMRI 2>/dev/null`
    4557        [ $? != 0 ] && VW_TIMEOUT=
    4658        VW_CHECK_INTERVAL=`/usr/bin/svcprop -p config/checkinterval $SMF_FMRI 2>/dev/null`
    4759        [ $? != 0 ] && VW_CHECK_INTERVAL=
     60        VW_THREADS=`/usr/bin/svcprop -p config/threads $SMF_FMRI 2>/dev/null`
     61        [ $? != 0 ] && VW_THREADS=
    4862        VW_KEEPALIVE=`/usr/bin/svcprop -p config/keepalive $SMF_FMRI 2>/dev/null`
    4963        [ $? != 0 ] && VW_KEEPALIVE=
     64        VW_AUTHENTICATION=`/usr/bin/svcprop -p config/authentication $SMF_FMRI 2>/dev/null`
     65        [ $? != 0 ] && VW_AUTHENTICATION=
     66        VW_LOGFILE=`/usr/bin/svcprop -p config/logfile $SMF_FMRI 2>/dev/null`
     67        [ $? != 0 ] && VW_LOGFILE=
    5068        VW_ROTATE=`/usr/bin/svcprop -p config/logrotate $SMF_FMRI 2>/dev/null`
    5169        [ $? != 0 ] && VW_ROTATE=
     
    6179        [ -z "$VW_TIMEOUT" ] && VW_TIMEOUT=20
    6280        [ -z "$VW_CHECK_INTERVAL" ] && VW_CHECK_INTERVAL=5
     81        [ -z "$VW_THREADS" ] && VW_THREADS=100
    6382        [ -z "$VW_KEEPALIVE" ] && VW_KEEPALIVE=100
    6483        [ -z "$VW_ROTATE" ] && VW_ROTATE=10
    6584        [ -z "$VW_LOGSIZE" ] && VW_LOGSIZE=104857600
    6685        [ -z "$VW_LOGINTERVAL" ] && VW_LOGINTERVAL=86400
    67         exec su - "$VW_USER" -c "/opt/VirtualBox/vboxwebsrv --background --host \"$VW_HOST\" --port \"$VW_PORT\" --timeout \"$VW_TIMEOUT\" --check-interval \"$VW_CHECK_INTERVAL\" --keepalive \"$VW_KEEPALIVE\" --logrotate \"$VW_ROTATE\" --logsize \"$VW_LOGSIZE\" --loginterval \"$VW_LOGINTERVAL\""
     86
     87        # Derived and optional settings
     88        VW_SSL=
     89        [ -n "$VW_SSL_KEYFILE" ] && VW_SSL=--ssl
     90        [ -n "$VW_SSL_KEYFILE" ] && VW_SSL_KEYFILE="--keyfile $VW_SSL_KEYFILE"
     91        [ -n "$VW_SSL_PASSWORDFILE" ] && VW_SSL_PASSWORDFILE="--passwordfile $VW_SSL_PASSWORDFILE"
     92        [ -n "$VW_SSL_CACERT" ] && VW_SSL_CACERT="--cacert $VW_SSL_CACERT"
     93        [ -n "$VW_SSL_CAPATH" ] && VW_SSL_CAPATH="--capath $VW_SSL_CAPATH"
     94        [ -n "$VW_SSL_DHFILE" ] && VW_SSL_DHFILE="--dhfile $VW_SSL_DHFILE"
     95        [ -n "$VW_SSL_RANDFILE" ] && VW_SSL_RANDFILE="--randfile $VW_SSL_RANDFILE"
     96        [ -n "$VW_LOGFILE" ] && VW_LOGFILE="--logfile $VW_LOGFILE"
     97
     98        exec su - "$VW_USER" -c "/opt/VirtualBox/vboxwebsrv --background --host \"$VW_HOST\" --port \"$VW_PORT\" $VW_SSL $VW_SSL_KEYFILE $VW_SSL_PASSWORDFILE $VW_SSL_CACERT $VW_SSL_CAPATH $VW_SSL_DHFILE $VW_SSL_RANDFILE --timeout \"$VW_TIMEOUT\" --check-interval \"$VW_CHECK_INTERVAL\" --threads \"$VW_THREADS\" --keepalive \"$VW_KEEPALIVE\" --authentication \"$VW_AUTHENTICATION\" $VW_LOGFILE --logrotate \"$VW_ROTATE\" --logsize \"$VW_LOGSIZE\" --loginterval \"$VW_LOGINTERVAL\""
    6899
    69100        VW_EXIT=$?
  • trunk/src/VBox/Installer/solaris/virtualbox-webservice.xml

    r36520 r40130  
    55# $Id$
    66
    7      Copyright (C) 2008-2011 Oracle Corporation
     7     Copyright (C) 2008-2012 Oracle Corporation
    88
    99     This file is part of VirtualBox Open Source Edition (OSE), as
     
    8787            <propval name='host' type='astring' value='localhost' />
    8888            <propval name='port' type='integer' value='18083' />
     89            <propval name='keyfile' type='astring' value='' />
    8990        </property_group>
    9091
  • trunk/src/VBox/Main/webservice/Makefile.kmk

    r39876 r40130  
    77
    88#
    9 # Copyright (C) 2006-2011 Oracle Corporation
     9# Copyright (C) 2006-2012 Oracle Corporation
    1010#
    1111# This file is part of VirtualBox Open Source Edition (OSE), as
     
    212212        $(VBOXWEB_OUT_DIR) \
    213213        $(PATH_SUB_CURRENT)
     214 ifdef VBOX_WITH_WEBSERVICES_SSL
     215  vboxsoap_DEFS += WITH_OPENSSL
     216  vboxsoap_SDKS += VBOX_OPENSSL2
     217 endif
    214218 ifdef VBOX_WITHOUT_SPLIT_SOAPC
    215219  vboxsoap_SOURCES = \
     
    287291 vboxwebsrv_LIBS += \
    288292        $(PATH_STAGE_LIB)/vboxsoap$(VBOX_SUFF_LIB) \
    289         $(VBOX_GSOAP_CXX_LIBS)
     293        $(VBOX_GSOAP_CXX_LIBS) \
     294        $(LIB_RUNTIME)
    290295 vboxwebsrv_LIBS.solaris += socket nsl
     296 ifdef VBOX_WITH_WEBSERVICES_SSL
     297  vboxwebsrv_DEFS += WITH_OPENSSL
     298  vboxwebsrv_SDKS += VBOX_OPENSSL2
     299 endif
    291300 vboxwebsrv_SOURCES = \
    292301        vboxweb.cpp \
     
    430439 webtest_LIBS += \
    431440        $(PATH_STAGE_LIB)/vboxsoap$(VBOX_SUFF_LIB) \
    432         $(VBOX_GSOAP_CXX_LIBS)
     441        $(VBOX_GSOAP_CXX_LIBS) \
     442        $(LIB_RUNTIME)
    433443 webtest_LIBS.solaris += nsl
     444 ifdef VBOX_WITH_WEBSERVICES_SSL
     445  webtest_DEFS += WITH_OPENSSL
     446  webtest_SDKS += VBOX_OPENSSL2
     447 endif
    434448 webtest_SOURCES = \
    435449        webtest.cpp \
  • trunk/src/VBox/Main/webservice/vboxweb.cpp

    r38802 r40130  
    66 *      server, to which clients can connect.
    77 *
    8  * Copyright (C) 2006-2011 Oracle Corporation
     8 * Copyright (C) 2006-2012 Oracle Corporation
    99 *
    1010 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2323#include <VBox/com/com.h>
    2424#include <VBox/com/array.h>
     25#include <VBox/com/string.h>
    2526#include <VBox/com/ErrorInfo.h>
    2627#include <VBox/com/errorprint.h>
     
    4243#include <iprt/rand.h>
    4344#include <iprt/semaphore.h>
     45#include <iprt/critsect.h>
    4446#include <iprt/string.h>
    4547#include <iprt/thread.h>
     
    4850#include <iprt/system.h>
    4951#include <iprt/base64.h>
     52#include <iprt/stream.h>
    5053
    5154// workaround for compile problems on gcc 4.1
     
    7578
    7679RT_C_DECLS_END
     80
     81static void WebLogSoapError(struct soap *soap);
    7782
    7883/****************************************************************************
     
    117122unsigned int            g_uBindToPort = 18083;          // port
    118123unsigned int            g_uBacklog = 100;               // backlog = max queue size for requests
     124
     125#ifdef WITH_OPENSSL
     126bool                    g_fSSL = false;                 // if SSL is enabled
     127const char              *g_pcszKeyFile = NULL;          // server key file
     128const char              *g_pcszPassword = NULL;         // password for server key
     129const char              *g_pcszCACert = NULL;           // file with trusted CA certificates
     130const char              *g_pcszCAPath = NULL;           // directory with trusted CA certificates
     131const char              *g_pcszDHFile = NULL;           // DH file name or DH key length in bits, NULL=use RSA
     132const char              *g_pcszRandFile = NULL;         // file with random data seed
     133const char              *g_pcszSID = "vboxwebsrv";      // server ID for SSL session cache
     134#endif /* WITH_OPENSSL */
     135
    119136unsigned int            g_cMaxWorkerThreads = 100;      // max. no. of worker threads
    120137unsigned int            g_cMaxKeepAlive = 100;          // maximum number of soap requests in one connection
     138
     139const char              *g_pcszAuthentication = NULL;   // web service authentication
    121140
    122141uint32_t                g_cHistory = 10;                // enable log rotation, 10 files
     
    180199        { "--host",             'H', RTGETOPT_REQ_STRING },
    181200        { "--port",             'p', RTGETOPT_REQ_UINT32 },
     201#ifdef WITH_OPENSSL
     202        { "--ssl",              's', RTGETOPT_REQ_NOTHING },
     203        { "--keyfile",          'K', RTGETOPT_REQ_STRING },
     204        { "--passwordfile",     'a', RTGETOPT_REQ_STRING },
     205        { "--cacert",           'c', RTGETOPT_REQ_STRING },
     206        { "--capath",           'C', RTGETOPT_REQ_STRING },
     207        { "--dhfile",           'D', RTGETOPT_REQ_STRING },
     208        { "--randfile",         'r', RTGETOPT_REQ_STRING },
     209#endif /* WITH_OPENSSL */
    182210        { "--timeout",          't', RTGETOPT_REQ_UINT32 },
    183211        { "--check-interval",   'i', RTGETOPT_REQ_UINT32 },
    184212        { "--threads",          'T', RTGETOPT_REQ_UINT32 },
    185213        { "--keepalive",        'k', RTGETOPT_REQ_UINT32 },
     214        { "--authentication",   'A', RTGETOPT_REQ_STRING },
    186215        { "--verbose",          'v', RTGETOPT_REQ_NOTHING },
    187216        { "--pidfile",          'P', RTGETOPT_REQ_STRING },
     
    226255                break;
    227256
     257#ifdef WITH_OPENSSL
     258            case 's':
     259                pcszDescr = "Enable SSL/TLS encryption.";
     260                break;
     261
     262            case 'K':
     263                pcszDescr = "Server key and certificate file, PEM format (\"\").";
     264                break;
     265
     266            case 'a':
     267                pcszDescr = "File name for password to server key (\"\").";
     268                break;
     269
     270            case 'c':
     271                pcszDescr = "CA certificate file, PEM format (\"\").";
     272                break;
     273
     274            case 'C':
     275                pcszDescr = "CA certificate path (\"\").";
     276                break;
     277
     278            case 'D':
     279                pcszDescr = "DH file name or DH key length in bits (\"\").";
     280                break;
     281
     282            case 'r':
     283                pcszDescr = "File containing seed for random number generator (\"\").";
     284                break;
     285#endif /* WITH_OPENSSL */
     286
    228287            case 't':
    229288                pcszDescr = "Session timeout in seconds; 0 = disable timeouts (" DEFAULT_TIMEOUT_SECS_STRING ").";
     
    236295            case 'k':
    237296                pcszDescr = "Maximum number of requests before a socket will be closed (100).";
     297                break;
     298
     299            case 'A':
     300                pcszDescr = "Authentication method for the webservice (\"\").";
    238301                break;
    239302
     
    516579        m_soap->recv_timeout = 60;
    517580        // process the request; this goes into the COM code in methodmaps.cpp
    518         soap_serve(m_soap);
     581        do {
     582#ifdef WITH_OPENSSL
     583            if (g_fSSL && soap_ssl_accept(m_soap))
     584            {
     585                WebLogSoapError(m_soap);
     586                break;
     587            }
     588#endif /* WITH_OPENSSL */
     589            soap_serve(m_soap);
     590        } while (0);
    519591
    520592        soap_destroy(m_soap); // clean up class instances
     
    632704 * @param soap
    633705 */
     706/*static*/
    634707void WebLogSoapError(struct soap *soap)
    635708{
     
    715788}
    716789
     790#ifdef WITH_OPENSSL
    717791/****************************************************************************
    718792 *
     793 * OpenSSL convenience functions for multithread support
     794 *
     795 ****************************************************************************/
     796
     797static RTCRITSECT *g_pSSLMutexes = NULL;
     798
     799struct CRYPTO_dynlock_value
     800{
     801    RTCRITSECT mutex;
     802};
     803
     804static unsigned long CRYPTO_id_function()
     805{
     806    return RTThreadNativeSelf();
     807}
     808
     809static void CRYPTO_locking_function(int mode, int n, const char * /*file*/, int /*line*/)
     810{
     811    if (mode & CRYPTO_LOCK)
     812        RTCritSectEnter(&g_pSSLMutexes[n]);
     813    else
     814        RTCritSectLeave(&g_pSSLMutexes[n]);
     815}
     816
     817static struct CRYPTO_dynlock_value *CRYPTO_dyn_create_function(const char * /*file*/, int /*line*/)
     818{
     819    struct CRYPTO_dynlock_value *value = (struct CRYPTO_dynlock_value *)RTMemAlloc(sizeof(struct CRYPTO_dynlock_value));
     820    if (value)
     821        RTCritSectInit(&value->mutex);
     822
     823    return value;
     824}
     825
     826static void CRYPTO_dyn_lock_function(int mode, struct CRYPTO_dynlock_value *value, const char * /*file*/, int /*line*/)
     827{
     828    if (mode & CRYPTO_LOCK)
     829        RTCritSectEnter(&value->mutex);
     830    else
     831        RTCritSectLeave(&value->mutex);
     832}
     833
     834static void CRYPTO_dyn_destroy_function(struct CRYPTO_dynlock_value *value, const char * /*file*/, int /*line*/)
     835{
     836    if (value)
     837    {
     838        RTCritSectDelete(&value->mutex);
     839        free(value);
     840    }
     841}
     842
     843static int CRYPTO_thread_setup()
     844{
     845    int num_locks = CRYPTO_num_locks();
     846    g_pSSLMutexes = (RTCRITSECT *)RTMemAlloc(num_locks * sizeof(RTCRITSECT));
     847    if (!g_pSSLMutexes)
     848        return SOAP_EOM;
     849
     850    for (int i = 0; i < num_locks; i++)
     851    {
     852        int rc = RTCritSectInit(&g_pSSLMutexes[i]);
     853        if (RT_FAILURE(rc))
     854        {
     855            for ( ; i >= 0; i--)
     856                RTCritSectDelete(&g_pSSLMutexes[i]);
     857            RTMemFree(g_pSSLMutexes);
     858            g_pSSLMutexes = NULL;
     859            return SOAP_EOM;
     860        }
     861    }
     862
     863    CRYPTO_set_id_callback(CRYPTO_id_function);
     864    CRYPTO_set_locking_callback(CRYPTO_locking_function);
     865    CRYPTO_set_dynlock_create_callback(CRYPTO_dyn_create_function);
     866    CRYPTO_set_dynlock_lock_callback(CRYPTO_dyn_lock_function);
     867    CRYPTO_set_dynlock_destroy_callback(CRYPTO_dyn_destroy_function);
     868
     869    return SOAP_OK;
     870}
     871
     872static void CRYPTO_thread_cleanup()
     873{
     874    if (!g_pSSLMutexes)
     875        return;
     876
     877    CRYPTO_set_id_callback(NULL);
     878    CRYPTO_set_locking_callback(NULL);
     879    CRYPTO_set_dynlock_create_callback(NULL);
     880    CRYPTO_set_dynlock_lock_callback(NULL);
     881    CRYPTO_set_dynlock_destroy_callback(NULL);
     882
     883    int num_locks = CRYPTO_num_locks();
     884    for (int i = 0; i < num_locks; i++)
     885        RTCritSectDelete(&g_pSSLMutexes[i]);
     886
     887    RTMemFree(g_pSSLMutexes);
     888    g_pSSLMutexes = NULL;
     889}
     890#endif /* WITH_OPENSSL */
     891
     892/****************************************************************************
     893 *
    719894 * SOAP queue pumper thread
    720895 *
     
    723898void doQueuesLoop()
    724899{
     900#ifdef WITH_OPENSSL
     901    if (g_fSSL && CRYPTO_thread_setup())
     902    {
     903        WebLog("Failed to set up OpenSSL thread mutex!");
     904        exit(RTEXITCODE_FAILURE);
     905    }
     906#endif /* WITH_OPENSSL */
     907
    725908    // set up gSOAP
    726909    struct soap soap;
    727910    soap_init(&soap);
     911
     912#ifdef WITH_OPENSSL
     913    if (g_fSSL && soap_ssl_server_context(&soap, SOAP_SSL_DEFAULT, g_pcszKeyFile,
     914                                         g_pcszPassword, g_pcszCACert, g_pcszCAPath,
     915                                         g_pcszDHFile, g_pcszRandFile, g_pcszSID))
     916    {
     917        WebLogSoapError(&soap);
     918        exit(RTEXITCODE_FAILURE);
     919    }
     920#endif /* WITH_OPENSSL */
    728921
    729922    soap.bind_flags |= SO_REUSEADDR;
     
    739932    else
    740933    {
    741         WebLog("Socket connection successful: host = %s, port = %u, master socket = %d\n",
     934        WebLog("Socket connection successful: host = %s, port = %u, %smaster socket = %d\n",
    742935               (g_pcszBindToHost) ? g_pcszBindToHost : "default (localhost)",
    743936               g_uBindToPort,
     937#ifdef WITH_OPENSSL
     938               g_fSSL ? "SSL, " : "",
     939#else /* !WITH_OPENSSL */
     940               "",
     941#endif /*!WITH_OPENSSL */
    744942               m);
    745943
     
    766964    }
    767965    soap_done(&soap); // close master socket and detach environment
     966
     967#ifdef WITH_OPENSSL
     968    if (g_fSSL)
     969        CRYPTO_thread_cleanup();
     970#endif /* WITH_OPENSSL */
    768971}
    769972
     
    8401043                break;
    8411044
     1045#ifdef WITH_OPENSSL
     1046            case 's':
     1047                g_fSSL = true;
     1048                break;
     1049
     1050            case 'K':
     1051                g_pcszKeyFile = ValueUnion.psz;
     1052                break;
     1053
     1054            case 'a':
     1055                if (ValueUnion.psz[0] == '\0')
     1056                    g_pcszPassword = NULL;
     1057                else
     1058                {
     1059                    PRTSTREAM StrmIn;
     1060                    if (!strcmp(ValueUnion.psz, "-"))
     1061                        StrmIn = g_pStdIn;
     1062                    else
     1063                    {
     1064                        int vrc = RTStrmOpen(ValueUnion.psz, "r", &StrmIn);
     1065                        if (RT_FAILURE(vrc))
     1066                            return RTMsgErrorExit(RTEXITCODE_FAILURE, "failed to open password file (%s, %Rrc)", ValueUnion.psz, vrc);
     1067                    }
     1068                    char szPasswd[512];
     1069                    int vrc = RTStrmGetLine(StrmIn, szPasswd, sizeof(szPasswd));
     1070                    if (RT_FAILURE(vrc))
     1071                        return RTMsgErrorExit(RTEXITCODE_FAILURE, "failed to read password (%s, %Rrc)", ValueUnion.psz, vrc);
     1072                    g_pcszPassword = RTStrDup(szPasswd);
     1073                    memset(szPasswd, '\0', sizeof(szPasswd));
     1074                    if (StrmIn != g_pStdIn)
     1075                        RTStrmClose(StrmIn);
     1076                }
     1077                break;
     1078
     1079            case 'c':
     1080                g_pcszCACert = ValueUnion.psz;
     1081                break;
     1082
     1083            case 'C':
     1084                g_pcszCAPath = ValueUnion.psz;
     1085                break;
     1086
     1087            case 'D':
     1088                g_pcszDHFile = ValueUnion.psz;
     1089                break;
     1090
     1091            case 'r':
     1092                g_pcszRandFile = ValueUnion.psz;
     1093                break;
     1094#endif /* WITH_OPENSSL */
     1095
    8421096            case 't':
    8431097                g_iWatchdogTimeoutSecs = ValueUnion.u32;
     
    8741128            case 'k':
    8751129                g_cMaxKeepAlive = ValueUnion.u32;
     1130                break;
     1131
     1132            case 'A':
     1133                g_pcszAuthentication = ValueUnion.psz;
    8761134                break;
    8771135
     
    9641222#endif
    9651223
     1224    // initialize SOAP SSL support if enabled
     1225#ifdef WITH_OPENSSL
     1226    if (g_fSSL)
     1227        soap_ssl_init();
     1228#endif /* WITH_OPENSSL */
     1229
    9661230    // initialize COM/XPCOM
    9671231    HRESULT hrc = com::Initialize();
     
    9891253        RTMsgError("Failed to get VirtualBox object (rc=%Rhrc)!", hrc);
    9901254        return RTEXITCODE_FAILURE;
     1255    }
     1256
     1257    // set the authentication method if requested
     1258    if (g_pVirtualBox && g_pcszAuthentication && g_pcszAuthentication[0])
     1259    {
     1260        ComPtr<ISystemProperties> pSystemProperties;
     1261        g_pVirtualBox->COMGETTER(SystemProperties)(pSystemProperties.asOutParam());
     1262        if (pSystemProperties)
     1263            pSystemProperties->COMSETTER(WebServiceAuthLibrary)(com::Bstr(g_pcszAuthentication).raw());
    9911264    }
    9921265
     
    11141387                ++it;
    11151388        }
     1389
     1390        // re-set the authentication method in case it has been changed
     1391        if (g_pVirtualBox && g_pcszAuthentication && g_pcszAuthentication[0])
     1392        {
     1393            ComPtr<ISystemProperties> pSystemProperties;
     1394            g_pVirtualBox->COMGETTER(SystemProperties)(pSystemProperties.asOutParam());
     1395            if (pSystemProperties)
     1396                pSystemProperties->COMSETTER(WebServiceAuthLibrary)(com::Bstr(g_pcszAuthentication).raw());
     1397        }
    11161398    }
    11171399
  • trunk/src/VBox/Main/webservice/webtest.cpp

    r33451 r40130  
    44 *      functionality of VBoxManage for testing purposes.
    55 *
    6  * Copyright (C) 2006-2010 Oracle Corporation
     6 * Copyright (C) 2006-2012 Oracle Corporation
    77 *
    88 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2626
    2727
     28static void usage(int exitcode)
     29{
     30    std::cout <<
     31       "webtest: VirtualBox webservice testcase.\n"
     32       "\nUsage: webtest [options] [command]...\n"
     33       "\nSupported options:\n"
     34       " -h: print this help message and exit.\n"
     35       " -c URL: specify the webservice server URL (default http://localhost:18083/).\n"
     36       "\nSupported commands:\n"
     37       " - IWebsessionManager:\n"
     38       "   - webtest logon <user> <pass>: IWebsessionManager::logon().\n"
     39       "   - webtest getsession <vboxref>: IWebsessionManager::getSessionObject().\n"
     40       "   - webtest logoff <vboxref>: IWebsessionManager::logoff().\n"
     41       " - IVirtualBox:\n"
     42       "   - webtest version <vboxref>: IVirtualBox::getVersion().\n"
     43       "   - webtest gethost <vboxref>: IVirtualBox::getHost().\n"
     44       "   - webtest getpc <vboxref>: IVirtualBox::getPerformanceCollector().\n"
     45       "   - webtest getmachines <vboxref>: IVirtualBox::getMachines().\n"
     46       "   - webtest createmachine <vboxref> <settingsPath> <name>: IVirtualBox::createMachine().\n"
     47       "   - webtest registermachine <vboxref> <machineref>: IVirtualBox::registerMachine().\n"
     48       " - IHost:\n"
     49       "   - webtest getdvddrives <hostref>: IHost::getDVDDrives.\n"
     50       " - IHostDVDDrive:\n"
     51       "   - webtest getdvdname <dvdref>: IHostDVDDrive::getname.\n"
     52       " - IMachine:\n"
     53       "   - webtest getname <machineref>: IMachine::getName().\n"
     54       "   - webtest getid <machineref>: IMachine::getId().\n"
     55       "   - webtest getostype <machineref>: IMachine::getGuestOSType().\n"
     56       "   - webtest savesettings <machineref>: IMachine::saveSettings().\n"
     57       " - IPerformanceCollector:\n"
     58       "   - webtest setupmetrics <pcref>: IPerformanceCollector::setupMetrics()\n"
     59       "   - webtest querymetricsdata <pcref>: IPerformanceCollector::QueryMetricsData()\n"
     60       " - All managed object references:\n"
     61       "   - webtest getif <ref>: report interface of object.\n"
     62       "   - webtest release <ref>: IUnknown::Release().\n";
     63    exit(exitcode);
     64}
     65
    2866/**
    2967 *
     
    3472int main(int argc, char* argv[])
    3573{
     74    bool fSSL = false;
     75    const char *pcszArgEndpoint = "http://localhost:18083/";
     76
     77    int ap;
     78    for (ap = 1; ap <= argc; ap++)
     79    {
     80        if (argv[ap][0] == '-')
     81        {
     82            if (!strcmp(argv[ap], "-h"))
     83                usage(0);
     84            else if (!strcmp(argv[ap], "-c"))
     85            {
     86                ap++;
     87                if (ap > argc)
     88                    usage(1);
     89                pcszArgEndpoint = argv[ap];
     90                fSSL = !strncmp(pcszArgEndpoint, "https://", 8);
     91            }
     92            else
     93                usage(1);
     94        }
     95        else
     96            break;
     97    }
     98
     99    if (argc < 1 + ap)
     100        usage(1);
     101
     102#ifdef WITH_OPENSSL
     103    if (fSSL)
     104        soap_ssl_init();
     105#endif /* WITH_OPENSSL */
     106
    36107    struct soap soap; // gSOAP runtime environment
    37108    soap_init(&soap); // initialize runtime environment (only once)
    38 
    39     if (argc < 2)
    40     {
    41         std::cout <<
    42                "webtest: VirtualBox webservice testcase.\n"
    43                "Usage:\n"
    44                " - IWebsessionManager:\n"
    45                "   - webtest logon <user> <pass>: IWebsessionManager::logon().\n"
    46                "   - webtest getsession <vboxref>: IWebsessionManager::getSessionObject().\n"
    47                "   - webtest logoff <vboxref>: IWebsessionManager::logoff().\n"
    48                " - IVirtualBox:\n"
    49                "   - webtest version <vboxref>: IVirtualBox::getVersion().\n"
    50                "   - webtest gethost <vboxref>: IVirtualBox::getHost().\n"
    51                "   - webtest getpc <vboxref>: IVirtualBox::getPerformanceCollector().\n"
    52                "   - webtest getmachines <vboxref>: IVirtualBox::getMachines().\n"
    53                "   - webtest createmachine <vboxref> <settingsPath> <name>: IVirtualBox::createMachine().\n"
    54                "   - webtest registermachine <vboxref> <machineref>: IVirtualBox::registerMachine().\n"
    55                " - IHost:\n"
    56                "   - webtest getdvddrives <hostref>: IHost::getDVDDrives.\n"
    57                " - IHostDVDDrive:\n"
    58                "   - webtest getdvdname <dvdref>: IHostDVDDrive::getname.\n"
    59                " - IMachine:\n"
    60                "   - webtest getname <machineref>: IMachine::getName().\n"
    61                "   - webtest getid <machineref>: IMachine::getId().\n"
    62                "   - webtest getostype <machineref>: IMachine::getGuestOSType().\n"
    63                "   - webtest savesettings <machineref>: IMachine::saveSettings().\n"
    64                " - IPerformanceCollector:\n"
    65                "   - webtest setupmetrics <pcref>: IPerformanceCollector::setupMetrics()\n"
    66                "   - webtest querymetricsdata <pcref>: IPerformanceCollector::QueryMetricsData()\n"
    67                " - All managed object references:\n"
    68                "   - webtest getif <ref>: report interface of object.\n"
    69                "   - webtest release <ref>: IUnknown::Release().\n";
     109#ifdef WITH_OPENSSL
     110    // Use SOAP_SSL_NO_AUTHENTICATION here to accept broken server configs.
     111    // In a real world setup please use at least SOAP_SSL_DEFAULT and provide
     112    // the necessary CA certificate for validating the server's certificate.
     113    if (fSSL && soap_ssl_client_context(&soap, SOAP_SSL_NO_AUTHENTICATION,
     114                                        NULL /*clientkey*/, NULL /*password*/,
     115                                        NULL /*cacert*/, NULL /*capath*/,
     116                                        NULL /*randfile*/))
     117    {
     118        soap_print_fault(&soap, stderr);
    70119        exit(1);
    71120    }
    72 
    73     const char *pcszArgEndpoint = "localhost:18083";
    74 
    75     const char *pcszMode = argv[1];
    76     int soaprc = 2;
     121#endif /* WITH_OPENSSL */
     122
     123    const char *pcszMode = argv[ap];
     124    int soaprc = SOAP_SVR_FAULT;
    77125
    78126    if (!strcmp(pcszMode, "logon"))
    79127    {
    80         if (argc < 4)
     128        if (argc < 3 + ap)
    81129            std::cout << "Not enough arguments for \"" << pcszMode << "\" mode.\n";
    82130        else
    83131        {
    84132            _vbox__IWebsessionManager_USCORElogon req;
    85             req.username = argv[2];
    86             req.password = argv[3];
     133            req.username = argv[ap + 1];
     134            req.password = argv[ap + 2];
    87135            _vbox__IWebsessionManager_USCORElogonResponse resp;
    88136
     
    97145    else if (!strcmp(pcszMode, "getsession"))
    98146    {
    99         if (argc < 3)
     147        if (argc < 2 + ap)
    100148            std::cout << "Not enough arguments for \"" << pcszMode << "\" mode.\n";
    101149        else
    102150        {
    103151            _vbox__IWebsessionManager_USCOREgetSessionObject req;
    104             req.refIVirtualBox = argv[2];
     152            req.refIVirtualBox = argv[ap + 1];
    105153            _vbox__IWebsessionManager_USCOREgetSessionObjectResponse resp;
    106154
     
    115163    else if (!strcmp(pcszMode, "logoff"))
    116164    {
    117         if (argc < 3)
     165        if (argc < 2 + ap)
    118166            std::cout << "Not enough arguments for \"" << pcszMode << "\" mode.\n";
    119167        else
    120168        {
    121169            _vbox__IWebsessionManager_USCORElogoff req;
    122             req.refIVirtualBox = argv[2];
     170            req.refIVirtualBox = argv[ap + 1];
    123171            _vbox__IWebsessionManager_USCORElogoffResponse resp;
    124172
     
    135183    else if (!strcmp(pcszMode, "version"))
    136184    {
    137         if (argc < 3)
     185        if (argc < 2 + ap)
    138186            std::cout << "Not enough arguments for \"" << pcszMode << "\" mode.\n";
    139187        else
    140188        {
    141189            _vbox__IVirtualBox_USCOREgetVersion req;
    142             req._USCOREthis = argv[2];
     190            req._USCOREthis = argv[ap + 1];
    143191            _vbox__IVirtualBox_USCOREgetVersionResponse resp;
    144192
     
    153201    else if (!strcmp(pcszMode, "gethost"))
    154202    {
    155         if (argc < 3)
     203        if (argc < 2 + ap)
    156204            std::cout << "Not enough arguments for \"" << pcszMode << "\" mode.\n";
    157205        else
    158206        {
    159207            _vbox__IVirtualBox_USCOREgetHost req;
    160             req._USCOREthis = argv[2];
     208            req._USCOREthis = argv[ap + 1];
    161209            _vbox__IVirtualBox_USCOREgetHostResponse resp;
    162210
     
    173221    else if (!strcmp(pcszMode, "getpc"))
    174222    {
    175         if (argc < 3)
     223        if (argc < 2 + ap)
    176224            std::cout << "Not enough arguments for \"" << pcszMode << "\" mode.\n";
    177225        else
    178226        {
    179227            _vbox__IVirtualBox_USCOREgetPerformanceCollector req;
    180             req._USCOREthis = argv[2];
     228            req._USCOREthis = argv[ap + 1];
    181229            _vbox__IVirtualBox_USCOREgetPerformanceCollectorResponse resp;
    182230
     
    193241    else if (!strcmp(pcszMode, "getmachines"))
    194242    {
    195         if (argc < 3)
     243        if (argc < 2 + ap)
    196244            std::cout << "Not enough arguments for \"" << pcszMode << "\" mode.\n";
    197245        else
    198246        {
    199247            _vbox__IVirtualBox_USCOREgetMachines req;
    200             req._USCOREthis = argv[2];
     248            req._USCOREthis = argv[ap + 1];
    201249            _vbox__IVirtualBox_USCOREgetMachinesResponse resp;
    202250
     
    219267    else if (!strcmp(pcszMode, "createmachine"))
    220268    {
    221         if (argc < 5)
     269        if (argc < 4 + ap)
    222270            std::cout << "Not enough arguments for \"" << pcszMode << "\" mode.\n";
    223271        else
    224272        {
    225273            _vbox__IVirtualBox_USCOREcreateMachine req;
    226             req._USCOREthis = argv[2];
    227             req.settingsFile = argv[3];
    228             req.name = argv[4];
     274            req._USCOREthis = argv[ap + 1];
     275            req.settingsFile = argv[ap + 2];
     276            req.name = argv[ap + 3];
    229277            std::cout << "createmachine: settingsFile = \"" << req.settingsFile << "\", name = \"" << req.name << "\"\n";
    230278            _vbox__IVirtualBox_USCOREcreateMachineResponse resp;
     
    240288    else if (!strcmp(pcszMode, "registermachine"))
    241289    {
    242         if (argc < 4)
     290        if (argc < 3 + ap)
    243291            std::cout << "Not enough arguments for \"" << pcszMode << "\" mode.\n";
    244292        else
    245293        {
    246294            _vbox__IVirtualBox_USCOREregisterMachine req;
    247             req._USCOREthis = argv[2];
    248             req.machine = argv[3];
     295            req._USCOREthis = argv[ap + 1];
     296            req.machine = argv[ap + 2];
    249297            _vbox__IVirtualBox_USCOREregisterMachineResponse resp;
    250298            if (!(soaprc = soap_call___vbox__IVirtualBox_USCOREregisterMachine(&soap,
     
    258306    else if (!strcmp(pcszMode, "getdvddrives"))
    259307    {
    260         if (argc < 3)
     308        if (argc < 2 + ap)
    261309            std::cout << "Not enough arguments for \"" << pcszMode << "\" mode.\n";
    262310        else
    263311        {
    264312            _vbox__IHost_USCOREgetDVDDrives req;
    265             req._USCOREthis = argv[2];
     313            req._USCOREthis = argv[ap + 1];
    266314            _vbox__IHost_USCOREgetDVDDrivesResponse resp;
    267315            if (!(soaprc = soap_call___vbox__IHost_USCOREgetDVDDrives(&soap,
     
    283331    else if (!strcmp(pcszMode, "getname"))
    284332    {
    285         if (argc < 3)
     333        if (argc < 2 + ap)
    286334            std::cout << "Not enough arguments for \"" << pcszMode << "\" mode.\n";
    287335        else
    288336        {
    289337            _vbox__IMachine_USCOREgetName req;
    290             req._USCOREthis = argv[2];
     338            req._USCOREthis = argv[ap + 1];
    291339            _vbox__IMachine_USCOREgetNameResponse resp;
    292340            if (!(soaprc = soap_call___vbox__IMachine_USCOREgetName(&soap,
     
    300348    else if (!strcmp(pcszMode, "getid"))
    301349    {
    302         if (argc < 3)
     350        if (argc < 2 + ap)
    303351            std::cout << "Not enough arguments for \"" << pcszMode << "\" mode.\n";
    304352        else
    305353        {
    306354            _vbox__IMachine_USCOREgetId req;
    307             req._USCOREthis = argv[2];
     355            req._USCOREthis = argv[ap + 1];
    308356            _vbox__IMachine_USCOREgetIdResponse resp;
    309357            if (!(soaprc = soap_call___vbox__IMachine_USCOREgetId(&soap,
     
    317365    else if (!strcmp(pcszMode, "getostypeid"))
    318366    {
    319         if (argc < 3)
     367        if (argc < 2 + ap)
    320368            std::cout << "Not enough arguments for \"" << pcszMode << "\" mode.\n";
    321369        else
    322370        {
    323371            _vbox__IMachine_USCOREgetOSTypeId req;
    324             req._USCOREthis = argv[2];
     372            req._USCOREthis = argv[ap + 1];
    325373            _vbox__IMachine_USCOREgetOSTypeIdResponse resp;
    326374            if (!(soaprc = soap_call___vbox__IMachine_USCOREgetOSTypeId(&soap,
     
    334382    else if (!strcmp(pcszMode, "savesettings"))
    335383    {
    336         if (argc < 3)
     384        if (argc < 2 + ap)
    337385            std::cout << "Not enough arguments for \"" << pcszMode << "\" mode.\n";
    338386        else
    339387        {
    340388            _vbox__IMachine_USCOREsaveSettings req;
    341             req._USCOREthis = argv[2];
     389            req._USCOREthis = argv[ap + 1];
    342390            _vbox__IMachine_USCOREsaveSettingsResponse resp;
    343391            if (!(soaprc = soap_call___vbox__IMachine_USCOREsaveSettings(&soap,
     
    351399    else if (!strcmp(pcszMode, "setupmetrics"))
    352400    {
    353         if (argc < 3)
     401        if (argc < 2 + ap)
    354402            std::cout << "Not enough arguments for \"" << pcszMode << "\" mode.\n";
    355403        else
    356404        {
    357405            _vbox__IPerformanceCollector_USCOREsetupMetrics req;
    358             req._USCOREthis = argv[2];
     406            req._USCOREthis = argv[ap + 1];
    359407//             req.metricNames[0] = "*";
    360408//             req.objects
     
    380428    else if (!strcmp(pcszMode, "querymetricsdata"))
    381429    {
    382         if (argc < 3)
     430        if (argc < 2 + ap)
    383431            std::cout << "Not enough arguments for \"" << pcszMode << "\" mode.\n";
    384432        else
    385433        {
    386434            _vbox__IPerformanceCollector_USCOREqueryMetricsData req;
    387             req._USCOREthis = argv[2];
     435            req._USCOREthis = argv[ap + 1];
    388436//             req.metricNames[0] = "*";
    389437//             req.objects
     
    407455    else if (!strcmp(pcszMode, "release"))
    408456    {
    409         if (argc < 3)
     457        if (argc < 2 + ap)
    410458            std::cout << "Not enough arguments for \"" << pcszMode << "\" mode.\n";
    411459        else
    412460        {
    413461            _vbox__IManagedObjectRef_USCORErelease req;
    414             req._USCOREthis = argv[2];
     462            req._USCOREthis = argv[ap + 1];
    415463            _vbox__IManagedObjectRef_USCOREreleaseResponse resp;
    416464            if (!(soaprc = soap_call___vbox__IManagedObjectRef_USCORErelease(&soap,
     
    435483                std::cout << "Bad object ID: " << soap.fault->detail->vbox__InvalidObjectFault->badObjectID << "\n";
    436484            }
    437             if (soap.fault->detail->vbox__RuntimeFault)
     485            else if (soap.fault->detail->vbox__RuntimeFault)
    438486            {
    439487                std::cout << "Result code:   0x" << std::hex << soap.fault->detail->vbox__RuntimeFault->resultCode << "\n";
     
    442490                std::cout << "Interface ID:  " << std::hex << soap.fault->detail->vbox__RuntimeFault->interfaceID << "\n";
    443491            }
     492            else
     493            {
     494                // generic fault
     495                std::cerr << "Generic fault message:\n";
     496                soap_print_fault(&soap, stderr); // display the SOAP fault message on the stderr stream
     497            }
    444498        }
    445499        else
  • trunk/src/VBox/Runtime/VBox/VBoxRTDeps.cpp

    r37277 r40130  
    55
    66/*
    7  * Copyright (C) 2006-2011 Oracle Corporation
     7 * Copyright (C) 2006-2012 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    4444#include <openssl/rsa.h>
    4545#include <openssl/ssl.h>
     46#include <openssl/rand.h>
    4647
    4748
     
    6364    (PFNRT)PEM_read_bio_PrivateKey,
    6465    (PFNRT)X509_free,
     66    (PFNRT)X509_verify_cert_error_string,
     67    (PFNRT)i2d_X509,
    6568    (PFNRT)i2d_X509,
    6669    (PFNRT)RSA_generate_key,
     70    (PFNRT)RAND_load_file,
     71    (PFNRT)CRYPTO_set_dynlock_create_callback,
     72    (PFNRT)CRYPTO_set_dynlock_lock_callback,
     73    (PFNRT)CRYPTO_set_dynlock_destroy_callback,
    6774    (PFNRT)RTAssertShouldPanic,
    6875    (PFNRT)ASMAtomicReadU64,
     
    7178    (PFNRT)SSL_free,
    7279    (PFNRT)SSL_library_init,
     80    (PFNRT)SSL_load_error_strings,
    7381    (PFNRT)SSL_CTX_free,
    7482    (PFNRT)SSL_CTX_use_certificate_file,
     83    (PFNRT)SSLv23_method,
    7584    (PFNRT)TLSv1_server_method,
    7685    NULL
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