From 741d603d871147fe3a9d047e27cdae30a03492c1 Mon Sep 17 00:00:00 2001 From: Dirk Koopman Date: Mon, 19 Nov 2007 13:47:23 +0000 Subject: [PATCH] add a create/user command Which is a big can of worms. Had a good shift around and changed set/user to be a real command (rather than an alias), renamed the existing command (which on I use) to set/uservar and sorted the Aliases so that unset/node still works. --- Changes | 1 + cmd/Aliases | 2 +- cmd/Commands_en.hlp | 5 +++ cmd/{unset/node.pl => create/user.pl} | 29 ++++++++++++------ cmd/set/user.pl | 44 +++++++++++++-------------- cmd/set/uservar.pl | 39 ++++++++++++++++++++++++ perl/Messages | 1 + perl/Version.pm | 2 +- 8 files changed, 89 insertions(+), 34 deletions(-) rename cmd/{unset/node.pl => create/user.pl} (50%) create mode 100644 cmd/set/uservar.pl diff --git a/Changes b/Changes index f19c7b95..5394d7a4 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,7 @@ 19Nov07======================================================================= 1. change MRTG graphs to be based on GMT, not localtime. This allows one to more easily compare debug data with traffic graphs. +2. Add a create/user command to just add a plain user. 17Nov07======================================================================= 1. Add Local::ann() as requested by Felipe PY1NB. 16Nov07======================================================================= diff --git a/cmd/Aliases b/cmd/Aliases index 1ea0c787..84b4c182 100644 --- a/cmd/Aliases +++ b/cmd/Aliases @@ -111,7 +111,6 @@ package CmdAlias; '^set/nota', 'unset/talk', 'unset/talk', '^set/noww', 'unset/wwv', 'unset/wwv', '^set/nowx', 'unset/wx', 'unset/wx', - '^set/user', 'unset/node', 'unset/node', '^set$', 'apropos set', 'apropos', '^sho?w?/u$', 'show/user', 'show/user', '^sho?w?/bul', 'show/files bulletins', 'show/files', @@ -154,6 +153,7 @@ package CmdAlias; ], 'u' => [ '^uns?e?t?$', 'apropos unset', 'apropos', + '^uns?e?t?/node$', 'set/user', 'set/user', ], 'v' => [ ], diff --git a/cmd/Commands_en.hlp b/cmd/Commands_en.hlp index 30c6aea5..4382ba75 100644 --- a/cmd/Commands_en.hlp +++ b/cmd/Commands_en.hlp @@ -406,6 +406,11 @@ DX cluster . This process creates a new 'client' process which will use the script in /spider/connect/ to effect the 'chat' exchange necessary to traverse the network(s) to logon to the cluster . +=== 5^CREATE/USER ...^Create this user from the User Database +This command will create one or more new users. None of the fields +like name, qth etc will be filled in. It is just a new entry in the user +database to which one can add more stuff like SET/PASSWORD or by SPOOF. + === 9^DELETE/USDB ...^Delete this user from the US State Database This command will completely remove a one or more callsigns from the US States database. diff --git a/cmd/unset/node.pl b/cmd/create/user.pl similarity index 50% rename from cmd/unset/node.pl rename to cmd/create/user.pl index b560e6ef..4eeece8a 100644 --- a/cmd/unset/node.pl +++ b/cmd/create/user.pl @@ -1,5 +1,5 @@ # -# set user type BACK TO 'U' (user) +# create a user # # Please note that this is only effective if the user is not on-line # @@ -15,20 +15,29 @@ my @out; my $user; my $create; -return (1, $self->msg('e5')) if $self->priv < 5; +return (1, $self->msg('e5')) if $self->priv < 9 || $self->remotecmd; foreach $call (@args) { $call = uc $call; - my $chan = DXChannel::get($call); - if ($chan) { - push @out, $self->msg('nodee1', $call); - } else { - $user = DXUser->get($call); - return (1, $self->msg('usernf', $call)) if !$user; + $user = DXUser->get($call); + unless ($user) { + $user = DXUser->new($call); $user->sort('U'); - $user->priv(0); + $user->homenode($main::mycall); $user->close(); - push @out, $self->msg('nodeu', $call); + push @out, $self->msg('creuser', $call); + } else { + push @out, $self->msg('hasha', $call, 'Users'); } } return (1, @out); + + + + + + + + + + diff --git a/cmd/set/user.pl b/cmd/set/user.pl index afe67c7e..832dcac6 100644 --- a/cmd/set/user.pl +++ b/cmd/set/user.pl @@ -1,34 +1,34 @@ # -# set any variable in the User file +# set back to user # -# This is a hack - use the UTMOST CAUTION!!!!!!!! +# Please note that this is only effective if the user is not on-line # -# Copyright (c) 1999 Dirk Koopman G1TLH +# Copyright (c) 1998 - Dirk Koopman # # # -my ($self, $line) = @_; -return (1, $self->msg('e5')) if $self->priv < 9; +my ($self, $line) = @_; my @args = split /\s+/, $line; -return (1, $self->msg('suser1')) if @args < 3; - -my $call = uc $args[0]; -my $ref = DXUser->get_current($call); -my $field = $args[1]; -my $value = $args[2]; - -return (1, $self->msg('suser2', $call)) unless $ref; -return (1, $self->msg('suser4', $field)) unless $ref->field_prompt($field); +my $call; my @out; +my $user; +my $create; -# set it (dates and silly things like that can come later) - -my $oldvalue = $ref->{$field}; -$ref->{$field} = $value; -$ref->put(); - -push @out, $self->msg('suser3', $field, $oldvalue, $value); -push @out, print_all_fields($self, $ref, "User Information $call"); +return (1, $self->msg('e5')) if $self->priv < 5; +foreach $call (@args) { + $call = uc $call; + my $chan = DXChannel::get($call); + if ($chan) { + push @out, $self->msg('nodee1', $call); + } else { + $user = DXUser->get($call); + return (1, $self->msg('usernf', $call)) if !$user; + $user->sort('U'); + $user->priv(0); + $user->close(); + push @out, $self->msg('nodeu', $call); + } +} return (1, @out); diff --git a/cmd/set/uservar.pl b/cmd/set/uservar.pl new file mode 100644 index 00000000..c5e39fb7 --- /dev/null +++ b/cmd/set/uservar.pl @@ -0,0 +1,39 @@ +# +# set any variable in the User file +# +# This is a hack - use the UTMOST CAUTION!!!!!!!! +# +# Copyright (c) 1999 Dirk Koopman G1TLH +# +# +# +my ($self, $line) = @_; + +my @args = split /\s+/, $line; +return (1, $self->msg('suser1')) if @args < 3; + + +my $call = uc $args[0]; +my $ref = DXUser->get_current($call); +my $field = $args[1]; +my $value = $args[2]; + +return (1, $self->msg('suser2', $call)) unless $ref; +return (1, $self->msg('suser4', $field)) unless $ref->field_prompt($field); +my @out; + +# set it (dates and silly things like that can come later) + +if ($self->priv < 9 || $self->remotecmd || $self->inscript) { + Log('DXCommand', $self->call . " attempted to set user var $field=$value on $call remotely"); + push @out, $self->msg('sorry'); +} + +my $oldvalue = $ref->{$field}; +$ref->{$field} = $value; +$ref->put(); + +push @out, $self->msg('suser3', $field, $oldvalue, $value); +push @out, print_all_fields($self, $ref, "User Information $call"); + +return (1, @out); diff --git a/perl/Messages b/perl/Messages index 7e811a1d..3b0db325 100644 --- a/perl/Messages +++ b/perl/Messages @@ -38,6 +38,7 @@ package DXM; confail => 'connection to $_[0] failed ($_[1])', constart => 'connection to $_[0] started', conbump => 'Reconnected as $_[0] at $_[1], this instance is disconnected', + creuser => 'User $_[0] has been created', deluser => 'User $_[0] has been deleted', db1 => 'This database is hosted at $_[0]', db2 => 'Sorry, but key: $_[0] was not found in $_[1]', diff --git a/perl/Version.pm b/perl/Version.pm index 4d7bf1c5..b96932ad 100644 --- a/perl/Version.pm +++ b/perl/Version.pm @@ -11,6 +11,6 @@ use vars qw($version $subversion $build); $version = '1.54'; $subversion = '0'; -$build = '191'; +$build = '192'; 1; -- 2.34.1