2 # Show a form for editing or creating a log source
4 require './syslog-ng-lib.pl';
7 # Show title and get the source
10 &ui_print_header(undef, $text{'source_title1'}, "");
13 &ui_print_header(undef, $text{'source_title2'}, "");
14 @sources = &find("source", $conf);
15 ($source) = grep { $_->{'value'} eq $in{'name'} } @sources;
16 $source || &error($text{'source_egone'});
20 print &ui_form_start("save_source.cgi", "post");
21 print &ui_hidden("new", $in{'new'}),"\n";
22 print &ui_hidden("old", $in{'name'}),"\n";
23 print &ui_table_start($text{'source_header'}, undef, 2);
26 print &ui_table_row($text{'source_name'},
27 &ui_textbox("name", $source->{'value'}, 20));
29 # Show internal option
30 $ttable = "<table>\n";
31 $internal = &find("internal", $source->{'members'});
32 $ttable .= "<tr> <td colspan=2>".&ui_checkbox("internal", 1, "<b>$text{'sources_typei'}</b>", $internal ? 1 : 0)."</td> </tr>\n";
34 # Show Unix stream and dgram socket options
35 foreach $t ("unix-stream", "unix-dgram") {
36 $unix = &find($t, $source->{'members'});
37 local ($unix_name, $unix_owner, $unix_group, $unix_perm,
38 $unix_keep, $unix_max);
40 $unix_name = $unix->{'value'};
41 $unix_owner = &find_value("owner", $unix->{'members'});
42 $unix_group = &find_value("group", $unix->{'members'});
43 $unix_perm = &find_value("perm", $unix->{'members'});
44 $unix_keep = &find_value("keep-alive", $unix->{'members'});
45 $unix_max = &find_value("max-connections", $unix->{'members'});
47 $msg = $t eq "unix-stream" ? 'sources_types' : 'sources_typed';
48 $ttable .= "<tr> <td valign=top>".&ui_checkbox($t, 1, "<b>$text{$msg}</b>", $unix ? 1 : 0)."</td> <td><table>\n";
51 $ttable .= "<tr> <td>$text{'destination_file'}</td> <td>".
52 &ui_textbox($t."_name", $unix_name, 35)." ".
53 &file_chooser_button("unix_name")."</td> </tr>\n";
55 # Socket owner and group
56 $ttable .= "<tr> <td>$text{'source_owner'}</td> <td>".
57 &ui_opt_textbox($t."_owner", $unix_owner, 15, $text{'default'})." ".
58 &user_chooser_button($t."_owner")."</td> </tr>\n";
59 $ttable .= "<tr> <td>$text{'source_group'}</td> <td>".
60 &ui_opt_textbox($t."_group", $unix_group, 15, $text{'default'})." ".
61 &group_chooser_button($t."_group")."</td> </tr>\n";
63 # File permissions, keep-alive and max connetions
64 $ttable .= "<tr> <td>$text{'source_perm'}</td> <td>".
65 &ui_opt_textbox($t."_perm", $unix_perm, 5,$text{'default'}).
67 if ($t eq "unix-stream") {
68 $ttable .= "<tr> <td>$text{'source_keep'}</td> <td>".
69 &ui_radio($t."_keep", $unix_keep,
70 [ [ 'y', $text{'yes'} ],
72 [ '', $text{'default'} ] ])."</td> </tr>\n";
73 $ttable .= "<tr> <td>$text{'source_max'}</td> <td>".
74 &ui_opt_textbox($t."_max", $unix_max, 5,
75 $text{'default'})."</td> </tr>\n";
78 $ttable .= "</table>\n";
79 $ttable .= "</td> </tr>\n";
82 # TCP and UDP network sockets
83 foreach $t ('tcp', 'udp') {
84 $net = &find($t, $source->{'members'});
85 local ($net_ip, $net_port, $net_keep, $net_tkeep, $net_max);
87 $net_ip = &find_value("ip", $net->{'members'}) ||
88 &find_value("localip", $net->{'members'});
89 $net_port = &find_value("port", $net->{'members'}) ||
90 &find_value("localport", $net->{'members'});
91 $net_keep = &find_value("keep-alive", $net->{'members'});
92 $net_tkeep = &find_value("tcp-keep-alive", $net->{'members'});
93 $net_max = &find_value("max-connections", $net->{'members'});
95 $msg = $t eq "tcp" ? 'sources_typet' : 'sources_typeu';
96 $ttable .= "<tr> <td valign=top>".&ui_checkbox($t, 1, "<b>$text{$msg}</b>", $net ? 1 : 0)."</td> <td><table>\n";
99 $ttable .= "<tr> <td>$text{'source_ip'}</td> <td>".
100 &ui_opt_textbox($t."_ip", $net_ip, 15, $text{'source_any'}).
102 $ttable .= "<tr> <td>$text{'source_port'}</td> <td>".
103 &ui_opt_textbox($t."_port", $net_port, 6, $text{'default'}." (514)").
106 # TCP-specific options and max connections
108 $ttable .= "<tr> <td>$text{'source_keep'}</td> <td>".
109 &ui_radio($t."_keep", $net_keep,
110 [ [ 'y', $text{'yes'} ],
111 [ 'n', $text{'no'} ],
112 [ '', $text{'default'} ] ])."</td> </tr>\n";
113 $ttable .= "<tr> <td>$text{'source_tkeep'}</td> <td>".
114 &ui_radio($t."_tkeep", $net_tkeep,
115 [ [ 'y', $text{'yes'} ],
116 [ 'n', $text{'no'} ],
117 [ '', $text{'default'} ] ])."</td> </tr>\n";
119 $ttable .= "<tr> <td>$text{'source_max'}</td> <td>".
120 &ui_opt_textbox($t."_max", $net_max, 5,
121 $text{'default'})."</td> </tr>\n";
123 $ttable .= "</table>\n";
124 $ttable .= "</td> </tr>\n";
128 $file = &find("file", $source->{'members'});
130 $file_name = $file->{'value'};
131 $file_prefix = &find_value("log_prefix", $file->{'members'});
133 $ttable .= "<tr> <td valign=top>".&ui_checkbox("file", 1, "<b>$text{'sources_typef'}</b>", $file ? 1 : 0)."</td> <td><table>\n";
136 $ttable .= "<tr> <td>$text{'destination_file'}</td> <td>".
137 &ui_textbox("file_name", $file_name, 35)." ".
138 &file_chooser_button("file_name")."</td> </tr>\n";
141 $ttable .= "<tr> <td>$text{'source_prefix'}</td> <td>".
142 &ui_opt_textbox("file_prefix", $file_prefix, 20,
143 $text{'source_none'})."</td> </tr>\n";
144 $ttable .= "</table>\n";
145 $ttable .= "</td> </tr>\n";
149 $pipe = &find("pipe", $source->{'members'});
151 $pipe_name = $pipe->{'value'};
152 $pipe_prefix = &find_value("log_prefix", $pipe->{'members'});
153 $pad_size = &find_value("pad_size", $pipe->{'members'});
155 $ttable .= "<tr> <td valign=top>".&ui_checkbox("pipe", 1, "<b>$text{'sources_typep'}</b>", $pipe ? 1 : 0)."</td> <td><table>\n";
158 $ttable .= "<tr> <td>$text{'destination_file'}</td> <td>".
159 &ui_textbox("pipe_name", $pipe_name, 35)." ".
160 &file_chooser_button("pipe_name")."</td> </tr>\n";
162 # Message prefix and pad size
163 $ttable .= "<tr> <td>$text{'source_prefix'}</td> <td>".
164 &ui_opt_textbox("pipe_prefix", $pipe_prefix, 20,
165 $text{'source_none'})."</td> </tr>\n";
166 $ttable .= "<tr> <td>$text{'source_pad'}</td> <td>".
167 &ui_opt_textbox("pad_size", $pad_size, 20,
168 $text{'source_none'})."</td> </tr>\n";
169 $ttable .= "</table>\n";
170 $ttable .= "</td> </tr>\n";
173 if (&supports_sun_streams()) {
175 $sun_streams = &find("sun-streams", $source->{'members'});
177 $sun_streams_name = $sun_streams->{'value'};
178 $sun_streams_door = &find_value("door", $sun_streams->{'members'});
180 $ttable .= "<tr> <td valign=top>".&ui_checkbox("sun-streams", 1, "<b>$text{'sources_typen'}</b>", $sun_streams ? 1 : 0)."</td> <td><table>\n";
183 $ttable .= "<tr> <td>$text{'destination_file'}</td> <td>".
184 &ui_textbox("sun_streams_name", $sun_streams_name, 35)." ".
185 &file_chooser_button("sun_streams_name")."</td> </tr>\n";
188 $ttable .= "<tr> <td>$text{'source_door'}</td> <td>".
189 &ui_textbox("sun_streams_door", $sun_streams_door, 35)." ".
190 &file_chooser_button("sun_streams_name")."</td> </tr>\n";
191 $ttable .= "</table>\n";
192 $ttable .= "</td> </tr>\n";
196 $ttable .= "</table>\n";
197 print "<tr> <td colspan=2><b>$text{'source_type'}</b><br>\n";
199 print "</td> </tr>\n";
201 # Form footer and buttons
202 print &ui_table_end();
204 print &ui_form_end([ [ "create", $text{'create'} ] ]);
207 print &ui_form_end([ [ "save", $text{'save'} ],
208 [ "delete", $text{'delete'} ] ]);
210 &ui_print_footer("list_sources.cgi", $text{'sources_return'});