[Asterisk-code-review] core/logging: Fix broken syslog levels on older glibc. (asterisk[13])

Walter Doekes asteriskteam at digium.com
Thu Mar 24 05:46:24 CDT 2016


Walter Doekes has uploaded a new change for review.

  https://gerrit.asterisk.org/2452

Change subject: core/logging: Fix broken syslog levels on older glibc.
......................................................................

core/logging: Fix broken syslog levels on older glibc.

The fix to ASTERISK-25407 introduced the usage of LOG_MAKEPRI. However
this function is broken in older glibc (< 2.17); it would left-shift the
facility a second time, causing the resultant priority to become
invalid.

The syslog manpage mentions nothing about LOG_MAKEPRI and suggests this:

    The priority argument is formed by ORing the facility and the level
    values [...].

Reported-by: Michael Newton
(closes issue ASTERISK-25510)

Change-Id: Ia89debe7fac5ad090c7ef595c0707f31bb1e3d03
---
M main/logger.c
1 file changed, 2 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/52/2452/1

diff --git a/main/logger.c b/main/logger.c
index 46d9cbb..9db33c9 100644
--- a/main/logger.c
+++ b/main/logger.c
@@ -1322,7 +1322,8 @@
 		return;
 	}
 
-	syslog_level = LOG_MAKEPRI(facility, syslog_level);
+	/* Don't use LOG_MAKEPRI because it's broken in glibc<2.17 */
+	syslog_level = facility | syslog_level; /* LOG_MAKEPRI(facility, syslog_level); */
 
 	snprintf(buf, sizeof(buf), "%s[%d]%s: %s:%d in %s: %s",
 		 levels[msg->level], msg->lwp, call_identifier_str, msg->file, msg->line, msg->function, msg->message);

-- 
To view, visit https://gerrit.asterisk.org/2452
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia89debe7fac5ad090c7ef595c0707f31bb1e3d03
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Owner: Walter Doekes <walter+asterisk at wjd.nu>



More information about the asterisk-code-review mailing list