Changeset 55f877f08dfd49f95ae5fd916d0a9162adcb59d4

Show
Ignore:
Timestamp:
12/16/05 12:18:38 (3 years ago)
Author:
Rémi Denis-Courmont <rem@videolan.org>
git-committer:
Rémi Denis-Courmont <rem@videolan.org> 1134731918 +0000
git-parent:

[a21fa2255e8a6cf288fe3ecc5c779428ec3585dc]

git-author:
Rémi Denis-Courmont <rem@videolan.org> 1134731918 +0000
Message:

Implement root wrapper to allow using privileged TCP ports
while not running the whole VLC as root - closes #440

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • Makefile.am

    r9ce752b r55f877f  
    7070    include/vlc/intf.h \ 
    7171    include/vlc/control.h \ 
    72     include/vlc/control_structures.h \  
     72    include/vlc/control_structures.h \ 
    7373    $(NULL) 
    7474 
     
    447447    src/network/udp.c \ 
    448448    src/network/httpd.c \ 
     449    src/network/rootwrap.c \ 
    449450    src/network/tls.c \ 
    450451    src/misc/charset.c \ 
  • src/network/tcp.c

    r8acc19a r55f877f  
    5151extern int net_Socket( vlc_object_t *p_this, int i_family, int i_socktype, 
    5252                       int i_protocol ); 
     53extern int rootwrap_bind (int family, int socktype, int protocol, 
     54                          const struct sockaddr *addr, size_t alen); 
    5355 
    5456/***************************************************************************** 
     
    303305#if defined(WIN32) || defined(UNDER_CE) 
    304306            msg_Warn( p_this, "cannot bind socket (%i)", WSAGetLastError( ) ); 
    305 #else 
    306             msg_Warn( p_this, "cannot bind socket (%s)", strerror( errno ) ); 
    307 #endif 
    308307            net_Close( fd ); 
    309308            continue; 
    310         } 
    311  
     309#else 
     310            int saved_errno; 
     311 
     312            saved_errno = errno; 
     313            net_Close( fd ); 
     314            fd = rootwrap_bind( ptr->ai_family, ptr->ai_socktype, 
     315                                ptr->ai_protocol, ptr->ai_addr, 
     316                                ptr->ai_addrlen ); 
     317            if( fd != -1 ) 
     318            { 
     319                msg_Dbg( p_this, "got socket %d from rootwrap", fd ); 
     320            } 
     321            else 
     322            { 
     323                msg_Warn( p_this, "cannot bind socket (%s)", 
     324                          strerror( saved_errno ) ); 
     325                continue; 
     326            } 
     327#endif 
     328        } 
     329 
     330        msg_Dbg( p_this, "using socket %d from rootwrap", fd ); 
    312331        /* Listen */ 
    313332        if( listen( fd, 100 ) == -1 ) 
  • src/vlc.c

    rc59fd2b r55f877f  
    4646#endif 
    4747 
     48extern void rootwrap( void ); 
     49 
    4850/***************************************************************************** 
    4951 * main: parse command line, start interface and spawn threads. 
     
    7476#endif 
    7577 
     78    rootwrap (); 
     79     
    7680    /* Create a libvlc structure */ 
    7781    i_ret = VLC_Create();