summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2009-06-02 14:22:15 -0700
committerAn-Cheng Huang <ancheng@vyatta.com>2009-07-17 14:30:20 -0700
commitba60053e94147f401efd298fe1bd4d38cf9f34f7 (patch)
tree0a52ff1572e9a8f7d6ff55c5297a719f60721726 /lib
parent6859b8c8e408817161a1723a19396c880ae6e889 (diff)
downloadvyatta-cfg-quagga-ba60053e94147f401efd298fe1bd4d38cf9f34f7.tar.gz
vyatta-cfg-quagga-ba60053e94147f401efd298fe1bd4d38cf9f34f7.zip
Change API for login modules
The login modules aren't really objects (if Perl really had objects), so just use dynamic invoke of update routine. (cherry picked from commit 37ba59896d4c9ac5c914d1901d86ed7e7d844871)
Diffstat (limited to 'lib')
-rw-r--r--lib/Vyatta/Login/RadiusServer.pm16
-rwxr-xr-xlib/Vyatta/Login/User.pm33
2 files changed, 8 insertions, 41 deletions
diff --git a/lib/Vyatta/Login/RadiusServer.pm b/lib/Vyatta/Login/RadiusServer.pm
index 97ae4eb6..34da8a31 100644
--- a/lib/Vyatta/Login/RadiusServer.pm
+++ b/lib/Vyatta/Login/RadiusServer.pm
@@ -83,25 +83,11 @@ sub add_radius_servers {
return 1;
}
-sub new {
- my $that = shift;
- my $class = ref($that) || $that;
+sub update {
my $rconfig = new Vyatta::Config;
$rconfig->setLevel("system login radius-server");
my %servers = $rconfig->listNodeStatus();
- my $self = \%servers;
-
- bless $self, $class;
-
- return $self;
-}
-
-sub update {
- my $self = shift;
- my %servers = %$self;
my $server_str = '';
- my $rconfig = new Vyatta::Config;
- $rconfig->setLevel('system login radius-server');
if (%servers) {
remove_radius_servers();
diff --git a/lib/Vyatta/Login/User.pm b/lib/Vyatta/Login/User.pm
index f053abf1..c4870986 100755
--- a/lib/Vyatta/Login/User.pm
+++ b/lib/Vyatta/Login/User.pm
@@ -20,29 +20,6 @@ use warnings;
use lib "/opt/vyatta/share/perl5";
use Vyatta::Config;
-sub new {
- my ( $that ) = @_;
- my $class = ref($that) || $that;
- my $config = new Vyatta::Config;
- $config->setLevel("system login user");
- my %users = $config->listNodeStatus();
- my @user_keys = sort keys %users;
-
- if ( ( scalar(@user_keys) <= 0 )
- || !( grep /^root$/, @user_keys )
- || ( $users{'root'} eq 'deleted' ) )
- {
-
- # root is deleted
- die "User \"root\" cannot be deleted\n";
- }
-
- my $self = \%users;
- bless $self, $class;
-
- return $self;
-}
-
# Exit codes form useradd.8 man page
my %reasons = (
0 => 'success',
@@ -81,10 +58,14 @@ sub get_groups {
}
sub update {
- my $self = shift;
- my %users = %$self;
my $membership = get_groups();
- my $uconfig = new Vyatta::Config;
+ my $uconfig = new Vyatta::Config;
+ $uconfig->setLevel("system login user");
+ my %users = $uconfig->listNodeStatus();
+
+ die "All users deleted!\n" unless %users;
+ die "User root cannot be deleted\n"
+ if (! defined $users{'root'} || $users{'root'} eq 'deleted');
foreach my $user ( keys %users ) {
if ( $users{$user} eq 'deleted' ) {