Skip to contentSkip to conversation

Moving xconsole from xserver to logging policy

PATCH Erich Schubert 2 participants 7 messages Sep 13, 2006 – Sep 14, 2006 SELinux security module

lore
Share & tools
lore
#0 lore raw

Hi,
Basically, /dev/xconsole is a FIFO written to by syslog, and often is present even when there is no X. Therefore, this should go into the logging policy.
Patch attached.

best regards,
Erich Schubert

Signature · 4 lines
     erich@(vitavonni.de|debian.org)    --    GPG Key ID: 4B3A135C    (o_
 Nothing prevents happiness like the memory of happiness. --- A. Gide //\
       Die einzige Hoffnung auf Freude liegt in den menschlichen      V_/_
               Beziehungen. --- Antoine de Saint-Exupéry
modules/services/xserver.te +1 -8
Index: policy/modules/services/xserver.te
===================================================================
@@ -19,12 +19,6 @@
 type xauth_exec_t;
 corecmd_executable_file(xauth_exec_t)
 
-# this is not actually a device, its a pipe
-type xconsole_device_t;
-files_type(xconsole_device_t)
-fs_associate_tmpfs(xconsole_device_t)
-files_associate_tmp(xconsole_device_t)
-
 type xdm_t;
 # real declaration moved to mls until
 # range_transition works in loadable modules
@@ -97,8 +91,6 @@
 # Supress permission check on .ICE-unix
 dontaudit xdm_t ice_tmp_t:dir { getattr setattr };
 
-allow xdm_t xconsole_device_t:fifo_file { getattr setattr };
-
 allow xdm_t xdm_tmp_t:dir manage_dir_perms;
 allow xdm_t xdm_tmp_t:file manage_file_perms;
 allow xdm_t xdm_tmp_t:sock_file manage_file_perms;
@@ -204,6 +196,7 @@
 libs_exec_lib_files(xdm_t)
 
 logging_read_generic_logs(xdm_t)
+logging_setattr_xconsole_pipes(xdm_t)
 
 miscfiles_read_localization(xdm_t)
 miscfiles_read_fonts(xdm_t)
modules/services/xserver.fc +0 -5
Index: policy/modules/services/xserver.fc
===================================================================
@@ -12,11 +12,6 @@
 ')
 
 #
-# /dev
-#
-/dev/xconsole		-p	gen_context(system_u:object_r:xconsole_device_t,s0)
-
-#
 # /etc
 #
 
modules/services/xserver.if +0 -36
Index: policy/modules/services/xserver.if
===================================================================
@@ -694,42 +694,6 @@
 
 ########################################
 ## <summary>
-##	Set the attributes of the X windows console named pipes.
-## </summary>
-## <param name="domain">
-##	<summary>
-##	Domain allowed access.
-##	</summary>
-## </param>
-#
-interface(`xserver_setattr_console_pipes',`
-	gen_require(`
-		type xconsole_device_t;
-	')
-
-	allow $1 xconsole_device_t:fifo_file setattr;
-')
-
-########################################
-## <summary>
-##	Read and write the X windows console named pipe.
-## </summary>
-## <param name="domain">
-##	<summary>
-##	Domain allowed access.
-##	</summary>
-## </param>
-#
-interface(`xserver_rw_console',`
-	gen_require(`
-		type xconsole_device_t;
-	')
-
-	allow $1 xconsole_device_t:fifo_file { getattr read write };
-')
-
-########################################
-## <summary>
 ##	Use file descriptors for xdm.
 ## </summary>
 ## <param name="domain">
modules/system/logging.te +9 -5
Index: policy/modules/system/logging.te
===================================================================
@@ -57,6 +57,12 @@
 type var_log_t;
 logging_log_file(var_log_t)
 
+# this is not actually a device, its a pipe
+type xconsole_device_t;
+files_type(xconsole_device_t)
+fs_associate_tmpfs(xconsole_device_t)
+files_associate_tmp(xconsole_device_t)
+
 ########################################
 #
 # Auditd local policy
@@ -294,6 +300,9 @@
 allow syslogd_t syslogd_var_run_t:dir rw_dir_perms;
 files_pid_filetrans(syslogd_t,syslogd_var_run_t,file)
 
+# log to xconsole
+allow syslogd_t xconsole_device_t:fifo_file rw_file_perms;
+
 kernel_read_kernel_sysctls(syslogd_t)
 kernel_read_proc_symlinks(syslogd_t)
 # Allow access to /proc/kmsg for syslog-ng
@@ -388,8 +397,3 @@
 optional_policy(`
 	udev_read_db(syslogd_t)
 ')
-
-optional_policy(`
-	# log to the xconsole
-	xserver_rw_console(syslogd_t)
-')
modules/system/logging.if +37 -0
Index: policy/modules/system/logging.if
===================================================================
@@ -583,3 +583,40 @@
 	allow $1 var_log_t:dir rw_dir_perms;
 	allow $1 var_log_t:file create_file_perms;
 ')
+
+########################################
+## <summary>
+##	Set the attributes of the xconsole named pipes.
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain allowed access.
+##	</summary>
+## </param>
+#
+interface(`logging_setattr_xconsole_pipes',`
+	gen_require(`
+		type xconsole_device_t;
+	')
+
+	allow $1 xconsole_device_t:fifo_file setattr;
+')
+
+########################################
+## <summary>
+##	Read the xconsole named pipe.
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain allowed access.
+##	</summary>
+## </param>
+#
+interface(`logging_r_xconsole',`
+	gen_require(`
+		type xconsole_device_t;
+	')
+
+	allow $1 xconsole_device_t:fifo_file { getattr read };
+')
+
modules/system/init.te +1 -3
Index: policy/modules/system/init.te
===================================================================
@@ -360,6 +360,7 @@
 logging_read_all_logs(initrc_t)
 logging_append_all_logs(initrc_t)
 logging_read_audit_config(initrc_t)
+logging_setattr_xconsole_pipes(initrc_t)
 
 miscfiles_read_localization(initrc_t)
 # slapd needs to read cert files from its initscript
@@ -757,9 +758,6 @@
 ')
 
 optional_policy(`
-	# Set device ownerships/modes.
-	xserver_setattr_console_pipes(initrc_t)
-
 	# init script wants to check if it needs to update windowmanagerlist
 	xserver_read_xdm_rw_config(initrc_t)
 ')
modules/system/logging.fc +1 -0
Index: policy/modules/system/logging.fc
===================================================================
@@ -1,5 +1,6 @@
 
 /dev/log		-s	gen_context(system_u:object_r:devlog_t,s0)
+/dev/xconsole		-p	gen_context(system_u:object_r:xconsole_device_t,s0)
 
 /etc/audit(/.*)?		gen_context(system_u:object_r:auditd_etc_t,s15:c0.c255)
 
#1 lore raw
Quoted 4 lines · Erich Schubert

Basically, /dev/xconsole is a FIFO written to by syslog, and often is present even when there is no X. Therefore, this should go into the logging policy.
Patch attached.

I don't agree with this; I believe it is a Debian thing that syslog writes to this. Even neglecting that, it still makes more sense to me that it stays in xserver.

Signature · 9 lines
Chris PeBenito
Tresys Technology, LLC
(410) 290-1411 x150


--
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

Hello Christopher,

Quoted 3 lines

I don't agree with this; I believe it is a Debian thing that syslog writes to this. Even neglecting that, it still makes more sense to me that it stays in xserver.

Please enlighten me then what /dev/xconsole is good for. The xconsole manpage just says "The xconsole program displays messages which are usually sent to /dev/console" and "monitor system console messages with X"

The only app I know that writes to /dev/xconsole is syslog. Do you know any others?

best regards,
Erich Schubert

Signature · 10 lines
    erich@(vitavonni.de|debian.org)    --    GPG Key ID: 4B3A135C     (o_
 The early bird gets the worm, but the second mouse gets the cheese.  //\
 Jemanden zu lieben heißt glücklich zu sein, ihn glücklich zu sehen.  V_/_



--
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.
#3 lore raw
Quoted 5 lines · Erich Schubert

Hello Christopher,

Quoted 3 lines

I don't agree with this; I believe it is a Debian thing that syslog writes to this. Even neglecting that, it still makes more sense to me that it stays in xserver.

Quoted 7 lines

Please enlighten me then what /dev/xconsole is good for. The xconsole manpage just says "The xconsole program displays messages which are usually sent to /dev/console" and "monitor system console messages with X"

The only app I know that writes to /dev/xconsole is syslog. Do you know any others?

I've seen it used for redirecting the stdout/err of programs started by the window manager. I think you can do that instead of ~/.xsession-errors.

Signature · 9 lines
Chris PeBenito
Tresys Technology, LLC
(410) 290-1411 x150


--
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.
#4 lore raw

Hi Christopher,

Quoted 3 lines

I've seen it used for redirecting the stdout/err of programs started by the window manager. I think you can do that instead of ~/.xsession-errors.

Not in strict, I guess... and you don't need a pipe in /dev for that, nor do you need to run xconsole to access /dev/xconsole. Just run xconsole -file ~/.xconsole and you won't need any extra information for that...
So that use is actually an abuse of /dev/xconsole IMHO.

best regards,
Erich Schubert

Signature · 10 lines
     erich@(vitavonni.de|debian.org)    --    GPG Key ID: 4B3A135C    (o_
 Nothing prevents happiness like the memory of happiness. --- A. Gide //\
     Mathematik: Das Alphabet, mit dessen Hilfe Gott das Universum    V_/_
                 beschrieben hat. --- Galileo Galilei


--
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.
#5 lore raw
Quoted 10 lines · Erich Schubert

Hi Christopher,

Quoted 3 lines

I've seen it used for redirecting the stdout/err of programs started by the window manager. I think you can do that instead of ~/.xsession-errors.

Not in strict, I guess... and you don't need a pipe in /dev for that, nor do you need to run xconsole to access /dev/xconsole. Just run xconsole -file ~/.xconsole and you won't need any extra information for that...
So that use is actually an abuse of /dev/xconsole IMHO.

Regardless if this is a good use or not, having a xconsole without an xserver makes no sense.

Signature · 9 lines
Chris PeBenito
Tresys Technology, LLC
(410) 290-1411 x150


--
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.
#6 lore raw

Hi,
Another reason why that usage you mentioned is broken - it's not multi-user compatible. They definitely should use a fifo in their home directory.

Quoted 2 lines

Regardless if this is a good use or not, having a xconsole without an xserver makes no sense.

How about displaying the information remotely?
There are so many uses for fifos...

best regards,
Erich Schubert

Signature · 10 lines
   erich@(vitavonni.de|debian.org)    --    GPG Key ID: 4B3A135C    (o_
     The future is here. It's just not evenly distributed yet.      //\
            Ohne Tränen hat die Seele keinen Regenbogen.            V_/_



--
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.