/usr/share/perl5/EBox/CGI/Network/Wizard/Network.pm is in zentyal-network 2.3.13+quantal1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | # Copyright (C) 2010-2012 eBox Technologies S.L.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License, version 2, as
# published by the Free Software Foundation.
#
# 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
package EBox::CGI::Network::Wizard::Network;
use strict;
use warnings;
use base 'EBox::CGI::WizardPage';
use EBox::Global;
use EBox::Gettext;
use EBox::Validate;
use Error qw(:try);
sub new # (cgi=?)
{
my $class = shift;
my $self = $class->SUPER::new('template' => 'network/wizard/network.mas',
@_);
bless($self, $class);
return $self;
}
sub _masonParameters
{
my ($self) = @_;
my $net = EBox::Global->modInstance('network');
my @exifaces = ();
my @inifaces = ();
foreach my $iface ( @{$net->ifaces} ) {
if ( $net->ifaceIsExternal($iface) ) {
push (@exifaces, $iface);
} else {
push (@inifaces, $iface);
}
}
my @params = ();
push (@params, 'extifaces' => \@exifaces);
push (@params, 'intifaces' => \@inifaces);
return \@params;
}
sub _processWizard
{
my ($self) = @_;
my $net = EBox::Global->modInstance('network');
my $gwModel = $net->model('GatewayTable');
# Remove possible gateways introduced by network-import script
$gwModel->removeAll();
my $interfaces = $net->get_hash('interfaces');
foreach my $iface ( @{$net->ifaces} ) {
my $method = $self->param($iface . '_method');
if ($method eq 'dhcp') {
my $ext = $net->ifaceIsExternal($iface);
$net->setIfaceDHCP($iface, $ext, 1);
# As after the installation the method is already set
# to DHCP, we need to force the change in order to
# execute ifup during the first save changes
$interfaces->{$iface}->{changed} = 1;
} elsif ($method eq 'static') {
my $ext = $net->ifaceIsExternal($iface);
my $addr = $self->param($iface . '_address');
my $nmask = $self->param($iface . '_netmask');
my $gw = $self->param($iface . '_gateway');
my $dns1 = $self->param($iface . '_dns1');
my $dns2 = $self->param($iface . '_dns2');
$net->setIfaceStatic($iface, $addr, $nmask, $ext, 1);
if ($gw ne '') {
try {
$gwModel->add(name => $gw,
ip => $gw,
interface => $iface,
weight => 1,
default => 1);
}
# ignore errors (probably gateway already exists)
otherwise {};
}
my $dnsModel = $net->model('DNSResolver');
if ($dns1 ne '') {
try {
$dnsModel->add(nameserver => $dns1);
} otherwise {};
}
if ($dns2 ne '') {
try {
$dnsModel->add(nameserver => $dns2);
} otherwise {};
}
}
}
$net->set('interfaces', $interfaces);
}
1;
|