From: Arvin Schnell Date: Tue, 3 May 2022 06:47:41 +0000 (+0200) Subject: - fixed error handling when reading configs (gh#openSUSE/snapper#715) X-Git-Tag: v0.10.2~1^2 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=478d7541550779352ec86ef9e4a2186c8dadbc0d;p=thirdparty%2Fsnapper.git - fixed error handling when reading configs (gh#openSUSE/snapper#715) --- diff --git a/LIBVERSION b/LIBVERSION index 09b254e9..5fe60723 100644 --- a/LIBVERSION +++ b/LIBVERSION @@ -1 +1 @@ -6.0.0 +6.0.1 diff --git a/package/snapper.changes b/package/snapper.changes index 8cf8ec06..9eca5d09 100644 --- a/package/snapper.changes +++ b/package/snapper.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Tue May 03 08:46:28 CEST 2022 - aschnell@suse.com + +- fixed error handling when reading configs + (gh#openSUSE/snapper#715) + ------------------------------------------------------------------- Thu Apr 21 09:35:06 CEST 2022 - aschnell@suse.com diff --git a/snapper/Selinux.cc b/snapper/Selinux.cc index 61c1de42..fefb2c62 100644 --- a/snapper/Selinux.cc +++ b/snapper/Selinux.cc @@ -32,9 +32,12 @@ namespace snapper { + using std::map; + + SnapperContexts::SnapperContexts() { - std::map snapperd_contexts; + map snapperd_contexts; try { @@ -59,13 +62,13 @@ namespace snapper } } } - catch (const FileNotFoundException& e) + catch (const Exception& e) { SN_CAUGHT(e); SN_THROW(SelinuxException("Failed to parse contexts file")); } - std::map::const_iterator cit = snapperd_contexts.find(selinux_snapperd_data); + map::const_iterator cit = snapperd_contexts.find(selinux_snapperd_data); if (cit == snapperd_contexts.end()) { SN_THROW(SelinuxException("Snapperd data context not found")); diff --git a/snapper/Snapper.cc b/snapper/Snapper.cc index 6a4d1395..87303500 100644 --- a/snapper/Snapper.cc +++ b/snapper/Snapper.cc @@ -111,7 +111,7 @@ namespace snapper { config_info = new ConfigInfo(config_name, root_prefix); } - catch (const FileNotFoundException& e) + catch (const Exception& e) { SN_CAUGHT(e); @@ -307,31 +307,25 @@ namespace snapper vector config_names; sysconfig.get_value("SNAPPER_CONFIGS", config_names); - for (vector::const_iterator it = config_names.begin(); it != config_names.end(); ++it) + for (const string& config_name : config_names) { try { - config_infos.push_back(getConfig(*it, root_prefix)); - } - catch (const FileNotFoundException& e) - { - SN_CAUGHT(e); - - y2err("config '" << *it << "' not found"); + config_infos.push_back(getConfig(config_name, root_prefix)); } - catch (const InvalidConfigException& e) + catch (const Exception& e) { SN_CAUGHT(e); - y2err("config '" << *it << "' is invalid"); + y2err("reading config '" << config_name << "' failed"); } } } - catch (const FileNotFoundException& e) + catch (const Exception& e) { SN_CAUGHT(e); - SN_THROW(ListConfigsFailedException("sysconfig-file not found")); + SN_THROW(ListConfigsFailedException("reading sysconfig-file failed")); } return config_infos; @@ -411,7 +405,7 @@ namespace snapper sysconfig.save(); } - catch (const FileNotFoundException& e) + catch (const Exception& e) { SN_CAUGHT(e); @@ -429,7 +423,7 @@ namespace snapper config.save(); } - catch (const FileNotFoundException& e) + catch (const Exception& e) { SN_CAUGHT(e); @@ -524,11 +518,11 @@ namespace snapper sysconfig.save(); } - catch (const FileNotFoundException& e) + catch (const Exception& e) { SN_CAUGHT(e); - SN_THROW(DeleteConfigFailedException("sysconfig-file not found")); + SN_THROW(DeleteConfigFailedException("modifying sysconfig-file failed")); } }