summaryrefslogtreecommitdiffstats
path: root/perl-install/standalone/tinyfirewall
blob: 86f59e5cb7dac79a6284097528b00ebf5ab95b07 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/usr/bin/perl

# DrakNet

# Copyright (C) 1999 MandrakeSoft (damien@mandrakesoft.com)
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

use lib qw(/usr/lib/libDrakX);
use interactive;
use standalone;
use tinyfirewall;

$::isEmbedded = ($::XID, $::CCPID) = "@ARGV" =~ /--embedded (\w+) (\w+)/;
$::isWizard = "@ARGV" =~ /--wizard/;
$::Wizard_pix_up = "wiz_firewall.png";
$::Wizard_title = _("Firewalling Configuration");

local $_ = join '', @ARGV;

my $in = 'interactive'->vnew('su', 'default');

$::isEmbedded && ref($in) =~ /gtk/ or goto dd;
require Gtk;
init Gtk;

my $window1 = $::isEmbedded ? new Gtk::Plug ($::XID) : new Gtk::Window -toplevel;
$window1->signal_connect ( delete_event => sub { Gtk->exit(0); });
$window1->set_position(1);
$window1->set_title(_("Firewalling configuration"));
$window1->border_width(10);
$::isEmbedded or $window1->set_usize(500, 400);
my $vbox1 = new Gtk::VBox(0,0);
$window1->add($vbox1);
my $hbox1 = new Gtk::HBox(0,0);
$vbox1->pack_start($hbox1,1,1,0);
my $label1 = new Gtk::Label("");
$hbox1->pack_start($label1,1,1,0);
my $hbox2 = new Gtk::HBox(0,0);
$vbox1->pack_start($hbox2,1,1,0);

my $bbox1 = new Gtk::HButtonBox;
$vbox1->pack_start($bbox1,0,0,0);
$bbox1->set_layout(-end);
my $button_conf = new Gtk::Button _("Configure");
$button_conf->signal_connect ( clicked => sub {
				 system("/usr/sbin/tinyfirewall --wizard");
				 update();
			     });
$bbox1->add($button_conf);
my $button_ok = new Gtk::Button _("Cancel");
$button_ok->signal_connect ( clicked => sub {
				 quit_global();
			     });
$bbox1->add($button_ok);
$window1->show_all();
update();
Gtk->main_iteration while Gtk->events_pending;
$::isEmbedded and kill USR2, $::CCPID;
Gtk->main;
Gtk->exit(0);

sub update {
$label1->set(-e "/etc/rc.d/rc3.d/S05bastille-firewall" ?
				  _("Firewalling

You already have set up a firewall.
Click on Configure to change or remove the firewall"):
				  _("Firewalling

Click on Configure to set up a standard firewall"));
}

sub quit_global {
    $::isEmbedded ? kill(USR1, $::CCPID) : Gtk->exit(0);
}

dd:
tinyfirewall::main($in);