-
Notifications
You must be signed in to change notification settings - Fork 3
/
identd
executable file
·30 lines (28 loc) · 714 Bytes
/
identd
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
#!/usr/bin/perl
use strict;
use warnings;
use IO::Socket;
my($client,$socket);
if (!defined($ARGV[0])) { die "Please supply ident\n"; }
my $ident=$ARGV[0];
$socket = IO::Socket::INET->new(
"Proto" => "tcp",
"LocalPort" => 113,
Reuse => 1,
"Listen" => 1) or die "Error: $!\n";
print "using ident: $ident\n";
while ($client=$socket->accept()) {
my $host=$client->peerhost();
print "connection: ", $host . "\n";
my $data = <$client>;
if ($data) {
print "$host recv: $data\n";
$data =~ s/^\s+//;
$data =~ s/\s+$//;
$ident =~ s/^\s+//;
$ident =~ s/\s+$//;
print $client "$data : USERID : UNIX : $ident\n";
close $client;
}
}
undef $client if $client;