Merge pull request #7891 from Icinga/bugfix/api-put-object-deletion-7726

ConfigObjectUtility#CreateObject(): check config objects for duplicates
This commit is contained in:
Alexander Aleksandrovič Klimov 2020-12-17 09:28:26 +01:00 committed by GitHub
commit 769a899749
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 4 deletions

View File

@ -152,12 +152,14 @@ bool ConfigObjectUtility::CreateObject(const Type::Ptr& type, const String& full
{
CreateStorage();
ConfigItem::Ptr item = ConfigItem::GetByTypeAndName(type, fullName);
{
auto configType (dynamic_cast<ConfigType*>(type.get()));
if (item) {
if (configType && configType->GetObject(fullName)) {
errors->Add("Object '" + fullName + "' already exists.");
return false;
}
}
String path;