Merge "Skip newlines for SELinux logs" am: c3a119caa3 am: f449ee1f89
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2521555 Change-Id: Ide0abf5137d0b396d047b58d32c385a1afca6f6a Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
e93f7196be
1 changed files with 11 additions and 10 deletions
|
|
@ -761,15 +761,7 @@ void SelinuxSetEnforcement() {
|
|||
|
||||
constexpr size_t kKlogMessageSize = 1024;
|
||||
|
||||
void SelinuxAvcLog(char* buf, size_t buf_len) {
|
||||
CHECK_GT(buf_len, 0u);
|
||||
|
||||
size_t str_len = strnlen(buf, buf_len);
|
||||
// trim newline at end of string
|
||||
if (buf[str_len - 1] == '\n') {
|
||||
buf[str_len - 1] = '\0';
|
||||
}
|
||||
|
||||
void SelinuxAvcLog(char* buf) {
|
||||
struct NetlinkMessage {
|
||||
nlmsghdr hdr;
|
||||
char buf[kKlogMessageSize];
|
||||
|
|
@ -835,8 +827,17 @@ int SelinuxKlogCallback(int type, const char* fmt, ...) {
|
|||
if (length_written <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 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.
|
||||
size_t str_len = strlen(buf);
|
||||
if (buf[str_len - 1] == '\n') {
|
||||
buf[str_len - 1] = '\0';
|
||||
}
|
||||
|
||||
if (type == SELINUX_AVC) {
|
||||
SelinuxAvcLog(buf, sizeof(buf));
|
||||
SelinuxAvcLog(buf);
|
||||
} else {
|
||||
android::base::KernelLogger(android::base::MAIN, severity, "selinux", nullptr, 0, buf);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue