]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
- catch all exceptions in dbus and non-dbus case 290/head
authorArvin Schnell <aschnell@suse.de>
Fri, 4 Nov 2016 15:30:37 +0000 (16:30 +0100)
committerArvin Schnell <aschnell@suse.de>
Fri, 4 Nov 2016 15:30:37 +0000 (16:30 +0100)
client/snapper.cc
package/snapper.changes

index 742a7b1ab998b9f2edd55779b12a6b7a029333d4..c3df0728874538584b5096c52cbd8e1ac47c83ee 100644 (file)
@@ -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);
index 821ffa6ef53973f1e8906ecf03edc78428a2ed43..78bc6547280b0bd676e212bee40af6403f01c007 100644 (file)
@@ -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