This file is indexed.

/usr/bin/socket_getnameinfo is in libsocket-getaddrinfo-perl 0.22-1build1.

This file is owned by root:root, with mode 0o755.

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
#!/usr/bin/perl 

eval 'exec /usr/bin/perl  -S $0 ${1+"$@"}'
    if 0; # not running under some shell

use strict;
use warnings;

use Getopt::Long;
use Socket::GetAddrInfo qw(
   getaddrinfo getnameinfo
   AI_NUMERICHOST AI_NUMERICSERV
   NI_DGRAM
);

sub usage
{
   my ( $exitcode ) = @_;

   my $basename = $0;
   $basename =~ m{/([^/]+?)$} and $basename = $1;

   print STDERR <<"EOF";
Performs a getnameinfo(3) lookup and prints the returned names

Usage:
  $basename [ADDRESS] [PORT] [options...]

Options:

  --address, -A ADDRESS Address to look up
  --port, -P PORT       Port number to look up

  --dgram               Set the NI_DGRAM flag; looks up a SOCK_DGRAM (udp)
                        rather than SOCK_STREAM (tcp) port

  --help                Display this help and exit

EOF

   exit $exitcode;
}

my $addr;
my $port;
my $flags = 0;

GetOptions(
   'address|A=s' => \$addr,
   'port|P=i'    => \$port,

   'dgram' => sub { $flags |= NI_DGRAM },

   'help|h' => sub { usage( 0 ) },
) or usage( 1 );

$addr = shift @ARGV if @ARGV and !defined $addr;
$port = shift @ARGV if @ARGV and !defined $port;

defined $addr or defined $port or
   usage( 1 );

# Need this in an address form first; we'll have to getaddrinfo() it
my ( $err, $sockaddr ) = getaddrinfo( $addr, $port, { flags => AI_NUMERICHOST|AI_NUMERICSERV } );

die "Unrecognised address or port format - $err\n" if $err;

( $err, my $host, my $service ) = getnameinfo( $sockaddr->{addr}, $flags );

die "Unable to resolve address - $err\n" if $err;

if( defined $addr and defined $port ) {
   print "Resolved address '$addr', port '$port'\n";
   print "\n";
   print "  $host $service\n";
}
elsif( defined $addr ) {
   print "Resolved address '$addr'\n";
   print "\n";
   print "  $host\n";
}
elsif( defined $port ) {
   print "Resolved port '$port'\n";
   print "\n";
   print "  $service\n";
}

__END__

=head1 NAME

C<socket_getnameinfo> - command-line tool to C<getnameinfo(3)> resolver

=head1 SYNOPSIS

B<socket_getnameinfo> [I<options...>] I<address> I<port>

=head1 DESCRIPTION

This tool provides a convenient command-line wrapper around the
C<getnameinfo(3)> resolver function. It will perform a single reverse lookup
to convert an address and port number into its host and service names. This is
mainly useful when debugging names resolution problems, because it allows
inspection of the C<getnameinfo(3)> behaviour itself, outside of any real
program that is trying to use it.

=head1 OPTIONS

=over 8

=item --address, -A ADDR

Numerical form of address to look up. If not supplied, will use the first
positional argument.

=item --port, -P PORT

Port number to look up. If not supplied, will use the second positional
argument.

=item --dgram 

Sets the C<NI_DGRAM> flag; looks up a C<SOCK_DGRAM> (udp) port allocation
rather than C<SOCK_STREAM> (tcp).

=item --help

Display a help summary and exit

=back

=head1 NOTE

Upstream this script is known as C<getnameinfo>, but was renamed on Debian.

=head1 AUTHOR

Paul Evans <leonerd@leonerd.org.uk>