so remove unused code and arguments.
/** Execute a program.
*
- * @param[in,out] ctx to allocate new fr_pair_t (s) in.
* @param[out] out buffer to append plaintext (non valuepair) output.
* @param[in] outlen length of out buffer.
- * @param[out] output_pairs list of value pairs - Data on child's stdout will be parsed and
- * added into this list of value pairs.
* @param[in] request Current request (may be NULL).
* @param[in] cmd Command to execute. This is parsed into argv[] parts, then each individual argv
* part is xlat'ed.
* - exit code if exec_wait!=0.
* - -1 on failure.
*/
-int radius_exec_program_legacy(TALLOC_CTX *ctx, char *out, size_t outlen, fr_pair_list_t *output_pairs,
+int radius_exec_program_legacy(char *out, size_t outlen,
request_t *request, char const *cmd, fr_pair_list_t *input_pairs,
bool exec_wait, bool shell_escape, fr_time_delta_t timeout)
{
pid_t pid;
int stdout_pipe;
- char *p;
pid_t child_pid;
- int comma = 0;
int status, ret = 0;
ssize_t len;
char answer[4096];
goto wait;
}
- /*
- * Parse the output, if any.
- */
- if (output_pairs) {
- fr_pair_list_t vps;
-
- fr_pair_list_init(&vps);
- /*
- * HACK: Replace '\n' with ',' so that
- * fr_pair_list_afrom_str() can parse the buffer in
- * one go (the proper way would be to
- * fix fr_pair_list_afrom_str(), but oh well).
- */
- for (p = answer; *p; p++) {
- if (*p == '\n') {
- *p = comma ? ' ' : ',';
- p++;
- comma = 0;
- }
- if (*p == ',') {
- comma++;
- }
- }
-
- /*
- * Replace any trailing comma by a NUL.
- */
- if (answer[len - 1] == ',') {
- answer[--len] = '\0';
- }
-
- if (fr_pair_list_afrom_str(ctx, fr_dict_root(request->dict), answer, sizeof(answer), &vps) == T_INVALID) {
- RPERROR("Failed parsing output from: %s", cmd);
- if (out) strlcpy(out, answer, len);
- ret = -1;
- }
-
- /*
- * We want to mark the new attributes as tainted,
- * but not the existing ones.
- */
- fr_pair_list_tainted(&vps);
- fr_pair_list_append(output_pairs, &vps);
-
- } else if (out) {
+ if (out) {
/*
* We've not been told to extract output pairs,
* just copy the programs output to the out
int radius_readfrom_program_legacy(int fd, pid_t pid, fr_time_delta_t timeout,
char *answer, int left);
-int radius_exec_program_legacy(TALLOC_CTX *ctx, char *out, size_t outlen, fr_pair_list_t *output_pairs,
+int radius_exec_program_legacy(char *out, size_t outlen,
request_t *request, char const *cmd, fr_pair_list_t *input_pairs,
- bool exec_wait, bool shell_escape, fr_time_delta_t timeout) CC_HINT(nonnull (5, 6));
+ bool exec_wait, bool shell_escape, fr_time_delta_t timeout) CC_HINT(nonnull (3, 4));
#ifdef __cplusplus
}
* if dst is an attribute, then we create an attribute of that type and then
* call fr_pair_value_from_str on the output of the script.
*/
- result = radius_exec_program_legacy(ctx, answer, sizeof(answer), NULL,
+ result = radius_exec_program_legacy(answer, sizeof(answer),
request, map->rhs->name, input_pairs ? input_pairs : NULL,
true, true, fr_time_delta_from_sec(EXEC_TIMEOUT));
talloc_free(expanded);
return -1;
}
- if (radius_exec_program_legacy(request, (char *)buff, bufflen, NULL, request, vpt->name, NULL,
+ if (radius_exec_program_legacy((char *)buff, bufflen, request, vpt->name, NULL,
true, false, fr_time_delta_from_sec(EXEC_TIMEOUT)) != 0) return -1;
fr_value_box_strdup_shallow(&value_to_cast, NULL, (char *)buff, true);
src_type = FR_TYPE_STRING;
RDEBUG4("EXPAND TMPL EXEC");
MEM(fr_value_box_bstr_alloc(tmp_ctx, &buff, &value, NULL, 1024, true));
- if (radius_exec_program_legacy(request, buff, 1024, NULL, request, vpt->name, NULL,
+ if (radius_exec_program_legacy(buff, 1024, request, vpt->name, NULL,
true, false, fr_time_delta_from_sec(EXEC_TIMEOUT)) != 0) {
error:
talloc_free(tmp_ctx);
/*
* Run the program, and expect that we get 16
*/
- result = radius_exec_program_legacy(request, buffer, sizeof(buffer), NULL, request, inst->ntlm_auth, NULL,
+ result = radius_exec_program_legacy(buffer, sizeof(buffer), request, inst->ntlm_auth, NULL,
true, true, inst->ntlm_auth_timeout);
if (result != 0) {
char *p;