#!/usr/local/bin/perl # Show a form for editing or creating a log source require './syslog-ng-lib.pl'; &ReadParse(); # Show title and get the source $conf = &get_config(); if ($in{'new'}) { &ui_print_header(undef, $text{'source_title1'}, ""); } else { &ui_print_header(undef, $text{'source_title2'}, ""); @sources = &find("source", $conf); ($source) = grep { $_->{'value'} eq $in{'name'} } @sources; $source || &error($text{'source_egone'}); } # Form header print &ui_form_start("save_source.cgi", "post"); print &ui_hidden("new", $in{'new'}),"\n"; print &ui_hidden("old", $in{'name'}),"\n"; print &ui_table_start($text{'source_header'}, undef, 2); # Source name print &ui_table_row($text{'source_name'}, &ui_textbox("name", $source->{'value'}, 20)); # Show internal option $ttable = "\n"; $internal = &find("internal", $source->{'members'}); $ttable .= "\n"; # Show Unix stream and dgram socket options foreach $t ("unix-stream", "unix-dgram") { $unix = &find($t, $source->{'members'}); local ($unix_name, $unix_owner, $unix_group, $unix_perm, $unix_keep, $unix_max); if ($unix) { $unix_name = $unix->{'value'}; $unix_owner = &find_value("owner", $unix->{'members'}); $unix_group = &find_value("group", $unix->{'members'}); $unix_perm = &find_value("perm", $unix->{'members'}); $unix_keep = &find_value("keep-alive", $unix->{'members'}); $unix_max = &find_value("max-connections", $unix->{'members'}); } $msg = $t eq "unix-stream" ? 'sources_types' : 'sources_typed'; $ttable .= "\n"; } # TCP and UDP network sockets foreach $t ('tcp', 'udp') { $net = &find($t, $source->{'members'}); local ($net_ip, $net_port, $net_keep, $net_tkeep, $net_max); if ($net) { $net_ip = &find_value("ip", $net->{'members'}) || &find_value("localip", $net->{'members'}); $net_port = &find_value("port", $net->{'members'}) || &find_value("localport", $net->{'members'}); $net_keep = &find_value("keep-alive", $net->{'members'}); $net_tkeep = &find_value("tcp-keep-alive", $net->{'members'}); $net_max = &find_value("max-connections", $net->{'members'}); } $msg = $t eq "tcp" ? 'sources_typet' : 'sources_typeu'; $ttable .= "\n"; } # Kernel log file $file = &find("file", $source->{'members'}); if ($file) { $file_name = $file->{'value'}; $file_prefix = &find_value("log_prefix", $file->{'members'}); } $ttable .= "\n"; # Pipe file $pipe = &find("pipe", $source->{'members'}); if ($pipe) { $pipe_name = $pipe->{'value'}; $pipe_prefix = &find_value("log_prefix", $pipe->{'members'}); $pad_size = &find_value("pad_size", $pipe->{'members'}); } $ttable .= "\n"; if (&supports_sun_streams()) { # Sun streams file $sun_streams = &find("sun-streams", $source->{'members'}); if ($sun_streams) { $sun_streams_name = $sun_streams->{'value'}; $sun_streams_door = &find_value("door", $sun_streams->{'members'}); } $ttable .= "\n"; } # Show types table $ttable .= "
".&ui_checkbox("internal", 1, "$text{'sources_typei'}", $internal ? 1 : 0)."
".&ui_checkbox($t, 1, "$text{$msg}", $unix ? 1 : 0)." \n"; # Socket filename $ttable .= "\n"; # Socket owner and group $ttable .= "\n"; $ttable .= "\n"; # File permissions, keep-alive and max connetions $ttable .= "\n"; if ($t eq "unix-stream") { $ttable .= "\n"; $ttable .= "\n"; } $ttable .= "
$text{'destination_file'} ". &ui_textbox($t."_name", $unix_name, 35)." ". &file_chooser_button("unix_name")."
$text{'source_owner'} ". &ui_opt_textbox($t."_owner", $unix_owner, 15, $text{'default'})." ". &user_chooser_button($t."_owner")."
$text{'source_group'} ". &ui_opt_textbox($t."_group", $unix_group, 15, $text{'default'})." ". &group_chooser_button($t."_group")."
$text{'source_perm'} ". &ui_opt_textbox($t."_perm", $unix_perm, 5,$text{'default'}). "
$text{'source_keep'} ". &ui_radio($t."_keep", $unix_keep, [ [ 'y', $text{'yes'} ], [ 'n', $text{'no'} ], [ '', $text{'default'} ] ])."
$text{'source_max'} ". &ui_opt_textbox($t."_max", $unix_max, 5, $text{'default'})."
\n"; $ttable .= "
".&ui_checkbox($t, 1, "$text{$msg}", $net ? 1 : 0)." \n"; # Local IP and port $ttable .= "\n"; $ttable .= "\n"; # TCP-specific options and max connections if ($t eq "tcp") { $ttable .= "\n"; $ttable .= "\n"; } $ttable .= "\n"; $ttable .= "
$text{'source_ip'} ". &ui_opt_textbox($t."_ip", $net_ip, 15, $text{'source_any'}). "
$text{'source_port'} ". &ui_opt_textbox($t."_port", $net_port, 6, $text{'default'}." (514)"). "
$text{'source_keep'} ". &ui_radio($t."_keep", $net_keep, [ [ 'y', $text{'yes'} ], [ 'n', $text{'no'} ], [ '', $text{'default'} ] ])."
$text{'source_tkeep'} ". &ui_radio($t."_tkeep", $net_tkeep, [ [ 'y', $text{'yes'} ], [ 'n', $text{'no'} ], [ '', $text{'default'} ] ])."
$text{'source_max'} ". &ui_opt_textbox($t."_max", $net_max, 5, $text{'default'})."
\n"; $ttable .= "
".&ui_checkbox("file", 1, "$text{'sources_typef'}", $file ? 1 : 0)." \n"; # Log filename $ttable .= "\n"; # Message prefix $ttable .= "\n"; $ttable .= "
$text{'destination_file'} ". &ui_textbox("file_name", $file_name, 35)." ". &file_chooser_button("file_name")."
$text{'source_prefix'} ". &ui_opt_textbox("file_prefix", $file_prefix, 20, $text{'source_none'})."
\n"; $ttable .= "
".&ui_checkbox("pipe", 1, "$text{'sources_typep'}", $pipe ? 1 : 0)." \n"; # Log pipename $ttable .= "\n"; # Message prefix and pad size $ttable .= "\n"; $ttable .= "\n"; $ttable .= "
$text{'destination_file'} ". &ui_textbox("pipe_name", $pipe_name, 35)." ". &file_chooser_button("pipe_name")."
$text{'source_prefix'} ". &ui_opt_textbox("pipe_prefix", $pipe_prefix, 20, $text{'source_none'})."
$text{'source_pad'} ". &ui_opt_textbox("pad_size", $pad_size, 20, $text{'source_none'})."
\n"; $ttable .= "
".&ui_checkbox("sun-streams", 1, "$text{'sources_typen'}", $sun_streams ? 1 : 0)." \n"; # Log filename $ttable .= "\n"; # Door name $ttable .= "\n"; $ttable .= "
$text{'destination_file'} ". &ui_textbox("sun_streams_name", $sun_streams_name, 35)." ". &file_chooser_button("sun_streams_name")."
$text{'source_door'} ". &ui_textbox("sun_streams_door", $sun_streams_door, 35)." ". &file_chooser_button("sun_streams_name")."
\n"; $ttable .= "
\n"; print " $text{'source_type'}
\n"; print $ttable; print " \n"; # Form footer and buttons print &ui_table_end(); if ($in{'new'}) { print &ui_form_end([ [ "create", $text{'create'} ] ]); } else { print &ui_form_end([ [ "save", $text{'save'} ], [ "delete", $text{'delete'} ] ]); } &ui_print_footer("list_sources.cgi", $text{'sources_return'});