Changeset 2348


Ignore:
Timestamp:
11/10/2008 22:01:38 (4 years ago)
Author:
chris
Message:

Use getpeerucred() to identify connecting socket clients on Solaris,
and silence warnings that the peer cannot be identified on this
platform.

Remove another use of uname -o which doesn't work on Solaris.

Location:
box/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • box/trunk/configure.ac

    r2339 r2348  
    183183AC_CHECK_DECLS([O_BINARY],,,) 
    184184 
     185# Solaris provides getpeerucred() instead of getpeereid() or SO_PEERCRED 
     186AC_CHECK_HEADERS([ucred.h]) 
     187AC_CHECK_FUNCS([getpeerucred]) 
     188 
    185189AC_CHECK_DECLS([optreset],,, [[#include <getopt.h>]]) 
    186190AC_CHECK_DECLS([dirfd],,, 
     
    312316client_parcel_dir=`perl infrastructure/parcelpath.pl backup-client $target_os` 
    313317 
    314 os_name=`uname -o` 
    315 if test "$os_name" = "Cygwin"; then 
     318if test "$build_os" = "cygwin"; then 
    316319        client_parcel_dir=`cygpath -wa $client_parcel_dir | sed -e 's|\\\|/|g'` 
    317         build_dir=`cygpath -wa $build_dir | sed -e 's|\\\|/|g'` 
     320        build_dir=`        cygpath -wa $build_dir        | sed -e 's|\\\|/|g'` 
    318321fi 
    319322 
  • box/trunk/lib/common/BoxPlatform.h

    r2257 r2348  
    7373 
    7474// Find out if credentials on UNIX sockets can be obtained 
    75 #ifndef HAVE_GETPEEREID 
    76         #if !HAVE_DECL_SO_PEERCRED 
    77                 #define PLATFORM_CANNOT_FIND_PEER_UID_OF_UNIX_SOCKET 
    78         #endif 
     75#ifdef HAVE_GETPEEREID 
     76        // 
     77#elif HAVE_DECL_SO_PEERCRED 
     78        // 
     79#elif HAVE_UCRED_H && HAVE_GETPEERUCRED 
     80        // 
     81#else 
     82        #define PLATFORM_CANNOT_FIND_PEER_UID_OF_UNIX_SOCKET 
    7983#endif 
    8084 
  • box/trunk/lib/server/SocketStream.cpp

    r2253 r2348  
    1919 
    2020#ifndef WIN32 
    21 #include <poll.h> 
     21        #include <poll.h> 
     22#endif 
     23 
     24#ifdef HAVE_UCRED_H 
     25        #include <ucred.h> 
    2226#endif 
    2327 
     
    479483#endif 
    480484 
     485#if HAVE_UCRED_H && HAVE_GETPEERUCRED 
     486        ucred_t *pucred = NULL; 
     487        if(::getpeerucred(mSocketHandle, &pucred) == 0) 
     488        { 
     489                rUidOut = ucred_geteuid(pucred); 
     490                rGidOut = ucred_getegid(pucred); 
     491                ucred_free(pucred); 
     492                if (rUidOut == -1 || rGidOut == -1) 
     493                { 
     494                        BOX_ERROR("Failed to get peer credentials on " 
     495                                "socket: insufficient information"); 
     496                        return false; 
     497                } 
     498                return true; 
     499        } 
     500 
     501        BOX_LOG_SYS_ERROR("Failed to get peer credentials on socket"); 
     502#endif 
     503 
    481504        // Not available 
    482505        return false; 
    483506} 
    484507 
    485  
    486  
    487  
Note: See TracChangeset for help on using the changeset viewer.