Skip to content

Commit 184d5f0

Browse files
committed
Modified ensure_rsyslog_log_file_conf OVAL to allow user/groupnames
Currently, only UID/GIDs were supported in the template, which fails with Ubuntu 22.04 server. This is because the server and desktop installations have different UIDs for syslog user (104/107), but have the same identifier in CaC. The proposed modification checks if the provided `owner` and `groupowner` values are numbers (== UID/GID), and if not, it first extracts UID/GID information from /etc/passwd and /etc/group (or /usr/lib/ in case of CoreOS) based on the provided username/groupname values.
1 parent 4b87b7f commit 184d5f0

File tree

3 files changed

+60
-11
lines changed
  • linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration
  • shared/templates/rsyslog_logfiles_attributes_modify

3 files changed

+60
-11
lines changed

linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_groupownership/rule.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ template:
7979
name: rsyslog_logfiles_attributes_modify
8080
vars:
8181
attribute: groupowner
82-
value: 0
83-
value@debian10: 4
84-
value@debian11: 4
85-
value@ubuntu1604: 4
86-
value@ubuntu2004: 4
87-
value@ubuntu2204: 4
82+
value: root
83+
value@debian10: adm
84+
value@debian11: adm
85+
value@ubuntu1604: adm
86+
value@ubuntu2004: adm
87+
value@ubuntu2204: adm

linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_ownership/rule.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,6 @@ template:
8787
name: rsyslog_logfiles_attributes_modify
8888
vars:
8989
attribute: owner
90-
value: 0
91-
value@ubuntu2004: 104
92-
value@ubuntu2204: 104
90+
value: root
91+
value@ubuntu2004: syslog
92+
value@ubuntu2204: syslog

shared/templates/rsyslog_logfiles_attributes_modify/oval.template

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,61 @@
120120
var_ref="var_{{{ _RULE_ID }}}_log_files_paths"/>
121121
</unix:file_object>
122122

123+
{{% if ATTRIBUTE == "groupowner" %}}
124+
{{% if VALUE is number %}}
125+
<!-- store groupowner GID in variable -->
126+
<constant_variable id="var_{{{ _RULE_ID }}}_{{{ ATTRIBUTE }}}_gid" datatype="int" version="1" comment="GID of {{{ ATTRIBUTE }}}"><value>{{{ VALUE }}}</value></constant_variable>
127+
128+
{{% else %}}
129+
<!-- get groupowner GID from name -->
130+
<ind:textfilecontent54_object id="obj_{{{ _RULE_ID }}}_{{{ ATTRIBUTE }}}_gid" version="1" comment="GID of group {{{ VALUE }}}">
131+
{{# Copied from file_groupowner template, assuming logic is still valid #}}
132+
{{%- if product in ["rhcos4","ocp4"] %}}
133+
<ind:filepath>/usr/lib/group</ind:filepath>
134+
{{%- else %}}
135+
<ind:filepath>/etc/group</ind:filepath>
136+
{{%- endif %}}
137+
<ind:pattern operation="pattern match">^{{{ VALUE }}}:\w+:(\w+):.*</ind:pattern>
138+
<ind:instance datatype="int" operation="equals">1</ind:instance>
139+
</ind:textfilecontent54_object>
140+
141+
<local_variable id="var_{{{ _RULE_ID }}}_{{{ ATTRIBUTE }}}_gid" datatype="int" version="1"
142+
comment="GID of group {{{ VALUE }}}">
143+
<object_component item_field="subexpression" object_ref="obj_{{{ _RULE_ID }}}_{{{ ATTRIBUTE }}}_gid"/>
144+
</local_variable>
145+
{{% endif %}}
146+
147+
{{% elif ATTRIBUTE == "owner" %}}
148+
{{% if VALUE is number %}}
149+
<!-- store owner UID in variable -->
150+
<constant_variable id="var_{{{ _RULE_ID }}}_{{{ ATTRIBUTE }}}_uid" datatype="int" version="1" comment="UID of {{{ ATTRIBUTE }}}"><value>{{{ VALUE }}}</value></constant_variable>
151+
152+
{{% else %}}
153+
<!-- get owner UID from name -->
154+
<ind:textfilecontent54_object id="obj_{{{ _RULE_ID }}}_{{{ ATTRIBUTE }}}_uid" version="1" comment="UID of user {{{ VALUE }}}">
155+
{{# Assuming same logic as above applies to users #}}
156+
{{%- if product in ["rhcos4","ocp4"] %}}
157+
<ind:filepath>/usr/lib/passwd</ind:filepath>
158+
{{%- else %}}
159+
<ind:filepath>/etc/passwd</ind:filepath>
160+
{{%- endif %}}
161+
<ind:pattern operation="pattern match">^{{{ VALUE }}}:\w+:(\w+):.*</ind:pattern>
162+
<ind:instance datatype="int" operation="equals">1</ind:instance>
163+
</ind:textfilecontent54_object>
164+
165+
<local_variable id="var_{{{ _RULE_ID }}}_{{{ ATTRIBUTE }}}_uid" datatype="int" version="1"
166+
comment="UID of user {{{ VALUE }}}">
167+
<object_component item_field="subexpression" object_ref="obj_{{{ _RULE_ID }}}_{{{ ATTRIBUTE }}}_uid"/>
168+
</local_variable>
169+
{{% endif %}}
170+
{{% endif %}}
171+
123172
<unix:file_state id="state_{{{ _RULE_ID }}}" version="1">
124173
<unix:type operation="equals">regular</unix:type>
125174
{{% if ATTRIBUTE == "groupowner" %}}
126-
<unix:group_id datatype="int">{{{ VALUE }}}</unix:group_id>
175+
<unix:group_id datatype="int" var_ref="var_{{{ _RULE_ID }}}_{{{ ATTRIBUTE }}}_gid"></unix:group_id>
127176
{{% elif ATTRIBUTE == "owner" %}}
128-
<unix:user_id datatype="int">{{{ VALUE }}}</unix:user_id>
177+
<unix:user_id datatype="int" var_ref="var_{{{ _RULE_ID }}}_{{{ ATTRIBUTE }}}_uid"></unix:user_id>
129178
{{% else %}}
130179
{{{ STATEMODE | indent(4) }}}
131180
{{% endif %}}

0 commit comments

Comments
 (0)