X-Git-Url: http://dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=cmd%2Fset%2Fpassword.pl;h=9366c0bb5e6b15b0728ddaff801d44d99456867f;hb=ab811a0c902225075a9bd69749f65594079433a9;hp=1aa425f610686a229cce343e06e01af1fd6d4e8b;hpb=6aca4e461103870de99b0ce452f21cf7fedeb54b;p=spider.git diff --git a/cmd/set/password.pl b/cmd/set/password.pl index 1aa425f6..9366c0bb 100644 --- a/cmd/set/password.pl +++ b/cmd/set/password.pl @@ -8,22 +8,41 @@ # my ($self, $line) = @_; -my @args = split /\s+/, $line; +my @args = split /\s+/, $line, 2; my $call = shift @args; my @out; my $user; my $ref; -return (1, $self->msg('e5')) if $self->priv < 9; +if ($self->remotecmd || $self->inscript) { + $call ||= $self->call; + Log('DXCommand', $self->call . " attempted to change password for $call remotely"); + return (1, $self->msg('e5')); +} -if ($ref = DXUser->get_current($call)) { - $line =~ s/^\s*$call\s+//; - $line =~ s/\s+//og; # remove any blanks - $ref->passwd($line); - $ref->put(); - push @out, $self->msg("password", $call); +if ($call) { + if ($self->priv < 9) { + Log('DXCommand', $self->call . " attempted to change password for $call"); + return (1, $self->msg('e5')); + } + return (1, $self->msg('e29')) unless @args; + if ($ref = DXUser::get_current($call)) { + $ref->passwd($args[0]); + $ref->put(); + push @out, $self->msg("password", $call); + Log('DXCommand', $self->call . " changed password for $call"); + } else { + push @out, $self->msg('e3', 'User record for', $call); + } } else { - push @out, $self->msg('e3', 'User record for', $call); + if ($self->conn->{csort} eq 'telnet' && $self->user->passwd) { + $self->conn->{decho} = $self->conn->{echo}; + $self->conn->{echo} = 0; + push @out, $self->msg('pw0'); + $self->state('passwd'); + } else { + push @out, $self->msg('e5'); + } } return (1, @out);