1#!/usr/local/bin/perl 2#/* 3# * (c) Copyright 1998-2001 by Rob Braun 4# * All rights reserved. The file named COPYRIGHT specifies the terms 5# * and conditions for redistribution. 6# */ 7 8# $RCSid = "$Id: xconv.pl,v 1.3 2005-03-29 15:50:34 bbraun Exp $"; 9 10sub print_header; 11sub print_defaults; 12 13 14print_header; 15print_defaults; 16 17while( <STDIN> ) { 18 19 chomp; 20 21 # Remove comment lines 22 if( grep /^#/, $_ ) { 23 next; 24 } 25 26 @command = split ; 27 28 if( !defined $command[0] ) { 29 next; 30 } 31 32 if( grep /rpc/, $command[2] ) { 33 print STDERR "Warning: Service $command[0] not added because\n"; 34 print STDERR "xinetd does not handle rpc services well\n"; 35 next; 36 } 37 38 print "service $command[0]\n"; 39 print "{\n"; 40 print "\tflags = NAMEINARGS\n"; 41 print "\tsocket_type = $command[1]\n"; 42 print "\tprotocol = $command[2]\n"; 43 if( grep /no/, $command[3] ) { 44 print "\twait = no\n"; 45 } else { 46 print "\twait = yes\n"; 47 } 48 @user = split /[:\.]/, $command[4]; 49 print "\tuser = $user[0]\n"; 50 if( defined $user[1] ) { 51 print "\tgroup = $user[1]\n"; 52 } 53 if( grep /internal/, $command[5] ) { 54 print "\ttype = INTERNAL\n"; 55 print "\tid = $command[0]-$command[1]\n"; 56 } else { 57 print "\tserver = $command[5]\n"; 58 print "\tserver_args = "; 59 60 $i = 6; 61 while( defined $command[$i] ) { 62 print "$command[$i] "; 63 $i++; 64 } 65 66 print "\n"; 67 } 68 print "}\n"; 69 print "\n"; 70} 71 72sub print_defaults 73{ 74 print "# The defaults section sets some information for all services\n"; 75 print "defaults\n"; 76 print "{\n"; 77 print "\t#The maximum number of requests a particular service may handle\n"; 78 print "\t# at once.\n"; 79 print "\tinstances = 25\n"; 80 print "\n"; 81 print "\t# The type of logging. This logs to a file that is specified.\n"; 82 print "\t# Another option is: SYSLOG syslog_facility [syslog_level]\n"; 83 print "\tlog_type = FILE /var/log/servicelog\n"; 84 print "\n"; 85 print "\t# What to log when the connection succeeds.\n"; 86 print "\t# PID logs the pid of the server processing the request.\n"; 87 print "\t# HOST logs the remote host's ip address.\n"; 88 print "\t# USERID logs the remote user (using RFC 1413)\n"; 89 print "\t# EXIT logs the exit status of the server.\n"; 90 print "\t# DURATION logs the duration of the session.\n"; 91 print "\tlog_on_success = HOST PID\n"; 92 print "\n"; 93 print "\t# What to log when the connection fails. Same options as above\n"; 94 print "\tlog_on_failure = HOST\n"; 95 print "\n"; 96 print "\t# The maximum number of connections a specific IP address can\n"; 97 print "\t# have to a specific service. \n"; 98 print "\tper_source = 5\n"; 99 100 print "}\n"; 101 print "\n"; 102} 103 104sub print_header 105{ 106 print "# This file generated by xconv.pl, included with the xinetd\n"; 107 print "# package. xconv.pl was written by Rob Braun (bbraun\@synack.net)\n"; 108 print "#\n"; 109 print "# The file is merely a translation of your inetd.conf file into\n"; 110 print "# the equivalent in xinetd.conf syntax. xinetd has many \n"; 111 print "# features that may not be taken advantage of with this translation.\n"; 112 print "# Please refer to the xinetd.conf man page for more information \n"; 113 print "# on how to properly configure xinetd.\n"; 114 print "\n"; 115 print "\n"; 116} 117