3 # Display a form for editing or creating an internet service
5 require './xinetd-lib.pl';
8 &ui_print_header(undef, $text{'serv_create'}, "");
11 &ui_print_header(undef, $text{'serv_edit'}, "");
12 @conf = &get_xinetd_config();
13 $xinet = $conf[$in{'idx'}];
14 $q = $xinet->{'quick'};
15 ($defs) = grep { $_->{'name'} eq 'defaults' } @conf;
16 foreach $m (@{$defs->{'members'}}) {
17 $ddisable{$m->{'value'}}++ if ($m->{'name'} eq 'disabled');
21 print "<form action=save_serv.cgi method=post>\n";
22 print "<input type=hidden name=new value='$in{'new'}'>\n";
23 print "<input type=hidden name=idx value='$in{'idx'}'>\n";
24 print "<table border width=100%>\n";
25 print "<tr $tb> <td><b>$text{'serv_header1'}</b></td> </tr>\n";
26 print "<tr $cb> <td><table width=100%>\n";
28 print "<tr> <td><b>$text{'serv_id'}</b></td>\n";
29 printf "<td><input name=id size=10 value='%s'></td>\n",
32 $id = $q->{'id'}->[0] || $xinet->{'value'};
33 $dis = $q->{'disable'}->[0] eq 'yes' || $ddisable{$id};
34 print "<td><b>$text{'serv_enabled'}</b></td>\n";
35 printf "<td><input type=radio name=disable value=0 %s> %s\n",
36 $dis ? '' : 'checked', $text{'yes'};
37 printf "<input type=radio name=disable value=1 %s> %s</td> </tr>\n",
38 $dis ? 'checked' : '', $text{'no'};
40 print "<td><b>$text{'serv_bind'}</b></td>\n";
41 printf "<td><input type=radio name=bind_def value=1 %s> %s\n",
42 $q->{'bind'} ? '' : 'checked', $text{'serv_bind_def'};
43 printf "<input type=radio name=bind_def value=0 %s>\n",
44 $q->{'bind'} ? 'checked' : '';
45 printf "<input name=bind size=20 value='%s'></td>\n",
48 print "<td><b>$text{'serv_port'}</b></td>\n";
49 printf "<td><input type=radio name=port_def value=1 %s> %s\n",
50 $q->{'port'} ? '' : 'checked', $text{'serv_port_def'};
51 printf "<input type=radio name=port_def value=0 %s>\n",
52 $q->{'port'} ? 'checked' : '';
53 printf "<input name=port size=8 value='%s'></td> </tr>\n",
56 print "<tr> <td><b>$text{'serv_sock'}</b></td>\n";
57 print "<td><select name=sock>\n";
58 foreach $s ('stream', 'dgram', 'raw', 'seqpacket') {
59 printf "<option value=%s %s>%s\n",
60 $s, $q->{'socket_type'}->[0] eq $s ? 'selected' : '',
63 print "</select></td>\n";
65 print "<td><b>$text{'serv_proto'}</b></td>\n";
66 print "<td><select name=proto>\n";
67 foreach $p ('', &list_protocols()) {
68 printf "<option value='%s' %s>%s\n",
69 $p, $q->{'protocol'}->[0] eq $p ? 'selected' : '',
70 $text{"proto_$p"} ? $text{"proto_$p"} : uc($p);
72 print "</select></td> </tr>\n";
74 print "</table></td></tr></table><p>\n";
75 print "<table border width=100%>\n";
76 print "<tr $tb> <td><b>$text{'serv_header2'}</b></td> </tr>\n";
77 print "<tr $cb> <td><table width=100%>\n";
79 $prog = &indexof('INTERNAL', @{$q->{'type'}}) >= 0 ? 0 :
80 $q->{'redirect'} ? 2 : 1;
81 print "<tr> <td valign=top><b>$text{'serv_prog'}</b></td> <td colspan=3>\n";
82 printf "<input type=radio name=prog value=0 %s> %s<br>\n",
83 $prog == 0 ? 'checked' : '', $text{'serv_internal'};
84 printf "<input type=radio name=prog value=1 %s> %s\n",
85 $prog == 1 ? 'checked' : '', $text{'serv_server'};
86 printf "<input name=server size=50 value='%s'><br>\n",
87 join(" ", $q->{'server'}->[0], @{$q->{'server_args'}});
88 printf "<input type=radio name=prog value=2 %s> %s\n",
89 $prog == 2 ? 'checked' : '', $text{'serv_redirect'};
90 printf "<input name=rhost size=20 value='%s'> %s\n",
91 $prog == 2 ? $q->{'redirect'}->[0] : "", $text{'serv_rport'};
92 printf "<input name=rport size=6 value='%s'></td> </tr>\n",
93 $prog == 2 ? $q->{'redirect'}->[1] : "";
95 print "<tr> <td><b>$text{'serv_user'}</b></td>\n";
96 printf "<td><input name=user size=10 value='%s'> %s</td>\n",
97 $q->{'user'}->[0], &user_chooser_button('user');
99 print "<td><b>$text{'serv_group'}</b></td>\n";
100 printf "<td><input type=radio name=group_def value=1 %s> %s\n",
101 $q->{'group'} ? '' : 'checked', $text{'serv_group_def'};
102 printf "<input type=radio name=group_def value=0 %s>\n",
103 $q->{'group'} ? 'checked' : '';
104 printf "<input name=group size=10 value='%s'> %s</td> </tr>\n",
105 $q->{'group'}->[0], &group_chooser_button('group');
107 print "<tr> <td><b>$text{'serv_wait'}</b></td>\n";
108 printf "<td><input type=radio name=wait value=1 %s> %s\n",
109 $q->{'wait'}->[0] eq 'yes' ? 'checked' : '', $text{'yes'};
110 printf "<input type=radio name=wait value=0 %s> %s</td>\n",
111 $q->{'wait'}->[0] eq 'yes' ? '' : 'checked', $text{'no'};
113 $inst = uc($q->{'instances'}->[0]) eq 'UNLIMITED' ? '' : $q->{'instances'}->[0];
114 print "<td><b>$text{'serv_inst'}</b></td>\n";
115 printf "<td><input type=radio name=inst_def value=1 %s> %s\n",
116 $inst ? '' : 'checked', $text{'serv_inst_def'};
117 printf "<input type=radio name=inst_def value=0 %s>\n",
118 $inst ? 'checked' : '';
119 printf "<input name=inst size=5 value='%s'></td> </tr>\n",
122 print "<tr> <td><b>$text{'serv_nice'}</b></td>\n";
123 printf "<td><input type=radio name=nice_def value=1 %s> %s\n",
124 $q->{'nice'} ? '' : 'checked', $text{'default'};
125 printf "<input type=radio name=nice_def value=0 %s>\n",
126 $q->{'nice'} ? 'checked' : '';
127 printf "<input name=nice size=5 value='%s'></td>\n",
130 $cps = uc($q->{'cps'}->[0]) eq 'UNLIMITED' ? '' : $q->{'cps'}->[0];
131 print "<td><b>$text{'serv_cps0'}</b></td>\n";
132 printf "<td><input type=radio name=cps_def value=1 %s> %s\n",
133 $cps ? '' : 'checked', $text{'serv_cps_def'};
134 printf "<input type=radio name=cps_def value=0 %s>\n",
135 $cps ? 'checked' : '';
136 printf "<input name=cps0 size=5 value='%s'> %s</td> </tr>\n",
139 print "<tr> <td colspan=2></td>\n";
140 print "<td><b>$text{'serv_cps1'}</b></td>\n";
141 printf "<td><input name=cps1 size=5 value='%s'> $text{'serv_sec'}</td> </tr>\n",
144 print "</table></td></tr></table><p>\n";
145 print "<table border width=100%>\n";
146 print "<tr $tb> <td><b>$text{'serv_header3'}</b></td> </tr>\n";
147 print "<tr $cb> <td><table width=100%>\n";
149 print "<tr> <td valign=top><b>$text{'serv_from'}</b></td>\n";
150 printf "<td><input type=radio name=from_def value=1 %s> %s\n",
151 $q->{'only_from'} ? '' : 'checked', $text{'serv_from_def'};
152 printf "<input type=radio name=from_def value=0 %s> %s<br>\n",
153 $q->{'only_from'} ? 'checked' : '', $text{'serv_from_sel'};
154 print "<textarea name=from rows=4 cols=20>",
155 join("\n", @{$q->{'only_from'}}),"</textarea></td>\n";
157 print "<td valign=top><b>$text{'serv_access'}</b></td>\n";
158 printf "<td><input type=radio name=access_def value=1 %s> %s\n",
159 $q->{'no_access'} ? '' : 'checked', $text{'serv_access_def'};
160 printf "<input type=radio name=access_def value=0 %s> %s<br>\n",
161 $q->{'no_access'} ? 'checked' : '', $text{'serv_access_sel'};
162 print "<textarea name=access rows=4 cols=20>",
163 join("\n", @{$q->{'no_access'}}),"</textarea></td> </tr>\n";
165 print "<tr> <td valign=top><b>$text{'serv_times'}</b></td>\n";
166 printf "<td colspan=3><input type=radio name=times_def value=1 %s> %s\n",
167 $q->{'access_times'} ? '' : 'checked', $text{'serv_times_def'};
168 printf "<input type=radio name=times_def value=0 %s>\n",
169 $q->{'access_times'} ? 'checked' : '';
170 printf "<input name=times size=40 value='%s'></td> </tr>\n",
171 join(" ", @{$q->{'access_times'}});
173 print "</table></td></tr></table>\n";
174 print "<table width=100%><tr>\n";
176 print "<td><input type=submit value='$text{'create'}'></td>\n";
179 print "<td><input type=submit value='$text{'save'}'></td>\n";
180 print "<td align=right><input type=submit name=delete ",
181 "value='$text{'delete'}'></td>\n";
183 print "</tr></table></form>\n";
185 &ui_print_footer("", $text{'index_return'});