]> scm.dxcluster.org Git - spider.git/blob - cmd/set/privilege.pl
fix EOF detection of incoming nodes
[spider.git] / cmd / set / privilege.pl
1 #
2 # set the privilege of the user
3 #
4 # call as set/priv n <call> ...
5 #
6 # Copyright (c) 1998 Dirk Koopman G1TLH
7 #
8 #
9 #
10 my ($self, $line) = @_;
11 my @args = split /\s+/, $line;
12 my $call;
13 my $priv = shift @args;
14 my @out;
15 my $user;
16 my $ref;
17
18 if ($self->priv < 9 || $self->remotecmd || $self->inscript) {
19         Log('DXCommand', $self->call . " attempted to set privilege $priv for @args");
20         return (1, $self->msg('e5'));
21 }
22
23 if ($priv < 0 || $priv > 9) {
24   return (1, $self->msg('e5')); 
25 }
26
27 foreach $call (@args) {
28         $call = uc $call;
29         unless ($self->remotecmd || $self->inscript) {
30                 if ($ref = DXChannel::get($call)) {
31                         $ref->priv($priv);
32                         $ref->user->priv($priv);
33                         $ref->user->put();
34                 }
35                 if (!$ref && ($user = DXUser::get($call))) {
36                         $user->priv($priv);
37                         $user->put();
38                 }
39                 if ($ref || $user) {
40                         push @out, $self->msg('priv', $call);
41                         Log('DXCommand', "Privilege set to $priv on $call by " . $self->call);
42                 } else {
43                         push @out, $self->msg('e3', "Set Privilege", $call);
44                 }
45         } else {
46                 push @out, $self->msg('sorry');
47                 Log('DXCommand', $self->call . " attempted to set privilege $priv for $call remotely");
48         }
49 }
50 return (1, @out);