}
#endif
-static void fix_up(REQUEST *request)
-{
- VALUE_PAIR *vp;
-
- request->username = NULL;
- request->password = NULL;
-
- for (vp = request->packet->vps; vp != NULL; vp = vp->next) {
- if (vp->vendor != 0) continue;
-
- if ((vp->attribute == PW_USER_NAME) &&
- !request->username) {
- request->username = vp;
-
- } else if (vp->attribute == PW_STRIPPED_USER_NAME) {
- request->username = vp;
-
- } else if (vp->attribute == PW_USER_PASSWORD) {
- request->password = vp;
- }
-
- if (request->username && request->password) break;
- }
-}
-
/*
* The pairmove() function in src/lib/valuepair.c does all sorts of
VALUE_PAIR *vp, *next, **last;
VALUE_PAIR **from_list, **to_list;
int *edited = NULL;
+ REQUEST *fixup = NULL;
/*
* Set up arrays for editing, to remove some of the
*to = NULL;
last = to;
+ if (to == &request->packet->vps) {
+ fixup = request;
+ } else if (request->parent && (to == &request->parent->packet->vps)) {
+ fixup = request->parent;
+ }
+ if (fixup) {
+ fixup->username = NULL;
+ fixup->password = NULL;
+ }
+
for (i = 0; i < tailto; i++) {
if (!to_list[i]) continue;
- RDEBUG4("::: to[%d] = %s", i, to_list[i]->name);
+ vp = to_list[i];
+ RDEBUG4("::: to[%d] = %s", i, vp->name);
/*
* Mash the operator to a simple '='. The
* file and debug output, where we don't want to
* see the operators.
*/
- to_list[i]->operator = T_OP_EQ;
+ vp->operator = T_OP_EQ;
+
+ /*
+ * Fix dumb cache issues
+ */
+ if (fixup && (vp->vendor == 0)) {
+ if ((vp->attribute == PW_USER_NAME) &&
+ !fixup->username) {
+ fixup->username = vp;
+
+ } else if (vp->attribute == PW_STRIPPED_USER_NAME) {
+ fixup->username = vp;
+
+ } else if (vp->attribute == PW_USER_PASSWORD) {
+ fixup->password = vp;
+ }
+ }
- *last = to_list[i];
+ *last = vp;
last = &(*last)->next;
}
rad_assert(request != NULL);
rad_assert(request->packet != NULL);
- /*
- * Fix dumb cache issues
- */
- if (to == &request->packet->vps) {
- fix_up(request);
- } else if (request->parent && (to == &request->parent->packet->vps)) {
- fix_up(request->parent);
- }
-
free(to_list);
free(edited);
}