This file is indexed.

/usr/share/perl5/EBox/Network/Model/DynDNS.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
# Copyright (C) 2009-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::Network::Model::DynDNS;

use base 'EBox::Model::DataForm';

use strict;
use warnings;

use EBox::Exceptions::MissingArgument;
use EBox::Gettext;
use EBox::Global;
use EBox::Types::DomainName;
use EBox::Types::Password;
use EBox::Types::Select;
use EBox::Types::Text;

use constant STORE_URL => 'http://store.zentyal.com/';
use constant BASIC_URL => STORE_URL . 'serversubscriptions/subscription-basic.html?utm_source=zentyal&utm_medium=network&utm_campaign=dynamicdns';
use constant SB_URL => STORE_URL . 'small-business-edition.html/?utm_source=zentyal&utm_medium=dyndns&utm_campaign=smallbusiness_edition';
use constant ENT_URL => STORE_URL . 'enterprise-edition.html/?utm_source=zentyal&utm_medium=dyndns&utm_campaign=enterprise_edition';

our %SERVICES = (
    dyndns => {
        printableValue => 'DynDNS',
        protocol => 'dyndns2',
        server => 'members.dyndns.org',
        use => 'web',
        web => 'checkip.dyndns.com',
        web_skip => 'Current IP Address:',
        require_info => 1,
    },
    zoneedit => {
        printableValue => 'ZoneEdit',
        protocol => 'zoneedit1',
        server => 'dynamic.zoneedit.com',
        use => 'web',
        web => 'dynamic.zoneedit.com/checkip.html',
        web_skip => 'Current IP Address:',
        require_info => 1,
    },
    easydns => {
        printableValue => 'EasyDNS',
        protocol => 'easydns',
        server => 'members.easydns.com',
        use => 'web',
        web => 'checkip.dyndns.com',
        web_skip => 'Current IP Address:',
        require_info => 1,
    },
#    disabled until ddclient bug #30 is fixed
#       http://sourceforge.net/apps/trac/ddclient/ticket/30
#     dnspark => {
#         printableValue => 'dnspark.com',
#         protocol => 'dnspark',
#         server => 'www.dnspark.com',
#         use => 'web',
#         web => 'ipdetect.dnspark.com',
#         web_skip => 'Current Address:',
#         require_info => 1,
#     },
    joker => {
        printableValue => 'Joker.com',
        protocol => 'dyndns2',
        server => 'svc.joker.com',
        use => 'web',
        web => 'svc.joker.com/nic/checkip',
        web_skip => 'Current IP Address:',
        require_info => 1,
    },
    cloud => {
        printableValue => __('Zentyal Cloud'),
        protocol => 'dyndns2',
        use => 'web',
        web => 'svc.joker.com/nic/checkip',
        web_skip => 'Current IP Address:',
        require_info => 0,
    },
);

# Dependencies

# Group: Public methods

# Constructor: new
#
#     Create the DynDNS model
#
# Overrides:
#
#     <EBox::Model::DataForm::new>
#
# Returns:
#
#     <EBox::Network::Model::DynDNS>
#
sub new
{

      my $class = shift;

      my $self = $class->SUPER::new(@_);

      bless ( $self, $class );

      return $self;

}

# Method: viewCustomizer
#
#    Overrides to disable the remainder fields if service selected is
#    Zentyal Cloud
#
# Overrides:
#
#    <EBox::Model::DataTable::viewCustomizer>
#
sub viewCustomizer
{
    my ($self) = @_;

    my $customizer = new EBox::View::Customizer();
    $customizer->setModel($self);
    my $remainderFields = [ qw(username password hostname) ];

    my $serviceAction = {};
    foreach my $serviceKey (keys %SERVICES) {
        if ( $SERVICES{$serviceKey}->{require_info} ) {
            $serviceAction->{$serviceKey} = { enable => $remainderFields };
        } else {
            $serviceAction->{$serviceKey} = { disable => $remainderFields };
        }
    }

    $customizer->setOnChangeActions( { service => $serviceAction } );
    unless ( $self->_isSubscribed() ) {
        $customizer->setPermanentMessage(_message(), 'ad');
    }

    return $customizer;

}

