"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "xinetd/ident.c" between
xinetd-2.3.15.tar.gz and xinetd-2.3.15.4.tar.xz

About: xinetd is a secure replacement for inetd, the internet services daemon (openSUSE fork).

ident.c  (xinetd-2.3.15):ident.c  (xinetd-2.3.15.4.tar.xz)
skipping to change at line 93 skipping to change at line 93
{ {
/* /*
* This shouldn't happen since identification only works for * This shouldn't happen since identification only works for
* connection-based services. * connection-based services.
*/ */
msg( LOG_ERR, func, "connection has no address" ) ; msg( LOG_ERR, func, "connection has no address" ) ;
return( IDR_ERROR ) ; return( IDR_ERROR ) ;
} }
CLEAR( sin_contact ); CLEAR( sin_contact );
sin_remote = *CONN_XADDRESS( SERVER_CONNECTION( serp ) ) ;
sin_len = sizeof( sin_remote );
if ( getpeername( SERVER_FD( serp ), &sin_remote.sa, &sin_len ) == -1 )
{
msg( LOG_ERR, func, "(%d) getpeername: %m", getpid() ) ;
return( IDR_ERROR ) ;
}
sin_contact = sin_remote; sin_contact = sin_remote;
memcpy( &sin_bind, &sin_local, sizeof(sin_bind) ) ; memcpy( &sin_bind, &sin_local, sizeof(sin_bind) ) ;
local_port = 0; local_port = 0;
remote_port = 0; remote_port = 0;
if( sin_remote.sa.sa_family == AF_INET ) { if( sin_remote.sa.sa_family == AF_INET6 ) {
local_port = ntohs( sin_local.sa_in6.sin6_port ) ; local_port = ntohs( sin_local.sa_in6.sin6_port ) ;
remote_port = ntohs( sin_remote.sa_in6.sin6_port ) ; remote_port = ntohs( sin_remote.sa_in6.sin6_port ) ;
sin_contact.sa_in6.sin6_port = htons( IDENTITY_SERVICE_PORT ) ; sin_contact.sa_in6.sin6_port = htons( IDENTITY_SERVICE_PORT ) ;
sin_bind.sa_in.sin_port = 0 ; sin_bind.sa_in.sin_port = 0 ;
} else if( sin_remote.sa.sa_family == AF_INET6 ) { } else if( sin_remote.sa.sa_family == AF_INET ) {
local_port = ntohs( sin_local.sa_in.sin_port ) ; local_port = ntohs( sin_local.sa_in.sin_port ) ;
remote_port = ntohs( sin_remote.sa_in.sin_port ) ; remote_port = ntohs( sin_remote.sa_in.sin_port ) ;
sin_contact.sa_in.sin_port = htons( IDENTITY_SERVICE_PORT ) ; sin_contact.sa_in.sin_port = htons( IDENTITY_SERVICE_PORT ) ;
sin_bind.sa_in6.sin6_port = 0 ; sin_bind.sa_in6.sin6_port = 0 ;
} }
/* /*
* Create a socket, bind it, and set the close-on-exec flag on the * Create a socket, bind it, and set the close-on-exec flag on the
* descriptor. We set the flag in case we are called as part of a * descriptor. We set the flag in case we are called as part of a
* successful attempt to start a server (i.e. execve will follow). * successful attempt to start a server (i.e. execve will follow).
* The socket must be bound to the receiving address or ident might * The socket must be bound to the receiving address or ident might
* fail for multi-homed hosts. * fail for multi-homed hosts.
*/ */
sd = socket( sin_remote.sa.sa_family, SOCK_STREAM, 0 ) ; sd = socket( sin_remote.sa.sa_family, SOCK_STREAM, 0 ) ;
if ( sd == -1 ) if ( sd == -1 )
{ {
msg( LOG_ERR, func, "socket creation: %m" ) ; msg( LOG_ERR, func, "socket creation: %m" ) ;
return( IDR_ERROR ) ; return( IDR_ERROR ) ;
} }
if ( bind(sd, &sin_bind.sa, sizeof(sin_bind.sa)) == -1 )
if ( sin_bind.sa.sa_family == AF_INET )
sin_len = sizeof( sin_bind.sa_in ) ;
else
sin_len = sizeof( sin_bind.sa_in6 ) ;
if ( bind(sd, &sin_bind.sa, sin_len) == -1 )
{ {
msg( LOG_ERR, func, "socket bind: %m" ) ; msg( LOG_ERR, func, "socket bind: %m" ) ;
(void) Sclose( sd ) ; (void) Sclose( sd ) ;
return( IDR_ERROR ) ; return( IDR_ERROR ) ;
} }
if ( fcntl( sd, F_SETFD, FD_CLOEXEC ) == -1 ) if ( fcntl( sd, F_SETFD, FD_CLOEXEC ) == -1 )
{ {
msg( LOG_ERR, func, "fcntl F_SETFD: %m" ) ; msg( LOG_ERR, func, "fcntl F_SETFD: %m" ) ;
(void) Sclose( sd ) ; (void) Sclose( sd ) ;
return( IDR_ERROR ) ; return( IDR_ERROR ) ;
 End of changes. 4 change blocks. 
4 lines changed or deleted 16 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)