3 # Display a form for editing or creating an internet service
5 require './inetd-lib.pl';
9 &ui_print_header(undef, $text{'editserv_title1'}, "");
12 local @servs = &list_services();
13 local @inets = &list_inets();
14 &ui_print_header(undef, $text{'editserv_title2'}, "");
15 if (defined($in{'name'})) {
17 for($i=0; $i<@servs; $i++) {
18 $in{'spos'} = $i if ($servs[$i]->[1] eq $in{'name'} &&
19 $servs[$i]->[3] eq $in{'proto'});
21 defined($in{'spos'}) || &error($text{'editserv_ename'});
22 for($i=0; $i<@inets; $i++) {
23 $in{'ipos'} = $i if ($inets[$i]->[3] eq $in{'name'} &&
24 $inets[$i]->[5] eq $in{'proto'});
27 @serv = @{$servs[$in{'spos'}]};
28 if ($in{'ipos'} =~ /\d/) {
29 @inet = @{$inets[$in{'ipos'}]};
33 print "<form action=\"save_serv.cgi\" method=post>\n";
35 print "<input type=hidden name=spos value=$in{'spos'}>\n";
36 print "<input type=hidden name=ipos value=$in{'ipos'}>\n";
38 print "<table border width=100%>\n";
39 print "<tr $tb> <td><b>$text{'editserv_detail'}</b></td> </tr>\n";
40 print "<tr $cb> <td><table width=100%>\n";
42 print "<tr> <td nowrap><b>$text{'editserv_name'}</b></td>\n";
43 print "<td><input size=20 name=name value=\"$serv[1]\"></td>\n";
45 print "<td nowrap><b>$text{'editserv_port'}</b></td>\n";
46 print "<td nowrap><input size=10 name=port value=\"$serv[2]\"></td> </tr>\n";
48 print "<tr> <td valign=top><b>$text{'editrpc_protocol'}</b></td>\n";
49 print "<td valign=top><select name=protocol>\n";
50 foreach $p (&list_protocols()) {
51 printf "<option value=$p %s>%s %s\n",
52 $serv[3] eq $p || (!@serv && $p eq "tcp") ? "selected" : "",
53 uc($p), $prot_name{$p} ? "($prot_name{$p})" : "";
55 print "</select></td>\n";
57 print "<td valign=top><b>$text{'editrpc_aliase'}</b></td>\n";
58 printf "<td valign=top><textarea name=aliases ".
59 "rows=3 cols=20>%s</textarea></td> </tr>\n",
60 join("\n", split(/\s+/, $serv[4]));
62 print "</table></td> </tr></table><p>\n";
64 print "<table border width=100%>\n";
65 print "<tr $tb> <td><b>$text{'editrpc_server'}</b></td> </tr>\n";
66 print "<tr $cb> <td><table width=100%>\n";
68 print "<tr> <td colspan=4>\n";
69 printf "<input type=radio name=act value=0 %s> $text{'editrpc_noassigned'}\n",
70 @inet ? "" : "checked";
71 printf "<input type=radio name=act value=1 %s> $text{'editrpc_disable'}\n",
72 @inet && !$inet[1] ? "checked" : "";
73 printf "<input type=radio name=act value=2 %s> $text{'editrpc_enable'}\n",
74 $inet[1] ? "checked" : "";
75 print "</td> </tr>\n";
77 print "<tr> <td><b>$text{'editserv_program'}</b></td>\n";
78 print "<td colspan=3>";
79 if (!$config{'no_internal'}) {
80 printf "<input type=radio name=serv value=1 %s>\n",
81 $inet[8] eq "internal" ? "checked" : "";
82 print "$text{'editserv_inetd'}</td> </tr>\n";
85 $qm = ($inet[8] =~ s/^\?//);
86 $tcpd = (-x $config{'tcpd_path'} && $inet[8] eq $config{'tcpd_path'});
87 print "<tr> <td></td>\n";
88 print "<td colspan=3>";
89 if (!$config{'no_internal'}) {
90 printf "<input type=radio name=serv value=2 %s> $text{'editrpc_command'}\n",
91 $inet[8] ne "internal" && !$tcpd ? "checked" : "";
92 printf "<input name=program size=30 value=\"%s\">\n",
93 $inet[8] ne "internal" && !$tcpd ? $inet[8] : "";
94 print &file_chooser_button("program", 0);
95 printf "$text{'editserv_args'} <input name=args size=30 value=\"%s\">\n",
96 $inet[5] ne "internal" && !$tcpd ? $inet[9] : "";
99 printf "<input type=radio name=serv value=2 %s> $text{'editrpc_command'}\n",
100 !$tcpd ? "checked" : "";
101 printf "<input name=program size=30 value=\"%s\">\n",
102 !$tcpd ? $inet[8] : "";
103 print &file_chooser_button("program", 0);
104 printf "$text{'editserv_args'} <input name=args size=30 value=\"%s\">\n",
105 !$tcpd ? $inet[9] : "";
107 if ($config{'qm_mode'}) {
108 print "<br>"," " x 5;
109 printf "<input type=checkbox name=qm value=1 %s> %s\n",
110 $qm ? "checked" : "", $text{'editserv_qm'};
112 print "</td> </tr>\n";
114 if (-x $config{'tcpd_path'}) {
115 print "<tr> <td></td>\n";
116 printf "<td colspan=3><input type=radio name=serv value=3 %s>\n",
117 $tcpd ? "checked" : "";
118 print "$text{'editserv_wrapper'}\n";
119 $inet[9] =~ /^(\S+)\s*(.*)$/;
120 printf "<input name=tcpd size=15 value=\"%s\">\n", $tcpd ? $1 : "";
121 printf "$text{'editserv_args'} <input name=args2 size=30 value=\"%s\"></td> </tr>\n",
125 @op1 = split(/[:\.\/]/, $inet[6]);
126 @op2 = split(/[:\.\/]/, $inet[7]);
127 if ($inet[7] =~ /\// && $inet[7] !~ /:/) {
128 # class but no group!
129 splice(@op2, 1, 0, undef);
131 print "<tr> <td nowrap><b>$text{'editrpc_waitmode'}</b></td> <td nowrap>\n";
132 printf "<input type=radio name=wait value=wait %s> $text{'editrpc_wait'}\n",
133 $op1[0] eq "wait" ? "checked" : "";
134 printf "<input type=radio name=wait value=nowait %s> $text{'editrpc_nowait'}</td>\n",
135 $op1[0] ne "wait" ? "checked" : "";
137 print "<td nowrap><b>$text{'editrpc_execasuser'}</b></td>\n";
138 print "<td nowrap><input name=user size=8 value=\"$op2[0]\"> ",
139 &user_chooser_button("user", 0),"</td> </tr>\n";
141 if ($config{'extended_inetd'} == 1) {
142 # Display max per minute and group options
143 # This is for systems like Linux
144 print "<tr> <td nowrap><b>$text{'editrpc_max'}</b></td> <td nowrap>\n";
145 printf "<input type=radio name=permin_def value=1 %s> $text{'editrpc_default'}\n",
146 @op1 < 2 ? "checked" : "";
147 printf " <input type=radio name=permin_def value=0 %s>\n",
148 @op1 < 2 ? "" : "checked";
149 printf "<input name=permin size=5 value=\"%s\"></td>\n",
150 @op1 < 2 ? "" : $op1[1];
152 print "<td nowrap><b>$text{'editrpc_execasgrp'}</b></td> <td nowrap>\n";
153 printf "<input type=radio name=group_def value=1 %s> %s\n",
154 $op2[1] ? "" : "checked", $text{'default'};
155 printf "<input type=radio name=group_def value=0 %s>\n",
156 $op2[1] ? "checked" : "";
157 print &unix_group_input("group", $op2[1]),"</td> </tr>\n";
159 elsif ($config{'extended_inetd'} == 2) {
160 # Display max child, max per minute, group and login class options
161 # This is for systems like FreeBSD
162 print "<tr> <td nowrap><b>$text{'editrpc_max'}</b></td> <td nowrap>\n";
163 printf "<input type=radio name=permin_def value=1 %s> $text{'editrpc_default'}\n",
164 @op1 < 3 ? "checked" : "";
165 printf " <input type=radio name=permin_def value=0 %s>\n",
166 @op1 < 3 ? "" : "checked";
167 printf "<input name=permin size=5 value=\"%s\"></td>\n",
168 @op1 < 3 ? "" : $op1[2];
170 print "<td nowrap><b>$text{'editrpc_execasgrp'}</b></td>\n";
171 print "<td nowrap><select name=group>\n";
172 printf "<option value=\"\" %s> $text{'editrpc_default'}",
173 $op2[1] ? "" : "selected";
175 while(@ginfo = getgrent()) {
176 printf "<option value=\"$ginfo[0]\" %s>$ginfo[0]\n",
177 $ginfo[0] eq $op2[1] ? "selected" : "";
179 print "</select></td> </tr>\n";
180 endgrent() if ($gconfig{'os_type'} ne 'hpux');
182 print "<tr> <td nowrap><b>$text{'editserv_maxchild'}</b></td> <td nowrap>\n";
183 printf "<input type=radio name=child_def value=1 %s> $text{'editrpc_default'}\n",
184 @op1 < 2 ? "checked" : "";
185 printf " <input type=radio name=child_def value=0 %s>\n",
186 @op1 < 2 ? "" : "checked";
187 printf "<input name=child size=5 value=\"%s\"></td>\n",
188 @op1 < 2 ? "" : $op1[1];
190 print "<td nowrap><b>$text{'editserv_execlogin'}</b></td>\n";
191 print "<td><input name=class size=10 value=\"$op2[2]\"></td> </tr>\n";
194 print "</table></td></tr></table>\n";
196 print "<table width=100%>\n";
197 print "<tr> <td><input type=submit value=$text{'index_save'}></td>\n";
198 print "</form><form action=\"delete_serv.cgi\">\n";
199 print "<input type=hidden name=spos value=\"$in{'spos'}\">\n";
200 print "<input type=hidden name=ipos value=\"$in{'ipos'}\">\n";
201 print "<td align=right><input type=submit value=$text{'index_delete'}></td> </tr>\n";
202 print "</form></table><p>\n";
205 print "<input type=submit value=$text{'index_create'}></form><p>\n";
208 &ui_print_footer("", $text{'index_list'});