Guest User

Untitled

a guest
May 2nd, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #!/usr/local/bin/perl
  2. use Authen::SASL::Authd qw(auth_cyrus);
  3. use strict;
  4. use warnings;
  5.  
  6. my $status = 1; # Default to pass
  7. my $username = $ARGV[0];
  8.  
  9. print "Please enter a password: ";
  10. my $password = <STDIN>;
  11. print "Reenter NEW password: ";
  12. my $npassword = <STDIN>;
  13. $password = trim($password);
  14. $npassword = trim($npassword);
  15.  
  16. if ($password ne $npassword) { $status = 0; }
  17. if (!$username) { $status = 0; }
  18. if (!$password) { $status = 0; }
  19.  
  20.  
  21. if ($status == 1) { auth_cyrus($username, $password) or $status = 0; }
  22.  
  23. if ($status == 1) { print "Passed\n"; }
  24. else { print "Failed\n"; }
  25.  
  26. sub trim {
  27. my $data = $_[0];
  28. $data =~ s/^\s+(.*)/$1/;
  29. $data =~ s/(.*)\s+$/$1/;
  30. chomp($data);
  31. return $data;
  32. }
Add Comment
Please, Sign In to add comment