Commit graph

14 commits

Author SHA1 Message Date
John Johansen
2e18cb9aed parser: rename rules.h perms_t to perm32_t
There are two distinct declarations of perms_t.
  rule.h: typedef uint32_t perms_t
  hfa.h: class perms_t

these definitions clash when the front end and backend share more info.
To avoid this rename rule.h to perm32_t, and move the definition into
perms.h and use it in struct aa_perms.

Signed-off-by: John Johansen <john.johansen@canonical.com>
2024-08-14 14:39:18 -07:00
Georgia Garcia
8da46c5e77 parser: fix getattr and setattr perm mapping on mqueue rules
Signed-off-by: Georgia Garcia <georgia.garcia@canonical.com>
2024-03-27 18:33:23 -03:00
John Johansen
5e8567c9e9 parser: rework perms rule merging
Instead of pushing the cmp logic for rule merging into each rule
class make it the default behavior for the perms_rule_t parent class.
Also save off the original perms for the merged rule.

For classes that don't want perms merging add an alternate
dedup_perms_rule_t clase.

Signed-off-by: John Johansen <john.johansen@canonical.com>
2023-07-10 20:04:53 -07:00
Georgia Garcia
cdb5e501d6 parser: add permission merging
By changing the compare function from each rule to use class_rule_t,
instead of perms_rule_t, we temporarily ignore if permissions are
different. If every rule attribute is the same, then the permissions
can be merged. This is done at the perms_rule_t's level.

Signed-off-by: Georgia Garcia <georgia.garcia@canonical.com>
2023-07-10 18:01:32 -03:00
John Johansen
ca976bf5cb parser: add rule merging for mqueue rules
Signed-off-by: John Johansen <john.johansen@canonical.com>
2023-07-07 17:41:10 -07:00
John Johansen
b3bb74c33c parser: convert valid_prefix and add_prefix to use const
The prefix can passed as a parameter can be const so it should be.

Signed-off-by: John Johansen <john.johansen@canonical.com>
2023-03-31 02:21:19 -07:00
John Johansen
10a75c431f parser: rename post_process() method and move code around
The post_process() method is misnamed, it fires when the profile is
finished parsing but fires before variable expansion. Rename it
to better reflect what it does and move the trigger code into
profile as a start of cleaning this stage up.

Also document the order the hooks fire in

Signed-off-by: John Johansen <john.johansen@canonical.com>
2023-03-31 02:17:28 -07:00
John Johansen
d371458533 parser: make base classes for rules using prefixes and perms and use them
Cleanup the parse code by making shared prefix and perms classes for
rules and convert rules to use them.

Signed-off-by: John Johansen <john.johansen@canonical.com>
2023-03-31 02:17:26 -07:00
John Johansen
fdf5b062a9 parser: fixup audit struct to audit enum
This removes the struct wrapper used in the previous patch to ensure
that all uses are properly converted.

Signed-off-by: John Johansen <john.johansen@canonical.com>
2023-03-31 02:12:35 -07:00
John Johansen
7a318d99f2 parser: convert audit from bool to enum
Audit control support is going to be extended to support allowing
policy to which rules should quiet auditing. Update the frontend
internals to prepare for this.

Signed-off-by: John Johansen <john.johansen@canonical.com>
2023-03-31 02:08:20 -07:00
John Johansen
134e95f783 parser: fixup remove struct from the audit bool conversion
This removes the struct wrapper used in the previous patch to ensure
that all uses are properly converted.

Signed-off-by: John Johansen <john.johansen@canonical.com>
2023-03-31 01:08:25 -07:00
John Johansen
44f3be091a parser: convert the stored audit from a bit mask to a bool
This delays the convertion of the audit flag until passing to the
backend. This is a step towards fix the parser front end so that it
doesn't use encoded permission mappings.

Note: the patch embedds the bool conversion into a struct to ensure
the compiler will fail to build unless every use is fixed. The
struct is removed in the following patch.

Signed-off-by: John Johansen <john.johansen@canonical.com>
2023-03-31 01:05:29 -07:00
John Johansen
fd9a6fe133 parser: int mode to perms
Move from using and int for permissions bit mask to a perms_t type.
Also move any perms mask that uses the name mode to perms to avoid
confusing it with other uses of mode.

Signed-off-by: John Johansen <john.johansen@canonical.com>
2023-03-29 10:45:44 -07:00
Georgia Garcia
d98c5c4cf9 parser: add parser support for message queue mediation
Message queue rules take the following format:

	mqueue [<access_mode>] [<type>] [<label>] [<mqueue name>],
	access_mode := 'r'|'w'|'rw'|'read'|'write'|
		       'create'|'open'|'delete'|
		       'getattr'|'setattr'
	type := 'type' '=' ('posix'|'sysv')
	label := 'label' '=' <target label>

Signed-off-by: Georgia Garcia <georgia.garcia@canonical.com>
Signed-off-by: John Johansen <john.johansen@canonical.com>
2022-11-22 19:31:15 +00:00