From 6bb5efadeceb8c4666c227a44113709bb47d23cb Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 20 Jan 2005 15:25:01 +0000 Subject: [PATCH] * Ensure that derivation names and sources don't end in `.drv'. --- src/libexpr/primops.cc | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc index f10597557..013eba594 100644 --- a/src/libexpr/primops.cc +++ b/src/libexpr/primops.cc @@ -16,21 +16,6 @@ static Expr primImport(EvalState & state, const ATermVector & args) } -#if 0 -static PathSet storeExprRootsCached(EvalState & state, const Path & nePath) -{ - DrvRoots::iterator i = state.drvRoots.find(nePath); - if (i != state.drvRoots.end()) - return i->second; - else { - PathSet paths = storeExprRoots(nePath); - state.drvRoots[nePath] = paths; - return paths; - } -} -#endif - - /* Returns the hash of a derivation modulo fixed-output subderivations. A fixed-output derivation is a derivation with one output (`out') for which an expected hash and hash algorithm are @@ -128,7 +113,10 @@ static void processBinding(EvalState & state, Expr e, Derivation & drv, } else if (matchPath(e, s)) { - Path srcPath(aterm2String(s)); + Path srcPath(canonPath(aterm2String(s))); + if (isDerivation(srcPath)) + throw Error(format("file names are not allowed to end in `%1%'") + % drvExtension); Path dstPath(addToStore(srcPath)); printMsg(lvlChatty, format("copied source `%1%' -> `%2%'") % srcPath % dstPath); @@ -272,6 +260,10 @@ static Expr primDerivation(EvalState & state, const ATermVector & _args) % *i % drvName); } + if (isDerivation(drvName)) + throw Error(format("derivation names are not allowed to end in `%1%'") + % drvExtension); + /* !!! the name should not end in the derivation extension (.drv). Likewise for sources. */