Skip to content

Commit 1d9948d

Browse files
author
Marcin Przepiorowski
committed
v2.4.12 - with password changes
2 parents d278c79 + f4e65d0 commit 1d9948d

File tree

2 files changed

+123
-81
lines changed

2 files changed

+123
-81
lines changed

bin/dxtools.conf.example

Lines changed: 59 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,63 @@
11
{
22
"data":[
3-
{
4-
"hostname" : "Landshark",
5-
"ip_address" : "delphix01",
6-
"username" : "admin",
7-
"password" : "delphix",
8-
"port" : "80",
9-
"default" : "false",
10-
"encrypted" : "false",
11-
"timeout" : "60"
12-
},
13-
{
14-
"hostname" : "Landshark2",
15-
"ip_address" : "delphix02",
16-
"username" : "admin",
17-
"password" : "delphix",
18-
"port" : "443",
19-
"default" : "true",
20-
"encrypted" : "false",
21-
"protocol" : "https"
22-
},
23-
{
24-
"hostname" : "Delphix32",
25-
"ip_address" : "192.168.1.32",
26-
"username" : "admin",
27-
"password" : "#papapaewiru32472931u12",
28-
"port" : "80",
29-
"default" : "true",
30-
"encrypted" : "true"
31-
},
32-
{
33-
"hostname" : "Delphix32",
34-
"ip_address" : "192.168.1.32",
35-
"username" : "admin",
36-
"passwordvar" : "DELPASS",
37-
"port" : "80",
38-
"default" : "true",
39-
"encrypted" : "false"
40-
},
41-
{
42-
"hostname" : "Delphix32",
43-
"ip_address" : "192.168.1.32",
44-
"username" : "admin",
45-
"passwordscript" : "/home/delphix/givemepass.sh",
46-
"additionalopt" : "safefordelphix32",
47-
"port" : "80",
48-
"default" : "true",
49-
"encrypted" : "false"
50-
},
51-
{
52-
"hostname" : "marcinapi",
53-
"ip_address" : "192.168.1.32",
54-
"clientid" : "0oa6rs0js1f1zrueye",
55-
"clientsecret" : "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
56-
"port" : "80",
57-
"default" : "true",
58-
"encrypted" : "false",
59-
"timeout" : "60"
60-
}
3+
{
4+
"hostname" : "Landshark",
5+
"ip_address" : "delphix01",
6+
"username" : "admin",
7+
"password" : "delphix",
8+
"port" : "80",
9+
"default" : "false",
10+
"encrypted" : "false",
11+
"timeout" : "60"
12+
},
13+
{
14+
"hostname" : "Landshark2",
15+
"ip_address" : "delphix02",
16+
"username" : "admin",
17+
"password" : "delphix",
18+
"port" : "443",
19+
"default" : "true",
20+
"encrypted" : "false",
21+
"protocol" : "https"
22+
},
23+
{
24+
"hostname" : "Delphix32",
25+
"ip_address" : "192.168.1.32",
26+
"username" : "admin",
27+
"password" : "#papapaewiru32472931u12",
28+
"port" : "80",
29+
"default" : "true",
30+
"encrypted" : "true"
31+
},
32+
{
33+
"hostname" : "Delphix32",
34+
"ip_address" : "192.168.1.32",
35+
"username" : "admin",
36+
"passwordvar" : "DELPASS",
37+
"port" : "80",
38+
"default" : "true",
39+
"encrypted" : "false"
40+
},
41+
{
42+
"hostname" : "Delphix32",
43+
"ip_address" : "192.168.1.32",
44+
"username" : "admin",
45+
"passwordscript" : "/home/delphix/givemepass.sh",
46+
"additionalopt" : "safefordelphix32",
47+
"prevalidate" : "false",
48+
"port" : "80",
49+
"default" : "true",
50+
"encrypted" : "false"
51+
},
52+
{
53+
"hostname" : "marcinapi",
54+
"ip_address" : "192.168.1.32",
55+
"clientid" : "0oa6rs0js1f1zrueye",
56+
"clientsecret" : "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
57+
"port" : "80",
58+
"default" : "true",
59+
"encrypted" : "false",
60+
"timeout" : "60"
61+
}
6162
]
6263
}

lib/Engine.pm

