Blame SOURCES/xinetd-2.3.15-tcpmux-nameinargs-disable-service.patch

4a9f2a
Xinetd parses and applies its configuration line by line. If a user wants to
4a9f2a
specify NAMEINARGS as a flag, it has to be *before* specifying 'server_args'.
4a9f2a
4a9f2a
Author: Jan Synacek <jsynacek@redhat.com>
4a9f2a
Resolves: #1033528
4a9f2a
4a9f2a
--- a/xinetd/parse.c	2013-11-21 10:51:25.025436376 +0100
4a9f2a
+++ b/xinetd/parse.c	2013-11-21 14:45:44.374121057 +0100
4a9f2a
@@ -633,7 +633,28 @@ static status_e identify_attribute( entr
4a9f2a
 
4a9f2a
    if ( (*ap->a_parser)( attr_values, scp, op ) == OK )
4a9f2a
    {    /* This is the normal path. */
4a9f2a
-	SC_SPECIFY( scp, ap->a_id ) ;
4a9f2a
+       /* If flags contain NAMEINARGS and server_args is already set, disable the service.
4a9f2a
+          Server args are already set incorrectly. */
4a9f2a
+       if ( strcmp( ap->a_name, "flags" ) == 0 &&
4a9f2a
+            SC_SERVER_ARGV( scp ) )
4a9f2a
+       {
4a9f2a
+           int i = 0, n = pset_count( attr_values ) ;
4a9f2a
+           for ( ; i < n ; i++ ) {
4a9f2a
+               char *v = (char *)pset_pointer( attr_values, i ) ;
4a9f2a
+               if ( strcmp( v, "NAMEINARGS" ) == 0 )
4a9f2a
+                   break ;
4a9f2a
+           }
4a9f2a
+
4a9f2a
+           if ( i != n ) {
4a9f2a
+               parsemsg( LOG_ERR, func,
4a9f2a
+                         "NAMEINARGS flag is set after server_args - DISABLING SERVICE" ) ;
4a9f2a
+               SC_DISABLE( scp ) ;
4a9f2a
+           }
4a9f2a
+       }
4a9f2a
+       else
4a9f2a
+       {
4a9f2a
+           SC_SPECIFY( scp, ap->a_id ) ;
4a9f2a
+       }
4a9f2a
    }
4a9f2a
    else if ( entry_type == SERVICE_ENTRY )
4a9f2a
    {
4a9f2a
--- a/xinetd/xinetd.conf.man	2013-12-03 10:06:35.717977075 +0100
4a9f2a
+++ b/xinetd/xinetd.conf.man	2013-12-03 10:41:14.779089430 +0100
4a9f2a
@@ -106,7 +106,8 @@
4a9f2a
 This will cause the first argument in "server_args" to be argv[0] when
4a9f2a
 executing the server, as specified in "server".  This allows you to use
4a9f2a
 tcpd by putting tcpd in "server" and the name of the server in "server_args"
4a9f2a
-like in normal inetd.
4a9f2a
+like in normal inetd. This flag has to be specified before "server_args",
4a9f2a
+otherwise is not taken into account.
4a9f2a
 .TP
4a9f2a
 .B NODELAY
4a9f2a
 If the service is a tcp service and the NODELAY flag is set, then the