3 # Display a list of known services, built from those handled by inetd and
4 # from the services file
6 require './inetd-lib.pl';
7 &ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1, 0,
8 &help_search_link("inetd", "man", "doc", "howto"));
10 # break down into rpc and internet services
12 foreach $i (&list_inets()) {
15 $i->[3] =~ /^(\S+)\//;
16 if ($i->[1]) { $rpc_active{$1} = $j; }
17 else { $rpc_disabled{$1} = $j; }
21 if ($i->[1]) { $int_active{$i->[3],$i->[5]} = $j; }
22 else { $int_disabled{$i->[3],$i->[5]} = $j; }
27 print "<form action=edit_serv.cgi>\n";
28 print "<a href=\"edit_serv.cgi?new=1\">$text{'index_newservice'}</a>.<br>\n";
29 print "<table border width=100%>\n";
30 print "<tr $tb> <td><b>$text{'index_service'}</b></td> </tr>\n";
31 print "<tr $cb> <td><table width=100%>\n";
33 @slist = &list_services();
34 if ($config{'sort_mode'} == 1) {
35 @slist = sort { uc($a->[1]) cmp uc($b->[1]) } @slist;
37 elsif ($config{'sort_mode'} == 2) {
38 @slist = sort { (defined($int_active{$b->[1],$b->[3]}) ? 2 :
39 defined($int_disabled{$b->[1],$b->[3]}) ? 1 : 0) <=>
40 (defined($int_active{$a->[1],$a->[3]}) ? 2 :
41 defined($int_disabled{$a->[1],$a->[3]}) ? 1 : 0) }
45 $ia = $int_active{$s->[1],$s->[3]};
46 $id = $int_disabled{$s->[1],$s->[3]};
47 if ($ia =~ /\d/) { $op = "<b>"; $cl = "</b>"; $ip = $ia; }
48 elsif ($id =~ /\d/) { $op = "<i><b>"; $cl = "</b></i>"; $ip = $id; }
49 elsif (!$config{'show_empty'}) { next; }
50 else { $op = $cl = $ip = ""; }
51 if ($i%4 == 0) { print "<tr>\n"; }
53 print "<a href=\"edit_serv.cgi?spos=$s->[5]&ipos=$ip\">",
54 &html_escape($s->[1]),"</a>(",&html_escape($s->[3]),")";
56 if ($i++%4 == 3) { print "</tr>\n"; }
58 print "</table></td></tr></table>\n";
60 print "<table width=100%><tr>\n";
61 print "<td><a href='edit_serv.cgi?new=1'>$text{'index_newservice'}</a></td>\n";
62 if (!$config{'show_empty'}) {
63 print "<td align=right>\n";
64 print "<input type=submit value='$text{'index_edit'}'>\n";
65 print "<input name=name size=12>\n";
66 print "<select name=proto>\n";
67 foreach $p (&list_protocols()) {
68 printf "<option value=%s %s>%s\n",
69 $p, $p eq "tcp" ? "selected" : "", $p;
71 print "</select></td>\n";
73 print "</tr></table></form>\n";
76 print "<a href=\"edit_rpc.cgi?new=1\">$text{'index_newrpc'}</a>. <br>\n";
77 print "<table border width=100%>\n";
78 print "<tr $tb> <td><b>$text{'index_rpc'}</b></td> </tr>\n";
79 print "<tr $cb> <td><table width=100%>\n";
81 @rlist = &list_rpcs();
82 if ($config{'sort_mode'} == 1) {
83 @rlist = sort { uc($a->[1]) cmp uc($b->[1]) } @rlist;
85 elsif ($config{'sort_mode'} == 2) {
86 @rlist = sort { ($rpc_active{$b->[1]} ? 2 :
87 $rpc_disabled{$b->[1]} ? 1 : 0) <=>
88 ($rpc_active{$a->[1]} ? 2 :
89 $rpc_disabled{$a->[1]} ? 1 : 0) } @rlist;
92 if ($i%4 == 0) { print "<tr $cb>\n"; }
93 $ra = $rpc_active{$r->[1]};
94 $rd = $rpc_disabled{$r->[1]};
95 $ranum = $rpc_active{$r->[2]};
96 $rdnum = $rpc_disabled{$r->[2]};
97 if ($ra =~ /\d/) { $op = "<b>"; $cl = "</b>"; $rp = $ra; }
98 elsif ($ranum =~ /\d/) { $op = "<b>"; $cl = "</b>"; $rp = $ranum; }
99 elsif ($rd =~ /\d/) { $op = "<i>"; $cl = "</i>"; $rp = $rd; }
100 elsif ($rdnum =~ /\d/) { $op = "<i>"; $cl = "</i>"; $rp = $rdnum; }
101 else { $op = $cl = $rp = ""; }
103 print "<a href=\"edit_rpc.cgi?rpos=$r->[4]&ipos=$rp\">",
104 &html_escape($r->[1]),"</a>$cl</td>\n";
105 if ($i++%4 == 3) { print "</tr>\n"; }
107 print "</table></td></tr></table>\n";
108 print "<a href=\"edit_rpc.cgi?new=1\">$text{'index_newrpc'}</a>. <p>\n";
111 print "<form action=restart_inetd.cgi>\n";
112 print "<table width=100%> <tr>\n";
113 print "<td><input type=submit value=\"$text{'index_apply'}\"></td>\n";
114 print "<td valign=top> $text{'index_applymsg'}</td>\n";
115 print "</tr> </table> </form>\n";
117 &ui_print_footer("/", $text{'index'});