Debian Codegraph @

examples/auth.pl

raw
1 # -*- perl -*-
2 use strict;
3 use warnings;
4 use Sys::Virt;
5
6 my $addr = @ARGV ? shift @ARGV : "";
7 print "Addr $addr\n";
8 my $con = Sys::Virt->new(address => $addr, readonly => 0, auth => 1,
9 credlist => [
10 Sys::Virt::CRED_AUTHNAME,
11 Sys::Virt::CRED_PASSPHRASE,
12 ],
13 callback => sub {
14 my $creds = shift;
15
16
17 foreach my $cred (@{$creds}) {
18 if ($cred->{type} == Sys::Virt::CRED_AUTHNAME) {
19 $cred->{result} = "test";
20 }
21 if ($cred->{type} == Sys::Virt::CRED_PASSPHRASE) {
22 $cred->{result} = "123456";
23 }
24
25 }
26 return 0;
27 });
28
29 print "VMM type: ", $con->get_type(), "\n";
30