VALUE_PAIR **reply_pairs);
VALUE_PAIR *radius_paircreate(REQUEST *request, VALUE_PAIR **vps,
int attribute, int type);
+VALUE_PAIR *radius_pairmake(REQUEST *request, VALUE_PAIR **vps,
+ const char *attribute, const char *value,
+ int operator);
/* xlat.c */
typedef int (*RADIUS_ESCAPE_STRING)(char *out, int outlen, const char *in);
const char **ptr, int evaluate_it, int *presult);
int radius_update_attrlist(REQUEST *request, CONF_SECTION *cs,
VALUE_PAIR *input_vps, const char *name);
-
-/* vmps.c */
-int vmps_process(REQUEST *);
-
#endif /*RADIUSD_H*/
* accordingly.
*/
case PW_AUTHENTICATION_ACK:
- tmp = paircreate(PW_AUTH_TYPE, PW_TYPE_INTEGER);
- if (tmp == NULL) {
- radlog(L_ERR|L_CONS, "Not enough memory");
- exit(1);
- }
- tmp->vp_integer = PW_AUTHTYPE_ACCEPT;
- pairadd(&request->config_items, tmp);
+ tmp = radius_paircreate(request,
+ &request->config_items,
+ PW_AUTH_TYPE, PW_TYPE_INTEGER);
+ if (tmp) tmp->vp_integer = PW_AUTHTYPE_ACCEPT;
break;
/*
* Challenges are punted back to the NAS without any
* Remove ALL reply attributes.
*/
pairfree(&request->reply->vps);
- tmp = pairmake("Reply-Message", user_msg, T_OP_SET);
- request->reply->vps = tmp;
+ radius_pairmake(request, &request->reply->vps,
+ "Reply-Message",
+ user_msg, T_OP_SET);
snprintf(logstr, sizeof(logstr), "Multiple logins (max %d) %s",
check_item->vp_integer,
}
}
-static VALUE_PAIR * radius_pairmake(REQUEST *request, VALUE_PAIR **vps,
- const char *attribute, const char *value)
-{
- VALUE_PAIR *vp;
-
- request = request; /* -Wunused */
-
- vp = pairmake(attribute, value, T_OP_SET);
- if (!vp) {
- radlog(L_ERR, "No memory!");
- rad_assert("No memory" == NULL);
- _exit(1);
- }
-
- pairadd(vps, vp);
-
- return vp;
-}
-
#ifdef WITH_SNMP
static void snmp_inc_counters(REQUEST *request)
{
*/
vp = pairfind(request->proxy->vps, PW_USER_NAME);
if (!vp) {
- vp = paircreate(PW_USER_NAME, PW_TYPE_STRING);
- if (!vp) {
- radlog(L_ERR|L_CONS, "no memory");
- exit(1);
- }
+ vp = radius_paircreate(request, NULL,
+ PW_USER_NAME, PW_TYPE_STRING);
+ rad_assert(vp != NULL); /* handled by above function */
/* Insert at the START of the list */
vp->next = request->proxy->vps;
request->proxy->vps = vp;
* Post-Auth-Type = Reject
*/
if (request->reply->code == PW_AUTHENTICATION_REJECT) {
- vp = pairmake("Post-Auth-Type", "Reject", T_OP_SET);
- if (vp) {
- pairdelete(&request->config_items, PW_POST_AUTH_TYPE);
- pairadd(&request->config_items, vp);
- rad_postauth(request);
- } /* else no Reject section defined */
+ pairdelete(&request->config_items, PW_POST_AUTH_TYPE);
+ vp = radius_pairmake(request, &request->config_items,
+ "Post-Auth-Type", "Reject",
+ T_OP_SET);
+ if (vp) rad_postauth(request);
/*
* If configured, delay Access-Reject packets.
request = NULL;
break;
}
-
-
}
/*
_exit(1);
}
- pairadd(vps, vp);
+ if (vps) pairadd(vps, vp);
return vp;
}
+
+/*
+ * Create a pair, and add it to a particular list of VPs
+ *
+ * Note that this function ALWAYS returns. If we're OOM, then
+ * it causes the server to exit!
+ */
+VALUE_PAIR *radius_pairmake(REQUEST *request, VALUE_PAIR **vps,
+ const char *attribute, const char *value,
+ int operator)
+{
+ VALUE_PAIR *vp;
+
+ request = request; /* -Wunused */
+
+ vp = pairmake(attribute, value, operator);
+ if (!vp) return NULL;
+
+ if (vps) pairadd(vps, vp);
+
+ return vp;
+}
+