File: sample_client

package info (click to toggle)
libauthen-krb5-perl 1.6-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 184 kB
  • ctags: 10
  • sloc: ansic: 3,067; perl: 217; makefile: 53
file content (39 lines) | stat: -rwxr-xr-x 870 bytes parent folder | download
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
#!/usr/bin/perl

# sample_client
# sends authentication info to a server via sendauth

use blib; # remove if not in module build directory
use IO::Socket;
use Authen::Krb5 (KRB5_NT_SRV_HST);

# 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();

$clientp = Authen::Krb5::parse_name($ENV{'USER'});
$serverp = Authen::Krb5::sname_to_principal($SERVER,$SERVICE,KRB5_NT_SRV_HST);
if (Authen::Krb5::sendauth($ac,$s,"V1",$clientp,$serverp,
	AP_OPTS_MUTUAL_REQUIRED,"test",undef,$cc)) {
	print "Sent authentication info.\n";
}
else {
	print "sendauth error: ",Authen::Krb5::error(),"\n";
}

close($s);

Authen::Krb5::free_context();