aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPhilipp Stephani2021-04-11 12:00:35 +0200
committerPhilipp Stephani2021-04-11 12:01:53 +0200
commit25937821bc445235d984c4db8cb18dfbacd6a4ff (patch)
treed8e6959d62941ec1fd83162f8c17bc7ca1eb91ab /src
parent3cf9e2a6e33599bb12a949a3b5bd1847f39ab948 (diff)
downloademacs-25937821bc445235d984c4db8cb18dfbacd6a4ff.tar.gz
emacs-25937821bc445235d984c4db8cb18dfbacd6a4ff.zip
Also check for needed seccomp macros.
It looks like these are not available on some versions of GNU/Linux, breaking the build. * configure.ac: Also check for needed seccomp macros. * src/emacs.c (SECCOMP_USABLE): New macro. (usage_message, main, standard_args): Use it.
Diffstat (limited to 'src')
-rw-r--r--src/emacs.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/emacs.c b/src/emacs.c
index 9d7b21cc76a..bd01d7bb461 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -61,7 +61,15 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
61# include <sys/socket.h> 61# include <sys/socket.h>
62#endif 62#endif
63 63
64#ifdef HAVE_LINUX_SECCOMP_H 64#if defined HAVE_LINUX_SECCOMP_H \
65 && HAVE_DECL_SECCOMP_SET_MODE_FILTER \
66 && HAVE_DECL_SECCOMP_FILTER_FLAG_TSYNC
67# define SECCOMP_USABLE 1
68#else
69# define SECCOMP_USABLE 0
70#endif
71
72#if SECCOMP_USABLE
65# include <linux/seccomp.h> 73# include <linux/seccomp.h>
66# include <linux/filter.h> 74# include <linux/filter.h>
67# include <sys/prctl.h> 75# include <sys/prctl.h>
@@ -248,7 +256,7 @@ Initialization options:\n\
248--dump-file FILE read dumped state from FILE\n\ 256--dump-file FILE read dumped state from FILE\n\
249", 257",
250#endif 258#endif
251#ifdef HAVE_LINUX_SECCOMP_H 259#if SECCOMP_USABLE
252 "\ 260 "\
253--sandbox=FILE read Seccomp BPF filter from FILE\n\ 261--sandbox=FILE read Seccomp BPF filter from FILE\n\
254" 262"
@@ -950,7 +958,7 @@ load_pdump (int argc, char **argv)
950} 958}
951#endif /* HAVE_PDUMPER */ 959#endif /* HAVE_PDUMPER */
952 960
953#ifdef HAVE_LINUX_SECCOMP_H 961#if SECCOMP_USABLE
954 962
955/* Wrapper function for the `seccomp' system call on GNU/Linux. This 963/* Wrapper function for the `seccomp' system call on GNU/Linux. This
956 system call usually doesn't have a wrapper function. See the 964 system call usually doesn't have a wrapper function. See the
@@ -1123,7 +1131,7 @@ maybe_load_seccomp (int argc, char **argv)
1123 fatal ("cannot enable seccomp filter from %s", file); 1131 fatal ("cannot enable seccomp filter from %s", file);
1124} 1132}
1125 1133
1126#endif /* HAVE_LINUX_SECCOMP_H */ 1134#endif /* SECCOMP_USABLE */
1127 1135
1128int 1136int
1129main (int argc, char **argv) 1137main (int argc, char **argv)
@@ -1135,7 +1143,7 @@ main (int argc, char **argv)
1135 /* First, check whether we should apply a seccomp filter. This 1143 /* First, check whether we should apply a seccomp filter. This
1136 should come at the very beginning to allow the filter to protect 1144 should come at the very beginning to allow the filter to protect
1137 the initialization phase. */ 1145 the initialization phase. */
1138#ifdef HAVE_LINUX_SECCOMP_H 1146#if SECCOMP_USABLE
1139 maybe_load_seccomp (argc, argv); 1147 maybe_load_seccomp (argc, argv);
1140#endif 1148#endif
1141 1149
@@ -2333,7 +2341,7 @@ static const struct standard_args standard_args[] =
2333#ifdef HAVE_PDUMPER 2341#ifdef HAVE_PDUMPER
2334 { "-dump-file", "--dump-file", 1, 1 }, 2342 { "-dump-file", "--dump-file", 1, 1 },
2335#endif 2343#endif
2336#ifdef HAVE_LINUX_SECCOMP_H 2344#if SECCOMP_USABLE
2337 { "-seccomp", "--seccomp", 1, 1 }, 2345 { "-seccomp", "--seccomp", 1, 1 },
2338#endif 2346#endif
2339#ifdef HAVE_NS 2347#ifdef HAVE_NS