~ubuntu-branches/ubuntu/vivid/ddclient/vivid

« back to all changes in this revision

Viewing changes to .pc/smc-barricade-fw-alt.diff/ddclient

  • Committer: Package Import Robot
  • Author(s): Artur Rona
  • Date: 2015-01-06 11:31:11 UTC
  • mfrom: (2.2.19 sid)
  • Revision ID: package-import@ubuntu.com-20150106113111-1ztk85fkmgbtlicj
Tags: 3.8.2-2ubuntu1
* Merge from Debian unstable.  Remaining changes:
  - debian/ddclient.NetworkManager, debian/rules:
    + Use NetworkManager dispatcher to stop/start ddclient,
      fixes DNS lookup errors that caused checkins to fail.
  - debian/patches/sample_ubuntu.diff:
    + Adjust ubuntu init script, set CONF file to /etc/ddclient.conf
* debian/patches/fix_digest_sha_freedns.diff:
  - Dropped, fixed upstream.
* debian/ddclient.init:
  + Changes have been fixed in Debian.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/perl -w
2
2
#!/usr/local/bin/perl -w
3
3
######################################################################
4
 
# $Id: ddclient 130 2011-07-11 21:02:07Z wimpunk $
 
4
# $Id: ddclient 157 2013-12-26 09:02:05Z wimpunk $
5
5
#
6
6
# DDCLIENT - a Perl client for updating DynDNS information
7
7
#
20
20
use Sys::Hostname;
21
21
use IO::Socket;
22
22
 
23
 
my ($VERSION) = q$Revision: 130 $ =~ /(\d+)/;
 
23
my ($VERSION) = q$Revision: 157 $ =~ /(\d+)/;
24
24
 
25
 
my $version  = "3.8.1";
 
25
my $version  = "3.8.2";
26
26
my $programd  = $0; 
27
27
$programd =~ s%^.*/%%;
28
28
my $program   = $programd;
554
554
                          $variables{'service-common-defaults'},
555
555
                        ),
556
556
    },
 
557
    'changeip' => {
 
558
        'updateable' => undef,
 
559
        'update'     => \&nic_changeip_update,
 
560
        'examples'   => \&nic_changeip_examples,
 
561
        'variables'  => merge(
 
562
                          { 'server'       => setv(T_FQDNP,  1, 0, 1, 'nic.changeip.com',    undef)    },
 
563
                          { 'min-interval' => setv(T_DELAY,  0, 0, 1, 0, interval('5m')),},
 
564
                          $variables{'service-common-defaults'},
 
565
                        ),
 
566
    },
557
567
    'dtdns' => {
558
568
        'updateable' => undef,
559
569
        'update'     => \&nic_dtdns_update,
723
733
 
724
734
                $0 = sprintf("%s - sleeping for %s seconds", $program, $left);
725
735
                $left -= sleep $delay;
 
736
                # preventing deep sleep - see [bugs:#46]
 
737
                if ($left > $daemon) {
 
738
                        $left = $daemon;
 
739
                }
726
740
        }
727
741
        $caught_hup = 0;
728
742
        $result = 0;
