Commit 55f877f0 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Implement root wrapper to allow using privileged TCP ports

while not running the whole VLC as root - closes #440
parent a21fa225
......@@ -69,7 +69,7 @@ dist_pkginclude_HEADERS = \
include/vlc/input.h \
include/vlc/intf.h \
include/vlc/control.h \
include/vlc/control_structures.h \
include/vlc/control_structures.h \
$(NULL)
noinst_HEADERS = $(HEADERS_include)
......@@ -446,6 +446,7 @@ SOURCES_libvlc_common = \
src/network/tcp.c \
src/network/udp.c \
src/network/httpd.c \
src/network/rootwrap.c \
src/network/tls.c \
src/misc/charset.c \
src/misc/md5.c \
......
This diff is collapsed.
......@@ -50,6 +50,8 @@ static int SocksHandshakeTCP( vlc_object_t *,
const char *psz_host, int i_port );
extern int net_Socket( vlc_object_t *p_this, int i_family, int i_socktype,
int i_protocol );
extern int rootwrap_bind (int family, int socktype, int protocol,
const struct sockaddr *addr, size_t alen);
/*****************************************************************************
* __net_ConnectTCP:
......@@ -302,13 +304,30 @@ int *__net_ListenTCP( vlc_object_t *p_this, const char *psz_host, int i_port )
{
#if defined(WIN32) || defined(UNDER_CE)
msg_Warn( p_this, "cannot bind socket (%i)", WSAGetLastError( ) );
#else
msg_Warn( p_this, "cannot bind socket (%s)", strerror( errno ) );
#endif
net_Close( fd );
continue;
#else
int saved_errno;
saved_errno = errno;
net_Close( fd );
fd = rootwrap_bind( ptr->ai_family, ptr->ai_socktype,
ptr->ai_protocol, ptr->ai_addr,
ptr->ai_addrlen );
if( fd != -1 )
{
msg_Dbg( p_this, "got socket %d from rootwrap", fd );
}
else
{
msg_Warn( p_this, "cannot bind socket (%s)",
strerror( saved_errno ) );
continue;
}
#endif
}
msg_Dbg( p_this, "using socket %d from rootwrap", fd );
/* Listen */
if( listen( fd, 100 ) == -1 )
{
......
......@@ -45,6 +45,8 @@
static void SigHandler ( int i_signal );
#endif
extern void rootwrap( void );
/*****************************************************************************
* main: parse command line, start interface and spawn threads.
*****************************************************************************/
......@@ -73,6 +75,8 @@ int main( int i_argc, char *ppsz_argv[] )
}
#endif
rootwrap ();
/* Create a libvlc structure */
i_ret = VLC_Create();
if( i_ret < 0 )
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment