Skip to content

Commit

Permalink
Change logging in radius_exec_program to use R* macros
Browse files Browse the repository at this point in the history
RERROR should always be used where an error may indicate a failure of an external resource like a script, or database and we have the REQUEST available.

It outputs to the main server log like ERROR but also includes the request number, so multiple errors can be tied together when inspecting the log.
  • Loading branch information
arr2036 committed Oct 2, 2014
1 parent cbe39df commit 6fe7087
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/main/exec.c
Expand Up @@ -522,7 +522,7 @@ int radius_exec_program(REQUEST *request, char const *cmd, bool exec_wait, bool
char answer[4096];
#endif

DEBUG2("Executing: %s:", cmd);
RDEBUG2("Executing: %s:", cmd);

if (user_msg) *user_msg = '\0';

Expand All @@ -542,7 +542,7 @@ int radius_exec_program(REQUEST *request, char const *cmd, bool exec_wait, bool
* Failure - radius_readfrom_program will
* have called close(from_child) for us
*/
DEBUG("Failed to read from child output");
RERROR("Failed to read from child output");
return -1;

}
Expand Down Expand Up @@ -587,7 +587,7 @@ int radius_exec_program(REQUEST *request, char const *cmd, bool exec_wait, bool
}

if (userparse(request, answer, output_pairs) == T_INVALID) {
ERROR("Failed parsing output from: %s: %s", cmd, fr_strerror());
RERROR("Failed parsing output from: %s: %s", cmd, fr_strerror());
strlcpy(user_msg, answer, len);
ret = -1;
}
Expand All @@ -608,7 +608,7 @@ int radius_exec_program(REQUEST *request, char const *cmd, bool exec_wait, bool
wait:
child_pid = rad_waitpid(pid, &status);
if (child_pid == 0) {
ERROR("Timeout waiting for child");
RERROR("Timeout waiting for child");

return -2;
}
Expand All @@ -617,16 +617,16 @@ int radius_exec_program(REQUEST *request, char const *cmd, bool exec_wait, bool
if (WIFEXITED(status)) {
status = WEXITSTATUS(status);
if ((status != 0) || (ret < 0)) {
ERROR("Program returned code (%d) and output '%s'", status, answer);
RERROR("Program returned code (%d) and output '%s'", status, answer);
} else {
DEBUG2("Program returned code (%d) and output '%s'", status, answer);
RDEBUG2("Program returned code (%d) and output '%s'", status, answer);
}

return ret < 0 ? ret : status;
}
}

ERROR("Abnormal child exit: %s", fr_syserror(errno));
RERROR("Abnormal child exit: %s", fr_syserror(errno));
#endif /* __MINGW32__ */

return -1;
Expand Down

0 comments on commit 6fe7087

Please sign in to comment.