|
| 1 | +<def-group> |
| 2 | + <definition class="compliance" |
| 3 | + id="{{{ rule_id }}}" version="1"> |
| 4 | + {{{ oval_metadata("All interactive user home directories must reside on a separate partition from root.", rule_title=rule_title) }}} |
| 5 | + <criteria operator="OR"> |
| 6 | + <criterion test_ref="test_{{{ rule_id }}}" |
| 7 | + comment="All interactive user home directories are on a separate partition"/> |
| 8 | + <criterion test_ref="test_{{{ rule_id }}}_no_interactive_users" |
| 9 | + comment="No interactive users exist on the system"/> |
| 10 | + </criteria> |
| 11 | + </definition> |
| 12 | + |
| 13 | + <!-- ============================================================ --> |
| 14 | + <!-- Part 1: Collect all non-root mount points from the system --> |
| 15 | + <!-- ============================================================ --> |
| 16 | + <linux:partition_object id="object_{{{ rule_id }}}_non_root_partitions" version="1"> |
| 17 | + <linux:mount_point operation="not equal">/</linux:mount_point> |
| 18 | + </linux:partition_object> |
| 19 | + |
| 20 | + <!-- Build regex patterns from mount points: ^<mount_point>(/|$) |
| 21 | + The (/|$) suffix prevents substring false matches, e.g. |
| 22 | + mount point /home should not match home directory /home2/user --> |
| 23 | + <local_variable id="var_{{{ rule_id }}}_mount_regex" datatype="string" version="1" |
| 24 | + comment="Regex patterns to match home dirs on non-root partitions"> |
| 25 | + <concat> |
| 26 | + <literal_component>^</literal_component> |
| 27 | + <object_component item_field="mount_point" |
| 28 | + object_ref="object_{{{ rule_id }}}_non_root_partitions"/> |
| 29 | + <literal_component>(/|$)</literal_component> |
| 30 | + </concat> |
| 31 | + </local_variable> |
| 32 | + |
| 33 | + <!-- ============================================================ --> |
| 34 | + <!-- Part 2: Extract home directories of interactive users --> |
| 35 | + <!-- Interactive users: UID >= 1000, shell not nologin, --> |
| 36 | + <!-- username not nobody/nfsnobody --> |
| 37 | + <!-- ============================================================ --> |
| 38 | + <ind:textfilecontent54_object id="object_{{{ rule_id }}}_interactive_users" version="1"> |
| 39 | + <ind:filepath>/etc/passwd</ind:filepath> |
| 40 | + <ind:pattern operation="pattern match" |
| 41 | + >^(?:(?!nobody|nfsnobody)[^:]*):(?:[^:]*:)[1-9]\d{3,}:(?:[^:]*:){2}([^:]+):(?!(?:/usr)?/sbin/nologin$)[^:]*$</ind:pattern> |
| 42 | + <ind:instance datatype="int" operation="greater than or equal">1</ind:instance> |
| 43 | + </ind:textfilecontent54_object> |
| 44 | + |
| 45 | + <!-- ============================================================ --> |
| 46 | + <!-- Part 3: Test that ALL interactive users' home directories --> |
| 47 | + <!-- match at least one non-root mount point regex --> |
| 48 | + <!-- ============================================================ --> |
| 49 | + <ind:textfilecontent54_test id="test_{{{ rule_id }}}" |
| 50 | + check="all" check_existence="at_least_one_exists" |
| 51 | + version="1" |
| 52 | + comment="All interactive user home dirs are on separate partitions"> |
| 53 | + <ind:object object_ref="object_{{{ rule_id }}}_interactive_users"/> |
| 54 | + <ind:state state_ref="state_{{{ rule_id }}}_on_separate_partition"/> |
| 55 | + </ind:textfilecontent54_test> |
| 56 | + |
| 57 | + <ind:textfilecontent54_state id="state_{{{ rule_id }}}_on_separate_partition" version="1"> |
| 58 | + <ind:subexpression operation="pattern match" var_check="at least one" |
| 59 | + var_ref="var_{{{ rule_id }}}_mount_regex"/> |
| 60 | + </ind:textfilecontent54_state> |
| 61 | + |
| 62 | + <!-- ============================================================ --> |
| 63 | + <!-- Part 4: Handle edge case - no interactive users on system --> |
| 64 | + <!-- ============================================================ --> |
| 65 | + <ind:textfilecontent54_test id="test_{{{ rule_id }}}_no_interactive_users" |
| 66 | + check="all" check_existence="none_exist" |
| 67 | + version="1" |
| 68 | + comment="No interactive users exist on the system"> |
| 69 | + <ind:object object_ref="object_{{{ rule_id }}}_interactive_users"/> |
| 70 | + </ind:textfilecontent54_test> |
| 71 | +</def-group> |
0 commit comments