All of lore.kernel.org
 help / color / mirror / Atom feed
* Additional rule files
@ 2004-09-04  1:12 Erich Schubert
  2004-09-05 10:19 ` Russell Coker
                   ` (3 more replies)
  0 siblings, 4 replies; 14+ messages in thread
From: Erich Schubert @ 2004-09-04  1:12 UTC (permalink / raw)
  To: selinux


[-- Attachment #1.1: Type: text/plain, Size: 1616 bytes --]

Attached is a set of additional rule files.
No diffs, because there are no rules yet in CVS for these.

First there are rule files for pptpd (poptop).

The next two rule sets are for the statistic tools "bindgraph" and
"mailgraph". The first parses bind query logs and does nice graphs out
of them, the second does the same for postfix+amavis logs.

Fourth rule set if for using the "fnord" web server with "tcpsvd"
(of the ipsvd package. very lightweight.)
I'd suggest only including this rule file in some "examples" section,
since you'll most probably need to adopt it to your wishes. For example
i havn't set up logging with this fnord installation, so no multilog
things are included (that would kind of require running it with
runit/minit/daemontools or such, which i am not)

But when writing this rule i encountered a small problem with current
policy WRT web files: it's very apache-centric.

For example the /var/www directory is only labeled when apache is
defined. Even the http_port_t is only used when apache is there.
IMHO these web-server-general things should be put into a web-server
domain. Maybe (except for the setuid/setgid/chroot part) i could even
use this generic web server domain for fnord, too.
But at least the general types for web files, cgi, ports should be
separated from the apache stuff.


Greetings,
Erich Schubert
-- 
     erich@(vitavonni.de|debian.org)    --    GPG Key ID: 4B3A135C     (o_
 A man doesn't know what he knows until he knows what he doesn't know. //\
   Wie kann ich wissen, was ich denke, bevor ich höre, was ich sage.   V_/_

[-- Attachment #1.2: bindgraph.fc --]
[-- Type: text/plain, Size: 337 bytes --]

# bindgraph
/var/lib/bindgraph(/.*)?	system_u:object_r:bindgraph_lib_t
/usr/sbin/bindgraph.pl	--	system_u:object_r:bindgraph_exec_t
/usr/lib/cgi-bin/bindgraph.cgi	--	system_u:object_r:bindgraph_cgi_exec_t
/var/run/bindgraph\.pid		system_u:object_r:bindgraph_var_run_t
/var/cache/bindgraph(/.*)?	system_u:object_r:bindgraph_cache_t

[-- Attachment #1.3: bindgraph.te --]
[-- Type: text/plain, Size: 1529 bytes --]

#DESC BINDGRAPH - bind statistics graph tool
# Authors:  Erich Schubert <erich@debian.org>
# X-Debian-Packages: bindgraph
#

daemon_domain(bindgraph)
daemon_domain(bindgraph_cgi)
# lib is for the RRD files (data gathered)
type bindgraph_lib_t, file_type, sysadmfile;
# the cache is storing generated images
type bindgraph_cache_t, file_type, sysadmfile;

# started by initrc_t
domain_auto_trans(initrc_t, bindgraph_exec_t, bindgraph_t)
# maybe the same pid file removal rule is needed as for mailgraph?

# read log files
r_dir_file(bindgraph_t, var_log_t)

# write own lib files (RRD files)
allow bindgraph_t var_lib_t:dir search;
create_dir_file(bindgraph_t, bindgraph_lib_t)
# the cgi may only read the RRD files
r_dir_file(bindgraph_cgi_t, bindgraph_lib_t)

# cgi can write in cache
create_dir_file(bindgraph_cgi_t, bindgraph_cache_t)
allow bindgraph_cgi_t var_lib_t:dir search;

# perl behaviour
allow { bindgraph_t bindgraph_cgi_t } { bin_t sbin_t }:dir { search getattr };
r_dir_file({ bindgraph_t bindgraph_cgi_t }, usr_t)
allow { bindgraph_t bindgraph_cgi_t } { random_device_t urandom_device_t }:chr_file read;

# cgi can be executed by web servers
# this is the execution rule for fnord
ifdef(`fnord-tcpsvd.te', `
can_exec_any(http_request_t)
domain_auto_trans(http_request_t, bindgraph_cgi_exec_t, bindgraph_cgi_t)
allow bindgraph_cgi_t tcpsvd_fnord_t:fd use;
allow bindgraph_cgi_t http_request_t:fifo_file { read write };
r_dir_file(bindgraph_cgi_t, httpd_sys_content_t)
')

[-- Attachment #1.4: fnord-tcpsvd.fc --]
[-- Type: text/plain, Size: 385 bytes --]

# web files
# this is mostly a local thing, but i believe the same as apache.fc uses?
/var/www(/.*)?			system_u:object_r:httpd_sys_content_t

# again, the pid file is a local thing, dependant on the startup script
# but there is no default startup script, not even an example
# included in the debian package.
/var/run/fnord-tcpsvd.pid	system_u:object_r:tcpsvd_fnord_var_run_t

[-- Attachment #1.5: fnord-tcpsvd.te --]
[-- Type: text/plain, Size: 2540 bytes --]

#DESC tcpsvd and fnord - tiny and fast web server
#
# Authors:  Erich Schubert <erich@debian.org>
# X-Debian-Packages: ipsvd fnord
#

# the http port itself
# had to redefine it, because it is in the apache.te file
# which i do not use.
type http_port_t, port_type;

# the web files
type httpd_sys_content_t, file_type, homedirfile, sysadmfile;

# domain for the server
daemon_domain(tcpsvd_fnord)
domain_auto_trans(initrc_t, tcpsvd_fnord_exec_t, tcpsvd_fnord_t)

# domain for request
type http_request_t, domain, privlog;
role system_r types http_request_t;

# the server can network
can_network(tcpsvd_fnord_t)
allow tcpsvd_fnord_t etc_t:file { getattr read ioctl };
allow tcpsvd_fnord_t http_port_t:tcp_socket name_bind;
allow http_request_t tcpsvd_fnord_t:tcp_socket setopt;
# tcpsvd will try to reverse-lookup the host
allow tcpsvd_fnord_t port_t:udp_socket name_bind;

# installation location of fnord
can_exec(tcpsvd_fnord_t, sbin_t)
can_exec(tcpsvd_fnord_t, bin_t)

# Use capabilities (tcpsvd will setuid/setgid).
allow tcpsvd_fnord_t self:unix_stream_socket create_socket_perms;
allow tcpsvd_fnord_t self:capability { setuid setgid net_bind_service };

# initrc can write pid file
allow initrc_t tcpsvd_fnord_var_run_t:file create_file_perms;

# allow any domain to connect to the web server
can_tcp_connect(userdomain, http_port_t)

allow tcpsvd_fnord_t { bin_t sbin_t }:dir search;
allow tcpsvd_fnord_t { bin_t sbin_t }:lnk_file read;

# transition to request type upon execution of
# the fnord web server (add bin_t here if fnord is labeled bin_t for you)
# i see no reason for that, but in debian it is installed in sbin
domain_auto_trans(tcpsvd_fnord_t, sbin_t, http_request_t)
allow tcpsvd_fnord_t http_request_t:process sigkill;

# daemon can change to web dir
allow tcpsvd_fnord_t { var_t httpd_sys_content_t }:dir r_dir_perms;
# request can read web files
r_dir_file(http_request_t, httpd_sys_content_t)
allow http_request_t null_device_t:chr_file { r_file_perms write };

# request can talk to tcp server
allow http_request_t tcpsvd_fnord_t:tcp_socket { read write };

# server can chroot itself to the request dir
allow http_request_t root_t:dir search;
allow http_request_t self:capability { sys_chroot };

# server can launch cgi and/or htaccess helper
allow http_request_t self:process { fork signal sigchld };
allow http_request_t self:fifo_file { read write };

# ignore violations
dontaudit { tcpsvd_fnord_t http_request_t } initrc_t:fd use;

[-- Attachment #1.6: mailgraph.fc --]
[-- Type: text/plain, Size: 301 bytes --]

# mailgraph
/usr/sbin/mailgraph.pl  --      system_u:object_r:mailgraph_exec_t
/usr/lib/cgi-bin/mailgraph.cgi  --      system_u:object_r:mailgraph_cgi_exec_t
/var/run/mailgraph\.pid         system_u:object_r:mailgraph_var_run_t
/var/cache/mailgraph(/.*)?      system_u:object_r:mailgraph_cache_t

[-- Attachment #1.7: mailgraph.te --]
[-- Type: text/plain, Size: 1598 bytes --]

#DESC MAILGRAPH - postfix/amavis statistics graph tool
# Authors: Erich Schubert <erich@debian.org>
# X-Debian-Packages: mailgraph
#

daemon_domain(mailgraph)
daemon_domain(mailgraph_cgi)
# mailgraph uses the cache for both RRD and graphics
# a split would be nice, maybe i'll do this in a diff later on
# (RRD files have the .rrd extension)
type mailgraph_cache_t, file_type, sysadmfile;

# started by initrc_t
domain_auto_trans(initrc_t, mailgraph_exec_t, mailgraph_t)
# for pid file
allow initrc_t mailgraph_var_run_t:file { getattr read write unlink };

# read log files (needed: mail.log)
r_dir_file(mailgraph_t, var_log_t)

# write own cache files
create_dir_file(mailgraph_t, mailgraph_cache_t)
create_dir_file(mailgraph_cgi_t, mailgraph_cache_t)

# perl behaviour
allow { mailgraph_t mailgraph_cgi_t } { bin_t sbin_t }:dir { search getattr };
r_dir_file({ mailgraph_t mailgraph_cgi_t }, usr_t)
allow { mailgraph_t mailgraph_cgi_t } { random_device_t urandom_device_t }:chr_file read;

# unsure what this is needed for. perl?
# maybe dontaudit is possible, havn't investigated that yet
# (and i'm not sure i've understood what these capabilities are)
allow mailgraph_t self:capability { dac_override dac_read_search };

# can be executed by fnord web server
ifdef(`fnord-tcpsvd.te', `
can_exec_any(http_request_t)
domain_auto_trans(http_request_t, mailgraph_cgi_exec_t, mailgraph_cgi_t)
allow mailgraph_cgi_t tcpsvd_fnord_t:fd use;
allow mailgraph_cgi_t http_request_t:fifo_file { read write };
r_dir_file(mailgraph_cgi_t, httpd_sys_content_t)
')


[-- Attachment #1.8: pptp.fc --]
[-- Type: text/plain, Size: 276 bytes --]

# pptpd
/usr/sbin/pptpd		--	system_u:object_r:pptpd_exec_t
/usr/sbin/pptpctrl	--	system_u:object_r:pptpd_exec_t
/usr/sbin/bcrelay	--	system_u:object_r:pptpd_exec_t
/etc/pptpd.conf		--	system_u:object_r:pptpd_etc_t
/var/run/pptpd.pid	--	system_u:object_r:pptpd_var_run_t

[-- Attachment #1.9: pptp.te --]
[-- Type: text/plain, Size: 1321 bytes --]

#DESC poptop - PPTP daemon
#
# Author:  Erich Schubert
# X-Debian-Packages: pptp
#

#################################
#
# Rules for the pptpd_t domain, et al.
#
# pptpd_t is the domain for the pptpd program.
# pptpd_exec_t is the type of the pptpd executable.
#
daemon_domain(pptpd)
etc_domain(pptpd)

# can execute own apps (pptpctrl)
can_exec(pptpd_t, pptpd_exec_t)

# Use the network.
can_network(pptpd_t)
allow pptpd_t self:capability { net_raw };
allow pptpd_t pptpd_t:unix_dgram_socket create_socket_perms;
allow pptpd_t { node_t pptpd_t }:rawip_socket { create_socket_perms node_bind };
allow pptpd_t { pptpd_t port_t}:tcp_socket { create_socket_perms name_bind };

can_create_pty(pptpd)

# find and execute pppd
allow pptpd_t sbin_t:dir { search };
can_exec(pptpd_t, pppd_exec_t)
domain_auto_trans(pptpd_t, pppd_exec_t, pppd_t)
allow pptpd_t pppd_t:process signal;

# allow pppd to access the pptp ptys
allow pppd_t pptpd_devpts_t:chr_file rw_file_perms;

# allow to read pppd options file
allow pptpd_t { pppd_etc_rw_t pppd_etc_t }:file { read getattr };
allow pptpd_t pppd_etc_t:dir { search };

# search /var/lib
allow pptpd_t var_lib_t:dir { search };

# allow reading of nsswitch.conf etc.
allow pptpd_t etc_t:dir search;
allow pptpd_t etc_t:file r_file_perms;

[-- Attachment #2: Dies ist ein digital signierter Nachrichtenteil --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2004-10-02 23:37 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-09-04  1:12 Additional rule files Erich Schubert
2004-09-05 10:19 ` Russell Coker
2004-09-06 17:12   ` Erich Schubert
2004-09-13 22:52   ` Erich Schubert
2004-09-19 10:02     ` Russell Coker
2004-10-02 23:37       ` Erich Schubert
2004-09-05 10:27 ` Russell Coker
2004-09-05 10:31 ` Russell Coker
2004-09-05 13:54   ` Erich Schubert
2004-09-05 17:34     ` Luke Kenneth Casson Leighton
2004-09-05 17:38       ` Erich Schubert
2004-09-05 18:50         ` Luke Kenneth Casson Leighton
2004-09-05 10:45 ` log file names (was Additional rule files) Russell Coker
     [not found]   ` <00ab01c4933f$c66e32f0$0a01a8c0@huey>
2004-09-05 12:52     ` Is anyone using Selinux for VOIP applications? Russell Coker

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.