Skip to contentSkip to conversation

rules uptimed

DISCUSSION Carsten Grohmann 2 participants 4 messages Jun 18, 2003 – Jun 20, 2003 SELinux security module

lore
Share & tools
lore
#0 lore raw

I use the uptimed from unixcode.org/uptimed/ since a few months. I wrote the rules last days. Feel free to use it....

# uptimed
/etc/uptimed.conf               system_u:object_r:etc_uptimed_t
/usr/sbin/uptimed		system_u:object_r:uptimed_exec_t
/var/spool/uptimed(/.*)?        system_u:object_r:uptimed_spool_t
# uprecords
/usr/bin/uprecords              system_u:object_r:uprecords_exec_t

#DESC uptimed - a uptime daemon
#
# Author: Carsten Grohmann <[email protected]> #
# Date: 11. June 2003
#

#################################
#
# General Types
#

type etc_uptimed_t, file_type, sysadmfile;
type uptimed_spool_t, file_type, sysadmfile;

#################################
#
# Rules for the uptimed_t domain.
#
daemon_domain(uptimed, `,privmail') file_type_auto_trans(uptimed_t, var_spool_t, uptimed_spool_t) allow uptimed_t { etc_uptimed_t proc_t readable_t }:file { getattr read }; allow uptimed_t uptimed_spool_t:file create_file_perms;
allow uptimed_t self:unix_dgram_socket { create connect write };

# to send mail
can_exec(uptimed_t, shell_exec_t)
allow uptimed_t { bin_t sbin_t }:dir { search };
allow uptimed_t bin_t:lnk_file { read };
allow uptimed_t etc_runtime_t:file { getattr read };
allow uptimed_t self:fifo_file { getattr write };

#################################
#
# Rules for the uprecords_t domain.
#
user_application_domain(uprecords)
allow uprecords_t { etc_uptimed_t readable_t uptimed_spool_t }:file { getattr read }; allow uprecords_t { var_t var_spool_t uptimed_spool_t } :dir { search };
allow uprecords_t local_login_t:fd { use };
allow uprecords_t { user_tty_device_t sysadm_tty_device_t }:chr_file { getattr ioctl read write };

#1 lore raw
Quoted 2 lines · Carsten Grohmann

I use the uptimed from unixcode.org/uptimed/ since a few months. I wrote the rules last days. Feel free to use it....

I've attached a version with a few minor changes.

I use create_socket_perms because there's no reason for denying socket access to itself, it makes the policy clearer, and avoids the chance of the program having a branch that hasn't been used in your tests that needs some extra access.

For the "fd use" rule it's important to use "privfd" so that it can run from ssh logins etc, and also to use "ttyfile ptyfile" for the terminal types.

However the uprecords_t domain may be a bad idea. If you want to grant users read access to uptimed_spool_t then the following would do:
allow userdomain uptimed_spool_t:dir search;
allow userdomain uptimed_spool_t:file { getattr read };

This gives simpler policy and it avoids having a program that can be run by the user which can write to the administrator tty (which means that a bug in that program could permit further attacks on system security).

Another option would be to have a user_uprecords_t domain etc, but that is probably unnecessary and blows out the policy size.

The file u.te uses "allow userdomain" rules and is what I've put in my policy tree.

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 uptimed - a uptime daemon
#
# Author: Carsten Grohmann <[email protected]> #
# Date: 11. June 2003
#

#################################
#
# General Types
#

type etc_uptimed_t, file_type, sysadmfile;
type uptimed_spool_t, file_type, sysadmfile;

#################################
#
# Rules for the uptimed_t domain.
#
daemon_domain(uptimed, `,privmail') file_type_auto_trans(uptimed_t, var_spool_t, uptimed_spool_t) allow uptimed_t { etc_uptimed_t proc_t readable_t }:file { getattr read }; allow uptimed_t uptimed_spool_t:file create_file_perms;
allow uptimed_t self:unix_dgram_socket create_socket_perms;

# to send mail
can_exec(uptimed_t, shell_exec_t)
allow uptimed_t { bin_t sbin_t }:dir search;
allow uptimed_t bin_t:lnk_file read;
allow uptimed_t etc_runtime_t:file { getattr read };
allow uptimed_t self:fifo_file { getattr write };

#################################
#
# Rules for the uprecords_t domain.
#
user_application_domain(uprecords)
allow uprecords_t { etc_uptimed_t readable_t uptimed_spool_t }:file { getattr read }; allow uprecords_t { var_t var_spool_t uptimed_spool_t } :dir { search }; allow uprecords_t privfd:fd use;
allow uprecords_t { ttyfile ptyfile }:chr_file { getattr ioctl read write };

#DESC uptimed - a uptime daemon
#
# Author: Carsten Grohmann <[email protected]> #
# Date: 11. June 2003
#

#################################
#
# General Types
#

type etc_uptimed_t, file_type, sysadmfile;
type uptimed_spool_t, file_type, sysadmfile;

#################################
#
# Rules for the uptimed_t domain.
#
daemon_domain(uptimed, `,privmail') file_type_auto_trans(uptimed_t, var_spool_t, uptimed_spool_t) allow uptimed_t { etc_uptimed_t proc_t readable_t }:file { getattr read }; allow uptimed_t uptimed_spool_t:file create_file_perms;
allow uptimed_t self:unix_dgram_socket create_socket_perms;

# to send mail
can_exec(uptimed_t, shell_exec_t)
allow uptimed_t { bin_t sbin_t }:dir search;
allow uptimed_t bin_t:lnk_file read;
allow uptimed_t etc_runtime_t:file { getattr read };
allow uptimed_t self:fifo_file { getattr write };

allow userdomain uptimed_spool_t:dir search; allow userdomain uptimed_spool_t:file { getattr read };

#2 lore raw

Am Donnerstag, 19. Juni 2003 02:56 schrieb Russell Coker:

Quoted 5 lines · Carsten Grohmann
Quoted 2 lines

I use the uptimed from unixcode.org/uptimed/ since a few months. I wrote the rules last days. Feel free to use it....

I've attached a version with a few minor changes.

Thank you!

You could also replace readable_t with locale_t. The new policy from the CVS used it to label /etc/localtime.
The attached version should runs fine with the current policy. I've apply all of Russels suggestions.

# uptimed
/etc/uptimed.conf               system_u:object_r:etc_uptimed_t
/usr/sbin/uptimed		system_u:object_r:uptimed_exec_t
/var/spool/uptimed(/.*)?        system_u:object_r:uptimed_spool_t

#DESC uptimed - a uptime daemon
#
# Author: Carsten Grohmann <[email protected]> #
# Date: 19. June 2003
#

#################################
#
# General Types
#

type etc_uptimed_t, file_type, sysadmfile;
type uptimed_spool_t, file_type, sysadmfile;

#################################
#
# Rules for the uptimed_t domain.
#
daemon_domain(uptimed, `,privmail') file_type_auto_trans(uptimed_t, var_spool_t, uptimed_spool_t) allow uptimed_t { etc_uptimed_t proc_t locale_t }:file { getattr read }; allow uptimed_t uptimed_spool_t:file create_file_perms; allow uptimed_t self:unix_dgram_socket create_socket_perms;

# to send mail
can_exec(uptimed_t, shell_exec_t)
allow uptimed_t { bin_t sbin_t }:dir search;
allow uptimed_t bin_t:lnk_file read;
allow uptimed_t etc_runtime_t:file { getattr read };
allow uptimed_t self:fifo_file { getattr write };
# rules for uprecords - it runs in the user context
allow userdomain uptimed_spool_t:dir search;
allow userdomain uptimed_spool_t:file { getattr read };
#3 lore raw
Quoted 11 lines · Carsten Grohmann

Am Donnerstag, 19. Juni 2003 02:56 schrieb Russell Coker:

Quoted 5 lines · Carsten Grohmann
Quoted 2 lines

I use the uptimed from unixcode.org/uptimed/ since a few months. I wrote the rules last days. Feel free to use it....

I've attached a version with a few minor changes.

Thank you!

You could also replace readable_t with locale_t. The new policy from the CVS used it to label /etc/localtime.

I've changed that to:
r_dir_file(uptimed_t, locale_t)
There are directories and sym-links with the same type...

Signature · 10 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.