]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
radius_exec_program_legacy() doesn't ever get passed output_pairs
authorAlan T. DeKok <aland@freeradius.org>
Sun, 29 Oct 2023 13:01:14 +0000 (09:01 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Sun, 29 Oct 2023 13:01:29 +0000 (09:01 -0400)
so remove unused code and arguments.

src/lib/server/exec_legacy.c
src/lib/server/exec_legacy.h
src/lib/server/map.c
src/lib/server/tmpl_eval.c
src/modules/rlm_mschap/rlm_mschap.c

index 075c9eac65d348375f2a649eb7af48cdad9d17ce..69530c633365589cd81410a2620d79a1e8dd7271 100644 (file)
@@ -456,11 +456,8 @@ int radius_readfrom_program_legacy(int fd, pid_t pid, fr_time_delta_t timeout, c
 
 /** 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.
@@ -474,15 +471,13 @@ int radius_readfrom_program_legacy(int fd, pid_t pid, fr_time_delta_t timeout, c
  *     - 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];
@@ -522,51 +517,7 @@ int radius_exec_program_legacy(TALLOC_CTX *ctx, char *out, size_t outlen, fr_pai
                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
index 28840929194ea782bb2a965e8390d4a72c60c576..7251d4856716364fc6717eae1d18015fac0056e0 100644 (file)
@@ -41,9 +41,9 @@ pid_t radius_start_program_legacy(int *stdin_fd, int *stdout_fd, int *stderr_fd,
 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
 }
index 8ff0c79a3c68a5bf9a5093eb606ed81d8cc4fdc0..893dd242daf3f8b34771086360367722a7c3c395 100644 (file)
@@ -1433,7 +1433,7 @@ static int map_exec_to_vp(TALLOC_CTX *ctx, fr_pair_list_t *out, request_t *reque
         *      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);
index d930082fcd9de7805cf3f3001821f400e21a0d4f..8fc66a016427fa5c0cd6203614ade74818172be5 100644 (file)
@@ -314,7 +314,7 @@ ssize_t _tmpl_to_type(void *out,
                        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;
@@ -592,7 +592,7 @@ ssize_t _tmpl_to_atype(TALLOC_CTX *ctx, void *out,
                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);
index f0e8576c613ee4dafe7a78037832eb2eb4398c72..739408daf5790fc60bcbd3e2d4cf6e064ee2ea9c 100644 (file)
@@ -1251,7 +1251,7 @@ static int CC_HINT(nonnull (1, 2, 4, 5, 6)) do_mschap(rlm_mschap_t const *inst,
                /*
                 *      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;