Gentoo-specific initrc
Subsystems (2)
PATCH 1/1 Gentoo-specific initrc
Here's a patch for Gentoo-specific initrc, against sourceforge CVS.
domains/program/initrc.te | 15 +++++++++++++++ file_contexts/program/initrc.fc | 8 ++++++++ 2 files changed, 23 insertions(+)
Signature · 8 lines
Chris PeBenito <[email protected]> Developer, Hardened Gentoo Linux Embedded Gentoo Linux Public Key: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0xE6AF9243 Key fingerprint = B0E6 877A 883F A57A 8E6A CB00 BC8E E42D E6AF 9243
Index: domains/program/initrc.te
===================================================================
RCS file: /cvsroot/selinux/nsa/selinux-usr/policy/domains/program/initrc.te,v retrieving revision 1.28
program/initrc.te +15 -0
@@ -319,3 +319,18 @@ ifdef(`dbusd.te', ` allow initrc_t system_dbusd_t:dbus { send_msg acquire_svc }; ') + +ifdef(`distro_gentoo', ` +# gentoo-specific init script state +type initrc_state_t, file_type, sysadmfile; +allow initrc_t initrc_state_t:lnk_file { create read unlink setattr }; +allow initrc_t initrc_state_t:file create_file_perms; +allow initrc_t initrc_state_t:dir { add_name remove_name read write rmdir create rename setattr }; + +# env-update: +allow initrc_t etc_runtime_t:dir read; +allow initrc_t etc_runtime_t:file unlink; + +# Gentoo integrated run_init+open_init_pty-runscript: +domain_auto_trans(sysadm_t,initrc_exec_t,run_init_t) +')
Index: file_contexts/program/initrc.fc
===================================================================
RCS file: /cvsroot/selinux/nsa/selinux-usr/policy/file_contexts/program/initrc.fc,v retrieving revision 1.7
program/initrc.fc +8 -0
@@ -11,6 +11,14 @@ /var/run/runlevel\.dir system_u:object_r:initrc_var_run_t /var/run/random-seed -- system_u:object_r:initrc_var_run_t /var/run/setmixer_flag -- system_u:object_r:initrc_var_run_t + +ifdef(`distro_gentoo', ` +/sbin/rc -- system_u:object_r:initrc_exec_t +/sbin/runscript -- system_u:object_r:initrc_exec_t +/sbin/runscript.sh -- system_u:object_r:initrc_exec_t +/var/lib/init.d(/.*)? system_u:object_r:initrc_state_t +') + # run_init /usr/sbin/run_init -- system_u:object_r:run_init_exec_t ifdef(`distro_debian', `
Quoted 1 line · Chris PeBenito
Here's a patch for Gentoo-specific initrc, against sourceforge CVS.
+allow initrc_t initrc_state_t:lnk_file { create read unlink setattr }; +allow initrc_t initrc_state_t:file create_file_perms;
+allow initrc_t initrc_state_t:dir { add_name remove_name read write rmdir create rename setattr };
Why not create_dir_file(initrc_t, initrc_state_t)? It does the same things and is easier to read.
+allow initrc_t etc_runtime_t:dir read;
Your patch doesn't include any .fc entries to label a directory as etc_runtime_t. Also the only reference to etc_runtime_t:dir in the CVS seems to be in macros/program/rssh_macros.te (a bug in rssh_macros.te, I've attached a patch to fix it).
It seems that your patch is incomplete in this regard.
+domain_auto_trans(sysadm_t,initrc_exec_t,run_init_t)
This isn't something I expected, I'm not sure if it's desirable to do it like that but I can't think of any better way. Steve, what do you think about this?
The initrc_state_t stuff is something that will get more general use I think. In both Debian and Fedora there is work on making machines boot from CD-ROM which needs such things. Is that what it's being used for in Gentoo?
Your patch is good, but I think we need to think about making it more generic before putting it in CVS. Probably making the CVS policy more like what you are doing in Gentoo in some ways will be better for everyone.
Signature · 4 lines
http://www.coker.com.au/selinux/ My NSA Security Enhanced Linux packages http://www.coker.com.au/bonnie++/ Bonnie++ hard drive benchmark http://www.coker.com.au/postal/ Postal SMTP/POP benchmark http://www.coker.com.au/~russell/ My home page
program/rssh_macros.te renamed from usr/src/se/policy/macros/program/rssh_macros.te +1 -1
@@ -27,7 +27,7 @@ base_file_read_access(rssh_$1_t); allow rssh_$1_t var_t:dir r_dir_perms; r_dir_file(rssh_$1_t, etc_t); -r_dir_file(rssh_$1_t, etc_runtime_t); +allow rssh_$1_t etc_runtime_t:file { getattr read }; r_dir_file(rssh_$1_t, locale_t); can_exec(rssh_$1_t, bin_t);
Quoted 10 lines · Russell Coker
Quoted 1 line · Chris PeBenito
Here's a patch for Gentoo-specific initrc, against sourceforge CVS.
(quoted diff) +3
-0+allow initrc_t initrc_state_t:lnk_file { create read unlink setattr }; +allow initrc_t initrc_state_t:file create_file_perms; +allow initrc_t initrc_state_t:dir { add_name remove_name read write rmdircreate rename setattr };
Why not
create_dir_file(initrc_t, initrc_state_t)? It does the same things and is easier to read.
Well I wrote this a long time ago, and thats a new macro. Its that way because its least privilege. Ok, the middle line isn't exactly least, but close, whereas the last line is half the possible permissions. However, I guess if other distros are going to start using state info, as you say later in the email, then it should be generalized to create_dir_file.
Quoted 4 lines
+allow
initrc_tetc_runtime_t:dir read;Your patch doesn't include any .fc entries to label a directory as
etc_runtime_t.
This is going to appear in my types.fc patch. The directory I'm referring to is not specific to initrc.
Quoted 5 lines
+domain_auto_trans(sysadm_t,initrc_exec_t,run_init_t)
This isn't something I expected, I'm not sure if it's desirable to do it like that but I can't think of any better way. Steve, what do you think about this?
Since run_init is integrated into our init script interpreter, there is afaik no other way to get into run_init_t since the scripts are run as usual (/etc/init.d/foo start).
Quoted 3 lines
The
initrc_state_tstuff is something that will get more general use I think. In both Debian and Fedora there is work on making machines boot from CD-ROM which needs such things. Is that what it's being used for in Gentoo?
It stores state and dependency info for the init scripts.
Quoted 3 lines
Your patch is good, but I think we need to think about making it more generic before putting it in CVS. Probably making the CVS policy more like what you are doing in Gentoo in some ways will be better for everyone.
Signature · 8 lines
Chris PeBenito <[email protected]> Developer, Hardened Gentoo Linux Embedded Gentoo Linux Public Key: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0xE6AF9243 Key fingerprint = B0E6 877A 883F A57A 8E6A CB00 BC8E E42D E6AF 9243
Quoted 7 lines · Chris PeBenito
Quoted 4 lines
+allow
initrc_tetc_runtime_t:dir read;Your patch doesn't include any .fc entries to label a directory as
etc_runtime_t.This is going to appear in my types.fc patch. The directory I'm referring to is not specific to initrc.
What is the purpose of a etc_runtime_t directory? Currently any process that can create files as etc_runtime_t can write to a directory labelled as etc_t. Are you planning to change that?
Quoted 9 lines
Quoted 5 lines
+domain_auto_trans(sysadm_t,initrc_exec_t,run_init_t)
This isn't something I expected, I'm not sure if it's desirable to do it like that but I can't think of any better way. Steve, what do you think about this?
Since
run_initis integrated into our init script interpreter, there is afaik no other way to get intorun_init_tsince the scripts are run as usual (/etc/init.d/foostart).
Yes.
Signature · 9 lines
http://www.coker.com.au/selinux/ My NSA Security Enhanced Linux packages http://www.coker.com.au/bonnie++/ Bonnie++ hard drive benchmark http://www.coker.com.au/postal/ Postal SMTP/POP benchmark http://www.coker.com.au/~russell/ My home page -- 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.
Quoted 11 lines · Russell Coker
Quoted 7 lines · Chris PeBenito
Quoted 4 lines
+allow
initrc_tetc_runtime_t:dir read;Your patch doesn't include any .fc entries to label a directory as
etc_runtime_t.This is going to appear in my types.fc patch. The directory I'm referring to is not specific to initrc.
What is the purpose of a
etc_runtime_tdirectory? Currently any process that can create files asetc_runtime_tcan write to a directory labelled asetc_t.
Good point, I'll send an updated patch when sourceforge cvs starts responding again for me. I guess I got a little overzealous on the labeling.
Quoted 1 line
Are you planning to change that?
No, unless I can think of (or someone tells me) a reason to do that.
Signature · 8 lines
Chris PeBenito <[email protected]> Developer, Hardened Gentoo Linux Embedded Gentoo Linux Public Key: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0xE6AF9243 Key fingerprint = B0E6 877A 883F A57A 8E6A CB00 BC8E E42D E6AF 9243
Quoted 6 lines · Chris PeBenito
Quoted 2 lines
What is the purpose of a
etc_runtime_tdirectory? Currently any process that can create files asetc_runtime_tcan write to a directory labelled asetc_t.Good point, I'll send an updated patch when sourceforge cvs starts responding again for me. I guess I got a little overzealous on the labeling.
Here's the updated patch, against CVS.
Signature · 3 lines
Chris PeBenito Tresys Technology, LLC (410) 290-1411 x150
Index: domains/program/initrc.te
===================================================================
RCS file: /cvsroot/selinux/nsa/selinux-usr/policy/domains/program/initrc.te,v retrieving revision 1.28
program/initrc.te +9 -0
@@ -319,3 +319,12 @@ ifdef(`dbusd.te', ` allow initrc_t system_dbusd_t:dbus { send_msg acquire_svc }; ') + +# init script state +type initrc_state_t, file_type, sysadmfile; +create_dir_file(initrc_t,initrc_state_t) + +ifdef(`distro_gentoo', ` +# Gentoo integrated run_init+open_init_pty-runscript: +domain_auto_trans(sysadm_t,initrc_exec_t,run_init_t) +')
Index: file_contexts/program/initrc.fc
===================================================================
RCS file: /cvsroot/selinux/nsa/selinux-usr/policy/file_contexts/program/initrc.fc,v retrieving revision 1.7
program/initrc.fc +10 -2
@@ -11,6 +11,14 @@ /var/run/runlevel\.dir system_u:object_r:initrc_var_run_t /var/run/random-seed -- system_u:object_r:initrc_var_run_t /var/run/setmixer_flag -- system_u:object_r:initrc_var_run_t + +ifdef(`distro_gentoo', ` +/sbin/rc -- system_u:object_r:initrc_exec_t +/sbin/runscript -- system_u:object_r:initrc_exec_t +/sbin/runscript.sh -- system_u:object_r:initrc_exec_t +/var/lib/init.d(/.*)? system_u:object_r:initrc_state_t +') + # run_init /usr/sbin/run_init -- system_u:object_r:run_init_exec_t ifdef(`distro_debian', `
@@ -19,6 +27,6 @@ /etc/nologin.* -- system_u:object_r:etc_runtime_t /etc/nohotplug -- system_u:object_r:etc_runtime_t ifdef(`distro_redhat', ` -/halt -- system_u:object_r:etc_runtime_t -/\.autofsck -- system_u:object_r:etc_runtime_t +/halt -- system_u:object_r:etc_runtime_t +/\.autofsck -- system_u:object_r:etc_runtime_t ')
Merged.
Quoted 9 lines · Christopher J. PeBenito
Quoted 6 lines · Chris PeBenito
Quoted 2 lines
What is the purpose of a
etc_runtime_tdirectory? Currently any process that can create files asetc_runtime_tcan write to a directory labelled asetc_t.Good point, I'll send an updated patch when sourceforge cvs starts responding again for me. I guess I got a little overzealous on the labeling.
Here's the updated patch, against CVS.
Signature · 7 lines
James Carter <[email protected]> National Security Agency -- 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.