From d0903bb7c839cdeb71ae93786cd69192c63e63a0 Mon Sep 17 00:00:00 2001 From: Arvin Schnell Date: Fri, 4 Nov 2016 16:30:37 +0100 Subject: [PATCH] - catch all exceptions in dbus and non-dbus case --- client/snapper.cc | 187 +++++++++++++++++++--------------------- package/snapper.changes | 5 ++ 2 files changed, 96 insertions(+), 96 deletions(-) diff --git a/client/snapper.cc b/client/snapper.cc index 742a7b1a..c3df0728 100644 --- a/client/snapper.cc +++ b/client/snapper.cc @@ -1368,11 +1368,10 @@ command_rollback(DBus::Connection* conn, Snapper* snapper) if (subvolume != "/") { cerr << sformat(_("Command 'rollback' cannot be used on a non-root subvolume %s."), - subvolume.c_str()) << endl; + subvolume.c_str()) << endl; exit(EXIT_FAILURE); } - unsigned int num1; unsigned int num2; @@ -1782,118 +1781,114 @@ main(int argc, char** argv) exit(EXIT_FAILURE); } - if (no_dbus) + try { - if (!cmd->works_without_dbus) + if (no_dbus) { - cerr << sformat(_("Command '%s' does not work without DBus."), cmd->name.c_str()) << endl; - exit(EXIT_FAILURE); - } + if (!cmd->works_without_dbus) + { + cerr << sformat(_("Command '%s' does not work without DBus."), cmd->name.c_str()) << endl; + exit(EXIT_FAILURE); + } - try - { Snapper* snapper = cmd->needs_snapper ? new Snapper(config_name, target_root) : NULL; (*cmd->cmd_func)(NULL, snapper); delete snapper; } - - catch (const ConfigNotFoundException& e) - { - SN_CAUGHT(e); - cerr << sformat(_("Config '%s' not found."), config_name.c_str()) << endl; - exit(EXIT_FAILURE); - } - catch (const InvalidConfigException& e) - { - SN_CAUGHT(e); - cerr << sformat(_("Config '%s' is invalid."), config_name.c_str()) << endl; - exit(EXIT_FAILURE); - } - catch (const ListConfigsFailedException& e) - { - SN_CAUGHT(e); - cerr << sformat(_("Listing configs failed (%s)."), e.what()) << endl; - exit(EXIT_FAILURE); - } - catch (const CreateConfigFailedException& e) - { - SN_CAUGHT(e); - cerr << sformat(_("Creating config failed (%s)."), e.what()) << endl; - exit(EXIT_FAILURE); - } - catch (const DeleteConfigFailedException& e) - { - SN_CAUGHT(e); - cerr << sformat(_("Deleting config failed (%s)."), e.what()) << endl; - exit(EXIT_FAILURE); - } - catch (const InvalidConfigdataException& e) - { - SN_CAUGHT(e); - cerr << _("Invalid configdata.") << endl; - exit(EXIT_FAILURE); - } - catch (const AclException& e) - { - SN_CAUGHT(e); - cerr << _("ACL error.") << endl; - exit(EXIT_FAILURE); - } - catch (const IOErrorException& e) - { - SN_CAUGHT(e); - cerr << sformat(_("IO error (%s)."), e.what()) << endl; - exit(EXIT_FAILURE); - } - catch (const InvalidUserException& e) - { - SN_CAUGHT(e); - cerr << _("Invalid user.") << endl; - exit(EXIT_FAILURE); - } - catch (const InvalidGroupException& e) - { - SN_CAUGHT(e); - cerr << _("Invalid group.") << endl; - exit(EXIT_FAILURE); - } - catch (const QuotaException& e) - { - SN_CAUGHT(e); - cerr << sformat(_("Quota error (%s)."), e.what()) << endl; - exit(EXIT_FAILURE); - } - } - else - { - try + else { DBus::Connection conn(DBUS_BUS_SYSTEM); (*cmd->cmd_func)(&conn, NULL); } - catch (const DBus::ErrorException& e) - { - SN_CAUGHT(e); - - if (strcmp(e.name(), "error.unknown_config") == 0 && config_name == "root") - { - cerr << _("The config 'root' does not exist. Likely snapper is not configured.") << endl - << _("See 'man snapper' for further instructions.") << endl; - exit(EXIT_FAILURE); - } + } + catch (const DBus::ErrorException& e) + { + SN_CAUGHT(e); - cerr << error_description(e) << endl; - exit(EXIT_FAILURE); - } - catch (const DBus::FatalException& e) + if (strcmp(e.name(), "error.unknown_config") == 0 && config_name == "root") { - SN_CAUGHT(e); - cerr << _("Failure") << " (" << e.what() << ")." << endl; + cerr << _("The config 'root' does not exist. Likely snapper is not configured.") << endl + << _("See 'man snapper' for further instructions.") << endl; exit(EXIT_FAILURE); } + + cerr << error_description(e) << endl; + exit(EXIT_FAILURE); + } + catch (const DBus::FatalException& e) + { + SN_CAUGHT(e); + cerr << _("Failure") << " (" << e.what() << ")." << endl; + exit(EXIT_FAILURE); + } + catch (const ConfigNotFoundException& e) + { + SN_CAUGHT(e); + cerr << sformat(_("Config '%s' not found."), config_name.c_str()) << endl; + exit(EXIT_FAILURE); + } + catch (const InvalidConfigException& e) + { + SN_CAUGHT(e); + cerr << sformat(_("Config '%s' is invalid."), config_name.c_str()) << endl; + exit(EXIT_FAILURE); + } + catch (const ListConfigsFailedException& e) + { + SN_CAUGHT(e); + cerr << sformat(_("Listing configs failed (%s)."), e.what()) << endl; + exit(EXIT_FAILURE); + } + catch (const CreateConfigFailedException& e) + { + SN_CAUGHT(e); + cerr << sformat(_("Creating config failed (%s)."), e.what()) << endl; + exit(EXIT_FAILURE); + } + catch (const DeleteConfigFailedException& e) + { + SN_CAUGHT(e); + cerr << sformat(_("Deleting config failed (%s)."), e.what()) << endl; + exit(EXIT_FAILURE); + } + catch (const InvalidConfigdataException& e) + { + SN_CAUGHT(e); + cerr << _("Invalid configdata.") << endl; + exit(EXIT_FAILURE); + } + catch (const AclException& e) + { + SN_CAUGHT(e); + cerr << _("ACL error.") << endl; + exit(EXIT_FAILURE); + } + catch (const IOErrorException& e) + { + SN_CAUGHT(e); + cerr << sformat(_("IO error (%s)."), e.what()) << endl; + exit(EXIT_FAILURE); + } + catch (const InvalidUserException& e) + { + SN_CAUGHT(e); + cerr << _("Invalid user.") << endl; + exit(EXIT_FAILURE); + } + catch (const InvalidGroupException& e) + { + SN_CAUGHT(e); + cerr << _("Invalid group.") << endl; + exit(EXIT_FAILURE); + } + catch (const QuotaException& e) + { + SN_CAUGHT(e); + cerr << sformat(_("Quota error (%s)."), e.what()) << endl; + exit(EXIT_FAILURE); } exit(EXIT_SUCCESS); diff --git a/package/snapper.changes b/package/snapper.changes index 821ffa6e..78bc6547 100644 --- a/package/snapper.changes +++ b/package/snapper.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Fri Nov 04 16:28:49 CET 2016 - aschnell@suse.com + +- catch exception if setting default subvolume fails (bsc#1008544) + ------------------------------------------------------------------- Wed Nov 02 22:17:16 CET 2016 - aschnell@suse.com -- 2.47.3