Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 466800 Details for
Bug 612406
net-misc/wakeonlan-0.41-r2: /etc/ethers lookup doesn't work for hostnames/fqdn
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
fixed patch
wakeonlan-0.41-ethers-lookup.patch (text/plain), 2.23 KB, created by
Cédric Schieli
on 2017-03-12 09:33:42 UTC
(
hide
)
Description:
fixed patch
Filename:
MIME Type:
Creator:
Cédric Schieli
Created:
2017-03-12 09:33:42 UTC
Size:
2.23 KB
patch
obsolete
>--- wakeonlan-0.41.orig/wakeonlan >+++ wakeonlan-0.41/wakeonlan >@@ -5,6 +5,7 @@ > ######################################################################### > > use strict; >+use Net::hostent; > use Socket; > use Getopt::Std; > use vars qw($VERSION $opt_v $opt_h $opt_i $opt_p $opt_f); >@@ -44,19 +45,64 @@ > > sub wake > { >- my $hwaddr = shift; >+ my $host = shift; > my $ipaddr = shift || $DEFAULT_IP; > my $port = shift || $DEFAULT_PORT; > > my ($raddr, $them, $proto); >- my ($hwaddr_re, $pkt); >+ my ($hwaddr, $hwaddr_re, $pkt); > >- # Validate hardware address (ethernet address) >+ # get the hardware address (ethernet address) > > $hwaddr_re = join(':', ('[0-9A-Fa-f]{1,2}') x 6); >- if ($hwaddr !~ m/^$hwaddr_re$/) { >- warn "Invalid hardware address: $hwaddr\n"; >- return undef; >+ if ($host =~ m/^$hwaddr_re$/) { >+ $hwaddr = $host; >+ } else { >+ # $host is not a hardware address, try to resolve it >+ my $ip_re = join('\.', ('([0-9]|[1-9][0-9]|1[0-9]{2}|2([0-4][0-9]|5[0-5]))') x 4); >+ my $ip_addr; >+ if ($host =~ m/^$ip_re$/) { >+ $ip_addr = $host; >+ } else { >+ my $h; >+ unless ($h = gethost($host)) { >+ warn "$host is not a hardware address and I could not resolve it as to an IP address.\n"; >+ return undef; >+ } >+ $ip_addr = inet_ntoa($h->addr); >+ } >+ # look up ip in /etc/ethers >+ unless (open (ETHERS, '<', '/etc/ethers')) { >+ warn "$host is not a hardware address and I could not open /etc/ethers.\n"; >+ return undef; >+ } >+ while (<ETHERS>) { >+ if (($_ !~ m/^$/) && ($_ !~ m/^#/)) { # ignore comments >+ my ($mac, $ip); >+ ($mac, $ip) = split(' ', $_, 3); >+ if ($ip =~ m/^$ip_re$/) { >+ if ($ip eq $ip_addr) { >+ $hwaddr = $mac; >+ last; >+ } >+ next; >+ } else { >+ my $h2; >+ unless ($h2 = gethost($ip)) { >+ next; >+ } >+ if (inet_ntoa($h2->addr) eq $ip_addr) { >+ $hwaddr = $mac; >+ last; >+ } >+ } >+ } >+ } >+ close (ETHERS); >+ unless (defined($hwaddr)) { >+ warn "Could not find $host in /etc/ethers\n"; >+ return undef; >+ } > } > > # Generate magic sequence >@@ -68,7 +114,7 @@ > > # Allocate socket and send packet > >- $raddr = gethostbyname($ipaddr); >+ $raddr = gethostbyname($ipaddr)->addr; > $them = pack_sockaddr_in($port, $raddr); > $proto = getprotobyname('udp'); >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 612406
: 466800