From d00987d3a6926615ddf6e65f9e1ea9f28595691f Mon Sep 17 00:00:00 2001 From: David CARLIER Date: Fri, 14 Jan 2022 15:36:21 +0000 Subject: [PATCH] freebsd audit api introduction. --- libc-test/build.rs | 1 + libc-test/semver/freebsd.txt | 6 ++++++ src/unix/bsd/freebsdlike/freebsd/mod.rs | 20 ++++++++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index 4fd9e8b7f393e..ec063e9bf9ace 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -1802,6 +1802,7 @@ fn test_freebsd(target: &str) { headers! { cfg: "aio.h", "arpa/inet.h", + "bsm/audit.h", "ctype.h", "dirent.h", "dlfcn.h", diff --git a/libc-test/semver/freebsd.txt b/libc-test/semver/freebsd.txt index 4772415cda887..06878e857787c 100644 --- a/libc-test/semver/freebsd.txt +++ b/libc-test/semver/freebsd.txt @@ -1416,6 +1416,11 @@ arc4random_buf arc4random_uniform arphdr atof +au_asid_t +au_id_t +au_mask_t +au_tid_t +auditinfo_t backtrace backtrace_symbols backtrace_symbols_fd @@ -1754,6 +1759,7 @@ semop sendfile sendmmsg sendmsg +setaudit setdomainname setgrent setgroups diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index 251f236c58f14..a0074468c61ac 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -41,6 +41,9 @@ pub type caddr_t = *mut ::c_char; pub type fhandle_t = fhandle; +pub type au_id_t = ::uid_t; +pub type au_asid_t = ::pid_t; + // It's an alias over "struct __kvm_t". However, its fields aren't supposed to be used directly, // making the type definition system dependent. Better not bind it exactly. pub type kvm_t = ::c_void; @@ -967,6 +970,22 @@ s! { pub ifc_ifcu: __c_anonymous_ifc_ifcu, } + pub struct au_mask_t { + pub am_success: ::c_uint, + pub am_failure: ::c_uint, + } + + pub struct au_tid_t { + pub port: u32, + pub machine: u32, + } + + pub struct auditinfo_t { + pub ai_auid: ::au_id_t, + pub ai_mask: ::au_mask_t, + pub ai_termid: au_tid_t, + pub ai_asid: ::au_asid_t, + } } s_no_extra_traits! { @@ -4182,6 +4201,7 @@ extern "C" { flags: ::c_int, ) -> ::c_int; pub fn memfd_create(name: *const ::c_char, flags: ::c_uint) -> ::c_int; + pub fn setaudit(auditinfo: *const auditinfo_t) -> ::c_int; } #[link(name = "kvm")]