From 8c74aadbf775c322494841de225b82737ec69b7c Mon Sep 17 00:00:00 2001 From: Sergei Zimmerman Date: Mon, 15 Dec 2025 00:33:24 +0300 Subject: [PATCH] libutil: Fix AutoRemoveJail special member functions These can't be copied and moving requires special logic too. --- .../freebsd/include/nix/util/freebsd-jail.hh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/libutil/freebsd/include/nix/util/freebsd-jail.hh b/src/libutil/freebsd/include/nix/util/freebsd-jail.hh index 33a86a398..cfab3c2a6 100644 --- a/src/libutil/freebsd/include/nix/util/freebsd-jail.hh +++ b/src/libutil/freebsd/include/nix/util/freebsd-jail.hh @@ -11,6 +11,24 @@ class AutoRemoveJail bool del; public: AutoRemoveJail(int jid); + AutoRemoveJail(const AutoRemoveJail &) = delete; + AutoRemoveJail & operator=(const AutoRemoveJail &) = delete; + + AutoRemoveJail(AutoRemoveJail && other) noexcept + : jid(other.jid) + , del(other.del) + { + other.cancel(); + } + + AutoRemoveJail & operator=(AutoRemoveJail && other) noexcept + { + jid = other.jid; + del = other.del; + other.cancel(); + return *this; + } + AutoRemoveJail(); ~AutoRemoveJail(); void cancel();