summaryrefslogtreecommitdiff
path: root/perl/lib/Wallet
diff options
context:
space:
mode:
Diffstat (limited to 'perl/lib/Wallet')
-rw-r--r--perl/lib/Wallet/ACL.pm5
-rw-r--r--perl/lib/Wallet/Admin.pm19
-rw-r--r--perl/lib/Wallet/Schema/Result/AclHistory.pm10
3 files changed, 28 insertions, 6 deletions
diff --git a/perl/lib/Wallet/ACL.pm b/perl/lib/Wallet/ACL.pm
index 57097c0..6f5172a 100644
--- a/perl/lib/Wallet/ACL.pm
+++ b/perl/lib/Wallet/ACL.pm
@@ -80,6 +80,7 @@ sub create {
# Add to the history table.
my $date = DateTime->from_epoch (epoch => $time);
%record = (ah_acl => $id,
+ ah_name => $name,
ah_action => 'create',
ah_by => $user,
ah_from => $host,
@@ -165,6 +166,7 @@ sub log_acl {
}
my $date = DateTime->from_epoch (epoch => $time);
my %record = (ah_acl => $self->{id},
+ ah_name => $self->{name},
ah_action => $action,
ah_scheme => $scheme,
ah_identifier => $identifier,
@@ -243,7 +245,8 @@ sub destroy {
# Create new history line for the deletion.
my $date = DateTime->from_epoch (epoch => $time);
- my %record = (ah_acl => $self->{id},
+ my %record = (ah_acl => $self->{id},
+ ah_name => $self->{name},
ah_action => 'destroy',
ah_by => $user,
ah_from => $host,
diff --git a/perl/lib/Wallet/Admin.pm b/perl/lib/Wallet/Admin.pm
index 29b2f21..b07c7d1 100644
--- a/perl/lib/Wallet/Admin.pm
+++ b/perl/lib/Wallet/Admin.pm
@@ -98,13 +98,22 @@ sub initialize {
$self->default_data;
# Create a default admin ACL.
- my $acl = Wallet::ACL->create ('ADMIN', $self->{schema}, $user,
- 'localhost');
- unless ($acl->add ('krb5', $user, $user, 'localhost')) {
- $self->error ($acl->error);
+ eval {
+ my $guard = $self->{schema}->txn_scope_guard;
+ $self->{schema}->resultset ('Acl')->populate ([
+ [ qw/ac_id ac_name/ ],
+ [ 1, 'ADMIN' ],
+ ]);
+ $self->{schema}->resultset ('AclEntry')->populate ([
+ [ qw/ae_id ae_scheme ae_identifier/ ],
+ [ 1, 'krb5', $user ],
+ ]);
+ $guard->commit;
+ };
+ if ($@) {
+ $self->error ("cannot add ADMIN ACL: $@");
return;
}
-
return 1;
}
diff --git a/perl/lib/Wallet/Schema/Result/AclHistory.pm b/perl/lib/Wallet/Schema/Result/AclHistory.pm
index 11593b7..82e18a9 100644
--- a/perl/lib/Wallet/Schema/Result/AclHistory.pm
+++ b/perl/lib/Wallet/Schema/Result/AclHistory.pm
@@ -41,6 +41,12 @@ __PACKAGE__->table("acl_history");
data_type: 'integer'
is_nullable: 0
+=head2 ah_name
+
+ data_type: 'varchar'
+ is_nullable: 1
+ size: 255
+
=head2 ah_action
data_type: 'varchar'
@@ -84,6 +90,8 @@ __PACKAGE__->add_columns(
{ data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
"ah_acl",
{ data_type => "integer", is_nullable => 0 },
+ "ah_name",
+ { data_type => "varchar", is_nullable => 1, size => 255 },
"ah_action",
{ data_type => "varchar", is_nullable => 0, size => 16 },
"ah_scheme",
@@ -108,6 +116,8 @@ sub sqlt_deploy_hook {
my ($self, $sqlt_table) = @_;
my $name = 'acl_history_idx_ah_acl';
$sqlt_table->add_index (name => $name, fields => [qw(ah_acl)]);
+ $name = 'acl_history_idx_ah_name';
+ $sqlt_table->add_index (name => $name, fields => [qw(ah_name)]);
}
1;