Lines changed: 64 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ sub load_config {
185185
$engines{$name}{passwordvar} = $host->{passwordvar};
186186
$engines{$name}{passwordscript} = $host->{passwordscript};
187187
$engines{$name}{additionalopt} = $host->{additionalopt};
188+
$engines{$name}{prevalidate} = defined($host->{prevalidate}) ? $host->{prevalidate} : 'false';
188189

189190
if (!defined($nodecrypt)) {
190191
if ($engines{$name}{encrypted} eq "true") {
@@ -477,6 +478,56 @@ sub getUsername {
477478
return $ret;
478479
}
479480

481+
482+
# Procedure extended_password
483+
# parameters:
484+
485+
486+
sub extended_password {
487+
my $self = shift;
488+
my $engine_config = shift;
489+
490+
logger($self->{_debug}, "Entering Engine::extended_password",1);
491+
if ((defined($engine_config->{passwordvar})) && ($engine_config->{passwordvar} ne "")) {
492+
logger($self->{_debug}, "Password variable $engine_config->{passwordvar} used to get password");
493+
if (defined($ENV{$engine_config->{passwordvar}})) {
494+
$self->{_password} = $ENV{$engine_config->{passwordvar}};
495+
} else {
496+
print "Password variable $engine_config->{passwordvar} not set\n";
497+
logger($self->{_debug}, "Password variable $engine_config->{passwordvar} not set");
498+
return 1;
499+
}
500+
} elsif ((defined($engine_config->{passwordscript})) && ($engine_config->{passwordscript} ne "")) {
501+
logger($self->{_debug}, "Password script $engine_config->{passwordscript} used to get password");
502+
my $line = $engine_config->{passwordscript} . " " . $self->{_enginename} . " " . $engine_config->{username} . " " . $engine_config->{ip_address};
503+
if ((defined($engine_config->{additionalopt})) && ($engine_config->{additionalopt} ne "")) {
504+
$line = $line . " " . $engine_config->{additionalopt};
505+
}
506+
logger($self->{_debug}, "Script command line $line");
507+
if (! -f "$engine_config->{passwordscript}") {
508+
print "Password script $engine_config->{passwordscript} doesn't exist\n";
509+
logger($self->{_debug}, "Password script $engine_config->{passwordscript} doesn't exist");
510+
return 1;
511+
}
512+
513+
if (! -x "$engine_config->{passwordscript}") {
514+
print "Password script $engine_config->{passwordscript} is not executable\n";
515+
logger($self->{_debug}, "Password script $engine_config->{passwordscript} is not executable");
516+
return 1;
517+
}
518+
519+
my $out = qx|$line|;
520+
if ( $? ne 0) {
521+
return 1;
522+
}
523+
$out =~ s/^\s+|\s+$//g;
524+
$self->{_password} = $out;
525+
}
526+
527+
return 0;
528+
529+
}
530+
480531
# Procedure getApi
481532
# parameters:
482533
# Return api version
@@ -547,31 +598,12 @@ sub dlpx_connect {
547598
}
548599

549600

550-
if ((defined($engine_config->{passwordvar})) && ($engine_config->{passwordvar} ne "")) {
551-
logger($self->{_debug}, "Password variable $engine_config->{passwordvar} used to get password");
552-
if (defined($ENV{$engine_config->{passwordvar}})) {
553-
$self->{_password} = $ENV{$engine_config->{passwordvar}};
554-
} else {
555-
print "Password variable $engine_config->{passwordvar} not set\n";
556-
logger($self->{_debug}, "Password variable $engine_config->{passwordvar} not set");
601+
if ($engine_config->{prevalidate} eq 'true') {
602+
logger($self->{_debug},"prevalidate set to true. checking variable and script for password");
603+
if ( $self->extended_password($engine_config) ) {
604+
print "Error with extended password support. Skipping engine\n";
557605
return 1;
558606
}
559-
} elsif ((defined($engine_config->{passwordscript})) && ($engine_config->{passwordscript} ne "")) {
560-
logger($self->{_debug}, "Password script $engine_config->{passwordscript} used to get password");
561-
my $line = $engine_config->{passwordscript} . " " . $self->{_enginename} . " " . $engine_config->{username} . " " . $engine_config->{ip_address};
562-
if ((defined($engine_config->{additionalopt})) && ($engine_config->{additionalopt} ne "")) {
563-
$line = $line . " " . $engine_config->{additionalopt};
564-
}
565-
logger($self->{_debug}, "Script command line $line");
566-
if (! -f "$engine_config->{passwordscript}") {
567-
print "Password script $engine_config->{passwordscript} doesn't exist\n";
568-
logger($self->{_debug}, "Password script $engine_config->{passwordscript} doesn't exist");
569-
return 1;
570-
}
571-
572-
my $out = qx|$line|;
573-
$out =~ s/^\s+|\s+$//g;
574-
$self->{_password} = $out;
575607
}
576608

577609
my $cookie_dir = File::Spec->tmpdir();
@@ -633,6 +665,15 @@ sub dlpx_connect {
633665
# there is no session in cookie
634666
# new session needs to be established
635667

668+
if ($engine_config->{prevalidate} eq 'false') {
669+
logger($self->{_debug},"prevalidate set to false. checking variable and script for password as session doesn't exist");
670+
if ( $self->extended_password($engine_config) ) {
671+
print "Error with extended password support. Skipping engine\n";
672+
return 1;
673+
}
674+
}
675+
676+
636677
if (defined($self->{_dever})) {
637678
if (defined($api_list{$self->{_dever}})) {
638679
$ses_version = $api_list{$self->{_dever}};

0 commit comments

Comments
 (0)