aboutsummaryrefslogtreecommitdiff
path: root/perl/Wallet/ACL.pm
diff options
context:
space:
mode:
authorRuss Allbery <rra@stanford.edu>2007-08-30 06:06:20 +0000
committerRuss Allbery <rra@stanford.edu>2007-08-30 06:06:20 +0000
commit427ad9f04713bf028fbb28a918046444898e8bd3 (patch)
tree1797dc02bf9ba2349ae98a870b1740b31e91b4b3 /perl/Wallet/ACL.pm
parentb8dbb0eb6f72d11adde4cb9ce6afbccdbf3993ff (diff)
Reject all-numeric ACL names since they're ambiguous. Change the stored
name on rename.
Diffstat (limited to 'perl/Wallet/ACL.pm')
-rw-r--r--perl/Wallet/ACL.pm8
1 files changed, 8 insertions, 0 deletions
diff --git a/perl/Wallet/ACL.pm b/perl/Wallet/ACL.pm
index 5a56c5c..1815199 100644
--- a/perl/Wallet/ACL.pm
+++ b/perl/Wallet/ACL.pm
@@ -69,6 +69,9 @@ sub new {
# the newly created ACL in the object. On failure, throws an exception.
sub create {
my ($class, $name, $dbh, $user, $host, $time) = @_;
+ if ($name =~ /^\d+\z/) {
+ die "ACL name may not be all numbers\n";
+ }
$dbh->{AutoCommit} = 0;
$dbh->{RaiseError} = 1;
$dbh->{PrintError} = 0;
@@ -144,6 +147,10 @@ sub log_acl {
# Returns true on success, false on failure.
sub rename {
my ($self, $name) = @_;
+ if ($name =~ /^\d+\z/) {
+ $self->{error} = "ACL name may not be all numbers";
+ return undef;
+ }
eval {
my $sql = 'update acls set ac_name = ? where ac_id = ?';
$self->{dbh}->do ($sql, undef, $name, $self->{id});
@@ -156,6 +163,7 @@ sub rename {
$self->{dbh}->rollback;
return undef;
}
+ $self->{name} = $name;
return 1;
}