@PACKAGE@_exec_svnserve(3)

NAME
@PACKAGE@_exec_svnserve - execute svnserve in tunnel mode

SYNOPSIS
#include <@PACKAGE@/exec_svnserve.h> int @PACKAGE@_exec_svnserve(const char* svnserve_path,
const char* svn_root,
const char* tunnel_user,
const char* const* argv,
const char* const* envp);

DESCRIPTION
Executes svnserve in tunnel mode with the tunnel user set to tunnel_user and the virtual repository root path set to svn_root. Specifically, the executable named by svnserve_path is executed (see exec(3)) with the environment set to envp and with arguments --root=svn_root , --tunnel , and --tunnel-user=tunnel_user appended to the arguments given in argv. This is thread-safe if the user's C POSIX library is thread-safe.

ARGUMENTS

svnserve_path
    Null-terminated string containing the path to the svnserve executable. This must be an absolute path and must refer to an existing executable file. This parameter must not be the null pointer. Callers are encouraged to use svnstsw_fso_is_changeable(3) to check the safety of using the path before calling this function.

svn_root
    Null-terminated string containing the repository virtual root path, passed to svnserve via its --root command-line parameter. If this parameter is the null pointer or an empty string, the root directory ('/') is used. The path must be an absolute path, must exist, and must refer to a directory. Callers are encouraged to use svnstsw_fso_is_changeable(3) to check the safety of using the path before calling this function.

tunnel_user
    Null-terminated string containing the Subversion username, passed to svnserve via its --tunnel-user command-line parameter. This parameter must not be the null pointer or an empty string. Callers are encouraged to use the string returned by svnstsw_get_tunnel_user_name(3) for this parameter.

argv
    Null-terminated array of null-terminated strings to use as the first arguments to the svnserve executable. Note that convention dictates that argv[0] must match svnserve_path. If this parameter is the null pointer, it is the equivalent to passing in a two-element array consisting of svnserve_path and a null terminator. The --root=svn_root , --tunnel , and --tunnel-user=user arguments will be appended to the arguments in argv before being passed to the executable named by svnserve_path.

envp
    Null-terminated array of null-terminated strings containing the desired environment for the svnserve process. If this parameter is the null pointer, it is the equivalent to passing in an array consisting of only a null terminator. By convention, each string in this array should be in the form of name=value. For security reasons, the contents of envp might not be passed as-is to the executable named by svnserve_path.

RETURN VALUE
Does not return on success. On failure, returns a negative value and sets errno (see errno(3)).

ERRORS
Error conditions and errno (see errno(3)) values are described in the specifications for stat(3), snprintf(3), and execve(3), with the addition that EINVAL may indicate an invalid parameter.

SECURITY CONSIDERATIONS
Executables using this function are expected to be installed with either the setuid or the setgid bit set. Because of this, there are a few recommendations:

    -   The executable named by the svnserve_path argument should not be a shell script because of numerous well-known attacks via specially-crafted environment variables and arguments.

    -   The envp argument should be empty (either the null pointer or an array containing only a null terminator). This is especially true if the executable named by the svnserve_path argument is a shell script.

    -   svnserve_path and svn_root should be passed through svnstsw_fso_is_changeable(3) to make sure that neither they nor their parent directories are writable by the user.

SEE ALSO
lib@PACKAGE@(3), @PACKAGE@_get_tunnel_user_name(3), @PACKAGE@_fso_is_changeable(3), @PACKAGE@(8), svnserve(8), exec(3)

AUTHOR
Richard Hansen <svnstsw@ir.bbn.com>

COPYING
Copyright (c) 2008 BBN Technologies Corp. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

    1.  Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

    2.  Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

    3.  Neither the name of BBN Technologies nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY BBN TECHNOLOGIES AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BBN TECHNOLOGIES OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.