|
|
43fe83 |
From 79615330836ae08cf6ed3773e2eaab7c3fa0cd31 Mon Sep 17 00:00:00 2001
|
|
|
43fe83 |
Message-Id: <79615330836ae08cf6ed3773e2eaab7c3fa0cd31.1379193140.git.jdenemar@redhat.com>
|
|
|
43fe83 |
From: "Daniel P. Berrange" <berrange@redhat.com>
|
|
|
43fe83 |
Date: Thu, 12 Sep 2013 17:34:46 +0100
|
|
|
43fe83 |
Subject: [PATCH] Fix naming of permission for detecting storage pools
|
|
|
43fe83 |
|
|
|
43fe83 |
https://bugzilla.redhat.com/show_bug.cgi?id=700443
|
|
|
43fe83 |
|
|
|
43fe83 |
The VIR_ACCESS_PERM_CONNECT_DETECT_STORAGE_POOLS enum
|
|
|
43fe83 |
constant had its string format be 'detect_storage_pool',
|
|
|
43fe83 |
note the missing trailing 's'. This prevent the ACL
|
|
|
43fe83 |
check from ever succeeding. Fix this and add a simple
|
|
|
43fe83 |
test script to validate this problem of matching names.
|
|
|
43fe83 |
|
|
|
43fe83 |
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
|
|
|
43fe83 |
(cherry picked from commit 935e7d02cfd6f5cca04f548d91a04f5f08fa4bcf)
|
|
|
43fe83 |
---
|
|
|
43fe83 |
src/Makefile.am | 8 ++++-
|
|
|
43fe83 |
src/access/viraccessperm.c | 2 +-
|
|
|
43fe83 |
src/check-aclperms.pl | 73 ++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
43fe83 |
3 files changed, 81 insertions(+), 2 deletions(-)
|
|
|
43fe83 |
create mode 100755 src/check-aclperms.pl
|
|
|
43fe83 |
|
|
|
43fe83 |
diff --git a/src/Makefile.am b/src/Makefile.am
|
|
|
43fe83 |
index 1b734e0..66bb6b9 100644
|
|
|
43fe83 |
--- a/src/Makefile.am
|
|
|
43fe83 |
+++ b/src/Makefile.am
|
|
|
43fe83 |
@@ -508,10 +508,16 @@ check-aclrules:
|
|
|
43fe83 |
$(REMOTE_PROTOCOL) \
|
|
|
43fe83 |
$(addprefix $(srcdir)/,$(filter-out /%,$(STATEFUL_DRIVER_SOURCE_FILES)))
|
|
|
43fe83 |
|
|
|
43fe83 |
+check-aclperms:
|
|
|
43fe83 |
+ $(AM_V_GEN)$(PERL) $(srcdir)/check-aclperms.pl \
|
|
|
43fe83 |
+ $(srcdir)/access/viraccessperm.h \
|
|
|
43fe83 |
+ $(srcdir)/access/viraccessperm.c
|
|
|
43fe83 |
+
|
|
|
43fe83 |
EXTRA_DIST += check-driverimpls.pl check-aclrules.pl
|
|
|
43fe83 |
|
|
|
43fe83 |
check-local: check-protocol check-symfile check-symsorting \
|
|
|
43fe83 |
- check-drivername check-driverimpls check-aclrules
|
|
|
43fe83 |
+ check-drivername check-driverimpls check-aclrules \
|
|
|
43fe83 |
+ check-aclperms
|
|
|
43fe83 |
.PHONY: check-protocol $(PROTOCOL_STRUCTS:structs=struct)
|
|
|
43fe83 |
|
|
|
43fe83 |
# Mock driver, covering domains, storage, networks, etc
|
|
|
43fe83 |
diff --git a/src/access/viraccessperm.c b/src/access/viraccessperm.c
|
|
|
43fe83 |
index 9c720f9..d517c66 100644
|
|
|
43fe83 |
--- a/src/access/viraccessperm.c
|
|
|
43fe83 |
+++ b/src/access/viraccessperm.c
|
|
|
43fe83 |
@@ -30,7 +30,7 @@ VIR_ENUM_IMPL(virAccessPermConnect,
|
|
|
43fe83 |
"search_storage_pools", "search_node_devices",
|
|
|
43fe83 |
"search_interfaces", "search_secrets",
|
|
|
43fe83 |
"search_nwfilters",
|
|
|
43fe83 |
- "detect_storage_pool", "pm_control",
|
|
|
43fe83 |
+ "detect_storage_pools", "pm_control",
|
|
|
43fe83 |
"interface_transaction");
|
|
|
43fe83 |
|
|
|
43fe83 |
VIR_ENUM_IMPL(virAccessPermDomain,
|
|
|
43fe83 |
diff --git a/src/check-aclperms.pl b/src/check-aclperms.pl
|
|
|
43fe83 |
new file mode 100755
|
|
|
43fe83 |
index 0000000..5b1b4db
|
|
|
43fe83 |
--- /dev/null
|
|
|
43fe83 |
+++ b/src/check-aclperms.pl
|
|
|
43fe83 |
@@ -0,0 +1,73 @@
|
|
|
43fe83 |
+#!/usr/bin/perl
|
|
|
43fe83 |
+#
|
|
|
43fe83 |
+# Copyright (C) 2013 Red Hat, Inc.
|
|
|
43fe83 |
+#
|
|
|
43fe83 |
+# This library is free software; you can redistribute it and/or
|
|
|
43fe83 |
+# modify it under the terms of the GNU Lesser General Public
|
|
|
43fe83 |
+# License as published by the Free Software Foundation; either
|
|
|
43fe83 |
+# version 2.1 of the License, or (at your option) any later version.
|
|
|
43fe83 |
+#
|
|
|
43fe83 |
+# This library is distributed in the hope that it will be useful,
|
|
|
43fe83 |
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
43fe83 |
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
43fe83 |
+# Lesser General Public License for more details.
|
|
|
43fe83 |
+#
|
|
|
43fe83 |
+# You should have received a copy of the GNU Lesser General Public
|
|
|
43fe83 |
+# License along with this library. If not, see
|
|
|
43fe83 |
+# <http://www.gnu.org/licenses/>.
|
|
|
43fe83 |
+#
|
|
|
43fe83 |
+# This script just validates that the stringified version of
|
|
|
43fe83 |
+# a virAccessPerm enum matches the enum constant name. We do
|
|
|
43fe83 |
+# a lot of auto-generation of code, so when these don't match
|
|
|
43fe83 |
+# problems occur, preventing auth from succeeding at all.
|
|
|
43fe83 |
+
|
|
|
43fe83 |
+my $hdr = shift;
|
|
|
43fe83 |
+my $impl = shift;
|
|
|
43fe83 |
+
|
|
|
43fe83 |
+my %perms;
|
|
|
43fe83 |
+
|
|
|
43fe83 |
+my @perms;
|
|
|
43fe83 |
+
|
|
|
43fe83 |
+open HDR, $hdr or die "cannot read $hdr: $!";
|
|
|
43fe83 |
+
|
|
|
43fe83 |
+while (<HDR>) {
|
|
|
43fe83 |
+ if (/^\s+VIR_ACCESS_PERM_([_A-Z]+)(,?|\s|$)/) {
|
|
|
43fe83 |
+ my $perm = $1;
|
|
|
43fe83 |
+
|
|
|
43fe83 |
+ $perms{$perm} = 1 unless ($perm =~ /_LAST$/);
|
|
|
43fe83 |
+ }
|
|
|
43fe83 |
+}
|
|
|
43fe83 |
+
|
|
|
43fe83 |
+close HDR;
|
|
|
43fe83 |
+
|
|
|
43fe83 |
+
|
|
|
43fe83 |
+open IMPL, $impl or die "cannot read $impl: $!";
|
|
|
43fe83 |
+
|
|
|
43fe83 |
+my $group;
|
|
|
43fe83 |
+my $warned = 0;
|
|
|
43fe83 |
+
|
|
|
43fe83 |
+while (defined (my $line = <IMPL>)) {
|
|
|
43fe83 |
+ if ($line =~ /VIR_ACCESS_PERM_([_A-Z]+)_LAST/) {
|
|
|
43fe83 |
+ $group = $1;
|
|
|
43fe83 |
+ } elsif ($line =~ /"[_a-z]+"/) {
|
|
|
43fe83 |
+ my @bits = split /,/, $line;
|
|
|
43fe83 |
+ foreach my $bit (@bits) {
|
|
|
43fe83 |
+ if ($bit =~ /"([_a-z]+)"/) {
|
|
|
43fe83 |
+ my $perm = uc($group . "_" . $1);
|
|
|
43fe83 |
+ if (!exists $perms{$perm}) {
|
|
|
43fe83 |
+ print STDERR "Unknown perm string $1 for group $group\n";
|
|
|
43fe83 |
+ $warned = 1;
|
|
|
43fe83 |
+ }
|
|
|
43fe83 |
+ delete $perms{$perm};
|
|
|
43fe83 |
+ }
|
|
|
43fe83 |
+ }
|
|
|
43fe83 |
+ }
|
|
|
43fe83 |
+}
|
|
|
43fe83 |
+close IMPL;
|
|
|
43fe83 |
+
|
|
|
43fe83 |
+foreach my $perm (keys %perms) {
|
|
|
43fe83 |
+ print STDERR "Perm $perm had not string form\n";
|
|
|
43fe83 |
+ $warned = 1;
|
|
|
43fe83 |
+}
|
|
|
43fe83 |
+
|
|
|
43fe83 |
+exit $warned;
|
|
|
43fe83 |
--
|
|
|
43fe83 |
1.8.3.2
|
|
|
43fe83 |
|