Skip to contentSkip to conversation

Allow systemd to getattr configfile

PATCH In review Sugar, David 2 participants 4 messages Jan 13, 2020 – Jan 22, 2020

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 Allow systemd to getattr configfile

v2 update - rework, creating interface 'init_systemd_conditional' as suggested. This grants getattr access to the type provided.

---
 policy/modules/services/chronyd.te |  2 ++
 policy/modules/system/init.if      | 26 ++++++++++++++++++++++++++
 2 files changed, 28 insertions(+)
policy/modules/services/chronyd.te +2 -0
index 5e680d39..7ae8bb5a 100644
@@ -102,6 +102,8 @@ miscfiles_read_localization(chronyd_t)
 chronyd_dgram_send_cli(chronyd_t)
 chronyd_read_config(chronyd_t)
 
+init_systemd_conditional(chronyd_conf_t)
+
 optional_policy(`
 	gpsd_rw_shm(chronyd_t)
 ')
policy/modules/system/init.if +26 -0
index 62ab4da8..5a0a78bf 100644
@@ -3232,6 +3232,32 @@ interface(`init_reload_all_units',`
 	allow $1 { init_script_file_type systemdunit }:service reload;
 ')
 
+
+########################################
+## <summary>
+##      Allow init_t getattr permissions.  Generally
+##      needed for types that are used in a Condition
+##      predicate.
+## </summary>
+## <param name="domain">
+##      <summary>
+##      type accessible by init_t
+##      </summary>
+## </param>
+#
+interface(`init_systemd_conditional',`
+	gen_require(`
+		type init_t;
+	')
+	allow init_t $1:dir search_dir_perms;
+	allow init_t $1:lnk_file read_lnk_file_perms;
+	allow init_t $1:fifo_file getattr_fifo_file_perms;
+	allow init_t $1:sock_file getattr_sock_file_perms;
+	allow init_t $1:file getattr_file_perms;
+	allow init_t $1:blk_file getattr_blk_file_perms;
+	allow init_t $1:chr_file getattr_chr_file_perms;
+')
+
 ########################################
 ## <summary>
 ##      Allow unconfined access to send instructions to init
Signature · 1 line
2.24.1
#1 lore raw
Quoted 34 lines · David

v2 update - rework, creating interface 'init_systemd_conditional' as suggested. This grants getattr access to the type provided.

---
  policy/modules/services/chronyd.te |  2 ++
  policy/modules/system/init.if      | 26 ++++++++++++++++++++++++++
  2 files changed, 28 insertions(+)
policy/modules/services/chronyd.te +2 -0
index 5e680d39..7ae8bb5a 100644
@@ -102,6 +102,8 @@ miscfiles_read_localization(chronyd_t)
  chronyd_dgram_send_cli(chronyd_t)
  chronyd_read_config(chronyd_t)
 
+init_systemd_conditional(chronyd_conf_t)
+
  optional_policy(`
  	gpsd_rw_shm(chronyd_t)
  ')
policy/modules/system/init.if +4 -0
index 62ab4da8..5a0a78bf 100644
@@ -3232,6 +3232,32 @@ interface(`init_reload_all_units',`
  	allow $1 { init_script_file_type systemdunit }:service reload;
  ')
 
+
+########################################
+## <summary>
+##      Allow init_t getattr permissions.  Generally

policy/modules/system/init.if interface(`init_reload_all_units',` · line 3248

Quoted 10 lines
policy/modules/system/init.if +10 -0
+##      needed for types that are used in a Condition
+##      predicate.
+## </summary>
+## <param name="domain">
+##      <summary>
+##      type accessible by init_t
+##      </summary>
+## </param>
+#
+interface(`init_systemd_conditional',`

systemd_ConditionPath is a more preferable name.

Quoted 16 lines
policy/modules/system/init.if +12 -0
+	gen_require(`
+		type init_t;
+	')
+	allow init_t $1:dir search_dir_perms;
+	allow init_t $1:lnk_file read_lnk_file_perms;
+	allow init_t $1:fifo_file getattr_fifo_file_perms;
+	allow init_t $1:sock_file getattr_sock_file_perms;
+	allow init_t $1:file getattr_file_perms;
+	allow init_t $1:blk_file getattr_blk_file_perms;
+	allow init_t $1:chr_file getattr_chr_file_perms;
+')
+
  ########################################
  ## <summary>
  ##      Allow unconfined access to send instructions to init
Signature · 1 line
Chris PeBenito
#2 lore raw
Quoted 39 lines · Chris PeBenito
Quoted 38 lines · David

v2 update - rework, creating interface 'init_systemd_conditional' as suggested.  This grants getattr access to the type provided.

---
  policy/modules/services/chronyd.te |  2 ++ policy/modules/system/init.if      | 26 ++++++++++++++++++++++++++

  2 files changed, 28 insertions(+)
policy/modules/services/chronyd.te +2 -0
index 5e680d39..7ae8bb5a 100644
@@ -102,6 +102,8 @@ miscfiles_read_localization(chronyd_t)
   chronyd_dgram_send_cli(chronyd_t)
   chronyd_read_config(chronyd_t)
+init_systemd_conditional(chronyd_conf_t)
+

  optional_policy(`
      gpsd_rw_shm(chronyd_t)
  ')

policy/modules/system/init.if +8 -0
index 62ab4da8..5a0a78bf 100644
@@ -3232,6 +3232,32 @@ interface(`init_reload_all_units',`
       allow $1 { init_script_file_type systemdunit }:service reload;
   ')
+
+########################################
+## <summary>
+##      Allow init_t getattr permissions.  Generally
+##      needed for types that are used in a Condition
+##      predicate.
+## </summary>
+## <param name="domain">
Quoted 9 lines

policy/modules/system/init.if interface(`init_reload_all_units',` · line 3248

Quoted 6 lines
policy/modules/system/init.if +6 -0
+##      <summary>
+##      type accessible by init_t
+##      </summary>
+## </param>
+#
+interface(`init_systemd_conditional',`

systemd_ConditionPath is a more preferable name.

I'm a little confused about the suggested name. I think this interface belongs in init.if due to the requiring of init_t. Due to this, I think it should have the init_ prefix. I also don't think there are any camel case interface names.

Is the name 'init_systemd_condition_path' acceptable? Or are some of my assumptions wrong?

Quoted 19 lines
Quoted 17 lines
policy/modules/system/init.if +12 -0
+    gen_require(`
+        type init_t;
+    ')
+    allow init_t $1:dir search_dir_perms;
+    allow init_t $1:lnk_file read_lnk_file_perms;
+    allow init_t $1:fifo_file getattr_fifo_file_perms;
+    allow init_t $1:sock_file getattr_sock_file_perms;
+    allow init_t $1:file getattr_file_perms;
+    allow init_t $1:blk_file getattr_blk_file_perms;
+    allow init_t $1:chr_file getattr_chr_file_perms;
+')
+
   ########################################
   ## <summary>
   ##      Allow unconfined access to send instructions to init
 
#3 lore raw
Quoted 50 lines · David
Quoted 39 lines · Chris PeBenito
Quoted 38 lines · David

v2 update - rework, creating interface 'init_systemd_conditional' as suggested.  This grants getattr access to the type provided.

---
   policy/modules/services/chronyd.te |  2 ++
   policy/modules/system/init.if      | 26 ++++++++++++++++++++++++++
   2 files changed, 28 insertions(+)
policy/modules/services/chronyd.te +2 -0
index 5e680d39..7ae8bb5a 100644
@@ -102,6 +102,8 @@ miscfiles_read_localization(chronyd_t)
   chronyd_dgram_send_cli(chronyd_t)
   chronyd_read_config(chronyd_t)
+init_systemd_conditional(chronyd_conf_t)
+
   optional_policy(`
       gpsd_rw_shm(chronyd_t)
   ')
policy/modules/system/init.if +8 -0
index 62ab4da8..5a0a78bf 100644
@@ -3232,6 +3232,32 @@ interface(`init_reload_all_units',`
       allow $1 { init_script_file_type systemdunit }:service reload;
   ')
+
+########################################
+## <summary>
+##      Allow init_t getattr permissions.  Generally
+##      needed for types that are used in a Condition
+##      predicate.
+## </summary>
+## <param name="domain">
Quoted 9 lines

policy/modules/system/init.if interface(`init_reload_all_units',` · line 3248

Quoted 6 lines
policy/modules/system/init.if +6 -0
+##      <summary>
+##      type accessible by init_t
+##      </summary>
+## </param>
+#
+interface(`init_systemd_conditional',`

systemd_ConditionPath is a more preferable name.

Quoted 7 lines

I'm a little confused about the suggested name. I think this interface belongs in init.if due to the requiring of init_t. Due to this, I think it should have the init_ prefix. I also don't think there are any camel case interface names.

Is the name 'init_systemd_condition_path' acceptable? Or are some of my assumptions wrong?

No, you're right, my mistake. However, this makes me reconsider the previous discussion on this. Is it really an issue for systemd to be able to getattr all files? Condition* works in many cases already since systemd already has lots of access all over the filesystem.

Signature · 1 line
Chris PeBenito