Skip to contentSkip to conversation

miscfiles: introduce the user certificate file context

PATCH Superseded Guido Trentalancia 3 participants 17 messages Sep 3, 2016 – Sep 10, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 miscfiles: introduce the user certificate file context

Introduce a new file context for user certificates (user_cert_t) located in home directories.

Introduce new auxiliary interfaces to read and manage such files files and directories.

---
 policy/modules/system/miscfiles.fc |    5 ++++
 policy/modules/system/miscfiles.if |   40 +++++++++++++++++++++++++++++++++++++
 policy/modules/system/miscfiles.te |    6 +++++
 3 files changed, 51 insertions(+)
policy/modules/system/miscfiles.fc +5 -0
@@ -1,4 +1,9 @@
 #
+# HOME_DIR
+#
+HOME_DIR/\.pki(/.*)?		gen_context(system_u:object_r:user_cert_t,s0)
+
+#
 # /emul
 #
 ifdef(`distro_gentoo',`
policy/modules/system/miscfiles.if +40 -0
@@ -171,6 +171,46 @@ interface(`miscfiles_manage_cert_files',
 
 ########################################
 ## <summary>
+##	Read user SSL certificates.
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain allowed access.
+##	</summary>
+## </param>
+## <rolecap/>
+#
+interface(`miscfiles_read_user_certs',`
+	gen_require(`
+		type user_cert_t;
+	')
+
+	allow $1 user_cert_t:dir list_dir_perms;
+	read_files_pattern($1, user_cert_t, user_cert_t)
+	read_lnk_files_pattern($1, user_cert_t, user_cert_t)
+')
+
+########################################
+## <summary>
+##	Manage user SSL certificates.
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain allowed access.
+##	</summary>
+## </param>
+#
+interface(`miscfiles_manage_user_cert',`
+	gen_require(`
+		type user_cert_t;
+	')
+
+	manage_dirs_pattern($1, user_cert_t, user_cert_t)
+	manage_files_pattern($1, user_cert_t, user_cert_t)
+')
+
+########################################
+## <summary>
 ##	Read fonts.
 ## </summary>
 ## <param name="domain">
policy/modules/system/miscfiles.te +6 -0
@@ -14,6 +14,12 @@ type cert_t;
 miscfiles_cert_type(cert_t)
 
 #
+# user_cert_t is the type of files in the home certs directories.
+#
+type user_cert_t;
+miscfiles_cert_type(user_cert_t)
+
+#
 # fonts_t is the type of various font
 # files in /usr
 #
#1 lore raw

PATCH 2/2 evolution: add support for the new user certificates

Update the evolution module so that it is able to create, read and write the newly created user certificates files and directories (user_cert_t).

---
 policy/modules/contrib/evolution.te |    2 ++
 1 file changed, 2 insertions(+)
policy/modules/contrib/evolution.te +2 -0
@@ -178,6 +178,7 @@ auth_use_nsswitch(evolution_t)
 
 logging_send_syslog_msg(evolution_t)
 
+miscfiles_manage_user_cert(evolution_t)
 miscfiles_read_generic_certs(evolution_t)
 miscfiles_read_localization(evolution_t)
 
@@ -432,6 +433,7 @@ fs_search_auto_mountpoints(evolution_ser
 
 auth_use_nsswitch(evolution_server_t)
 
+miscfiles_manage_user_cert(evolution_server_t)
 miscfiles_read_localization(evolution_server_t)
 miscfiles_read_generic_certs(evolution_server_t)
 
#2 lore raw

PATCH 2/2 evolution: add support for the new user certificates

Quoted 19 lines · Guido Trentalancia via refpolicy

Update the evolution module so that it is able to create, read and write the newly created user certificates files and directories (user_cert_t).

---
 policy/modules/contrib/evolution.te |    2 ++
 1 file changed, 2 insertions(+)
policy/modules/contrib/evolution.te +1 -0
@@ -178,6 +178,7 @@ auth_use_nsswitch(evolution_t)
 
 logging_send_syslog_msg(evolution_t)
 
+miscfiles_manage_user_cert(evolution_t)
 miscfiles_read_generic_certs(evolution_t)
 miscfiles_read_localization(evolution_t)
 

policy/modules/contrib/evolution.te fs_search_auto_mountpoints(evolution_ser · line 438

Quoted 6 lines
policy/modules/contrib/evolution.te +1 -0
@@ -432,6 +433,7 @@ fs_search_auto_mountpoints(evolution_ser
 
 auth_use_nsswitch(evolution_server_t)
 
+miscfiles_manage_user_cert(evolution_server_t)
 miscfiles_read_localization(evolution_server_t)
 miscfiles_read_generic_certs(evolution_server_t)

One question I have is, do we want to make this access conditional? Since the certificates are not specific to evolution, perhaps users may not want evolution to access them? Maybe read only access is a third alternative?

i.e. conditionals to achieve these options:
1. manage access
2. read-only access
3. no access

is something to consider.

Signature · 1 line
Chris PeBenito
#3 lore raw

PATCH 2/2 evolution: add support for the new user certificates

Hello Christopher.

My reply follows the quoted text...

Quoted 41 lines · Chris PeBenito
Quoted 26 lines · Guido Trentalancia via refpolicy

Update the evolution module so that it is able to create, read and write
the newly created user certificates files and directories (user_cert_t).

---
?policy/modules/contrib/evolution.te |????2 ++
?1 file changed, 2 insertions(+)

--- refpolicy-git-14082016-orig-
evolution/policy/modules/contrib/evolution.te 2016-09-03
15:51:41.893570747 +0200
+++ refpolicy-git-14082016-user-certs-
evolution/policy/modules/contrib/evolution.te 2016-09-03
15:52:43.680488794 +0200

policy/modules/contrib/evolution.te +1 -0
@@ -178,6 +178,7 @@ auth_use_nsswitch(evolution_t)
 
 ?logging_send_syslog_msg(evolution_t)
 
+miscfiles_manage_user_cert(evolution_t)
 ?miscfiles_read_generic_certs(evolution_t)
 ?miscfiles_read_localization(evolution_t)
 

policy/modules/contrib/evolution.te fs_search_auto_mountpoints(evolution_ser · line 438

Quoted 6 lines
policy/modules/contrib/evolution.te +1 -0
@@ -432,6 +433,7 @@ fs_search_auto_mountpoints(evolution_ser
 
 ?auth_use_nsswitch(evolution_server_t)
 
+miscfiles_manage_user_cert(evolution_server_t)
 ?miscfiles_read_localization(evolution_server_t)
 ?miscfiles_read_generic_certs(evolution_server_t)

One question I have is, do we want to make this access conditional?? Since the certificates are not specific to evolution, perhaps users may?
not want evolution to access them???Maybe read only access is a third?
alternative?

Quoted 6 lines

i.e. conditionals to achieve these options:
1. manage access
2. read-only access
3. no access

is something to consider.

I am not sure about this, especially forbidding the access completely.

The use of digital certificates is now part of every fully-featured mail client application.

The point is that either the user trusts evolution as a mail client application or not.

If evolution is a trusted application, then there is no reason to limit its ability to access the user certificates.

On the other hand, if the user doesn't trust evolution, he/she can just use another application and that is the end of the story.

Finally, I believe that an effective policy should not include too many booleans, otherwise there is an high risk that it becomes too difficult to use and that's not what we want.

I have created a new version (v2) of this patch (attached to the next message) that only switches the read/write operation on user certificates, thus adding some configurability value, without being excessively difficult to use.

I hope you agree with me...

Best regards,

Guido

#4 lore raw

PATCH v2 2/2 evolution: add support for the new user certificates

In reply to Guido Trentalancia

Update the evolution module so that it is able to create, read and write the newly created user certificates files and directories (user_cert_t).

By default only read access on the user certificates is enabled. To also enable write access, the user can set a new boolean policy variable.

---
 policy/modules/contrib/evolution.te |   23 +++++++++++++++++++++++
 policy/modules/system/userdomain.if |   22 ++++++++++++++++++++++
 2 files changed, 45 insertions(+)
policy/modules/contrib/evolution.te +23 -0
@@ -5,6 +5,15 @@ policy_module(evolution, 2.4.0)
 # Declarations
 #
 
+## <desc>
+## <p>
+## Allow evolution to create and write
+## user certificates in addition to
+## being able to read them
+## </p>
+## </desc>
+gen_tunable(evolution_manage_user_certs, false)
+
 attribute_role evolution_roles;
 
 type evolution_t;
@@ -185,6 +194,13 @@ udev_read_state(evolution_t)
 
 userdom_use_user_terminals(evolution_t)
 
+tunable_policy(`evolution_manage_user_certs',`
+	userdom_manage_user_certs(evolution_t)
+',`
+	userdom_dontaudit_manage_user_certs(evolution_t)
+	userdom_read_user_certs(evolution_t)
+')
+
 userdom_manage_user_tmp_dirs(evolution_t)
 userdom_manage_user_tmp_files(evolution_t)
 
@@ -437,6 +453,13 @@ miscfiles_read_generic_certs(evolution_s
 
 userdom_dontaudit_read_user_home_content_files(evolution_server_t)
 
+tunable_policy(`evolution_manage_user_certs',`
+	userdom_manage_user_certs(evolution_server_t)
+',`
+	userdom_dontaudit_manage_user_certs(evolution_server_t)
+	userdom_read_user_certs(evolution_server_t)
+')
+
 tunable_policy(`use_nfs_home_dirs',`
 	fs_manage_nfs_dirs(evolution_server_t)
 	fs_manage_nfs_files(evolution_server_t)
policy/modules/system/userdomain.if +22 -0
@@ -2366,6 +2366,28 @@ interface(`userdom_read_user_certs',`
 
 ########################################
 ## <summary>
+##	Do not audit attempts to manage
+##	the user SSL certificates.
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain allowed access.
+##	</summary>
+## </param>
+## <rolecap/>
+#
+interface(`userdom_dontaudit_manage_user_certs',`
+	gen_require(`
+		type user_cert_t;
+	')
+
+	dontaudit $1 user_cert_t:dir manage_dir_perms;
+	dontaudit $1 user_cert_t:file manage_file_perms;
+	dontaudit $1 user_cert_t:lnk_file manage_file_perms;
+')
+
+########################################
+## <summary>
 ##	Manage user SSL certificates.
 ## </summary>
 ## <param name="domain">
#5 lore raw

PATCH v2 2/2 evolution: add support for the new user certificates

Now that 1/2 has been merged, how about this?

Regards,

Guido

Quoted 102 lines · Guido Trentalancia via refpolicy

Update the evolution module so that it is able to create, read and write
the newly created user certificates files and directories (user_cert_t).

By default only read access on the user certificates is enabled. To also
enable write access, the user can set a new boolean policy variable.

---

policy/modules/contrib/evolution.te |   23 +++++++++++++++++++++++
policy/modules/system/userdomain.if |   22 ++++++++++++++++++++++
2 files changed, 45 insertions(+)

--- refpolicy-git-orig/policy/modules/contrib/evolution.te 2016-09-06
00:56:30.269432993 +0200
+++
refpolicy-git-evolution-user_cert_t/policy/modules/contrib/evolution.te 2016-09-06
01:04:03.715929145 +0200

policy/modules/contrib/evolution.te +23 -0
@@ -5,6 +5,15 @@ policy_module(evolution, 2.4.0)
 # Declarations
 #
 
+## <desc>
+## <p>
+## Allow evolution to create and write
+## user certificates in addition to
+## being able to read them
+## </p>
+## </desc>
+gen_tunable(evolution_manage_user_certs, false)
+
 attribute_role evolution_roles;
 
 type evolution_t;
@@ -185,6 +194,13 @@ udev_read_state(evolution_t)
 
 userdom_use_user_terminals(evolution_t)
 
+tunable_policy(`evolution_manage_user_certs',`
+	userdom_manage_user_certs(evolution_t)
+',`
+	userdom_dontaudit_manage_user_certs(evolution_t)
+	userdom_read_user_certs(evolution_t)
+')
+
 userdom_manage_user_tmp_dirs(evolution_t)
 userdom_manage_user_tmp_files(evolution_t)
 
@@ -437,6 +453,13 @@ miscfiles_read_generic_certs(evolution_s
 
 userdom_dontaudit_read_user_home_content_files(evolution_server_t)
 
+tunable_policy(`evolution_manage_user_certs',`
+	userdom_manage_user_certs(evolution_server_t)
+',`
+	userdom_dontaudit_manage_user_certs(evolution_server_t)
+	userdom_read_user_certs(evolution_server_t)
+')
+

tunable_policy(use_nfs_home_dirs',
fs_manage_nfs_dirs(evolution_server_t)
fs_manage_nfs_files(evolution_server_t)
--- refpolicy-git-orig/policy/modules/system/userdomain.if 2016-09-06
00:54:51.184008920 +0200
+++
refpolicy-git-evolution-user_cert_t/policy/modules/system/userdomain.if 2016-09-06
01:02:10.691313023 +0200

policy/modules/system/userdomain.if +22 -0
@@ -2366,6 +2366,28 @@ interface(`userdom_read_user_certs',`
 
 ########################################
 ## <summary>
+##	Do not audit attempts to manage
+##	the user SSL certificates.
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain allowed access.
+##	</summary>
+## </param>
+## <rolecap/>
+#
+interface(`userdom_dontaudit_manage_user_certs',`
+	gen_require(`
+		type user_cert_t;
+	')
+
+	dontaudit $1 user_cert_t:dir manage_dir_perms;
+	dontaudit $1 user_cert_t:file manage_file_perms;
+	dontaudit $1 user_cert_t:lnk_file manage_file_perms;
+')
+
+########################################
+## <summary>
 ##	Manage user SSL certificates.
 ## </summary>
 ## <param name="domain">

_______________________________________________
refpolicy mailing list
refpolicy at oss.tresys.com
http://oss.tresys.com/mailman/listinfo/refpolicy

#6 lore raw

PATCH v2 2/2 evolution: add support for the new user certificates

Quoted 1 line · Guido Trentalancia

Now that 1/2 has been merged, how about this?

This was merged, I just forgot to email about it.

Quoted 104 lines · Guido Trentalancia via refpolicy
Quoted 102 lines

Update the evolution module so that it is able to create, read and write
the newly created user certificates files and directories (user_cert_t).

By default only read access on the user certificates is enabled. To also
enable write access, the user can set a new boolean policy variable.

---

policy/modules/contrib/evolution.te |   23 +++++++++++++++++++++++
policy/modules/system/userdomain.if |   22 ++++++++++++++++++++++
2 files changed, 45 insertions(+)

--- refpolicy-git-orig/policy/modules/contrib/evolution.te 2016-09-06
00:56:30.269432993 +0200
+++
refpolicy-git-evolution-user_cert_t/policy/modules/contrib/evolution.te 2016-09-06
01:04:03.715929145 +0200

policy/modules/contrib/evolution.te +23 -0
@@ -5,6 +5,15 @@ policy_module(evolution, 2.4.0)
 # Declarations
 #
 
+## <desc>
+## <p>
+## Allow evolution to create and write
+## user certificates in addition to
+## being able to read them
+## </p>
+## </desc>
+gen_tunable(evolution_manage_user_certs, false)
+
 attribute_role evolution_roles;
 
 type evolution_t;
@@ -185,6 +194,13 @@ udev_read_state(evolution_t)
 
 userdom_use_user_terminals(evolution_t)
 
+tunable_policy(`evolution_manage_user_certs',`
+	userdom_manage_user_certs(evolution_t)
+',`
+	userdom_dontaudit_manage_user_certs(evolution_t)
+	userdom_read_user_certs(evolution_t)
+')
+
 userdom_manage_user_tmp_dirs(evolution_t)
 userdom_manage_user_tmp_files(evolution_t)
 
@@ -437,6 +453,13 @@ miscfiles_read_generic_certs(evolution_s
 
 userdom_dontaudit_read_user_home_content_files(evolution_server_t)
 
+tunable_policy(`evolution_manage_user_certs',`
+	userdom_manage_user_certs(evolution_server_t)
+',`
+	userdom_dontaudit_manage_user_certs(evolution_server_t)
+	userdom_read_user_certs(evolution_server_t)
+')
+

tunable_policy(use_nfs_home_dirs',
fs_manage_nfs_dirs(evolution_server_t)
fs_manage_nfs_files(evolution_server_t)
--- refpolicy-git-orig/policy/modules/system/userdomain.if 2016-09-06
00:54:51.184008920 +0200
+++
refpolicy-git-evolution-user_cert_t/policy/modules/system/userdomain.if 2016-09-06
01:02:10.691313023 +0200

policy/modules/system/userdomain.if +22 -0
@@ -2366,6 +2366,28 @@ interface(`userdom_read_user_certs',`
 
 ########################################
 ## <summary>
+##	Do not audit attempts to manage
+##	the user SSL certificates.
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain allowed access.
+##	</summary>
+## </param>
+## <rolecap/>
+#
+interface(`userdom_dontaudit_manage_user_certs',`
+	gen_require(`
+		type user_cert_t;
+	')
+
+	dontaudit $1 user_cert_t:dir manage_dir_perms;
+	dontaudit $1 user_cert_t:file manage_file_perms;
+	dontaudit $1 user_cert_t:lnk_file manage_file_perms;
+')
+
+########################################
+## <summary>
 ##	Manage user SSL certificates.
 ## </summary>
 ## <param name="domain">

_______________________________________________
refpolicy mailing list
refpolicy at oss.tresys.com
http://oss.tresys.com/mailman/listinfo/refpolicy

Signature · 1 line
Chris PeBenito
#7 lore raw

PATCH v2 2/2 evolution: add support for the new user certificates

Quoted 6 lines · Chris PeBenito
Quoted 2 lines · Guido Trentalancia

Now that 1/2 has been merged, how about this?

This was merged, I just forgot to email about it.

All right, thanks.

Quoted 110 lines
Quoted 110 lines
Quoted 108 lines · Guido Trentalancia via refpolicy

Update the evolution module so that it is able to create, read and
write
the newly created user certificates files and directories (user_cert_t).

By default only read access on the user certificates is enabled. To
also
enable write access, the user can set a new boolean policy variable.

---
policy/modules/contrib/evolution.te |???23
+++++++++++++++++++++++
policy/modules/system/userdomain.if |???22 ++++++++++++++++++++++

2 files changed, 45 insertions(+)

--- refpolicy-git-orig/policy/modules/contrib/evolution.te 2016-09-06
00:56:30.269432993 +0200
+++
refpolicy-git-evolution-
user_cert_t/policy/modules/contrib/evolution.te 2016-09-06
01:04:03.715929145 +0200

policy/modules/contrib/evolution.te +16 -0
@@ -5,6 +5,15 @@ policy_module(evolution, 2.4.0)
 # Declarations
 #
 
+## <desc>
+## <p>
+## Allow evolution to create and write
+## user certificates in addition to
+## being able to read them
+## </p>
+## </desc>
+gen_tunable(evolution_manage_user_certs, false)
+
 attribute_role evolution_roles;
 
 type evolution_t;
@@ -185,6 +194,13 @@ udev_read_state(evolution_t)
 
 userdom_use_user_terminals(evolution_t)
 
+tunable_policy(`evolution_manage_user_certs',`
+	userdom_manage_user_certs(evolution_t)
+',`
+	userdom_dontaudit_manage_user_certs(evolution_t)
+	userdom_read_user_certs(evolution_t)
+')
+
 userdom_manage_user_tmp_dirs(evolution_t)
 userdom_manage_user_tmp_files(evolution_t)
 
@@ -437,6 +453,13 @@ miscfiles_read_generic_certs(evolution_s
 

userdom_dontaudit_read_user_home_content_files(evolution_server_t )

policy/modules/contrib/evolution.te +7 -0
+tunable_policy(`evolution_manage_user_certs',`
+	userdom_manage_user_certs(evolution_server_t)
+',`
+	userdom_dontaudit_manage_user_certs(evolution_server_t)
+	userdom_read_user_certs(evolution_server_t)
+')
+

tunable_policy(use_nfs_home_dirs',
fs_manage_nfs_dirs(evolution_server_t) fs_manage_nfs_files(evolution_server_t)
--- refpolicy-git-orig/policy/modules/system/userdomain.if 2016-09-06
00:54:51.184008920 +0200
+++
refpolicy-git-evolution-
user_cert_t/policy/modules/system/userdomain.if 2016-09-06
01:02:10.691313023 +0200

policy/modules/system/userdomain.if +22 -0
@@ -2366,6 +2366,28 @@ interface(`userdom_read_user_certs',`
 
 ########################################
 ## <summary>
+##	Do not audit attempts to manage
+##	the user SSL certificates.
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain allowed access.
+##	</summary>
+## </param>
+## <rolecap/>
+#
+interface(`userdom_dontaudit_manage_user_certs',`
+	gen_require(`
+		type user_cert_t;
+	')
+
+	dontaudit $1 user_cert_t:dir manage_dir_perms;
+	dontaudit $1 user_cert_t:file manage_file_perms;
+	dontaudit $1 user_cert_t:lnk_file manage_file_perms;
+')
+
+########################################
+## <summary>
 ##	Manage user SSL certificates.
 ## </summary>
 ## <param name="domain">
#8 lore raw

PATCH 1/2 miscfiles: introduce the user certificate file context

In reply to Guido Trentalancia
Quoted 5 lines · Guido Trentalancia via refpolicy

Introduce a new file context for user certificates (user_cert_t) located in home directories.

Introduce new auxiliary interfaces to read and manage such files files and directories.

I'm fine adding this type, but I think it should go in userdomain, as it is related to users.

Quoted 88 lines
---
 policy/modules/system/miscfiles.fc |    5 ++++
 policy/modules/system/miscfiles.if |   40 +++++++++++++++++++++++++++++++++++++
 policy/modules/system/miscfiles.te |    6 +++++
 3 files changed, 51 insertions(+)
policy/modules/system/miscfiles.fc +5 -0
@@ -1,4 +1,9 @@
 #
+# HOME_DIR
+#
+HOME_DIR/\.pki(/.*)?		gen_context(system_u:object_r:user_cert_t,s0)
+
+#
 # /emul
 #
 ifdef(`distro_gentoo',`
policy/modules/system/miscfiles.if +40 -0
@@ -171,6 +171,46 @@ interface(`miscfiles_manage_cert_files',
 
 ########################################
 ## <summary>
+##	Read user SSL certificates.
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain allowed access.
+##	</summary>
+## </param>
+## <rolecap/>
+#
+interface(`miscfiles_read_user_certs',`
+	gen_require(`
+		type user_cert_t;
+	')
+
+	allow $1 user_cert_t:dir list_dir_perms;
+	read_files_pattern($1, user_cert_t, user_cert_t)
+	read_lnk_files_pattern($1, user_cert_t, user_cert_t)
+')
+
+########################################
+## <summary>
+##	Manage user SSL certificates.
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain allowed access.
+##	</summary>
+## </param>
+#
+interface(`miscfiles_manage_user_cert',`
+	gen_require(`
+		type user_cert_t;
+	')
+
+	manage_dirs_pattern($1, user_cert_t, user_cert_t)
+	manage_files_pattern($1, user_cert_t, user_cert_t)
+')
+
+########################################
+## <summary>
 ##	Read fonts.
 ## </summary>
 ## <param name="domain">
policy/modules/system/miscfiles.te +6 -0
@@ -14,6 +14,12 @@ type cert_t;
 miscfiles_cert_type(cert_t)
 
 #
+# user_cert_t is the type of files in the home certs directories.
+#
+type user_cert_t;
+miscfiles_cert_type(user_cert_t)
+
+#
 # fonts_t is the type of various font
 # files in /usr
 #

_______________________________________________
refpolicy mailing list
refpolicy at oss.tresys.com
http://oss.tresys.com/mailman/listinfo/refpolicy

Signature · 1 line
Chris PeBenito
#9 lore raw

PATCH 1/2 miscfiles: introduce the user certificate file context

Quoted 10 lines · Chris PeBenito
Quoted 5 lines · Guido Trentalancia via refpolicy

Introduce a new file context for user certificates (user_cert_t) located in home directories.

Introduce new auxiliary interfaces to read and manage such files files and directories.

I'm fine adding this type, but I think it should go in userdomain, as it is related to users.

[...]

Quoted 30 lines
Quoted 30 lines

--- refpolicy-git-06082016-orig/policy/modules/system/miscfiles.if

2016-08-06 21:26:43.305774396 +0200
+++ refpolicy-git-06082016/policy/modules/system/miscfiles.if
2016-09-03 15:20:38.951593020 +0200
policy/modules/system/miscfiles.if +22 -0
@@ -171,6 +171,46 @@ interface(`miscfiles_manage_cert_files',
 
 ########################################
 ## <summary>
+##    Read user SSL certificates.
+## </summary>
+## <param name="domain">
+##    <summary>
+##    Domain allowed access.
+##    </summary>
+## </param>
+## <rolecap/>
+#
+interface(`miscfiles_read_user_certs',`
+    gen_require(`
+        type user_cert_t;
+    ')
+
+    allow $1 user_cert_t:dir list_dir_perms;
+    read_files_pattern($1, user_cert_t, user_cert_t)
+    read_lnk_files_pattern($1, user_cert_t, user_cert_t)
+')
+
+########################################
+## <summary>
+##    Manage user SSL certificates.
Quoted 8 lines

policy/modules/system/miscfiles.if interface(`miscfiles_manage_cert_files', · line 203

Quoted 8 lines
policy/modules/system/miscfiles.if +8 -0
+## </summary>
+## <param name="domain">
+##    <summary>
+##    Domain allowed access.
+##    </summary>
+## </param>
+#
+interface(`miscfiles_manage_user_cert',`

This should be plural, like the interface above it (userdom_manage_user_certs).

Quoted 7 lines
Quoted 7 lines
policy/modules/system/miscfiles.if +7 -0
+    gen_require(`
+        type user_cert_t;
+    ')
+
+    manage_dirs_pattern($1, user_cert_t, user_cert_t)
+    manage_files_pattern($1, user_cert_t, user_cert_t)
+')
Signature · 1 line
Chris PeBenito
#10 lore raw

PATCH v2 1/2 miscfiles: introduce the user certificate file context

In reply to Guido Trentalancia

Introduce a new file context for user certificates (user_cert_t) located in home directories.

Introduce new auxiliary interfaces to read and manage such files files and directories.

Thanks to Christopher PeBenito for the useful suggestions that led to this improved version of the patch.

---
 policy/modules/system/userdomain.fc |    1
 policy/modules/system/userdomain.if |   44 ++++++++++++++++++++++++++++++++++++
 policy/modules/system/userdomain.te |    3 ++
 3 files changed, 48 insertions(+)
policy/modules/system/userdomain.fc +1 -0
@@ -1,5 +1,6 @@
 HOME_DIR	-d	gen_context(system_u:object_r:user_home_dir_t,s0-mls_systemhigh)
 HOME_DIR/.+		gen_context(system_u:object_r:user_home_t,s0)
+HOME_DIR/\.pki(/.*)?	gen_context(system_u:object_r:user_cert_t,s0)
 
 /tmp/gconfd-USER -d	gen_context(system_u:object_r:user_tmp_t,s0)
 
policy/modules/system/userdomain.if +44 -0

56 lines not on this page · raw message

policy/modules/system/userdomain.te +3 -0
@@ -76,6 +76,9 @@ files_associate_tmp(user_home_t)
 files_poly_parent(user_home_t)
 files_mountpoint(user_home_t)
 
+type user_cert_t;
+userdom_user_home_content(user_cert_t)
+
 type user_devpts_t alias { staff_devpts_t sysadm_devpts_t secadm_devpts_t auditadm_devpts_t unconfined_devpts_t };
 dev_node(user_devpts_t)
 files_type(user_devpts_t)
#11 lore raw

PATCH v3 1/2 userdomain: introduce the user certificate file context (was miscfiles: introduce the user certificate file context)

Introduce a new file context for user certificates (user_cert_t) located in home directories.

Introduce new auxiliary interfaces to read and manage such files files and directories.

Thanks to Christopher PeBenito for the useful suggestions that led to improved versions of the patch.

Compared to the previous version, this patch adds the ability to search the user home directories in the new interfaces.

---
 policy/modules/system/userdomain.fc |    1
 policy/modules/system/userdomain.if |   46 ++++++++++++++++++++++++++++++++++++
 policy/modules/system/userdomain.te |    3 ++
 3 files changed, 50 insertions(+)
policy/modules/system/userdomain.fc +1 -0
@@ -1,5 +1,6 @@
 HOME_DIR	-d	gen_context(system_u:object_r:user_home_dir_t,s0-mls_systemhigh)
 HOME_DIR/.+		gen_context(system_u:object_r:user_home_t,s0)
+HOME_DIR/\.pki(/.*)?	gen_context(system_u:object_r:user_cert_t,s0)
 
 /tmp/gconfd-USER -d	gen_context(system_u:object_r:user_tmp_t,s0)
 
policy/modules/system/userdomain.if +46 -0

58 lines not on this page · raw message

policy/modules/system/userdomain.te +3 -0
@@ -76,6 +76,9 @@ files_associate_tmp(user_home_t)
 files_poly_parent(user_home_t)
 files_mountpoint(user_home_t)
 
+type user_cert_t;
+userdom_user_home_content(user_cert_t)
+
 type user_devpts_t alias { staff_devpts_t sysadm_devpts_t secadm_devpts_t auditadm_devpts_t unconfined_devpts_t };
 dev_node(user_devpts_t)
 files_type(user_devpts_t)
#12 lore raw

PATCH v3 1/2 userdomain: introduce the user certificate file context (was miscfiles: introduce the user certificate file context)

Quoted 31 lines · Guido Trentalancia via refpolicy

Introduce a new file context for user certificates (user_cert_t) located in home directories.

Introduce new auxiliary interfaces to read and manage such files files and directories.

Thanks to Christopher PeBenito for the useful suggestions that led to improved versions of the patch.

Compared to the previous version, this patch adds the ability to search the user home directories in the new interfaces.

---
 policy/modules/system/userdomain.fc |    1
 policy/modules/system/userdomain.if |   46 ++++++++++++++++++++++++++++++++++++
 policy/modules/system/userdomain.te |    3 ++
 3 files changed, 50 insertions(+)
policy/modules/system/userdomain.fc +1 -0
@@ -1,5 +1,6 @@
 HOME_DIR	-d	gen_context(system_u:object_r:user_home_dir_t,s0-mls_systemhigh)
 HOME_DIR/.+		gen_context(system_u:object_r:user_home_t,s0)
+HOME_DIR/\.pki(/.*)?	gen_context(system_u:object_r:user_cert_t,s0)
 
 /tmp/gconfd-USER -d	gen_context(system_u:object_r:user_tmp_t,s0)
 

policy/modules/system/userdomain.if template(`userdom_base_user_template',` · line 113

Quoted 6 lines
policy/modules/system/userdomain.if +3 -0
@@ -108,6 +108,9 @@ template(`userdom_base_user_template',`
 
 	sysnet_read_config($1_t)
 
+	userdom_manage_user_certs($1_t)
+	userdom_user_home_dir_filetrans($1_t, user_cert_t, dir, ".pki")
+

should be implemented as part of "userdom_manage_home_role" instead, and the user should also be able to relabel this. also cert_home_t is a better name inho

Quoted 70 lines
policy/modules/system/userdomain.if +43 -0
 	tunable_policy(`allow_execmem',`
 		# Allow loading DSOs that require executable stack.
 		allow $1_t self:process execmem;
@@ -2340,6 +2343,49 @@ interface(`userdom_user_home_dir_filetra
 	files_search_home($1)
 ')
 
+########################################
+## <summary>
+##	Read user SSL certificates.
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain allowed access.
+##	</summary>
+## </param>
+## <rolecap/>
+#
+interface(`userdom_read_user_certs',`
+	gen_require(`
+		type user_cert_t;
+	')
+
+	allow $1 user_cert_t:dir list_dir_perms;
+	read_files_pattern($1, user_cert_t, user_cert_t)
+	read_lnk_files_pattern($1, user_cert_t, user_cert_t)
+	files_search_home($1)
+')
+
+########################################
+## <summary>
+##	Manage user SSL certificates.
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain allowed access.
+##	</summary>
+## </param>
+#
+interface(`userdom_manage_user_certs',`
+	gen_require(`
+		type user_cert_t;
+	')
+
+	manage_dirs_pattern($1, user_cert_t, user_cert_t)
+	manage_files_pattern($1, user_cert_t, user_cert_t)
+	manage_lnk_files_pattern($1, user_cert_t, user_cert_t)
+	files_search_home($1)
+')
+
 ########################################
 ## <summary>
 ##	Write to user temporary named sockets.
policy/modules/system/userdomain.te +3 -0
@@ -76,6 +76,9 @@ files_associate_tmp(user_home_t)
 files_poly_parent(user_home_t)
 files_mountpoint(user_home_t)
 
+type user_cert_t;
+userdom_user_home_content(user_cert_t)
+
 type user_devpts_t alias { staff_devpts_t sysadm_devpts_t secadm_devpts_t auditadm_devpts_t unconfined_devpts_t };
 dev_node(user_devpts_t)
 files_type(user_devpts_t)

_______________________________________________
refpolicy mailing list
refpolicy at oss.tresys.com
http://oss.tresys.com/mailman/listinfo/refpolicy

Signature · 11 lines
Key fingerprint = 5F4D 3CDB D3F8 3652 FBD8  02D5 3B6C 5F1D 2C7B 6B02
https://sks-keyservers.net/pks/lookup?op=get&search=0x3B6C5F1D2C7B6B02
Dominick Grift

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 648 bytes
Desc: OpenPGP digital signature
Url : http://oss.tresys.com/pipermail/refpolicy/attachments/20160906/00efb69f/attachment.bin 
#13 lore raw

PATCH v3 1/2 userdomain: introduce the user certificate file context (was miscfiles: introduce the user certificate file context)

Quoted 46 lines · Dominick Grift via refpolicy
Quoted 45 lines · Guido Trentalancia via refpolicy

Introduce a new file context for user certificates (user_cert_t) located in home directories.

Introduce new auxiliary interfaces to read and manage such files files and directories.

Thanks to Christopher PeBenito for the useful suggestions that led to improved versions of the patch.

Compared to the previous version, this patch adds the ability to search the user home directories in the new interfaces.

---
?policy/modules/system/userdomain.fc |????1
?policy/modules/system/userdomain.if |???46
++++++++++++++++++++++++++++++++++++
?policy/modules/system/userdomain.te |????3 ++
?3 files changed, 50 insertions(+)

--- refpolicy-git-orig/policy/modules/system/userdomain.fc 2
016-08-14 21:24:48.972382416 +0200
+++ refpolicy-git-user_cert_t/policy/modules/system/userdomain.fc

2016-09-06 15:53:44.822018010 +0200
(quoted diff) +0 -0
@@ -1,5 +1,6 @@

?HOME_DIR -d gen_context(system_u:object_r:user_home_
dir_t,s0-mls_systemhigh)
?HOME_DIR/.+ gen_context(system_u:object_r:user_home
_t,s0)
+HOME_DIR/\.pki(/.*)? gen_context(system_u:object_r:user_cer
t_t,s0)
?
?/tmp/gconfd-USER -d gen_context(system_u:object_r:user_tmp_
t,s0)
?
--- refpolicy-git-orig/policy/modules/system/userdomain.if 2
016-08-14 22:10:42.755848904 +0200
+++ refpolicy-git-user_cert_t/policy/modules/system/userdomain.if

2016-09-06 15:54:19.668611757 +0200
(quoted diff) +0 -0
@@ -108,6 +108,9 @@ template(`userdom_base_user_template',`

?
? sysnet_read_config($1_t)
?

policy/modules/system/userdomain.if +1 -0
+	userdom_manage_user_certs($1_t)
Quoted 8 lines
Quoted 3 lines
(quoted diff) +1 -0
+	userdom_user_home_dir_filetrans($1_t, user_cert_t, dir,

".pki")
+

should be implemented as part of "userdom_manage_home_role" instead, and
the user should also be able to relabel this. also cert_home_t is a better name inho

I really don't think it should be part of
the?"userdom_manage_home_role".

Perhaps, it could have been used to create a new "role" interface, but at the end I decided to leave it where it is now, because the system- wide certificates (miscfiles) are read from there (in order not to spread related permissions around).

Regards,

Guido

#14 lore raw

PATCH v3 1/2 userdomain: introduce the user certificate file context (was miscfiles: introduce the user certificate file context)

Quoted 56 lines · Guido Trentalancia via refpolicy
Quoted 45 lines · Dominick Grift via refpolicy
Quoted 44 lines · Guido Trentalancia via refpolicy

Introduce a new file context for user certificates (user_cert_t) located in home directories.

Introduce new auxiliary interfaces to read and manage such files files and directories.

Thanks to Christopher PeBenito for the useful suggestions that led to improved versions of the patch.

Compared to the previous version, this patch adds the ability to search the user home directories in the new interfaces.

---
 policy/modules/system/userdomain.fc |    1
 policy/modules/system/userdomain.if |   46
++++++++++++++++++++++++++++++++++++
 policy/modules/system/userdomain.te |    3 ++
 3 files changed, 50 insertions(+)

--- refpolicy-git-orig/policy/modules/system/userdomain.fc 2
016-08-14 21:24:48.972382416 +0200
+++ refpolicy-git-user_cert_t/policy/modules/system/userdomain.fc

2016-09-06 15:53:44.822018010 +0200
(quoted diff) +1 -0
@@ -1,5 +1,6 @@
 HOME_DIR	-d	gen_context(system_u:object_r:user_home_
 dir_t,s0-mls_systemhigh)
 HOME_DIR/.+		gen_context(system_u:object_r:user_home
 _t,s0)
+HOME_DIR/\.pki(/.*)?	gen_context(system_u:object_r:user_cer
 t_t,s0)

/tmp/gconfd-USER -d gen_context(system_u:object_r:user_tmp_
t,s0)

--- refpolicy-git-orig/policy/modules/system/userdomain.if 2
016-08-14 22:10:42.755848904 +0200
+++ refpolicy-git-user_cert_t/policy/modules/system/userdomain.if

2016-09-06 15:54:19.668611757 +0200
policy/modules/system/userdomain.if +0 -0
@@ -108,6 +108,9 @@ template(`userdom_base_user_template',`
 
 	sysnet_read_config($1_t)
 
Quoted 9 lines

policy/modules/system/userdomain.if template(`userdom_base_user_template',` · line 113

Quoted 4 lines
policy/modules/system/userdomain.if +3 -0
+	userdom_manage_user_certs($1_t)
+	userdom_user_home_dir_filetrans($1_t, user_cert_t, dir,
 ".pki")
+

should be implemented as part of "userdom_manage_home_role" instead, and
the user should also be able to relabel this. also cert_home_t is a better name inho

Quoted 7 lines

I really don't think it should be part of
the "userdom_manage_home_role".

Perhaps, it could have been used to create a new "role" interface, but at the end I decided to leave it where it is now, because the system- wide certificates (miscfiles) are read from there (in order not to spread related permissions around).

It should not be part of userdom_base_user_template(). That template is supposed to represent the minimum amount of rules for a user domain. It doesn't even have home dir access.

I can see it as part of userdom_manage_home_role(). I can also see it as part of a new template, though I don't think that it's probably worth it.

Signature · 1 line
Chris PeBenito
#15 lore raw

PATCH v4 1/2 userdomain: introduce the user certificate file context (was miscfiles: introduce the user certificate file context)

In reply to Guido Trentalancia

Introduce a new file context for user certificates (user_cert_t) located in home directories.

Introduce new auxiliary interfaces to read and manage such files files and directories.

Thanks to Christopher PeBenito for the useful suggestions that led to this improved version of the patch.

Compared to the previous version, this patch adds the ability to search the user home directories in the new interfaces.

---
 policy/modules/system/userdomain.fc |    1
 policy/modules/system/userdomain.if |   46 ++++++++++++++++++++++++++++++++++++
 policy/modules/system/userdomain.te |    3 ++
 3 files changed, 50 insertions(+)
policy/modules/system/userdomain.fc +1 -0
diff -pru refpolicy-git-orig/policy/modules/system/userdomain.fc refpolicy-git-user_cert_t/policy/modules/system/userdomain.fc
@@ -1,5 +1,6 @@
 HOME_DIR	-d	gen_context(system_u:object_r:user_home_dir_t,s0-mls_systemhigh)
 HOME_DIR/.+		gen_context(system_u:object_r:user_home_t,s0)
+HOME_DIR/\.pki(/.*)?	gen_context(system_u:object_r:user_cert_t,s0)
 
 /tmp/gconfd-USER -d	gen_context(system_u:object_r:user_tmp_t,s0)
 
policy/modules/system/userdomain.if +46 -0

58 lines not on this page · raw message

policy/modules/system/userdomain.te +3 -0
diff -pru refpolicy-git-orig/policy/modules/system/userdomain.te refpolicy-git-user_cert_t/policy/modules/system/userdomain.te
@@ -93,6 +93,9 @@ files_associate_tmp(user_home_t)
 files_poly_parent(user_home_t)
 files_mountpoint(user_home_t)
 
+type user_cert_t;
+userdom_user_home_content(user_cert_t)
+
 type user_devpts_t alias { staff_devpts_t sysadm_devpts_t secadm_devpts_t auditadm_devpts_t unconfined_devpts_t };
 dev_node(user_devpts_t)
 files_type(user_devpts_t)
#16 lore raw

PATCH v4 1/2 userdomain: introduce the user certificate file context (was miscfiles: introduce the user certificate file context)

Quoted 11 lines · Guido Trentalancia

Introduce a new file context for user certificates (user_cert_t) located in home directories.

Introduce new auxiliary interfaces to read and manage such files files and directories.

Thanks to Christopher PeBenito for the useful suggestions that led to this improved version of the patch.

Compared to the previous version, this patch adds the ability to search the user home directories in the new interfaces.

Merged.

Quoted 94 lines
---
 policy/modules/system/userdomain.fc |    1
 policy/modules/system/userdomain.if |   46 ++++++++++++++++++++++++++++++++++++
 policy/modules/system/userdomain.te |    3 ++
 3 files changed, 50 insertions(+)

diff -pru refpolicy-git-orig/policy/modules/system/userdomain.fc refpolicy-git-user_cert_t/policy/modules/system/userdomain.fc

policy/modules/system/userdomain.fc +1 -0
@@ -1,5 +1,6 @@
 HOME_DIR	-d	gen_context(system_u:object_r:user_home_dir_t,s0-mls_systemhigh)
 HOME_DIR/.+		gen_context(system_u:object_r:user_home_t,s0)
+HOME_DIR/\.pki(/.*)?	gen_context(system_u:object_r:user_cert_t,s0)
 
 /tmp/gconfd-USER -d	gen_context(system_u:object_r:user_tmp_t,s0)
 

diff -pru refpolicy-git-orig/policy/modules/system/userdomain.if refpolicy-git-user_cert_t/policy/modules/system/userdomain.if

policy/modules/system/userdomain.if +46 -0
@@ -246,6 +246,9 @@ interface(`userdom_manage_home_role',`
 	# cjp: this should probably be removed:
 	allow $2 user_home_dir_t:dir { manage_dir_perms relabel_dir_perms };
 
+	userdom_manage_user_certs($2)
+	userdom_user_home_dir_filetrans($2, user_cert_t, dir, ".pki")
+
 	tunable_policy(`use_nfs_home_dirs',`
 		fs_manage_nfs_dirs($2)
 		fs_manage_nfs_files($2)
@@ -2350,6 +2353,49 @@ interface(`userdom_user_home_dir_filetra
 	files_search_home($1)
 ')
 
+########################################
+## <summary>
+##	Read user SSL certificates.
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain allowed access.
+##	</summary>
+## </param>
+## <rolecap/>
+#
+interface(`userdom_read_user_certs',`
+	gen_require(`
+		type user_cert_t;
+	')
+
+	allow $1 user_cert_t:dir list_dir_perms;
+	read_files_pattern($1, user_cert_t, user_cert_t)
+	read_lnk_files_pattern($1, user_cert_t, user_cert_t)
+	files_search_home($1)
+')
+
+########################################
+## <summary>
+##	Manage user SSL certificates.
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain allowed access.
+##	</summary>
+## </param>
+#
+interface(`userdom_manage_user_certs',`
+	gen_require(`
+		type user_cert_t;
+	')
+
+	manage_dirs_pattern($1, user_cert_t, user_cert_t)
+	manage_files_pattern($1, user_cert_t, user_cert_t)
+	manage_lnk_files_pattern($1, user_cert_t, user_cert_t)
+	files_search_home($1)
+')
+
 ########################################
 ## <summary>
 ##	Write to user temporary named sockets.

diff -pru refpolicy-git-orig/policy/modules/system/userdomain.te refpolicy-git-user_cert_t/policy/modules/system/userdomain.te

policy/modules/system/userdomain.te +3 -0
@@ -93,6 +93,9 @@ files_associate_tmp(user_home_t)
 files_poly_parent(user_home_t)
 files_mountpoint(user_home_t)
 
+type user_cert_t;
+userdom_user_home_content(user_cert_t)
+
 type user_devpts_t alias { staff_devpts_t sysadm_devpts_t secadm_devpts_t auditadm_devpts_t unconfined_devpts_t };
 dev_node(user_devpts_t)
 files_type(user_devpts_t)
Signature · 1 line
Chris PeBenito