From aba6eb348e0ed8177da1e7f1df46ba00d20eab96 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Mon, 19 Dec 2022 14:06:07 +0100 Subject: libstore: Make sure that initNix has been called Prevent bugs like https://github.com/cachix/cachix/pull/477 --- src/libstore/globals.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/libstore/globals.cc') diff --git a/src/libstore/globals.cc b/src/libstore/globals.cc index b7f55cae7..130c5b670 100644 --- a/src/libstore/globals.cc +++ b/src/libstore/globals.cc @@ -291,4 +291,18 @@ void initPlugins() settings.pluginFiles.pluginsLoaded = true; } +static bool initLibStoreDone = false; + +void assertLibStoreInitialized() { + if (!initLibStoreDone) { + printError("The program must call nix::initNix() before calling any libstore library functions."); + abort(); + }; +} + +void initLibStore() { + initLibStoreDone = true; +} + + } -- cgit v1.2.3