773
787
                foreach my $h (sort keys %config) {
774
788
                        next if $config{$h}{'protocol'} ne lc($s);
775
789
                        $examined{$h} = 1;
776
 
                        my $use = $config{$h}{'use'} || opt('use');
777
 
                        local $opt{$use} = $config{$h}{$use} if $config{$h}{$use};
778
 
                        # bug #13: we should only do this once
779
 
                        # use isn't enough, we have to save the origin to.
780
 
                        # this will break the multiple ip stuff if use has 
781
 
                        # been used twice for the same device.
 
790
                        # we only do this once per 'use' and argument combination
 
791
                        my $use = opt('use', $h);
 
792
                        my $arg_ip = opt('ip', $h) || '';
 
793
                        my $arg_fw = opt('fw', $h) || '';
 
794
                        my $arg_if = opt('if', $h) || '';
 
795
                        my $arg_web = opt('web', $h) || '';
 
796
                        my $arg_cmd = opt('cmd', $h) || '';
782
797
                        my $ip = "";
783
 
                        if (defined $iplist{$use}) {
784
 
                                $ip = $iplist{$use};
 
798
                        if (exists $iplist{$use}{$arg_ip}{$arg_fw}{$arg_if}{$arg_web}{$arg_cmd}) {
 
799
                                $ip = $iplist{$use}{$arg_ip}{$arg_fw}{$arg_if}{$arg_web}{$arg_cmd};
785
800
                        } else {
786
801
                                $ip = get_ip($use, $h);
787
802
                                if (!defined $ip || !$ip) {
793
808
                                        warning("malformed IP address (%s)", $ip);
794
809
                                        next;
795
810
                                }
796
 
                                $iplist{$use} = $ip;
 
811
                                $iplist{$use}{$arg_ip}{$arg_fw}{$arg_if}{$arg_web}{$arg_cmd} = $ip;
797
812
                        }
798
813
                        $config{$h}{'wantip'} = $ip;
799
814
                        next if !nic_updateable($h, $updateable);
1779
1794
######################################################################
1780
1795
sub load_sha1_support {
1781
1796
    my $sha1_loaded = eval {require Digest::SHA1};
1782
 
    unless ($sha1_loaded) {
 
1797
    my $sha_loaded = eval {require Digest::SHA};
 
1798
    unless ($sha1_loaded || $sha_loaded) {
1783
1799
        fatal(<<"EOM");
1784
 
Error loading the Perl module Digest::SHA1 needed for freedns update.
1785
 
On Debian, the package libdigest-sha1-perl must be installed.
 
1800
Error loading the Perl module Digest::SHA1 or Digest::SHA needed for freedns update.
 
1801
On Debian, the package libdigest-sha1-perl or libdigest-sha-perl must be installed.
1786
1802
EOM
1787
1803
    }
1788
 
    import  Digest::SHA1 (qw/sha1_hex/);
 
1804
    if($sha1_loaded) {
 
1805
        import  Digest::SHA1 (qw/sha1_hex/);
 
1806
    } elsif($sha_loaded) {
 
1807
        import  Digest::SHA (qw/sha1_hex/);
 
1808
    }
1789
1809
}
1790
1810
######################################################################
1791
1811
## geturl
1928
1948
sub get_ip {
1929
1949
    my $use = lc shift;
1930
1950
    my $h = shift;
1931
 
    my ($ip, $arg, $reply, $url, $skip) = (undef, opt($use), '');
 
1951
    my ($ip, $arg, $reply, $url, $skip) = (undef, opt($use, $h), '');
1932
1952
    $arg = '' unless $arg;
1933
1953
 
1934
1954
    if ($use eq 'ip') {
1938
1958
    } elsif ($use eq 'if') {
1939
1959
        $skip  = opt('if-skip', $h)  || '';
1940
1960
        $reply = `ifconfig $arg 2> /dev/null`;
 
1961
        $reply = `ip addr list dev $arg 2> /dev/null` if $?;
1941
1962
        $reply = '' if $?;
1942
1963
 
1943
1964
    } elsif ($use eq 'cmd') {
3588
3609
    }
3589
3610
}
3590
3611
 
3591
 
######################################################################
 
3612
###################################################################### 
 
3613
## nic_changeip_examples 
 
3614
###################################################################### 
 
3615
sub nic_changeip_examples {
 
3616
return <<EoEXAMPLE;
 
3617
 
 
3618
o 'changeip'
 
3619
 
 
3620
The 'changeip' protocol is used by DNS services offered by changeip.com.
 
3621
 
 
3622
Configuration variables applicable to the 'changeip' protocol are:
 
3623
  protocol=changeip            ##
 
3624
  server=fqdn.of.service       ## defaults to nic.changeip.com
 
3625
  login=service-login          ## login name and password registered with the service
 
3626
  password=service-password    ##
 
3627
  fully.qualified.host         ## the host registered with the service.
 
3628
 
 
3629
Example ${program}.conf file entries:
 
3630
  ## single host update
 
3631
  protocol=changeip,                                               \\
 
3632
  login=my-my-changeip.com-login,                                  \\
 
3633
  password=my-changeip.com-password                                \\
 
3634
  myhost.changeip.org
 
3635
 
 
3636
EoEXAMPLE
 
3637
 
3638
 
 
3639
######################################################################
 
3640
## nic_changeip_update
 
3641
##
 
3642
## adapted by Michele Giorato
 
3643
##
 
3644
## https://nic.ChangeIP.com/nic/update?hostname=host.example.org&myip=66.185.162.19
 
3645
##
 
3646
######################################################################
 
3647
sub nic_changeip_update {
 
3648
 
 
3649
 
 
3650
    debug("\nnic_changeip_update -------------------");
 
3651
 
 
3652
    ## update each configured host
 
3653
    foreach my $h (@_) {
 
3654
        my $ip = delete $config{$h}{'wantip'};
 
3655
        info("setting IP address to %s for %s", $ip, $h);
 
3656
        verbose("UPDATE:","updating %s", $h);
 
3657
 
 
3658
        my $url;
 
3659
        $url   = "http://$config{$h}{'server'}/nic/update";
 
3660
        $url  .= "?hostname=$h";
 
3661
        $url  .= "&ip=";
 
3662
        $url  .= $ip if $ip;
 
3663
 
 
3664
                my $reply = geturl(opt('proxy'), $url, $config{$h}{'login'}, $config{$h}{'password'});
 
3665
        if (!defined($reply) || !$reply) {
 
3666
            failed("updating %s: Could not connect to %s.", $h, $config{$h}{'server'});
 
3667
            last;
 
3668
        }
 
3669
        last if !header_ok($h, $reply);
 
3670
 
 
3671
        my @reply = split /\n/, $reply;
 
3672
        if (grep /success/i, @reply) {
 
3673
            $config{$h}{'ip'}     = $ip;
 
3674
            $config{$h}{'mtime'}  = $now;
 
3675
            $config{$h}{'status'} = 'good';
 
3676
            success("updating %s: good: IP address set to %s", $h, $ip);
 
3677
        } else {
 
3678
            $config{$h}{'status'} = 'failed';
 
3679
            warning("SENT:    %s", $url) unless opt('verbose');
 
3680
            warning("REPLIED: %s", $reply);
 
3681
            failed("updating %s: Invalid reply.", $h);
 
3682
        }
 
3683
    }
 
3684
}
3592
3685
 
3593
3686
######################################################################
3594
3687
## nic_dtdns_examples