# -d: dry-run: make no changes
# -r: replace: overwrite existing passwords (otherwise only "*" passwords will
# be changed)
+# -b: blowfish replace: overwrite existing passwords only if they are
+# blowfish-encrypted
use strict;
use vars qw(%part_svc);
use FS::svc_acct;
use FS::part_svc;
-use vars qw($opt_d $opt_r);
-getopts("dr");
+use vars qw($opt_d $opt_r $opt_b);
+getopts("drb");
my $user = shift or die &usage;
adminsuidsetup $user;
die "No services with svcdb svc_acct!\n" unless %part_svc;
print "\n\n", &menu_svc, "\n", <<END;
-Enter part number to import.
+Enter part number or part numbers to import.
END
-my($shell_svcpart)=&getpart;
+my($shell_svcpart)=&getvalue;
+my @shell_svcpart = split(/[,\s]+/, $shell_svcpart);
print "\n\n", <<END;
Enter the location and name of your _user_ shadow file, for example
chop;
my($username,$password)=split(/:/);
- my @svc_acct = grep { $_->cust_svc->svcpart == $shell_svcpart }
- qsearch('svc_acct', { 'username' => $username } );
+# my @svc_acct = grep { $_->cust_svc->svcpart == $shell_svcpart }
+# qsearch('svc_acct', { 'username' => $username } );
+ my @svc_acct = grep {
+ my $svcpart = $_->cust_svc->svcpart;
+ grep { $_ == $svcpart } @shell_svcpart;
+ } qsearch('svc_acct', { 'username' => $username } );
next unless @svc_acct;
my $svc_acct = shift @svc_acct;
- next unless $svc_acct->_password eq '*' || $opt_r;
+ next unless $svc_acct->_password eq '*'
+ || $opt_r
+ || ( $opt_b && $svc_acct->_password =~ /^\$2a?\$/ );
+
+ next if $svc_acct->username eq 'root';
+
+ next if $password eq 'NP' || $password eq '*LK*';
next if $svc_acct->_password eq $password;
next if $svc_acct->_password =~ /^\*SUSPENDED\*/;