diff --git a/include/GroupTemplate.h b/include/GroupTemplate.h index 30ab9b96ad..b7e7a32648 100644 --- a/include/GroupTemplate.h +++ b/include/GroupTemplate.h @@ -32,9 +32,9 @@ public: // ------------------------------------------------------------------------- // Restricted attributes interface implementation // ------------------------------------------------------------------------- - bool check_restricted(std::string& rs_attr, const Template* base) override + bool check_restricted(std::string& rs_attr, const Template* base, bool append) override { - return Template::check_restricted(rs_attr, base, restricted); + return Template::check_restricted(rs_attr, base, restricted, append); } bool check_restricted(std::string& rs_attr) override diff --git a/include/ImageTemplate.h b/include/ImageTemplate.h index 3d0eddf791..57d4327f73 100644 --- a/include/ImageTemplate.h +++ b/include/ImageTemplate.h @@ -53,9 +53,9 @@ public: // ------------------------------------------------------------------------- // Restricted attributes interface implementation // ------------------------------------------------------------------------- - bool check_restricted(std::string& rs_attr, const Template* base) override + bool check_restricted(std::string& rs_attr, const Template* base, bool append) override { - return Template::check_restricted(rs_attr, base, restricted); + return Template::check_restricted(rs_attr, base, restricted, append); } bool check_restricted(std::string& rs_attr) override diff --git a/include/Template.h b/include/Template.h index 8669eff440..79f91e5454 100644 --- a/include/Template.h +++ b/include/Template.h @@ -460,7 +460,7 @@ public: * The version of this method without base template just look for any * restricted attribute. */ - virtual bool check_restricted(std::string& rs_attr, const Template* base) + virtual bool check_restricted(std::string& rs_attr, const Template* base, bool append) { return false; } @@ -549,7 +549,7 @@ protected: * in the template */ bool check_restricted(std::string& rs_attr, const Template* base, - const std::map >& ras); + const std::map >& ras, bool append); bool check_restricted(std::string& rs_attr, const std::map >& ras); diff --git a/include/UserTemplate.h b/include/UserTemplate.h index 214dbe2138..bf26e8fc8c 100644 --- a/include/UserTemplate.h +++ b/include/UserTemplate.h @@ -32,9 +32,9 @@ public: // ------------------------------------------------------------------------- // Restricted attributes interface implementation // ------------------------------------------------------------------------- - bool check_restricted(std::string& rs_attr, const Template* base) override + bool check_restricted(std::string& rs_attr, const Template* base, bool append) override { - return Template::check_restricted(rs_attr, base, restricted); + return Template::check_restricted(rs_attr, base, restricted, append); } bool check_restricted(std::string& rs_attr) override diff --git a/include/VirtualMachine.h b/include/VirtualMachine.h index 81ab2485c2..da208e7c48 100644 --- a/include/VirtualMachine.h +++ b/include/VirtualMachine.h @@ -1224,9 +1224,9 @@ public: * @param ra the restricted attribute found to be different * @return true if a different restricted is found */ - bool check_restricted(std::string& ra, VirtualMachineTemplate * tgt) const + bool check_restricted(std::string& ra, VirtualMachineTemplate * tgt, bool append) const { - return tgt->check_restricted(ra, obj_template.get()); + return tgt->check_restricted(ra, obj_template.get(), append); } // ------------------------------------------------------------------------- diff --git a/include/VirtualMachineTemplate.h b/include/VirtualMachineTemplate.h index 0f79e41279..705e31b540 100644 --- a/include/VirtualMachineTemplate.h +++ b/include/VirtualMachineTemplate.h @@ -72,9 +72,9 @@ public: // ------------------------------------------------------------------------- // Restricted attributes interface implementation // ------------------------------------------------------------------------- - bool check_restricted(std::string& rs_attr, const Template* base) override + bool check_restricted(std::string& rs_attr, const Template* base, bool append) override { - return Template::check_restricted(rs_attr, base, restricted); + return Template::check_restricted(rs_attr, base, restricted, append); } bool check_restricted(std::string& rs_attr) override diff --git a/include/VirtualNetworkTemplate.h b/include/VirtualNetworkTemplate.h index 0b55f1e8dc..41efeed73b 100644 --- a/include/VirtualNetworkTemplate.h +++ b/include/VirtualNetworkTemplate.h @@ -39,9 +39,9 @@ public: // ------------------------------------------------------------------------- // Restricted attributes interface implementation // ------------------------------------------------------------------------- - bool check_restricted(std::string& rs_attr, const Template* base) override + bool check_restricted(std::string& rs_attr, const Template* base, bool append) override { - return Template::check_restricted(rs_attr, base, restricted); + return Template::check_restricted(rs_attr, base, restricted, append); } bool check_restricted(std::string& rs_attr) override diff --git a/src/pool/PoolObjectSQL.cc b/src/pool/PoolObjectSQL.cc index db4808a7d0..87496d38c5 100644 --- a/src/pool/PoolObjectSQL.cc +++ b/src/pool/PoolObjectSQL.cc @@ -278,7 +278,7 @@ int PoolObjectSQL::replace_template( if (obj_template) { if ( keep_restricted && - new_tmpl->check_restricted(ra, obj_template.get()) ) + new_tmpl->check_restricted(ra, obj_template.get(), false) ) { error = "Tried to change restricted attribute: " + ra; @@ -339,11 +339,12 @@ int PoolObjectSQL::append_template( if ( obj_template ) { if (keep_restricted && - new_tmpl->check_restricted(rname, obj_template.get())) + new_tmpl->check_restricted(rname, obj_template.get(), true)) { error ="User Template includes a restricted attribute " + rname; return -1; } + old_tmpl = std::make_unique