build.rs 955 B

123456789101112131415161718192021222324252627282930313233343536373839
  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; 11] = [
  13. Allow::Mmap,
  14. Allow::Mprotect,
  15. Allow::Read,
  16. Allow::Write,
  17. Allow::Recv,
  18. Allow::Send,
  19. Allow::Listen,
  20. Allow::TcpAccept,
  21. Allow::UnixConnect,
  22. Allow::Signal,
  23. Allow::Futex,
  24. ];
  25. fn main() {
  26. let arch = target_arch().expect("Failed to get build target architecture");
  27. let out_dir = std::env::var("OUT_DIR").expect("OUT_DIR is not set");
  28. // Precompile the seccomp filters.
  29. Filter::precompile(&SECCOMP_ALLOW_LIST, arch.as_str(), Path::new(&out_dir))
  30. .expect("Failed to precompile seccomp BPF");
  31. }
  32. // vim: ts=4 sw=4 expandtab