mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-06-14 12:31:25 +00:00
Fix the Android build again
* exec/trace.c (ARRAYELTS, establish_seccomp_filter): Restore ARRAYELTS, since Gnulib is not available in the exec library.
This commit is contained in:
parent
6728239f32
commit
330b4e2a94
1 changed files with 10 additions and 8 deletions
18
exec/trace.c
18
exec/trace.c
|
|
@ -28,7 +28,6 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
|
|||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <signal.h>
|
||||
#include <stdcountof.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
|
|
@ -1539,6 +1538,9 @@ static int interesting_syscalls[] =
|
|||
READLINKAT_SYSCALL,
|
||||
};
|
||||
|
||||
/* Number of elements in an array. */
|
||||
#define ARRAYELTS(arr) (sizeof (arr) / sizeof (arr)[0])
|
||||
|
||||
/* Install a secure computing filter that will notify attached tracers
|
||||
when a system call of interest to this module is received. Value is
|
||||
0 if successful, 1 otherwise. */
|
||||
|
|
@ -1546,7 +1548,7 @@ static int interesting_syscalls[] =
|
|||
static int
|
||||
establish_seccomp_filter (void)
|
||||
{
|
||||
struct sock_filter statements[1 + countof (interesting_syscalls) + 2];
|
||||
struct sock_filter statements[1 + ARRAYELTS (interesting_syscalls) + 2];
|
||||
struct sock_fprog program;
|
||||
int index, rc;
|
||||
|
||||
|
|
@ -1565,27 +1567,27 @@ establish_seccomp_filter (void)
|
|||
statements[index]
|
||||
= ((struct sock_filter)
|
||||
BPF_JUMP (BPF_JMP + BPF_JEQ + BPF_K, EXEC_SYSCALL,
|
||||
countof (interesting_syscalls), 0)); index++;
|
||||
ARRAYELTS (interesting_syscalls), 0)); index++;
|
||||
#ifdef OPEN_SYSCALL
|
||||
statements[index]
|
||||
= ((struct sock_filter)
|
||||
BPF_JUMP (BPF_JMP + BPF_JEQ + BPF_K, OPEN_SYSCALL,
|
||||
countof (interesting_syscalls) - index + 1, 0)); index++;
|
||||
ARRAYELTS (interesting_syscalls) - index + 1, 0)); index++;
|
||||
#endif /* OPEN_SYSCALL */
|
||||
statements[index]
|
||||
= ((struct sock_filter)
|
||||
BPF_JUMP (BPF_JMP + BPF_JEQ + BPF_K, OPENAT_SYSCALL,
|
||||
countof (interesting_syscalls) - index + 1, 0)); index++;
|
||||
ARRAYELTS (interesting_syscalls) - index + 1, 0)); index++;
|
||||
#ifdef READLINK_SYSCALL
|
||||
statements[index]
|
||||
= ((struct sock_filter)
|
||||
BPF_JUMP (BPF_JMP + BPF_JEQ + BPF_K, READLINK_SYSCALL,
|
||||
countof (interesting_syscalls) - index + 1, 0)); index++;
|
||||
ARRAYELTS (interesting_syscalls) - index + 1, 0)); index++;
|
||||
#endif /* READLINK_SYSCALL */
|
||||
statements[index]
|
||||
= ((struct sock_filter)
|
||||
BPF_JUMP (BPF_JMP + BPF_JEQ + BPF_K, READLINKAT_SYSCALL,
|
||||
countof (interesting_syscalls) - index + 1, 0)); index++;
|
||||
ARRAYELTS (interesting_syscalls) - index + 1, 0)); index++;
|
||||
|
||||
/* If not intercepted above, permit this system call to execute as
|
||||
normal. */
|
||||
|
|
@ -1598,7 +1600,7 @@ establish_seccomp_filter (void)
|
|||
if (rc)
|
||||
return 1;
|
||||
|
||||
program.len = countof (statements);
|
||||
program.len = ARRAYELTS (statements);
|
||||
program.filter = statements;
|
||||
rc = prctl (PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &program);
|
||||
if (rc)
|
||||
|
|
|
|||
Loading…
Reference in a new issue