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

« back to all changes in this revision

Viewing changes to .pc/config_path.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;
559
559
                          $variables{'service-common-defaults'},
560
560
                        ),
561
561
    },
 
562
    'changeip' => {
 
563
        'updateable' => undef,
 
564
        'update'     => \&nic_changeip_update,
 
565
        'examples'   => \&nic_changeip_examples,
 
566
        'variables'  => merge(
 
567
                          { 'server'       => setv(T_FQDNP,  1, 0, 1, 'nic.changeip.com',    undef)    },
 
568
                          { 'min-interval' => setv(T_DELAY,  0, 0, 1, 0, interval('5m')),},
 
569
                          $variables{'service-common-defaults'},
 
570
                        ),
 
571
    },
562
572
    'dtdns' => {
563
573
        'updateable' => undef,
564
574
        'update'     => \&nic_dtdns_update,
728
738
 
729
739
                $0 = sprintf("%s - sleeping for %s seconds", $program, $left);
730
740
                $left -= sleep $delay;
 
741
                # preventing deep sleep - see [bugs:#46]
 
742
                if ($left > $daemon) {
 
743
                        $left = $daemon;
 
744
                }
731
745
        }
732
746
        $caught_hup = 0;
733
747
        $result = 0;
778
792
                foreach my $h (sort keys %config) {
779
793
                        next if $config{$h}{'protocol'} ne lc($s);
780
794
                        $examined{$h} = 1;
781
 
                        my $use = $config{$h}{'use'} || opt('use');
782
 
                        local $opt{$use} = $config{$h}{$use} if $config{$h}{$use};
783
 
                        # bug #13: we should only do this once
784
 
                        # use isn't enough, we have to save the origin to.
785
 
                        # this will break the multiple ip stuff if use has 
786
 
                        # been used twice for the same device.
 
795
                        # we only do this once per 'use' and argument combination
 
796
                        my $use = opt('use', $h);
 
797
                        my $arg_ip = opt('ip', $h) || '';
 
798
                        my $arg_fw = opt('fw', $h) || '';
 
799
                        my $arg_if = opt('if', $h) || '';
 
800
                        my $arg_web = opt('web', $h) || '';
 
801
                        my $arg_cmd = opt('cmd', $h) || '';
787
802
                        my $ip = "";
788
 
                        if (defined $iplist{$use}) {
789
 
                                $ip = $iplist{$use};
 
803
                        if (exists $iplist{$use}{$arg_ip}{$arg_fw}{$arg_if}{$arg_web}{$arg_cmd}) {
 
804
                                $ip = $iplist{$use}{$arg_ip}{$arg_fw}{$arg_if}{$arg_web}{$arg_cmd};
790
805
                        } else {
791
806
                                $ip = get_ip($use, $h);
792
807
                                if (!defined $ip || !$ip) {
798
813
                                        warning("malformed IP address (%s)", $ip);
799
814
                                        next;
800
815
                                }
801
 
                                $iplist{$use} = $ip;
 
816
                                $iplist{$use}{$arg_ip}{$arg_fw}{$arg_if}{$arg_web}{$arg_cmd} = $ip;
802
817
                        }
803
818
                        $config{$h}{'wantip'} = $ip;
804
819
                        next if !nic_updateable($h, $updateable);
1784
1799
######################################################################
1785
1800
sub load_sha1_support {
1786
1801
    my $sha1_loaded = eval {require Digest::SHA1};
1787
 
    unless ($sha1_loaded) {
 
1802
    my $sha_loaded = eval {require Digest::SHA};
 
1803
    unless ($sha1_loaded || $sha_loaded) {
1788
1804
        fatal(<<"EOM");
1789
 
Error loading the Perl module Digest::SHA1 needed for freedns update.
1790
 
On Debian, the package libdigest-sha1-perl must be installed.
 
1805
Error loading the Perl module Digest::SHA1 or Digest::SHA needed for freedns update.
 
1806
On Debian, the package libdigest-sha1-perl or libdigest-sha-perl must be installed.
1791
1807
EOM
1792
1808
    }
1793
 
    import  Digest::SHA1 (qw/sha1_hex/);
 
1809
    if($sha1_loaded) {
 
1810
        import  Digest::SHA1 (qw/sha1_hex/);
 
1811
    } elsif($sha_loaded) {
 
1812
        import  Digest::SHA (qw/sha1_hex/);
 
1813
    }
1794
1814
}
1795
1815
######################################################################
1796
1816
## geturl
1933
1953
sub get_ip {
1934
1954
    my $use = lc shift;
1935
1955
    my $h = shift;
1936
 
    my ($ip, $arg, $reply, $url, $skip) = (undef, opt($use), '');
 
1956
    my ($ip, $arg, $reply, $url, $skip) = (undef, opt($use, $h), '');
1937
1957
    $arg = '' unless $arg;
1938
1958
 
1939
1959
    if ($use eq 'ip') {
1943
1963
    } elsif ($use eq 'if') {
1944
1964
        $skip  = opt('if-skip', $h)  || '';
1945
1965
        $reply = `ifconfig $arg 2> /dev/null`;
 
1966
        $reply = `ip addr list dev $arg 2> /dev/null` if $?;
1946
1967
        $reply = '' if $?;
1947
1968
 
1948
1969
    } elsif ($use eq 'cmd') {
3593
3614
    }
3594
3615
}
3595
3616
 
3596
 
######################################################################
 
3617
###################################################################### 
 
3618
## nic_changeip_examples 
 
3619
###################################################################### 
 
3620
sub nic_changeip_examples {
 
3621
return <<EoEXAMPLE;
 
3622
 
 
3623
o 'changeip'
 
3624
 
 
3625
The 'changeip' protocol is used by DNS services offered by changeip.com.
 
3626
 
 
3627
Configuration variables applicable to the 'changeip' protocol are:
 
3628
  protocol=changeip            ##
 
3629
  server=fqdn.of.service       ## defaults to nic.changeip.com
 
3630
  login=service-login          ## login name and password registered with the service
 
3631
  password=service-password    ##
 
3632
  fully.qualified.host         ## the host registered with the service.
 
3633
 
 
3634
Example ${program}.conf file entries:
 
3635
  ## single host update
 
3636
  protocol=changeip,                                               \\
 
3637
  login=my-my-changeip.com-login,                                  \\
 
3638
  password=my-changeip.com-password                                \\
 
3639
  myhost.changeip.org
 
3640
 
 
3641
EoEXAMPLE
 
3642
 
3643
 
 
3644
######################################################################
 
3645
## nic_changeip_update
 
3646
##
 
3647
## adapted by Michele Giorato
 
3648
##
 
3649
## https://nic.ChangeIP.com/nic/update?hostname=host.example.org&myip=66.185.162.19
 
3650
##
 
3651
######################################################################
 
3652
sub nic_changeip_update {
 
3653
 
 
3654
 
 
3655
    debug("\nnic_changeip_update -------------------");
 
3656
 
 
3657
    ## update each configured host
 
3658
    foreach my $h (@_) {
 
3659
        my $ip = delete $config{$h}{'wantip'};
 
3660
        info("setting IP address to %s for %s", $ip, $h);
 
3661
        verbose("UPDATE:","updating %s", $h);
 
3662
 
 
3663
        my $url;
 
3664
        $url   = "http://$config{$h}{'server'}/nic/update";
 
3665
        $url  .= "?hostname=$h";
 
3666
        $url  .= "&ip=";
 
3667
        $url  .= $ip if $ip;
 
3668
 
 
3669
                my $reply = geturl(opt('proxy'), $url, $config{$h}{'login'}, $config{$h}{'password'});
 
3670
        if (!defined($reply) || !$reply) {
 
3671
            failed("updating %s: Could not connect to %s.", $h, $config{$h}{'server'});
 
3672
            last;
 
3673
        }
 
3674
        last if !header_ok($h, $reply);
 
3675
 
 
3676
        my @reply = split /\n/, $reply;
 
3677
        if (grep /success/i, @reply) {
 
3678
            $config{$h}{'ip'}     = $ip;
 
3679
            $config{$h}{'mtime'}  = $now;
 
3680
            $config{$h}{'status'} = 'good';
 
3681
            success("updating %s: good: IP address set to %s", $h, $ip);
 
3682
        } else {
 
3683
            $config{$h}{'status'} = 'failed';
 
3684
            warning("SENT:    %s", $url) unless opt('verbose');
 
3685
            warning("REPLIED: %s", $reply);
 
3686
            failed("updating %s: Invalid reply.", $h);
 
3687
        }
 
3688
    }
 
3689
}
3597
3690
 
3598
3691
######################################################################
3599
3692
## nic_dtdns_examples