# Method: validateTypedRow
#
#   Check the used service requires info from form
#
# Overrides:
#
#      <EBox::Model::DataTable::validateTypedRow>
#
sub validateTypedRow
{
    my ($self, $action, $changedFields, $allFields) = @_;

    if ( $allFields->{enableDDNS}->value()
         and $SERVICES{$allFields->{service}->value()}->{require_info} ) {
        # Check the username, password and domain name are set
        foreach my $field (qw(username password hostname)) {
            unless ( $allFields->{$field}->value() ) {
                throw EBox::Exceptions::MissingArgument( $allFields->{$field}->printableName() );
            }
        }
    }
}

# Group: Protected methods

# Method: _table
#
# Overrides:
#
#     <EBox::Model::DataForm::_table>
#
sub _table
{
    my ($self) = @_;

    my @tableHeader =
      (
       new EBox::Types::Boolean(
           'fieldName'     => 'enableDDNS',
           'printableName' => __('Enable Dynamic DNS'),
           'editable'      => 1,
           ),
       new EBox::Types::Select(
           'fieldName'     => 'service',
           'printableName' => __('Service'),
           'populate'      => \&services,
           'editable'      => 1,
           ),
       new EBox::Types::Text(
           'fieldName'     => 'username',
           'printableName' => __('Username'),
           'editable'      => 1,
           'optional'      => 1,
           ),
       new EBox::Types::Password(
           'fieldName'     => 'password',
           'printableName' => __('Password'),
           'editable'      => 1,
           'optional'      => 1,
           ),
       new EBox::Types::DomainName(
           'fieldName'     => 'hostname',
           'printableName' => __('Hostname'),
           'editable'      => 1,
           'optional'      => 1,
           ),
      );

      my $dataTable = {
                       tableName          => 'DynDNS',
                       disableAutocomplete => 1,
                       pageTitle          => ('Dynamic DNS'),
                       printableTableName => __('Configuration'),
                       defaultActions     => [ 'editField', 'changeView' ],
                       tableDescription   => \@tableHeader,
                       class              => 'dataForm',
                       help               => __('You should select your provider from the list '
                                               . 'and enter your account data. '
                                               . 'You also need to enable it in order to work.'),
                       modelDomain        => 'Network',
                     };

      return $dataTable;

}

# Group: Callback functions

# Service populate function
sub services
{
    my @providers;
    foreach my $serviceKey (keys %SERVICES) {
        push @providers, {
            value => $serviceKey,
            printableValue => $SERVICES{$serviceKey}->{printableValue}
        };
        if ( $serviceKey eq 'cloud' ) {
            $providers[-1]->{disabled} = not _isSubscribed();
        }
    }
    return \@providers;
}

# Group: Private methods

sub _isSubscribed
{

    my $gl = EBox::Global->getInstance(1);
    if ( $gl->modExists('remoteservices') ) {
        my $rs = $gl->modInstance('remoteservices');
        if ( $rs->eBoxSubscribed() ) {
            return 1;
        }
    }
    return 0;

}

sub _message
{
    return __sx('You can configure your Dynamic DNS provider here. If yor server is already subscribed to Zentyal Cloud, your provider is Zentyal Cloud. Get the Free {ohb}Basic Subscription{ch}, or {ohs}Small Business{ch} or {ohe}Enterprise{ch} to obtain zentyal.me subdomain for your server.',
                ohb => '<a href="' . BASIC_URL . '" target="_blank">',
                ohs => '<a href="' . SB_URL . '" target="_blank">',
                ohe => '<a href="' . ENT_URL . '" target="_blank">',
                ch  => '</a>');
}

1;