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 <string.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <stdcountof.h>
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
@ -1539,6 +1538,9 @@ static int interesting_syscalls[] =
|
||||||
READLINKAT_SYSCALL,
|
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
|
/* Install a secure computing filter that will notify attached tracers
|
||||||
when a system call of interest to this module is received. Value is
|
when a system call of interest to this module is received. Value is
|
||||||
0 if successful, 1 otherwise. */
|
0 if successful, 1 otherwise. */
|
||||||
|
|
@ -1546,7 +1548,7 @@ static int interesting_syscalls[] =
|
||||||
static int
|
static int
|
||||||
establish_seccomp_filter (void)
|
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;
|
struct sock_fprog program;
|
||||||
int index, rc;
|
int index, rc;
|
||||||
|
|
||||||
|
|
@ -1565,27 +1567,27 @@ establish_seccomp_filter (void)
|
||||||
statements[index]
|
statements[index]
|
||||||
= ((struct sock_filter)
|
= ((struct sock_filter)
|
||||||
BPF_JUMP (BPF_JMP + BPF_JEQ + BPF_K, EXEC_SYSCALL,
|
BPF_JUMP (BPF_JMP + BPF_JEQ + BPF_K, EXEC_SYSCALL,
|
||||||
countof (interesting_syscalls), 0)); index++;
|
ARRAYELTS (interesting_syscalls), 0)); index++;
|
||||||
#ifdef OPEN_SYSCALL
|
#ifdef OPEN_SYSCALL
|
||||||
statements[index]
|
statements[index]
|
||||||
= ((struct sock_filter)
|
= ((struct sock_filter)
|
||||||
BPF_JUMP (BPF_JMP + BPF_JEQ + BPF_K, OPEN_SYSCALL,
|
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 */
|
#endif /* OPEN_SYSCALL */
|
||||||
statements[index]
|
statements[index]
|
||||||
= ((struct sock_filter)
|
= ((struct sock_filter)
|
||||||
BPF_JUMP (BPF_JMP + BPF_JEQ + BPF_K, OPENAT_SYSCALL,
|
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
|
#ifdef READLINK_SYSCALL
|
||||||
statements[index]
|
statements[index]
|
||||||
= ((struct sock_filter)
|
= ((struct sock_filter)
|
||||||
BPF_JUMP (BPF_JMP + BPF_JEQ + BPF_K, READLINK_SYSCALL,
|
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 */
|
#endif /* READLINK_SYSCALL */
|
||||||
statements[index]
|
statements[index]
|
||||||
= ((struct sock_filter)
|
= ((struct sock_filter)
|
||||||
BPF_JUMP (BPF_JMP + BPF_JEQ + BPF_K, READLINKAT_SYSCALL,
|
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
|
/* If not intercepted above, permit this system call to execute as
|
||||||
normal. */
|
normal. */
|
||||||
|
|
@ -1598,7 +1600,7 @@ establish_seccomp_filter (void)
|
||||||
if (rc)
|
if (rc)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
program.len = countof (statements);
|
program.len = ARRAYELTS (statements);
|
||||||
program.filter = statements;
|
program.filter = statements;
|
||||||
rc = prctl (PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &program);
|
rc = prctl (PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &program);
|
||||||
if (rc)
|
if (rc)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue