From: Arran Cudbard-Bell Date: Thu, 27 Sep 2012 18:07:04 +0000 (+0100) Subject: debug: should output previous level instead of the level that was just set. X-Git-Tag: release_3_0_0_beta1~1678 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=41ca210e7c7991b9175c8d9f1aebe5db03fdda33;p=thirdparty%2Ffreeradius-server.git debug: should output previous level instead of the level that was just set. Don't set debug to 0 if no fmt string was passed, do nothing. --- diff --git a/src/main/xlat.c b/src/main/xlat.c index 47e12a14f0b..942d89157bd 100644 --- a/src/main/xlat.c +++ b/src/main/xlat.c @@ -71,7 +71,6 @@ static const char * const xlat_foreach_names[] = {"Foreach-Variable-0", #endif static int xlat_inst[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8 }; /* up to 8 for regex */ - /** * @brief Convert the value on a VALUE_PAIR to string */ @@ -661,7 +660,6 @@ static size_t xlat_regex(void *instance, REQUEST *request, } #endif /* HAVE_REGEX_H */ - /** * @brief Dynamically change the debugging level for the current request * @@ -672,9 +670,19 @@ static size_t xlat_debug(UNUSED void *instance, REQUEST *request, UNUSED RADIUS_ESCAPE_STRING func) { int level = 0; + + /* + * Expand to previous (or current) level + */ + snprintf(out, outlen, "%d", request->options & RAD_REQUEST_OPTION_DEBUG4); - if (*fmt) level = atoi(fmt); - + /* + * Assume we just want to get the current value and NOT set it to 0 + */ + if (!*fmt) + goto done; + + level = atoi(fmt); if (level == 0) { request->options = RAD_REQUEST_OPTION_NONE; request->radlog = NULL; @@ -684,8 +692,8 @@ static size_t xlat_debug(UNUSED void *instance, REQUEST *request, request->options = level; request->radlog = radlog_request; } - - snprintf(out, outlen, "%d", level); + + done: return strlen(out); }