/*
* Convert a value-box list to a LHS attribute #tmpl_t
*/
-static int tmpl_attr_from_result(TALLOC_CTX *ctx, edit_result_t *out, request_t *request)
+static int tmpl_attr_from_result(TALLOC_CTX *ctx, map_t const *map, edit_result_t *out, request_t *request)
{
ssize_t slen;
fr_value_box_t *box = fr_value_box_list_head(&out->result);
return -1;
}
+ /*
+ * String outputs can be interpreted as attribute references.
+ *
+ * LHS of an assignment MUST be an attribute. The RHS
+ * MAY be an attribute, if the stars align.
+ */
+ if (map && map->rhs) {
+ /*
+ * &foo := "bar"
+ *
+ * RHS can't be an attribute.
+ */
+ if (map->rhs->quote != T_BARE_WORD) return 0;
+
+ /*
+ * &foo := %{bin:0102030005060708}
+ *
+ * RHS is octets (or other non-string), and can't be an attribute references.
+ */
+ if (box->type != FR_TYPE_STRING) return 0;
+
+ /*
+ * @todo - arguably the assignment should be something like:
+ *
+ * &foo := &%{expansion}
+ *
+ * To say "yes, we really want the RHS to be an attribute reference".
+ */
+ }
+
/*
* Mash all of the results together.
*/
return check_rhs(request, state, current);
}
- if (tmpl_attr_from_result(state, ¤t->rhs, request) < 0) return -1;
+ if (tmpl_attr_from_result(state, map, ¤t->rhs, request) < 0) return -1;
return check_rhs(request, state, current);
}
{
REXDENT();
- if (tmpl_attr_from_result(state, ¤t->lhs, request) < 0) return -1;
+ if (tmpl_attr_from_result(state, NULL, ¤t->lhs, request) < 0) return -1;
return current->check_lhs(request, state, current);
}
test_fail
}
-debug_request
-
-if ( &Relay-Agent-Information.Circuit-Id != 0xabcdef ) {
+if (&Relay-Agent-Information.Circuit-Id != 0xabcdef) {
test_fail
}
-if ( &Relay-Agent-Information.Remote-Id != 0x010203040506 ) {
+if (&Relay-Agent-Information.Remote-Id != 0x010203040506) {
test_fail
}
-&Tmp-Octets-1 := "%(encode.dhcpv4:&request[*])"
-if ( &Tmp-Octets-1 != 0x520d0103abcdef0206010203040506 ) {
+&Tmp-Octets-1 := %(encode.dhcpv4:&request)
+
+if !(&Tmp-Octets-1 == 0x520d0103abcdef0206010203040506) {
test_fail
}
-debug_control
success