void-packages/srcpkgs/audit/patches/musl.patch

159 lines
4.4 KiB
Diff

Source: Hoshpak, based on earlier work by doughdemon
Upstream: No
Reason: musl compatibility
From 81e3ac4db3e779f38e92cb9d9329db4cd76a8954 Mon Sep 17 00:00:00 2001
From: Helmut Pozimski <helmut@pozimski.eu>
Date: Fri, 21 Sep 2018 20:22:47 +0200
Subject: [PATCH] conditionally switch to alternatives for strndupa and
rawmemchr for non-glibc libcs
---
auparse/auparse.c | 17 +++++++++++++----
auparse/interpret.c | 4 ++++
src/auditd.c | 7 ++++++-
src/ausearch-lol.c | 16 ++++++++++++----
4 files changed, 35 insertions(+), 9 deletions(-)
diff --git a/auparse/auparse.c b/auparse/auparse.c
index 69127b7..9e444f6 100644
--- auparse/auparse.c
+++ auparse/auparse.c
@@ -1126,10 +1126,19 @@ static int extract_timestamp(const char *b, au_event_t *e)
int rc = 1;
e->host = NULL;
- if (*b == 'n')
- tmp = strndupa(b, 340);
- else
- tmp = strndupa(b, 80);
+ #ifdef __GLIBC__
+ tmp = alloca(340);
+ if (*b == 'n')
+ tmp = strndupa(b, 340);
+ else
+ tmp = strndupa(b, 80);
+ #else
+ tmp = alloca(340);
+ if (*b == 'n')
+ tmp = strncpy(tmp, b, 340);
+ else
+ tmp = strncpy(tmp, b, 80);
+ #endif
ptr = audit_strsplit(tmp);
if (ptr) {
// Optionally grab the node - may or may not be included
diff --git a/auparse/interpret.c b/auparse/interpret.c
index 4783d86..d779fc7 100644
--- auparse/interpret.c
+++ auparse/interpret.c
@@ -864,7 +864,11 @@ static const char *print_proctitle(const char *val)
// Proctitle has arguments separated by NUL bytes
// We need to write over the NUL bytes with a space
// so that we can see the arguments
+ #ifdef __GLIBC__
while ((ptr = rawmemchr(ptr, '\0'))) {
+ #else
+ while (ptr < end) {
+ #endif
if (ptr >= end)
break;
*ptr = ' ';
diff --git a/src/auditd.c b/src/auditd.c
index 4939b5a..8ad08d8 100644
--- src/auditd.c
+++ src/auditd.c
@@ -224,7 +224,12 @@ static int extract_type(const char *str)
// ptr should be at 't'
ptr2 = strchr(ptr, ' ');
// get type=xxx in a buffer
- tptr = strndupa(ptr, ptr2 - ptr);
+ #ifdef __GLIBC__
+ tptr = strndupa(ptr, ptr2 - ptr);
+ #else
+ tptr = alloca(ptr2 - ptr);
+ tptr = strncpy(tptr, ptr, ptr2 - ptr);
+ #endif
// find =
str = strchr(tptr, '=');
if (str == NULL)
diff --git a/src/ausearch-lol.c b/src/ausearch-lol.c
index ec6f453..51e7696 100644
--- src/ausearch-lol.c
+++ src/ausearch-lol.c
@@ -160,10 +160,18 @@ static int extract_timestamp(const char *b, event *e)
char *ptr, *tmp, *tnode, *ttype;
e->node = NULL;
- if (*b == 'n')
- tmp = strndupa(b, 340);
- else
- tmp = strndupa(b, 80);
+ #ifdef __GLIBC__
+ if (*b == 'n')
+ tmp = strndupa(b, 340);
+ else
+ tmp = strndupa(b, 80);
+ #else
+ tmp = alloca(340);
+ if (*b == 'n')
+ tmp = strncpy(tmp, b, 340);
+ else
+ tmp = strncpy(tmp, b, 80);
+ #endif
ptr = audit_strsplit(tmp);
if (ptr) {
// Check to see if this is the node info
--
2.19.0
From ca1590b95b3f786ca11f165656c31e525359e19c Mon Sep 17 00:00:00 2001
From: Helmut Pozimski <helmut@pozimski.eu>
Date: Fri, 21 Sep 2018 20:44:18 +0200
Subject: [PATCH 2/2] replace usage of pthread_yield with sched_yield
---
audisp/plugins/zos-remote/zos-remote-queue.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/audisp/plugins/zos-remote/zos-remote-queue.c b/audisp/plugins/zos-remote/zos-remote-queue.c
index 8071dca..d5e30dd 100644
--- audisp/plugins/zos-remote/zos-remote-queue.c
+++ audisp/plugins/zos-remote/zos-remote-queue.c
@@ -77,7 +77,7 @@ retry:
pthread_mutex_unlock(&queue_lock);
} else {
pthread_mutex_unlock(&queue_lock);
- pthread_yield(); /* Let dequeue thread run to clear queue */
+ sched_yield(); /* Let dequeue thread run to clear queue */
retry_cnt++;
goto retry;
}
--
2.19.0
From 5c52c6c662f0a3ab3b2f7a45024ef7aee9a6999d Mon Sep 17 00:00:00 2001
From: Helmut Pozimski <helmut@pozimski.eu>
Date: Fri, 21 Sep 2018 21:24:56 +0200
Subject: [PATCH 3/3] change stdint include to import in auditswig.i to
accomodate compilation on musl
---
bindings/swig/src/auditswig.i | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/bindings/swig/src/auditswig.i b/bindings/swig/src/auditswig.i
index 356a5ab..8ad09da 100644
--- bindings/swig/src/auditswig.i
+++ bindings/swig/src/auditswig.i
@@ -41,6 +41,6 @@ typedef unsigned __u32;
typedef unsigned uid_t;
%include "/usr/include/linux/audit.h"
#define __extension__ /*nothing*/
-%include "/usr/include/stdint.h"
+%import "/usr/include/stdint.h"
%include "../lib/libaudit.h"
--
2.19.0