Added configure check for the unix domain sockaddr length.
This commit is contained in:
parent
3d54d6a7eb
commit
2d33ab91f4
|
@ -5987,14 +5987,51 @@ EOF
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
echo $ac_n "checking "whether we need to define __i386__"""... $ac_c" 1>&6
|
echo $ac_n "checking "for sun_len in struct sockaddr_un"""... $ac_c" 1>&6
|
||||||
echo "configure:5992: checking "whether we need to define __i386__"" >&5
|
echo "configure:5992: checking "for sun_len in struct sockaddr_un"" >&5
|
||||||
if eval "test \"`echo '$''{'ac_cv_cpp_def_i386'+set}'`\" = set"; then
|
if eval "test \"`echo '$''{'ac_cv_c_sun_len'+set}'`\" = set"; then
|
||||||
echo $ac_n "(cached) $ac_c" 1>&6
|
echo $ac_n "(cached) $ac_c" 1>&6
|
||||||
else
|
else
|
||||||
cat > conftest.$ac_ext <<EOF
|
cat > conftest.$ac_ext <<EOF
|
||||||
#line 5997 "configure"
|
#line 5997 "configure"
|
||||||
#include "confdefs.h"
|
#include "confdefs.h"
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <sys/un.h>
|
||||||
|
int main() {
|
||||||
|
static struct sockaddr_un addr; addr.sun_len = 1
|
||||||
|
; return 0; }
|
||||||
|
EOF
|
||||||
|
if { (eval echo configure:6006: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||||
|
rm -rf conftest*
|
||||||
|
ac_cv_c_sun_len="yes"
|
||||||
|
else
|
||||||
|
echo "configure: failed program was:" >&5
|
||||||
|
cat conftest.$ac_ext >&5
|
||||||
|
rm -rf conftest*
|
||||||
|
ac_cv_c_sun_len="no"
|
||||||
|
fi
|
||||||
|
rm -f conftest*
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "$ac_t""$ac_cv_c_sun_len" 1>&6
|
||||||
|
if test "$ac_cv_c_sun_len" = "yes"
|
||||||
|
then
|
||||||
|
cat >> confdefs.h <<\EOF
|
||||||
|
#define HAVE_SOCKADDR_SUN_LEN 1
|
||||||
|
EOF
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
echo $ac_n "checking "whether we need to define __i386__"""... $ac_c" 1>&6
|
||||||
|
echo "configure:6029: checking "whether we need to define __i386__"" >&5
|
||||||
|
if eval "test \"`echo '$''{'ac_cv_cpp_def_i386'+set}'`\" = set"; then
|
||||||
|
echo $ac_n "(cached) $ac_c" 1>&6
|
||||||
|
else
|
||||||
|
cat > conftest.$ac_ext <<EOF
|
||||||
|
#line 6034 "configure"
|
||||||
|
#include "confdefs.h"
|
||||||
#if (defined(i386) || defined(__i386)) && !defined(__i386__)
|
#if (defined(i386) || defined(__i386)) && !defined(__i386__)
|
||||||
yes
|
yes
|
||||||
#endif
|
#endif
|
||||||
|
|
12
configure.in
12
configure.in
|
@ -891,6 +891,18 @@ then
|
||||||
AC_DEFINE(HAVE_MSGHDR_ACCRIGHTS)
|
AC_DEFINE(HAVE_MSGHDR_ACCRIGHTS)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
dnl *** Check for the sun_len member in struct sockaddr_un
|
||||||
|
|
||||||
|
AC_CACHE_CHECK("for sun_len in struct sockaddr_un", ac_cv_c_sun_len,
|
||||||
|
AC_TRY_COMPILE([#include <sys/types.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <sys/un.h>], [static struct sockaddr_un addr; addr.sun_len = 1],
|
||||||
|
ac_cv_c_sun_len="yes", ac_cv_c_sun_len="no"))
|
||||||
|
if test "$ac_cv_c_sun_len" = "yes"
|
||||||
|
then
|
||||||
|
AC_DEFINE(HAVE_SOCKADDR_SUN_LEN)
|
||||||
|
fi
|
||||||
|
|
||||||
dnl *** check for the need to define __i386__
|
dnl *** check for the need to define __i386__
|
||||||
|
|
||||||
AC_CACHE_CHECK("whether we need to define __i386__",ac_cv_cpp_def_i386,
|
AC_CACHE_CHECK("whether we need to define __i386__",ac_cv_cpp_def_i386,
|
||||||
|
|
|
@ -53,6 +53,9 @@
|
||||||
/* Define if struct msghdr contains msg_accrights */
|
/* Define if struct msghdr contains msg_accrights */
|
||||||
#undef HAVE_MSGHDR_ACCRIGHTS
|
#undef HAVE_MSGHDR_ACCRIGHTS
|
||||||
|
|
||||||
|
/* Define if struct sockaddr_un has the member sun_len */
|
||||||
|
#undef HAVE_SOCKADDR_SUN_LEN
|
||||||
|
|
||||||
/* Define if you have the Xxf86dga library (-lXxf86dga). */
|
/* Define if you have the Xxf86dga library (-lXxf86dga). */
|
||||||
#undef HAVE_LIBXXF86DGA
|
#undef HAVE_LIBXXF86DGA
|
||||||
|
|
||||||
|
|
|
@ -340,7 +340,7 @@ static int server_connect( const char *oldcwd, const char *serverdir )
|
||||||
{
|
{
|
||||||
struct sockaddr_un addr;
|
struct sockaddr_un addr;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
int s;
|
int s, slen;
|
||||||
|
|
||||||
if (chdir( serverdir ) == -1)
|
if (chdir( serverdir ) == -1)
|
||||||
{
|
{
|
||||||
|
@ -366,7 +366,11 @@ static int server_connect( const char *oldcwd, const char *serverdir )
|
||||||
if ((s = socket( AF_UNIX, SOCK_STREAM, 0 )) == -1) fatal_perror( "socket" );
|
if ((s = socket( AF_UNIX, SOCK_STREAM, 0 )) == -1) fatal_perror( "socket" );
|
||||||
addr.sun_family = AF_UNIX;
|
addr.sun_family = AF_UNIX;
|
||||||
strcpy( addr.sun_path, SOCKETNAME );
|
strcpy( addr.sun_path, SOCKETNAME );
|
||||||
if (connect( s, &addr, sizeof(addr.sun_family) + strlen(addr.sun_path) ) == -1)
|
slen = sizeof(addr) - sizeof(addr.sun_path) + strlen(addr.sun_path) + 1;
|
||||||
|
#ifdef HAVE_SOCKADDR_SUN_LEN
|
||||||
|
addr.sun_len = slen;
|
||||||
|
#endif
|
||||||
|
if (connect( s, (struct sockaddr *)&addr, slen ) == -1)
|
||||||
{
|
{
|
||||||
close( s );
|
close( s );
|
||||||
return -2;
|
return -2;
|
||||||
|
|
|
@ -345,13 +345,17 @@ static void create_server_dir(void)
|
||||||
void open_master_socket(void)
|
void open_master_socket(void)
|
||||||
{
|
{
|
||||||
struct sockaddr_un addr;
|
struct sockaddr_un addr;
|
||||||
int fd;
|
int fd, slen;
|
||||||
|
|
||||||
create_server_dir();
|
create_server_dir();
|
||||||
if ((fd = socket( AF_UNIX, SOCK_STREAM, 0 )) == -1) fatal_perror( "socket" );
|
if ((fd = socket( AF_UNIX, SOCK_STREAM, 0 )) == -1) fatal_perror( "socket" );
|
||||||
addr.sun_family = AF_UNIX;
|
addr.sun_family = AF_UNIX;
|
||||||
strcpy( addr.sun_path, "socket" );
|
strcpy( addr.sun_path, SOCKETNAME );
|
||||||
if (bind( fd, &addr, sizeof(addr.sun_family) + strlen(addr.sun_path) ) == -1)
|
slen = sizeof(addr) - sizeof(addr.sun_path) + strlen(addr.sun_path) + 1;
|
||||||
|
#ifdef HAVE_SOCKADDR_SUN_LEN
|
||||||
|
addr.sun_len = slen;
|
||||||
|
#endif
|
||||||
|
if (bind( fd, (struct sockaddr *)&addr, slen ) == -1)
|
||||||
{
|
{
|
||||||
if ((errno == EEXIST) || (errno == EADDRINUSE))
|
if ((errno == EEXIST) || (errno == EADDRINUSE))
|
||||||
fatal_error( "another server is already running\n" );
|
fatal_error( "another server is already running\n" );
|
||||||
|
@ -360,7 +364,7 @@ void open_master_socket(void)
|
||||||
}
|
}
|
||||||
atexit( socket_cleanup );
|
atexit( socket_cleanup );
|
||||||
|
|
||||||
chmod( "socket", 0600 ); /* make sure no other user can connect */
|
chmod( SOCKETNAME, 0600 ); /* make sure no other user can connect */
|
||||||
if (listen( fd, 5 ) == -1) fatal_perror( "listen" );
|
if (listen( fd, 5 ) == -1) fatal_perror( "listen" );
|
||||||
|
|
||||||
if (!(master_socket = alloc_object( &master_socket_ops, fd )))
|
if (!(master_socket = alloc_object( &master_socket_ops, fd )))
|
||||||
|
|
Loading…
Reference in New Issue