my( $kernel, $heap, $who, $what, $src, $dest, $replypath ) = @_;
my( $whom, $target ) = split( / /, $what, 2 );
- unless( exists( $heap->{ 'access' }->{ uc( $target ) } ) ) {
+ unless( exists( $heap->{ 'useraccess' }->{ uc( $target ) } ) ) {
$kernel->post( $src, $replypath, "'$target' has no access; link not allowed.", $dest );
return;
}
- if( access2( $heap->{ 'access' }, $target, {} ) > accessLevel( $kernel, $heap, $who ) ) {
+ if( access2( $heap->{ 'useraccess' }, $target, {} ) > accessLevel( $kernel, $heap, $who ) ) {
$kernel->post( $src, $replypath, "You may not grant access exceeding your own.", $dest );
return;
}
if( exists( $heap->{ 'privs' }->{ uc( $whom ) } ) ) {
- $heap->{ 'access' }->{ uc( $whom ) } = "~".$target;
- DumpFile( "access.yaml", $heap->{ 'access' } );
+ $heap->{ 'useraccess' }->{ uc( $whom ) } = "~".$target;
+ DumpFile( "useraccess.yaml", $heap->{ 'useraccess' } );
$kernel->post( $src, $replypath, "Set.", $dest );
} else {
$kernel->post( $src, $replypath, "'$whom' not registered.", $dest );
$kernel->post( $src, $replypath, "Access level should be a non-negative integer. (Did you want LINK?)", $dest );
return;
}
- if( $level > access2( $heap->{ 'access' }, $who, {} ) ) {
+ if( $level > access2( $heap->{ 'useraccess' }, $who, {} ) ) {
$kernel->post( $src, $replypath, "You may not grant access exceeding your own.", $dest );
return;
}
if( exists( $heap->{ 'privs' }->{ uc( $whom ) } ) ) {
- $heap->{ 'access' }->{ uc( $whom ) } = $level;
- DumpFile( "access.yaml", $heap->{ 'access' } );
+ $heap->{ 'useraccess' }->{ uc( $whom ) } = $level;
+ DumpFile( "useraccess.yaml", $heap->{ 'useraccess' } );
$kernel->post( $src, $replypath, "Set.", $dest );
} else {
$kernel->post( $src, $replypath, "'$whom' not registered.", $dest );
return;
}
if( exists( $heap->{ 'commands' }->{ uc( $cmd ) } ) ) {
- $heap->{ 'access' }->{ "@".uc( $cmd ) } = $level;
- DumpFile( "access.yaml", $heap->{ 'access' } );
+ $heap->{ 'cmdaccess' }->{ uc( $cmd ) } = $level;
+ DumpFile( "cmdaccess.yaml", $heap->{ 'cmdaccess' } );
$kernel->post( $src, $replypath, "Set.", $dest );
} else {
$kernel->post( $src, $replypath, "'$cmd' not found.", $dest );
sub {
my( $kernel, $heap, $who, $what, $src, $dest, $replypath ) = @_;
$kernel->post( $src, $replypath, "Commands:", $dest );
- foreach( keys( %{ $heap->{ 'access' } } ) ) {
- if( substr( $_, 0, 1 ) eq "@" ) {
- $kernel->post( $src, $replypath, " $_: ".$heap->{ 'access' }->{ $_ }, $dest );
- }
+ foreach( keys( %{ $heap->{ 'cmdaccess' } } ) ) {
+ $kernel->post( $src, $replypath, " $_: ".$heap->{ 'cmdaccess' }->{ $_ }, $dest );
}
$kernel->post( $src, $replypath, "Users:", $dest );
- foreach( keys( %{ $heap->{ 'access' } } ) ) {
- unless( substr( $_, 0, 1 ) eq "@" ) {
- $kernel->post( $src, $replypath, " $_: ".$heap->{ 'access' }->{ $_ }, $dest );
- }
+ foreach( keys( %{ $heap->{ 'useraccess' } } ) ) {
+ $kernel->post( $src, $replypath, " $_: ".$heap->{ 'useraccess' }->{ $_ }, $dest );
}
}
sub {
use Digest::MD5 qw( md5_hex );
my( $kernel, $heap, $who, $what, $src, $dest, $replypath ) = @_;
- my( $whom, $password ) = split( / /, $what, 2 );
+ print( STDERR "register( '$what' )\n" );
+ my $nargs = ($what =~ s/ / /g);
+ if( !$nargs ) {
+ $nargs = 1;
+ } else {
+ $nargs++;
+ }
+ if( $nargs < 1 || $nargs > 2 ) {
+ $kernel->post( $src, $replypath, "Usage: REGISTER [<name>] <password>", $dest );
+ return;
+ }
+
+ my( $whom, $password );
+ if( $nargs == 1 ) {
+ $password = $what;
+ $whom = $who;
+ }
+ if( $nargs == 2 ) {
+ ( $whom, $password ) = split( / /, $what, 2 );
+ }
+
+ print( STDERR "register( $whom, $password ) == $nargs\n" );
if( $password ) {
$heap->{ 'privs' }->{ uc( $whom ) } = md5_hex( $password );
print( "CORE: No factoids found.\n" );
}
- if( -e "access.yaml" ) {
- $heap->{ 'access' } = \%{ LoadFile( "access.yaml" ) };
+ if( -e "cmdaccess.yaml" ) {
+ $heap->{ 'cmdaccess' } = \%{ LoadFile( "cmdaccess.yaml" ) };
print( "CORE: Access levels loaded.\n" );
} else {
- $heap->{ 'access' } = { };
+ $heap->{ 'cmdaccess' } = { };
}
if( -e "privs.yaml" ) {
print( "CORE: No users found.\n" );
}
+ if( -e "useraccess.yaml" ) {
+ $heap->{ 'useraccess' } = \%{ LoadFile( "useraccess.yaml" ) };
+ print( "CORE: User access loaded.\n" );
+ } else {
+ $heap->{ 'useraccess' } = { };
+ print( "CORE: No user access found.\n" );
+ }
+
if( -e "ignored.yaml" ) {
$heap->{ 'ignored' } = \%{ LoadFile( "ignored.yaml" ) };
print( "CORE: Ignored users loaded.\n" );
}
if( exists( $heap->{ 'commands' }->{ uc( $cmd ) } ) ) {
- if( !exists $heap->{ 'access' }->{ "@".uc( $cmd ) } ||
- $heap->{ 'access' }->{ "@".uc( $cmd ) } == 0 || (
+ if( !exists $heap->{ 'cmdaccess' }->{ uc( $cmd ) } ||
+ $heap->{ 'cmdaccess' }->{ uc( $cmd ) } == 0 || (
exists $heap->{ 'identified' }->{ $src.uc( $who ) } &&
- accessLevel( $kernel, $heap, uc( $who ), $src ) >= $heap->{ 'access' }->{ "@".uc( $cmd ) } ) ) {
+ accessLevel( $kernel, $heap, uc( $who ), $src ) >= $heap->{ 'cmdaccess' }->{ uc( $cmd ) } ) ) {
&{ $heap->{ 'commands' }->{ uc( $cmd ) } }( $kernel, $heap, $who, $subj, $src, $dest, $replypath );
} else {
- $kernel->post( $src, $replypath, "$who: An access level of ".$heap->{ 'access' }->{ "@".uc( $cmd ) }." is required for '$cmd'", $dest );
+ $kernel->post( $src, $replypath, "$who: An access level of ".$heap->{ 'cmdaccess' }->{ uc( $cmd ) }." is required for '$cmd'", $dest );
}
} elsif( exists( $heap->{ 'db' }->{ uc( $what ) } ) && !$noparse ) {
&{ $heap->{ 'commands' }->{ 'PARSE' } }( $kernel, $heap, $who, $what, $src, $dest, $replypath );
print( "ACC: $whom isn't idenfitied.\n" );
return 0;
}
- return access2( $heap->{ 'access' }, $whom, {} );
+ return access2( $heap->{ 'useraccess' }, $whom, {} );
}
# Put this in two parts so we don't get infinite loops.