From 427ad9f04713bf028fbb28a918046444898e8bd3 Mon Sep 17 00:00:00 2001 From: Russ Allbery Date: Thu, 30 Aug 2007 06:06:20 +0000 Subject: Reject all-numeric ACL names since they're ambiguous. Change the stored name on rename. --- perl/Wallet/ACL.pm | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'perl/Wallet/ACL.pm') 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; } -- cgit v1.2.3