*/
typedef struct rlm_exec_t {
char *xlat_name;
+ int bare;
int wait;
char *program;
char *input;
return &request->reply->vps;
}
+#ifdef WITH_PROXY
if (strcmp(string, "proxy-request") == 0) {
if (!request->proxy) return NULL;
return &request->proxy_reply->vps;
}
+#endif
if (strcmp(string, "config") == 0) {
return &request->config_items;
}
xlat_name = cf_section_name2(conf);
- if (xlat_name == NULL)
+ if (xlat_name == NULL) {
xlat_name = cf_section_name1(conf);
+ inst->bare = 1;
+ }
if (xlat_name){
inst->xlat_name = strdup(xlat_name);
xlat_register(xlat_name, exec_xlat, inst);
*/
if (!((inst->packet_code == 0) ||
(request->packet->code == inst->packet_code) ||
- (request->reply->code == inst->packet_code) ||
- (request->proxy &&
+ (request->reply->code == inst->packet_code)
+#ifdef WITH_PROXY
+ || (request->proxy &&
(request->proxy->code == inst->packet_code)) ||
(request->proxy_reply &&
- (request->proxy_reply->code == inst->packet_code)))) {
+ (request->proxy_reply->code == inst->packet_code))
+#endif
+ )) {
RDEBUG2("Packet type is not %s. Not executing.",
inst->packet_type);
return RLM_MODULE_NOOP;
} else if ((vp = pairfind(request->reply->vps, PW_EXEC_PROGRAM_WAIT, 0)) != NULL) {
exec_wait = 1;
}
- if (!vp) goto dispatch;
+ if (!vp) {
+ if (!inst->program) return RLM_MODULE_NOOP;
+
+ return exec_dispatch(instance, request);
+ }
tmp = NULL;
result = radius_exec_program(vp->vp_strvalue, request, exec_wait,
return RLM_MODULE_REJECT;
}
- dispatch:
- if (!inst->program) return RLM_MODULE_NOOP;
+ return RLM_MODULE_OK;
+}
+
+/*
+ * First, look for Exec-Program && Exec-Program-Wait.
+ *
+ * Then, call exec_dispatch.
+ */
+static int exec_accounting(void *instance, REQUEST *request)
+{
+ int result;
+ int exec_wait = 0;
+ VALUE_PAIR *vp;
+ rlm_exec_t *inst = (rlm_exec_t *) instance;
+
+ /*
+ * The "bare" exec module takes care of handling
+ * Exec-Program and Exec-Program-Wait.
+ */
+ if (!inst->bare) return exec_dispatch(instance, request);
+
+ vp = pairfind(request->reply->vps, PW_EXEC_PROGRAM, 0);
+ if (vp) {
+ exec_wait = 0;
+
+ } else if ((vp = pairfind(request->reply->vps, PW_EXEC_PROGRAM_WAIT, 0)) != NULL) {
+ exec_wait = 1;
+ }
+ if (!vp) return RLM_MODULE_NOOP;
+
+ result = radius_exec_program(vp->vp_strvalue, request, exec_wait,
+ NULL, 0, request->packet->vps, NULL,
+ inst->shell_escape);
+ if (result != 0) {
+ return RLM_MODULE_REJECT;
+ }
- return exec_dispatch(instance, request);
+ return RLM_MODULE_OK;
}
/*
exec_dispatch, /* authentication */
exec_dispatch, /* authorization */
exec_dispatch, /* pre-accounting */
- exec_dispatch, /* accounting */
+ exec_accounting, /* accounting */
NULL, /* check simul */
exec_dispatch, /* pre-proxy */
exec_dispatch, /* post-proxy */
exec_postauth /* post-auth */
+#ifdef WITH_COA
+ , exec_dispatch,
+ exec_dispatch
+#endif
},
};