/*
- * Copyright (c) [2016-2024] SUSE LLC
+ * Copyright (c) [2016-2025] SUSE LLC
*
* All Rights Reserved.
*
void
-ProxySnapshotDbus::setReadOnly(bool read_only)
+ProxySnapshotDbus::setReadOnly(bool read_only, Plugins::Report& report)
{
command_set_snapshot_read_only(conn(), configName(), num, read_only);
}
/*
- * Copyright (c) [2016-2024] SUSE LLC
+ * Copyright (c) [2016-2025] SUSE LLC
*
* All Rights Reserved.
*
virtual time_t getDate() const override { return date; }
virtual uid_t getUid() const override { return uid; }
virtual bool isReadOnly() const override;
- virtual void setReadOnly(bool read_only) override;
+ virtual void setReadOnly(bool read_only, Plugins::Report& report) override;
virtual unsigned int getPreNum() const override { return pre_num; }
virtual const string& getDescription() const override { return description; }
virtual const string& getCleanup() const override { return cleanup; }
virtual time_t getDate() const override { return it->getDate(); }
virtual uid_t getUid() const override { return it->getUid(); }
virtual bool isReadOnly() const override { return it->isReadOnly(); }
- virtual void setReadOnly(bool read_only) override { it->setReadOnly(read_only); }
+ virtual void setReadOnly(bool read_only, Plugins::Report& report) override { it->setReadOnly(read_only, report); }
virtual unsigned int getPreNum() const override { return it->getPreNum(); }
virtual const string& getDescription() const override { return it->getDescription(); }
virtual const string& getCleanup() const override { return it->getCleanup(); }
/*
- * Copyright (c) [2016-2024] SUSE LLC
+ * Copyright (c) [2016-2025] SUSE LLC
*
* All Rights Reserved.
*
time_t getDate() const { return impl->getDate(); }
uid_t getUid() const { return impl->getUid(); }
bool isReadOnly() const { return impl->isReadOnly(); }
- void setReadOnly(bool read_only) { impl->setReadOnly(read_only); }
+ void setReadOnly(bool read_only, Plugins::Report& report) { impl->setReadOnly(read_only, report); }
unsigned int getPreNum() const { return impl->getPreNum(); }
const string& getDescription() const { return impl->getDescription(); }
const string& getCleanup() const { return impl->getCleanup(); }
virtual time_t getDate() const = 0;
virtual uid_t getUid() const = 0;
virtual bool isReadOnly() const = 0;
- virtual void setReadOnly(bool read_only) = 0;
+ virtual void setReadOnly(bool read_only, Plugins::Report& report) = 0;
virtual unsigned int getPreNum() const = 0;
virtual const string& getDescription() const = 0;
virtual const string& getCleanup() const = 0;
/*
* Copyright (c) [2011-2015] Novell, Inc.
- * Copyright (c) [2016-2023] SUSE LLC
+ * Copyright (c) [2016-2025] SUSE LLC
*
* All Rights Reserved.
*
if (set_read_only)
{
- snapshot->setReadOnly(read_only);
+ snapshot->setReadOnly(read_only, report);
}
if (set_default)
<refentry id='snapper8' xmlns:xlink="http://www.w3.org/1999/xlink">
<refentryinfo>
- <date>2025-07-23</date>
+ <date>2025-09-02</date>
</refentryinfo>
<refmeta>
<refentrytitle>snapper</refentrytitle>
<manvolnum>8</manvolnum>
- <refmiscinfo class='date'>2025-07-23</refmiscinfo>
+ <refmiscinfo class='date'>2025-09-02</refmiscinfo>
<refmiscinfo class='version'>@VERSION@</refmiscinfo>
<refmiscinfo class='manual'>Filesystem Snapshot Management</refmiscinfo>
</refmeta>
<para>Executed after a snapshot was removed</para>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term><option>set-read-only-pre <replaceable>subvolume</replaceable> <replaceable>fstype</replaceable> <replaceable>snapshot-number</replaceable></option></term>
+ <listitem>
+ <para>Executed before a snapshot is set read-only or read-write</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>set-read-only-post <replaceable>subvolume</replaceable> <replaceable>fstype</replaceable> <replaceable>snapshot-number</replaceable></option></term>
+ <listitem>
+ <para>Executed after a snapshot is set read-only or read-write</para>
+ </listitem>
+ </varlistentry>
<varlistentry>
<term><option>set-default-snapshot-pre <replaceable>subvolume</replaceable> <replaceable>fstype</replaceable> <replaceable>snapshot-number</replaceable></option></term>
<listitem>
+-------------------------------------------------------------------
+Tue Sep 02 14:29:41 CEST 2025 - aschnell@suse.com
+
+- added generic plugin action used when setting snapshot read-only
+ (bsc#1246172)
+
-------------------------------------------------------------------
Mon Aug 04 17:00:45 CEST 2025 - Arvin Schnell <aschnell@suse.com>
if (snap == snapshots.end())
SN_THROW(IllegalSnapshotException());
- snap->setReadOnly(read_only);
+ snap->setReadOnly(read_only, report);
DBus::MessageMethodReturn reply(msg);
/*
- * Copyright (c) 2024 SUSE LLC
+ * Copyright (c) [2024-2025] SUSE LLC
*
* All Rights Reserved.
*
#include "snapper/Snapper.h"
#include "snapper/SnapperTmpl.h"
#include "snapper/SnapperDefines.h"
-
+#include "snapper/PluginsImpl.h"
#include "snapper/Acls.h"
#include "snapper/Exception.h"
#ifdef ENABLE_SELINUX
void
- Bcachefs::setSnapshotReadOnly(unsigned int num, bool read_only) const
+ Bcachefs::setSnapshotReadOnly(unsigned int num, bool read_only, Plugins::Report& report) const
{
+ Plugins::set_read_only(Plugins::Stage::PRE_ACTION, subvolume, this, num, report);
+
SDir snapshot_dir = openSnapshotDir(num);
set_subvolume_read_only(snapshot_dir.fd(), read_only);
+
+ Plugins::set_read_only(Plugins::Stage::POST_ACTION, subvolume, this, num, report);
}
/*
- * Copyright (c) 2024 SUSE LLC
+ * Copyright (c) [2024-2025] SUSE LLC
*
* All Rights Reserved.
*
virtual void umountSnapshot(unsigned int num) const override;
virtual bool isSnapshotReadOnly(unsigned int num) const override;
- virtual void setSnapshotReadOnly(unsigned int num, bool read_only) const override;
+ virtual void setSnapshotReadOnly(unsigned int num, bool read_only, Plugins::Report& report) const override;
virtual bool checkSnapshot(unsigned int num) const override;
/*
* Copyright (c) [2011-2015] Novell, Inc.
- * Copyright (c) [2016-2024] SUSE LLC
+ * Copyright (c) [2016-2025] SUSE LLC
*
* All Rights Reserved.
*
void
- Btrfs::setSnapshotReadOnly(unsigned int num, bool read_only) const
+ Btrfs::setSnapshotReadOnly(unsigned int num, bool read_only, Plugins::Report& report) const
{
+ Plugins::set_read_only(Plugins::Stage::PRE_ACTION, subvolume, this, num, report);
+
SDir snapshot_dir = openSnapshotDir(num);
set_subvolume_read_only(snapshot_dir.fd(), read_only);
+
+ Plugins::set_read_only(Plugins::Stage::POST_ACTION, subvolume, this, num, report);
}
/*
* Copyright (c) [2011-2015] Novell, Inc.
- * Copyright (c) [2016-2023] SUSE LLC
+ * Copyright (c) [2016-2025] SUSE LLC
*
* All Rights Reserved.
*
virtual void umountSnapshot(unsigned int num) const override;
virtual bool isSnapshotReadOnly(unsigned int num) const override;
- virtual void setSnapshotReadOnly(unsigned int num, bool read_only) const override;
+ virtual void setSnapshotReadOnly(unsigned int num, bool read_only, Plugins::Report& report) const override;
virtual bool checkSnapshot(unsigned int num) const override;
/*
* Copyright (c) [2011-2015] Novell, Inc.
- * Copyright (c) [2016-2023] SUSE LLC
+ * Copyright (c) [2016-2025] SUSE LLC
*
* All Rights Reserved.
*
virtual void umountSnapshot(unsigned int num) const = 0;
virtual bool isSnapshotReadOnly(unsigned int num) const = 0;
- virtual void setSnapshotReadOnly(unsigned int num, bool read_only) const = 0;
+ virtual void setSnapshotReadOnly(unsigned int num, bool read_only, Plugins::Report& report) const = 0;
virtual bool checkSnapshot(unsigned int num) const = 0;
/*
* Copyright (c) [2011-2014] Novell, Inc.
- * Copyright (c) [2020-2023] SUSE LLC
+ * Copyright (c) [2020-2025] SUSE LLC
*
* All Rights Reserved.
*
#include "snapper/SystemCmd.h"
#include "snapper/SnapperDefines.h"
#include "snapper/LvmCache.h"
+#include "snapper/PluginsImpl.h"
#ifdef ENABLE_SELINUX
#include "snapper/Selinux.h"
#endif
void
- Lvm::setSnapshotReadOnly(unsigned int num, bool read_only) const
+ Lvm::setSnapshotReadOnly(unsigned int num, bool read_only, Plugins::Report& report) const
{
try
{
+ Plugins::set_read_only(Plugins::Stage::PRE_ACTION, subvolume, this, num, report);
+
cache->set_read_only(vg_name, snapshotLvName(num), read_only);
+
+ Plugins::set_read_only(Plugins::Stage::POST_ACTION, subvolume, this, num, report);
}
catch (const LvmCacheException& e)
{
/*
* Copyright (c) [2011-2014] Novell, Inc.
- * Copyright (c) 2023 SUSE LLC
+ * Copyright (c) [2023-2025] SUSE LLC
*
* All Rights Reserved.
*
virtual void umountSnapshot(unsigned int num) const override;
virtual bool isSnapshotReadOnly(unsigned int num) const override;
- virtual void setSnapshotReadOnly(unsigned int num, bool read_only) const override;
+ virtual void setSnapshotReadOnly(unsigned int num, bool read_only, Plugins::Report& report) const override;
virtual bool checkSnapshot(unsigned int num) const override;
}
+ void
+ Plugins::set_read_only(Stage stage, const string& subvolume, const Filesystem* filesystem,
+ unsigned int num, Report& report)
+ {
+ switch (stage)
+ {
+ case Stage::PRE_ACTION:
+ run_scripts({ "set-read-only-pre", subvolume, filesystem->fstype(),
+ std::to_string(num) }, report);
+ break;
+
+ case Stage::POST_ACTION:
+ grub(subvolume, filesystem, "--enable", report);
+ run_scripts({ "set-read-only-post", subvolume, filesystem->fstype(),
+ std::to_string(num) }, report);
+ break;
+ }
+ }
+
+
void
Plugins::set_default_snapshot(Stage stage, const string& subvolume, const Filesystem* filesystem,
unsigned int num, Report& report)
/*
* Copyright (c) [2011-2015] Novell, Inc.
- * Copyright (c) [2022-2023] SUSE LLC
+ * Copyright (c) [2022-2025] SUSE LLC
*
* All Rights Reserved.
*
void delete_snapshot(Stage stage, const string& subvolume, const Filesystem* filesystem,
const Snapshot& snapshot, Report& report);
+ void set_read_only(Stage stage, const string& subvolume, const Filesystem* filesystem,
+ unsigned int num, Report& report);
+
void set_default_snapshot(Stage stage, const string& subvolume, const Filesystem* filesystem,
unsigned int num, Report& report);
void
- Snapshot::setReadOnly(bool read_only)
+ Snapshot::setReadOnly(bool read_only, Plugins::Report& report)
{
if (isCurrent())
SN_THROW(IllegalSnapshotException());
Snapshot::read_only = read_only;
- snapper->getFilesystem()->setSnapshotReadOnly(num, read_only);
+ snapper->getFilesystem()->setSnapshotReadOnly(num, read_only, report);
if (!read_only)
deleteFilelists();
SDir openSnapshotDir() const;
/**
- * Determine iff snapshot is read-only (only for btrfs).
+ * Determine iff snapshot is read-only (may not be supported by all file system types).
*/
bool isReadOnly() const;
/**
- * Set snapshot read-only or read-write (only for btrfs).
+ * Set snapshot read-only or read-write (may not be supported by all file system types).
*/
- void setReadOnly(bool read_only);
+ void setReadOnly(bool read_only, Plugins::Report& report);
/**
* Determine iff snapshot is default (will be activated on next boot time).