@@ -185,6 +185,7 @@ sub load_config {
185
185
$engines {$name }{passwordvar } = $host -> {passwordvar };
186
186
$engines {$name }{passwordscript } = $host -> {passwordscript };
187
187
$engines {$name }{additionalopt } = $host -> {additionalopt };
188
+ $engines {$name }{prevalidate } = defined ($host -> {prevalidate }) ? $host -> {prevalidate } : ' false' ;
188
189
189
190
if (!defined ($nodecrypt )) {
190
191
if ($engines {$name }{encrypted } eq " true" ) {
@@ -477,6 +478,56 @@ sub getUsername {
477
478
return $ret ;
478
479
}
479
480
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
+
480
531
# Procedure getApi
481
532
# parameters:
482
533
# Return api version
@@ -547,31 +598,12 @@ sub dlpx_connect {
547
598
}
548
599
549
600
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 " ;
557
605
return 1;
558
606
}
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 ;
575
607
}
576
608
577
609
my $cookie_dir = File::Spec-> tmpdir();
@@ -633,6 +665,15 @@ sub dlpx_connect {
633
665
# there is no session in cookie
634
666
# new session needs to be established
635
667
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
+
636
677
if (defined ($self -> {_dever })) {
637
678
if (defined ($api_list {$self -> {_dever }})) {
638
679
$ses_version = $api_list {$self -> {_dever }};
0 commit comments