Skip to contentSkip to conversation

Adding a booleans.subs file to selinux policy.

PATCH Daniel J Walsh 2 participants 3 messages Mar 30, 2012 – Apr 2, 2012 SELinux security module

lore
Share & tools
lore
#0 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Basically I am sick of some of the bad names we chose for booleans when we were first writing policy, so I want a mechanism to allow us to change the names but still support the old names.

This patch will allow policy developers to ship a
/etc/selinux/targeted/contexts/booleans.subs

Then libselinux will check if a boolean name exists, if not it will see if there is a substitute name and attempt to use that.

I have attached the libselinux_bools-subs.patch and the first pass at what a booleans.subs file will look like in Fedora 18.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk912A4ACgkQrlYvE4MpobMrlgCfZxzuF2VoA19pnI0Uu6Ivn2zM Fd4AoI1Rvrk7z05siNDadM+FCS6U8Jsx
=ry7g
-----END PGP SIGNATURE-----

allow_auditadm_exec_content auditadm_exec_content allow_console_login login_console_enabled allow_cvs_read_shadow cvs_read_shadow allow_daemons_dump_core daemons_dump_core allow_daemons_use_tcp_wrapper daemons_use_tcp_wrapper allow_daemons_use_tty daemons_use_tty
allow_domain_fd_use domain_fd_use
allow_execheap selinuxuser_execheap
allow_execmod selinuxuser_execmod
allow_execstack selinuxuser_execstack allow_ftpd_anon_write ftpd_anon_write allow_ftpd_full_access ftpd_full_access allow_ftpd_use_cifs ftpd_use_cifs
allow_ftpd_use_nfs ftpd_use_nfs
allow_gssd_read_tmp gssd_read_tmp allow_guest_exec_content guest_exec_content allow_httpd_anon_write httpd_anon_write allow_httpd_mod_auth_ntlm_winbind httpd_mod_auth_ntlm_winbind allow_httpd_mod_auth_pam httpd_mod_auth_pam allow_httpd_sys_script_anon_write httpd_sys_script_anon_write allow_kerberos kerberos_enabled
allow_mplayer_execstack mplayer_execstack allow_mount_anyfile mount_anyfile
allow_nfsd_anon_write nfsd_anon_write allow_polyinstantiation polyinstantiation_enabled allow_postfix_local_write_mail_spool postfix_local_write_mail_spool allow_rsync_anon_write rsync_anon_write allow_saslauthd_read_shadow saslauthd_read_shadow allow_secadm_exec_content secadm_exec_content allow_smbd_anon_write smbd_anon_write
allow_ssh_keysign ssh_keysign
allow_staff_exec_content staff_exec_content allow_sysadm_exec_content sysadm_exec_content allow_user_exec_content user_exec_content allow_user_mysql_connect selinuxuser_mysql_connect_enabled allow_user_postgresql_connect selinuxuser_postgresql_connect_enabled allow_write_xshm xserver_clients_write_xshm allow_xguest_exec_content xguest_exec_content allow_xserver_execmem xserver_execmem
allow_ypbind nis_enabled
allow_zebra_write_config zebra_write_config user_direct_dri selinuxuser_direct_dri_enabled
user_ping selinuxuser_ping
user_share_music selinuxuser_share_music

libselinux/include/selinux/selinux.h +1 -0
index fbcd3ac..8e6f917 100644
@@ -515,6 +515,7 @@ extern const char *selinux_x_context_path(void);
 extern const char *selinux_sepgsql_context_path(void);
 extern const char *selinux_contexts_path(void);
 extern const char *selinux_securetty_types_path(void);
+extern const char *selinux_booleans_subs_path(void);
 extern const char *selinux_booleans_path(void);
 extern const char *selinux_customizable_types_path(void);
 extern const char *selinux_users_path(void);
libselinux/src/booleans.c +96 -31

174 lines not on this page · raw message

libselinux/src/file_path_suffixes.h +1 -0
index 0b00156..1aa4734 100644
@@ -25,3 +25,4 @@ S_(BINPOLICY, "/policy/policy")
     S_(FILE_CONTEXT_SUBS, "/contexts/files/file_contexts.subs")
     S_(FILE_CONTEXT_SUBS_DIST, "/contexts/files/file_contexts.subs_dist")
     S_(SEPGSQL_CONTEXTS, "/contexts/sepgsql_contexts")
