proxy.cc proxy.h \
proxy-dbus.cc proxy-dbus.h \
proxy-lib.cc proxy-lib.h \
+ locker.cc locker.h \
misc.cc misc.h \
MyFiles.cc MyFiles.h \
GlobalOptions.cc GlobalOptions.h
proxy.cc proxy.h \
proxy-dbus.cc proxy-dbus.h \
proxy-lib.cc proxy-lib.h \
+ locker.cc locker.h \
misc.cc misc.h
systemd_helper_LDADD = libclient.la ../snapper/libsnapper.la utils/libutils.la ../dbus/libdbus.la
/*
* Copyright (c) [2011-2014] Novell, Inc.
- * Copyright (c) [2016-2021] SUSE LLC
+ * Copyright (c) [2016-2024] SUSE LLC
*
* All Rights Reserved.
*
#include "utils/equal-date.h"
#include "utils/HumanString.h"
#include "cleanup.h"
+#include "locker.h"
using namespace std;
public:
Cleaner(ProxySnapper* snapper, bool verbose, const Parameters& parameters)
- : snapper(snapper), verbose(verbose), parameters(parameters) {}
+ : snapper(snapper), locker(snapper), verbose(verbose), parameters(parameters) {}
virtual ~Cleaner() {}
ProxySnapper* snapper;
+ Locker locker;
+
const bool verbose;
const Parameters& parameters;
/*
* Copyright (c) [2011-2015] Novell, Inc.
- * Copyright (c) [2016-2023] SUSE LLC
+ * Copyright (c) [2016-2024] SUSE LLC
*
* All Rights Reserved.
*
#include "utils/text.h"
#include "GlobalOptions.h"
#include "proxy.h"
+#include "locker.h"
#include "misc.h"
#include "utils/TableFormatter.h"
#include "utils/CsvFormatter.h"
bool skip_snapshot(const ProxySnapshot& snapshot, ListMode list_mode) const;
const ProxySnapper* snapper;
+
+ private:
+
+ Locker locker;
+
+ public:
+
const ProxySnapshots& snapshots;
private:
OutputHelper::OutputHelper(const ProxySnapper* snapper, const vector<Column>& columns)
- : snapper(snapper), snapshots(snapper->getSnapshots()), default_snapshot(snapshots.end()),
- active_snapshot(snapshots.end())
+ : snapper(snapper), locker(snapper), snapshots(snapper->getSnapshots()),
+ default_snapshot(snapshots.end()), active_snapshot(snapshots.end())
{
try
{
/*
* Copyright (c) [2012-2015] Novell, Inc.
- * Copyright (c) [2016-2023] SUSE LLC
+ * Copyright (c) [2016-2024] SUSE LLC
*
* All Rights Reserved.
*
}
+void
+command_lock_config(DBus::Connection& conn, const string& config_name)
+{
+ DBus::MessageMethodCall call(SERVICE, OBJECT, INTERFACE, "LockConfig");
+
+ DBus::Marshaller marshaller(call);
+ marshaller << config_name;
+
+ conn.send_with_reply_and_block(call);
+}
+
+
+void
+command_unlock_config(DBus::Connection& conn, const string& config_name)
+{
+ DBus::MessageMethodCall call(SERVICE, OBJECT, INTERFACE, "UnlockConfig");
+
+ DBus::Marshaller marshaller(call);
+ marshaller << config_name;
+
+ conn.send_with_reply_and_block(call);
+}
+
+
vector<XReport>
command_get_plugins_report(DBus::Connection& conn)
{
/*
* Copyright (c) [2012-2015] Novell, Inc.
- * Copyright (c) [2016-2023] SUSE LLC
+ * Copyright (c) [2016-2024] SUSE LLC
*
* All Rights Reserved.
*
FreeSpaceData
command_query_free_space(DBus::Connection& conn, const string& config_name);
+void
+command_lock_config(DBus::Connection& conn, const string& config_name);
+
+void
+command_unlock_config(DBus::Connection& conn, const string& config_name);
+
void
command_sync(DBus::Connection& conn, const string& config_name);
--- /dev/null
+/*
+ * Copyright (c) 2024 SUSE LLC
+ *
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may
+ * find current contact information at www.novell.com.
+ */
+
+
+#include "locker.h"
+
+
+namespace snapper
+{
+
+ Locker::Locker(const ProxySnapper* snapper)
+ : snapper(snapper)
+ {
+ snapper->lock_config();
+ }
+
+
+ Locker::~Locker()
+ {
+ snapper->unlock_config();
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2024 SUSE LLC
+ *
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may
+ * find current contact information at www.novell.com.
+ */
+
+
+#include "proxy.h"
+
+
+namespace snapper
+{
+
+ class Locker
+ {
+
+ public:
+
+ Locker(const ProxySnapper* snapper);
+ ~Locker();
+
+ private:
+
+ const ProxySnapper* snapper;
+
+ };
+
+}
/*
- * Copyright (c) [2016-2023] SUSE LLC
+ * Copyright (c) [2016-2024] SUSE LLC
*
* All Rights Reserved.
*
}
+void
+ProxySnapperDbus::lock_config() const
+{
+ command_lock_config(conn(), config_name);
+}
+
+
+void
+ProxySnapperDbus::unlock_config() const
+{
+ command_unlock_config(conn(), config_name);
+}
+
+
string
ProxySnapshotDbus::mountFilesystemSnapshot(bool user_request) const
{
/*
- * Copyright (c) [2016-2023] SUSE LLC
+ * Copyright (c) [2016-2024] SUSE LLC
*
* All Rights Reserved.
*
virtual void calculateUsedSpace() const override;
+ virtual void lock_config() const override;
+ virtual void unlock_config() const override;
+
DBus::Connection& conn() const;
private:
/*
- * Copyright (c) [2016-2023] SUSE LLC
+ * Copyright (c) [2016-2024] SUSE LLC
*
* All Rights Reserved.
*
virtual void calculateUsedSpace() const override { snapper->calculateUsedSpace(); }
+ virtual void lock_config() const override {}
+ virtual void unlock_config() const override {}
+
std::unique_ptr<Snapper> snapper;
private:
/*
- * Copyright (c) [2016-2023] SUSE LLC
+ * Copyright (c) [2016-2024] SUSE LLC
*
* All Rights Reserved.
*
virtual void calculateUsedSpace() const = 0;
+ virtual void lock_config() const = 0;
+ virtual void unlock_config() const = 0;
+
};
snapper.LockConfig("root")
+print("locked")
+
+snapper.LockConfig("root")
+snapper.UnlockConfig("root")
+print("still locked")
sleep(10)
snapper.UnlockConfig("root")
+print("unlocked")
+
+sleep(10)
+-------------------------------------------------------------------
+Wed Feb 07 11:16:40 CET 2024 - aschnell@suse.com
+
+- lock config during list and cleanup commands and in zypper plugin
+ (gh#openSUSE/snapper#867)
+
-------------------------------------------------------------------
Fri Dec 08 09:06:30 CET 2023 - aschnell@suse.com
/*
- * Copyright (c) [2019-2023] SUSE LLC
+ * Copyright (c) [2019-2024] SUSE LLC
*
* All Rights Reserved.
*
ZyppCommitPlugin::Message
SnapperZyppCommitPlugin::plugin_begin(const Message& msg)
{
- y2mil("PLUGINBEGIN");
+ y2mil("PLUGIN BEGIN");
userdata = get_userdata(msg);
ZyppCommitPlugin::Message
SnapperZyppCommitPlugin::plugin_end(const Message& msg)
{
- y2mil("PLUGINEND");
+ y2mil("PLUGIN END");
return ack();
}
ZyppCommitPlugin::Message
SnapperZyppCommitPlugin::commit_begin(const Message& msg)
{
- y2mil("COMMITBEGIN");
+ y2mil("COMMIT BEGIN");
set<string> solvables = get_solvables(msg, Phase::BEFORE);
y2deb("solvables: " << solvables);
if (found || important)
{
+ try
+ {
+ y2deb("lock config");
+ command_lock_config(dbus_conn, snapper_cfg);
+ }
+ catch (const Exception& ex)
+ {
+ SN_CAUGHT(ex);
+ }
+
userdata["important"] = important ? "yes" : "no";
try
ZyppCommitPlugin::Message
SnapperZyppCommitPlugin::commit_end(const Message& msg)
{
- y2mil("COMMITEND");
+ y2mil("COMMIT END");
if (pre_snapshot_num != 0)
{
SN_CAUGHT(ex);
}
}
+
+ try
+ {
+ y2deb("unlock config");
+ command_unlock_config(dbus_conn, snapper_cfg);
+ }
+ catch (const Exception& ex)
+ {
+ SN_CAUGHT(ex);
+ }
}
return ack();
const string snapper_cfg;
DBus::Connection dbus_conn;
- unsigned int pre_snapshot_num;
+ unsigned int pre_snapshot_num = 0;
string snapshot_description;
map<string, string> userdata;