3 # Display all xinetd services
5 require './xinetd-lib.pl';
6 &ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1, 0,
7 &help_search_link("xinetd", "man", "doc", "google"));
9 # Check for config file
10 if (!-r $config{'xinetd_conf'}) {
11 print "<p>",&text('index_econf', "<tt>$config{'xinetd_conf'}</tt>",
12 "$gconfig{'webprefix'}/config.cgi?$module_name"),"<p>\n";
13 &ui_print_footer("/", $text{'index'});
17 @conf = &get_xinetd_config();
18 ($defs) = grep { $_->{'name'} eq 'defaults' } @conf;
19 foreach $m (@{$defs->{'members'}}) {
20 $ddisable{$m->{'value'}}++ if ($m->{'name'} eq 'disabled');
24 print "<form action=mass_enable.cgi method=post>\n";
25 @links = ( &select_all_link("serv"),
26 &select_invert_link("serv"),
27 "<a href='edit_serv.cgi?new=1'>$text{'index_add_inet'}</a>" );
28 print &ui_links_row(\@links);
30 print &ui_columns_start([ "",
36 $text{'index_server'},
37 $text{'index_enabled'} ], 100, 0, \@tds);
39 # Show one row for each service
41 next if ($x->{'name'} ne 'service');
42 local $q = $x->{'quick'};
44 if ($q->{'type'}->[0] eq 'UNLISTED') {
45 # Port and protocol specified
46 @s = ( $x->{'name'}, undef, $q->{'port'}->[0],
47 $q->{'protocol'}->[0] );
49 elsif ($q->{'protocol'}) {
50 # Protocol specified, find port from service
51 if ($config{'lookup_servs'}) {
52 @s = getservbyname($x->{'value'}, $q->{'protocol'}->[0]);
55 @s = ( $x->{'name'}, undef, $q->{'port'}->[0],
56 $q->{'protocol'}->[0] );
60 # Only service specified, check protocols based on socket type,
61 # or failing that all protocols
62 if ($config{'lookup_servs'}) {
64 if ($q->{'socket_type'}->[0] eq 'stream') {
67 elsif ($q->{'socket_type'}->[0] eq 'dgram') {
71 @protos = &list_protocols();
73 foreach $p (@protos) {
74 @s = getservbyname($x->{'value'}, $p);
80 push(@cols, "<a href='edit_serv.cgi?idx=$x->{'index'}'>".
81 &html_escape($x->{'value'})."</a>");
82 push(@cols, &indexof('RPC', @{$q->{'type'}}) < 0 ?
83 $text{'index_inet'} : $text{'index_rpc'});
85 push(@cols, &html_escape($s[2]) ||
86 "<i>$text{'index_noport'}</i>");
87 push(@cols, &html_escape(uc($s[3])));
90 push(@cols, "<i>$text{'index_noport'}</i>", "");
92 push(@cols, $q->{'user'} ? &html_escape($q->{'user'}->[0]) : "");
93 push(@cols, &indexof('INTERNAL', @{$q->{'type'}}) >= 0 ?
94 $text{'index_internal'} : $q->{'redirect'} ?
95 &text('index_redirect', "<tt>".&html_escape($q->{'redirect'}->[0])."</tt>") :
96 &html_escape($q->{'server'}->[0]));
97 $id = $q->{'id'}->[0] || $x->{'value'};
98 push(@cols, $q->{'disable'}->[0] eq 'yes' || $ddisable{$id} ?
99 "<font color=#ff0000>$text{'no'}</font>" : $text{'yes'});
100 print &ui_checked_columns_row(\@cols, \@tds, "serv", $x->{'index'});
102 print &ui_columns_end();
103 print &ui_links_row(\@links);
105 print "<input type=submit name=enable value='$text{'index_enable'}'>\n";
106 print "<input type=submit name=disable value='$text{'index_disable'}'>\n";
111 print &ui_buttons_start();
112 print &ui_buttons_row("edit_defaults.cgi", $text{'index_defaults'},
113 $text{'index_defaultsmsg'});
115 if ($pid = &is_xinetd_running()) {
116 print &ui_buttons_row("restart.cgi", $text{'index_apply'},
117 $text{'index_applymsg'});
120 print &ui_buttons_row("start.cgi", $text{'index_start'},
121 $text{'index_startmsg'});
123 print &ui_buttons_end();
125 &ui_print_footer("/", $text{'index'});