/usr/share/doc/libauthen-krb5-perl/examples/sample_server is in libauthen-krb5-perl 1.9-3build2.
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 | #!/usr/bin/perl
# sample_server
# receives authentication info from a client using recvauth
use blib; # remove if not in module build directory
use IO::Socket;
use Sys::Hostname;
use Authen::Krb5 (KRB5_NT_SRV_HST);
# replace with your own stuff
$SERVICE = "sample";
$KEYTAB_FILE = "/etc/krb5.keytab";
chomp($SERVER = hostname());
Authen::Krb5::init_context();
$ac = new Authen::Krb5::AuthContext;
$s = new IO::Socket::INET(
LocalAddr => $SERVER,
LocalPort => 12345,
Proto => 'tcp',
Reuse => 1,
Listen => 5
);
defined $s or die $!;
$ns = $s->accept();
$sprinc = Authen::Krb5::sname_to_principal($SERVER,$SERVICE,KRB5_NT_SRV_HST);
$kt = Authen::Krb5::kt_resolve("FILE:$KEYTAB_FILE");
$t = Authen::Krb5::recvauth($ac,$ns,"V1",$sprinc,$kt);
if ($t) {
print "Received authentication info.\n";
$client = $t->enc_part2->client;
print "Hello, ",$client->data,".\n";
}
else {
print "recvauth error: ",Authen::Krb5::error(),"\n";
}
close($ns);
close($s);
Authen::Krb5::free_context();
|