]> scm.dxcluster.org Git - spider.git/blob - cmd/set/password.pl
added show/ik3qar command
[spider.git] / cmd / set / password.pl
1 #
2 # set a user's password
3 #
4 # Copyright (c) 1998 Iain Phillips G0RDI
5 # 21-Dec-1998
6 #
7 # Syntax:       set/pass <callsign> <password> 
8 #
9
10 my ($self, $line) = @_;
11 my @args = split /\s+/, $line, 2;
12 my $call = shift @args;
13 my @out;
14 my $user;
15 my $ref;
16
17 if ($self->remotecmd || $self->inscript) {
18         $call ||= $self->call;
19         Log('DXCommand', $self->call . " attempted to change password for $call remotely");
20         return (1, $self->msg('e5'));
21 }
22
23 if ($call) {
24         if ($self->priv < 9) {
25                 Log('DXCommand', $self->call . " attempted to change password for $call");
26                 return (1, $self->msg('e5'));
27         }
28         return (1, $self->msg('e29')) unless @args;
29         if ($ref = DXUser::get_current($call)) {
30                 $ref->passwd($args[0]);
31                 $ref->put();
32                 push @out, $self->msg("password", $call);
33                 Log('DXCommand', $self->call . " changed password for $call");
34         } else {
35                 push @out, $self->msg('e3', 'User record for', $call);
36         }
37 } else {
38         if ($self->conn->{csort} eq 'telnet' && $self->user->passwd) {
39                 $self->conn->{decho} = $self->conn->{echo};
40                 $self->conn->{echo} = 0;
41                 push @out, $self->msg('pw0');
42                 $self->state('passwd');
43         } else {
44                 push @out, $self->msg('e5');
45         }
46 }
47
48 return (1, @out);