From baa4fda34032373f2e4d5fdb5565132522c24983 Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Fri, 9 Aug 2024 00:58:38 +0200 Subject: [PATCH] main: require argv[0] sure, linux has been providing argv[0] by default for a while now. other OSes may not be as forthcoming though, and relying on the OS to create a world in which we can just make assumptions we could test for instead is unnecessarily lazy. we *could* default argv0, but that's a little silly. notably we abort instead of returning normally to avoid confusions where a caller interprets our exit status like a Worker build results bitmask. Change-Id: Id73f8cd0a630293b789c59a8c4b0c4a2b936b505 --- src/nix/main.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/nix/main.cc b/src/nix/main.cc index 981aa2fc5..1c1e9df7e 100644 --- a/src/nix/main.cc +++ b/src/nix/main.cc @@ -503,6 +503,11 @@ void mainWrapped(int argc, char * * argv) int main(int argc, char * * argv) { + if (argc < 1) { + std::cerr << "no, we don't have pkexec at home. provide argv[0]." << std::endl; + std::abort(); + } + // Increase the default stack size for the evaluator and for // libstdc++'s std::regex. nix::setStackSize(64 * 1024 * 1024);