build.rs 1019 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // -*- coding: utf-8 -*-
  2. //
  3. // Copyright (C) 2024 Michael Büsch <m@bues.ch>
  4. //
  5. // Licensed under the Apache License version 2.0
  6. // or the MIT license, at your option.
  7. // SPDX-License-Identifier: Apache-2.0 OR MIT
  8. #![forbid(unsafe_code)]
  9. use build_target::target_arch;
  10. use letmein_seccomp::{Allow, Filter};
  11. use std::path::Path;
  12. const SECCOMP_ALLOW_LIST: [Allow; 12] = [
  13. Allow::Mmap,
  14. Allow::Mprotect,
  15. Allow::Read,
  16. Allow::Write,
  17. Allow::Fcntl {
  18. op: Some(libc::F_GETFD as _),
  19. },
  20. Allow::Recv,
  21. Allow::Send,
  22. Allow::Listen,
  23. Allow::TcpAccept,
  24. Allow::UnixConnect,
  25. Allow::Signal,
  26. Allow::Futex,
  27. ];
  28. fn main() {
  29. let arch = target_arch().expect("Failed to get build target architecture");
  30. let out_dir = std::env::var("OUT_DIR").expect("OUT_DIR is not set");
  31. // Precompile the seccomp filters.
  32. Filter::precompile(&SECCOMP_ALLOW_LIST, arch.as_str(), Path::new(&out_dir))
  33. .expect("Failed to precompile seccomp BPF");
  34. }
  35. // vim: ts=4 sw=4 expandtab