AUDIT_ADD_RULE_DATA(3)

πŸ“¦
version 4.2.1 Β· 2 versions
, in alpine 3.23, alpine 3.24, arch rolling, centos-stream 10, fedora 43, fedora 44, nixpkgs unstable, ubuntu resolute, ubuntu stonking

πŸ’– AUDIT_ADD_RULE_DATA πŸ’–

okay bestie, so this one lives in the Linux Audit API section of the manual (section 3, the library-calls girlies 🫢), and it's literally the moment your handcrafted audit rule finally gets yeeted into the kernel. let's get into it.


✨ NAME ✨

audit_add_rule_data β€” add a brand new audit rule. that's it. that's the vibe. πŸ’…


🌸 SYNOPSIS 🌸

#include <libaudit.h>

int audit_add_rule_data(int fd, struct audit_rule_data *rule, int flags, int action);

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea: audit_add_rule_data takes an audit rule that you already built with audit_rule_fieldpair_data(3) and drops it into one of the kernel's several event filters. which filter tho?? that's decided by the fd file descriptor and the flags argument. periodt.

the possible values for flags are giving very much menu-of-destiny:

  • AUDIT_FILTER_USER β€” apply the rule to userspace generated messages. this is the user filter. normally all user space originating events are accepted, and rules on this filter are typically written to block specific events. 🚫
  • AUDIT_FILTER_TASK β€” apply the rule at task creation (not syscall). this is the task filter. it's normally used to exclude an application from being audited. πŸ™ˆ
  • AUDIT_FILTER_EXIT β€” apply the rule at syscall exit. this is the main filter, the one used for syscalls and filesystem watches. normally all syscalls do not trigger events, so this is normally used to specify the events that are actually of interest. main character filter fr fr πŸ‘‘
  • AUDIT_FILTER_EXCLUDE β€” apply the rule at audit_log_start. this is the exclude filter, which discards any records that match. the action type is ignored for this filter and defaults to "never". 😭
  • AUDIT_FILTER_FS β€” apply the rule when adding PATH auxiliary records to SYSCALL events. this is the filesystem filter, used to ignore PATH records that are not of interest. 🧚

and the rule's action? only two possible values, no more no less:

  • AUDIT_NEVER β€” do not build context if the rule matches. πŸ’€
  • AUDIT_ALWAYS β€” generate an audit record if the rule matches. πŸ”₯

⭐ RETURN VALUE ⭐

the return value is <= 0 on error. otherwise? it's the netlink sequence id number. and ngl this function can have any error that sendto would encounter β€” so whatever sendto is going through, she's going through too. πŸ’œ


🌈 SEE ALSO 🌈


πŸŽ€ AUTHOR πŸŽ€

Steve Grubb. ty for your service king 🫢


and that's a wrap bestie!! this page came to you courtesy of Red Hat, dated Aug 2009 β€” yes she's an elder but she's still iconic, no cap. βœ¨πŸ’–πŸ¦‹