aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2013-11-19 14:29:39 +0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2013-11-19 14:29:39 +0100
commit30b986908eed5d8fd6a2b21da98878f2a0bf19c0 (patch)
tree90193b0624a66c87297b6be0aeb50851fe918b88 /src/libexpr
parent0f24400d90daf65cf20142a662f8245008437e2c (diff)
Check meta values and warn about bad ones
Diffstat (limited to 'src/libexpr')
-rw-r--r--src/libexpr/get-drvs.cc22
-rw-r--r--src/libexpr/get-drvs.hh2
2 files changed, 22 insertions, 2 deletions
diff --git a/src/libexpr/get-drvs.cc b/src/libexpr/get-drvs.cc
index 42776b22a..0ed644e9b 100644
--- a/src/libexpr/get-drvs.cc
+++ b/src/libexpr/get-drvs.cc
@@ -91,12 +91,30 @@ StringSet DrvInfo::queryMetaNames()
}
+bool DrvInfo::checkMeta(Value & v)
+{
+ state->forceValue(v);
+ if (v.type == tList) {
+ for (unsigned int n = 0; n < v.list.length; ++n)
+ if (!checkMeta(*v.list.elems[n])) return false;
+ return true;
+ }
+ else if (v.type == tAttrs) {
+ Bindings::iterator i = v.attrs->find(state->sOutPath);
+ if (i != v.attrs->end()) return false;
+ foreach (Bindings::iterator, i, *v.attrs)
+ if (!checkMeta(*i->value)) return false;
+ return true;
+ }
+ else return v.type == tInt || v.type == tBool || v.type == tString;
+}
+
+
Value * DrvInfo::queryMeta(const string & name)
{
if (!getMeta()) return 0;
Bindings::iterator a = meta->find(state->symbols.create(name));
- if (a == meta->end()) return 0;
- state->forceValue(*a->value);
+ if (a == meta->end() || !checkMeta(*a->value)) return 0;
return a->value;
}
diff --git a/src/libexpr/get-drvs.hh b/src/libexpr/get-drvs.hh
index b5aebc188..aaafff190 100644
--- a/src/libexpr/get-drvs.hh
+++ b/src/libexpr/get-drvs.hh
@@ -30,6 +30,8 @@ private:
Bindings * getMeta();
+ bool checkMeta(Value & v);
+
public:
string name;
string attrPath; /* path towards the derivation */