Skip newlines for SELinux logs am: 366f01fd64
am: 273398f7b8
am: 829be6bea0
am: 0db1ceb25e
am: 40bb36cc64
Original change: https://android-review.googlesource.com/c/platform/external/selinux/+/2519660 Change-Id: Ib820bf164f107aa9a8fc7f0caabdd7f2178ee763 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
57e9ee5343
1 changed files with 45 additions and 47 deletions
|
@ -176,57 +176,55 @@ struct selabel_handle* selinux_android_keystore2_key_context_handle(void)
|
|||
return context_handle(SELABEL_CTX_ANDROID_KEYSTORE2_KEY, &keystore2_context_paths, "keystore2");
|
||||
}
|
||||
|
||||
static void __selinux_log_callback(bool add_to_event_log, int type, const char *fmt, va_list ap) {
|
||||
int priority;
|
||||
char *strp;
|
||||
|
||||
switch(type) {
|
||||
case SELINUX_WARNING:
|
||||
priority = ANDROID_LOG_WARN;
|
||||
break;
|
||||
case SELINUX_INFO:
|
||||
priority = ANDROID_LOG_INFO;
|
||||
break;
|
||||
default:
|
||||
priority = ANDROID_LOG_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
int len = vasprintf(&strp, fmt, ap);
|
||||
if (len < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* libselinux log messages usually contain a new line character, while
|
||||
* Android LOG() does not expect it. Remove it to avoid empty lines in
|
||||
* the log buffers.
|
||||
*/
|
||||
if (len > 0 && strp[len - 1] == '\n') {
|
||||
strp[len - 1] = '\0';
|
||||
}
|
||||
LOG_PRI(priority, "SELinux", "%s", strp);
|
||||
if (add_to_event_log) {
|
||||
LOG_EVENT_STRING(AUDITD_LOG_TAG, strp);
|
||||
}
|
||||
free(strp);
|
||||
}
|
||||
|
||||
int selinux_log_callback(int type, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int priority;
|
||||
char *strp;
|
||||
|
||||
switch(type) {
|
||||
case SELINUX_WARNING:
|
||||
priority = ANDROID_LOG_WARN;
|
||||
break;
|
||||
case SELINUX_INFO:
|
||||
priority = ANDROID_LOG_INFO;
|
||||
break;
|
||||
default:
|
||||
priority = ANDROID_LOG_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
va_start(ap, fmt);
|
||||
if (vasprintf(&strp, fmt, ap) != -1) {
|
||||
LOG_PRI(priority, "SELinux", "%s", strp);
|
||||
LOG_EVENT_STRING(AUDITD_LOG_TAG, strp);
|
||||
free(strp);
|
||||
}
|
||||
va_end(ap);
|
||||
return 0;
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
__selinux_log_callback(true, type, fmt, ap);
|
||||
va_end(ap);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int selinux_vendor_log_callback(int type, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int priority;
|
||||
char *strp;
|
||||
|
||||
switch(type) {
|
||||
case SELINUX_WARNING:
|
||||
priority = ANDROID_LOG_WARN;
|
||||
break;
|
||||
case SELINUX_INFO:
|
||||
priority = ANDROID_LOG_INFO;
|
||||
break;
|
||||
default:
|
||||
priority = ANDROID_LOG_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
va_start(ap, fmt);
|
||||
if (vasprintf(&strp, fmt, ap) != -1) {
|
||||
LOG_PRI(priority, "SELinux", "%s", strp);
|
||||
free(strp);
|
||||
}
|
||||
va_end(ap);
|
||||
return 0;
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
__selinux_log_callback(false, type, fmt, ap);
|
||||
va_end(ap);
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue