patch to automount
okay.
this one requires some explanation.
i modified the usb-mount script i found [google search] to, instead of manually mounting and unmounting the drive, to update autofs files, do an /etc/init.d/autofs reload, that sort of thing.
by adding an entry into /etc/autofs.master with a timeout of 2 seconds, the age-old problem under linux of "oo, you muuust force the user to unmount the driiive" which is just such total bullshit _no_ sane ordinary computer user gives a monkeys about umount, well this problem just ... goes away [and becomes autofs's problem :)]
in order to avoid having to give [my new] usbmount.te permission to write to /etc, which i didn't want to do, i instead have made a separate filetype for /etc/auto.usb, /etc/auto.misc and /etc/auto.net.
now i feel sure that someone else will think of better ways to do this however here is at least a step in the right direction.
if anyone actually _wants_ the usbmount.te policy i wrote, let me know. it's not very good, it involves hacks to hotplug.te as well, but hey, ItWorks(tm).
l.
Signature · 7 lines
-- Truth, honesty and respect are rare commodities that all spring from the same well: Love. If you love yourself and everyone and everything around you, funnily and coincidentally enough, life gets a lot better. -- <a href="http://lkcl.net"> lkcl.net </a> <br /> <a href="mailto:[email protected]"> [email protected] </a> <br />
domains/program/automount.te +4 -3
@@ -15,6 +15,7 @@ allow automount_t urandom_device_t:chr_file read; type autofs_t, fs_type, root_dir_type, sysadmfile; +type automount_etc_t, fs_type, sysadmfile; # for if the mount point is not labelled allow automount_t file_t:dir getattr;
@@ -24,7 +25,7 @@ allow automount_t fs_type:dir getattr; allow autofs_t self:filesystem associate; -allow automount_t { etc_t etc_runtime_t }:file { getattr read }; +allow automount_t { automount_etc_t etc_t etc_runtime_t }:file { getattr read }; allow automount_t proc_t:file { getattr read }; allow automount_t self:process { setpgid setsched }; allow automount_t self:capability { sys_nice };
@@ -32,7 +33,7 @@ allow automount_t self:unix_dgram_socket create_socket_perms; # because config files can be shell scripts -can_exec(automount_t, etc_t) +can_exec(automount_t, automount_etc_t) can_network(automount_t) can_ypbind(automount_t)
@@ -65,5 +66,5 @@ allow kernel_t autofs_t:dir { getattr ioctl read search }; allow automount_t home_root_t:dir { getattr }; -allow automount_t mnt_t:dir { getattr }; +allow automount_t mnt_t:dir { getattr search };
domains/program/initrc.te +24 -0
@@ -312,3 +312,27 @@ # allow initrc_t security_t:dir { getattr search }; allow initrc_t security_t:file { getattr read }; + + + + + + + + + + + + + + + + + + +allow initrc_t automount_etc_t:file { getattr }; + #EXE=/bin/bash PATH=/etc/auto.misc : getattr + #EXE=/bin/bash PATH=/etc/auto.misc : getattr + #EXE=/bin/bash PATH=/etc/auto.usb : getattr + #EXE=/bin/bash PATH=/etc/auto.usb : getattr +
file_contexts/program/automount.fc +3 -0
@@ -2,3 +2,6 @@ /usr/sbin/automount -- system_u:object_r:automount_exec_t /etc/apm/event\.d/autofs -- system_u:object_r:automount_exec_t /var/run/autofs(/.*)? system_u:object_r:automount_var_run_t +/etc/auto.misc -- system_u:object_r:automount_etc_t +/etc/auto.net -- system_u:object_r:automount_etc_t +/etc/auto.usb -- system_u:object_r:automount_etc_t
Quoted 8 lines · Luke Kenneth Casson Leighton
okay.
this one requires some explanation.
i modified the usb-mount script i found [google search] to, instead of manually mounting and unmounting the drive, to update autofs files, do an
/etc/init.d/autofsreload, that sort of thing.
I've updated the policy in my tree to do things similar to what you are doing.
I've attached the files.
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
#DESC Automount - Automount daemon
#
# Authors: Stephen Smalley <[email protected]> # Modified by Russell Coker <[email protected]> # X-Debian-Packages: amd am-utils autofs
#
#################################
#
# Rules for the automount_t domain.
#daemon_domain(automount)
etc_domain(automount)
# for SSP allow automount_t urandom_device_t:chr_file read;
# for if the mount point is not labelled allow automount_t file_t:dir getattr; allow automount_t default_t:dir getattr;
allow automount_t autofs_t:dir { create_dir_perms ioctl }; allow automount_t fs_type:dir getattr;
allow automount_t { etc_t etc_runtime_t }:file { getattr read }; allow automount_t proc_t:file { getattr read };
allow automount_t self:process { setpgid setsched }; allow automount_t self:capability { sys_nice };
allow automount_t self:unix_stream_socket create_socket_perms; allow automount_t self:unix_dgram_socket create_socket_perms;
# because config files can be shell scripts
can_exec(automount_t, { etc_t automount_etc_t })can_network(automount_t)can_ypbind(automount_t)
ifdef(fsadm.te', domain_auto_trans(automount_t, fsadm_exec_t, fsadm_t) ')
lock_domain(automount)
tmp_domain(automount)
allow automount_t self:fifo_file rw_file_perms;
# Run mount in the mount_t domain. domain_auto_trans(automount_t, mount_exec_t, mount_t) allow mount_t autofs_t:dir { search mounton read }; allow mount_t automount_tmp_t:dir mounton;
ifdef(`apmd.te',
`domain_auto_trans(apmd_t, automount_exec_t, automount_t) can_exec(automount_t, bin_t)')
allow automount_t { bin_t sbin_t }:dir search;can_exec(automount_t, mount_exec_t)
allow mount_t autofs_t:dir getattr;
dontaudit automount_t var_t:dir write;
allow userdomain autofs_t:dir r_dir_perms;
allow kernel_t autofs_t:dir { getattr ioctl read search };
allow automount_t home_root_t:dir { getattr };
allow automount_t mnt_t:dir { getattr search };
allow initrc_t automount_etc_t:file getattr;
# automount /usr/sbin/automount -- system_u:object_r:automount_exec_t /etc/apm/event\.d/autofs -- system_u:object_r:automount_exec_t /var/run/autofs(/.*)? system_u:object_r:automount_var_run_t /etc/auto\..+ -- system_u:object_r:automount_etc_t