+    S_(BOOLEAN_SUBS, "/booleans.subs")
libselinux/src/selinux_config.c +8 -1
index 907b004..2ffaa84 100644
@@ -47,7 +47,8 @@
 #define FILE_CONTEXT_SUBS 23
 #define SEPGSQL_CONTEXTS  24
 #define FILE_CONTEXT_SUBS_DIST 25
-#define NEL               26
+#define BOOLEAN_SUBS      26
+#define NEL               27
 
 /* Part of one-time lazy init */
 static pthread_once_t once = PTHREAD_ONCE_INIT;
@@ -442,6 +443,12 @@ const char *selinux_virtual_image_context_path(void)
 
 hidden_def(selinux_virtual_image_context_path)
 
+const char * selinux_booleans_subs_path(void) {
+	return get_path(BOOLEAN_SUBS);
+}
+
+hidden_def(selinux_booleans_subs_path)
+
 const char * selinux_file_context_subs_path(void) {
 	return get_path(FILE_CONTEXT_SUBS);
 }
libselinux/src/selinux_internal.h +1 -0
index 4db366a..8d752f7 100644
@@ -60,6 +60,7 @@ hidden_proto(selinux_mkload_policy)
     hidden_proto(security_setenforce)
     hidden_proto(security_deny_unknown)
     hidden_proto(selinux_binary_policy_path)
+    hidden_proto(selinux_booleans_subs_path)
     hidden_proto(selinux_current_policy_path)
     hidden_proto(selinux_default_context_path)
     hidden_proto(selinux_securetty_types_path)
#1 lore raw
Quoted 7 lines · Daniel J Walsh

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Basically I am sick of some of the bad names we chose for booleans when we were first writing policy, so I want a mechanism to allow us to change the names but still support the old names.

Quoted 8 lines

This patch will allow policy developers to ship a
/etc/selinux/targeted/contexts/booleans.subs

Then libselinux will check if a boolean name exists, if not it will see if there is a substitute name and attempt to use that.

I have attached the libselinux_bools-subs.patch and the first pass at what a booleans.subs file will look like in Fedora 18.

+static int bool_open(const char *name, int flag) {
    ...

+
+ len = strlen(name) + strlen(selinux_mnt) + sizeof(SELINUX_BOOL_DIR);
Calling strlen() on NULL is not valid C, IIRC.

+ snprintf(fname, len, "%s%s%s", selinux_mnt, SELINUX_BOOL_DIR, name);
Silent truncation?

Should work under benign conditions. Will probably fail in a hostile environment.

Jeff

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#2 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 26 lines · Jeffrey Walton
Quoted 6 lines · Daniel J Walsh

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1

Basically I am sick of some of the bad names we chose for booleans when we were first writing policy, so I want a mechanism to allow us to change the names but still support the old names.

Quoted 8 lines

This patch will allow policy developers to ship a
/etc/selinux/targeted/contexts/booleans.subs

Then libselinux will check if a boolean name exists, if not it will see if there is a substitute name and attempt to use that.

I have attached the libselinux_bools-subs.patch and the first pass at what a booleans.subs file will look like in Fedora 18.

+static int bool_open(const char *name, int flag) { ... + + len =
strlen(name) + strlen(selinux_mnt) + sizeof(SELINUX_BOOL_DIR); Calling strlen() on NULL is not valid C, IIRC.

libselinux/src/booleans.c +1 -0
+	snprintf(fname, len, "%s%s%s", selinux_mnt, SELINUX_BOOL_DIR, name); 

Silent truncation?

Should work under benign conditions. Will probably fail in a hostile environment.

Quoted 6 lines

Jeff

-- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

Ok adding

	if (!name) {
		errno = EINVAL;
		return fd;
	}

At the beginning of bool_open.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk95wqAACgkQrlYvE4MpobOW1gCfWqW9HitmVXgRBG5CVMJRi8U6 AqUAmwT5g4X4Q5TNWAjwdvTuXe/+7Fgn
=L56v
-----END PGP SIGNATURE-----

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.