---
name: "audit_add_rule_data"
section: "3"
platform: "linux"
package: "audit"
version: "4.2.1-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/audit_add_rule_data"
---

# audit\_add\_rule\_data(3)

Add new audit rule

## NAME

audit\_add\_rule\_data - Add new audit rule

## SYNOPSIS

```
#include <libaudit.h>
```

**int audit\_add\_rule\_data(int** *fd***, struct audit\_rule\_data \****rule***, int** *flags***, int** *action***);"**

## DESCRIPTION

audit\_add\_rule\_data adds an audit rule previously constructed with audit\_rule\_fieldpair\_data(3) to one of several kernel event filters. The filter is specified by the *fd* file descriptor and the *flags* argument. Possible values for *flags* are:

- •

  AUDIT\_FILTER\_USER - Apply rule to userspace generated messages. This is the user filter. Normally all user space originating events are accepted. Rules on this filter are typically written to block specific events.

- •

  AUDIT\_FILTER\_TASK - Apply 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 rule at syscall exit. This is the main filter that is used for syscalls and filesystem watches. Normally all syscall do not trigger events, so this is normally used to specify events that are of interest.

- •

  AUDIT\_FILTER\_EXCLUDE - Apply rule at audit\_log\_start. This is the exclude filter which discards any records that match.  The action type is ignored for this filter, defaulting to "never".

- •

  AUDIT\_FILTER\_FS - Apply rule when adding PATH auxiliary records to SYSCALL events. This is the filesystem filter. This is used to ignore PATH records that are not of interest.

The rule's action has two possible values:

- •

  AUDIT\_NEVER - Do not build context if rule matches.

- •

  AUDIT\_ALWAYS - Generate audit record if rule matches.

## RETURN VALUE

The return value is \<= 0 on error, otherwise it is the netlink sequence id number. This function can have any error that sendto would encounter.

## SEE ALSO

**audit\_rule\_fieldpair\_data**(3), [**audit\_delete\_rule\_data**(3)](/audit_delete_rule_data/3.md), [**auditctl**(8)](/auditctl/8.md).

## AUTHOR

Steve Grubb.
