⚲
Project
General
Profile
Sign in
Register
Home
Projects
Help
Search
:
Rudder
All Projects
Rudder
Overview
Activity
Roadmap
Issues
Repository
Download (1.09 KB)
User story #3178
ยป check_zmd_keys.pl
Nicolas PERRON, 2013-01-11 18:05
#!/usr/bin/env perl
use
strict
;
use
warnings
;
# Splits the output of the rug command
# and checks if the given key fingerprint matches
# one of the key list
sub
Logic
{
# Variables init
my
$name
=
$_
[
0
];
my
$key_id
=
$_
[
1
];
my
$key_fingerprint
=
$_
[
2
];
my
$index
=
$_
[
3
];
my
$rug_cmd
=
'
/usr/bin/rug kl
';
open
(
RUG_CMD
,
"
$rug_cmd
|
")
or
die
;
while
(
defined
(
my
$line
=
<
RUG_CMD
>
)
)
{
# print $line;
chomp
(
$line
);
# Suppress CR/LF
if
(
my
(
$regexp
)
=
(
$line
=~
m/^(.*)\s+\| (.*?) +\| (\S*)\s*/
)
)
{
# Does this words matches the wanted ones ?
if
(
(
$name
eq
$
1
)
&&
(
$key_id
eq
$
2
)
&&
(
$key_fingerprint
eq
$
3
)
)
{
print
("
+key_
"
.
$index
.
"
_matched
");
exit
(
0
);
}
}
}
print
("
+key_
"
.
$index
.
"
_not_matched
");
}
Logic
(
@ARGV
);
(1-1/1)
Loading...