/usr/share/doc/libauthen-krb5-perl/examples/simple_client 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 48 49 50 51 52 53 54 55 56 57 | #!/usr/bin/perl
# simple_client
# uses mk_req & mk_priv to send an authenticated and encrypted message
use blib; # remove if not in module build directory
use IO::Socket;
use Authen::Krb5 (ADDRTYPE_INET,ADDRTYPE_IPPORT);
# replace with your own stuff
$SERVICE = "sample";
$SERVER = "server.domain.edu";
Authen::Krb5::init_context();
$ac = new Authen::Krb5::AuthContext;
$s = new IO::Socket::INET(
PeerAddr => $SERVER,
PeerPort => 12345,
Proto => 'tcp'
);
defined $s or die $!;
$cc = Authen::Krb5::cc_default();
$d = Authen::Krb5::mk_req($ac,0,$SERVICE,$SERVER,'testing',$cc);
unless ($d) {
print "mk_req error: ",Authen::Krb5::error(),"\n";
exit(1);
}
# set local and remote addresses, using network byte order
$addr = new Authen::Krb5::Address(ADDRTYPE_INET,pack("N",$s->sockaddr()));
$ports = new Authen::Krb5::Address(ADDRTYPE_IPPORT,pack("n",$s->sockport()));
$ac->setaddrs($addr,undef);
$ac->setports($ports,undef);
# create the replay cache
($l,$r) = $ac->getaddrs();
$lap = Authen::Krb5::gen_portaddr($l,$s->sockport());
$rcn = Authen::Krb5::gen_replay_name($lap,"foobar");
$rc = Authen::Krb5::get_server_rcache($rcn);
$ac->setrcache($rc);
#encrypt the message
$enc = Authen::Krb5::mk_priv($ac,"There's more than one way to do it.");
unless ($enc) {
print "mk_priv error: ",Authen::Krb5::error(),"\n";
exit(1);
}
print $s $d."__END\n".$enc."__END\n";
print "Sent authentication info and encrypted message.\n";
close($s);
Authen::Krb5::free_context();
|