All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH][RFC] Allow administrator control over per-user default_contexts
@ 2004-05-21 16:02 Stephen Smalley
  2004-05-21 22:13 ` Valdis.Kletnieks
  0 siblings, 1 reply; 14+ messages in thread
From: Stephen Smalley @ 2004-05-21 16:02 UTC (permalink / raw)
  To: selinux; +Cc: Daniel J Walsh, Russell Coker, selinux-dev

[-- Attachment #1: Type: text/plain, Size: 2163 bytes --]

Hi,

A Fedora user expressed a desire to be able to have the administrator
control the per-user default_contexts configuration rather than allowing
users to specify their own prioritization via $HOME/.default_contexts.
This patch implements such support by changing libselinux to check for
the existence of an /etc/security/default_contexts.user directory.  If
the directory is present, then libselinux will check for a file named by
the username in that directory and use that file if it exists for any
per-user default_contexts ordering.  Only if the directory is not
present will libselinux check for $HOME/.default_contexts and use it. 
Thus, an administrator can simply create the directory to prohibit any
use of $HOME/.default_contexts and can then optionally chose to create
per-user configurations under it if desired.

Note that the use of $HOME/.default_contexts has never been well
supported by policy, as login/sshd typically lack permission to read
user home directory files and a separate type was never introduced for
per-user default_contexts.  While Fedora Core 2 is using a
/root/.default_contexts file, that is naturally administratively
controlled and labeled with default_context_t so that it can be accessed
by login/sshd.  But if we truly wanted to allow ordinary users to create
their own $HOME/.default_contexts files, we would need a separate type
for this purpose, e.g. $1_default_context_t for each user domain, allow
the user domains to create/relabel such files, and allow login/sshd to
read such files.

Questions:

- Does this change seem reasonable?

- Should the policy include support for the $HOME/.default_contexts
files for ordinary users?

- Should Fedora transition to using
/etc/security/default_contexts.user/root instead of
/root/.default_contexts, thus prohibiting use of $HOME/.default_contexts
by default?  Administrators who want to allow $HOME/.default_contexts
would then need to copy the root entry to /root/.default_contexts and
remove the directory to enable such support.

- Should the support for $HOME/.default_contexts be retained at all?

-- 
Stephen Smalley <sds@epoch.ncsc.mil>
National Security Agency

[-- Attachment #2: libselinux-usercon.patch --]
[-- Type: text/x-patch, Size: 1803 bytes --]

Index: libselinux/include/selinux/get_context_list.h
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/libselinux/include/selinux/get_context_list.h,v
retrieving revision 1.3
diff -u -r1.3 get_context_list.h
--- libselinux/include/selinux/get_context_list.h	6 Oct 2003 19:55:18 -0000	1.3
+++ libselinux/include/selinux/get_context_list.h	21 May 2004 14:53:02 -0000
@@ -4,6 +4,7 @@
 #include <selinux/selinux.h>
 
 #define _DEFCONTEXT_PATH "/etc/security/default_contexts"
+#define _DEFCONTEXT_USER_PATH "/etc/security/default_contexts.user"
 #define _FAILSAFECONTEXT_PATH "/etc/security/failsafe_context"
 #define SELINUX_DEFAULTUSER "user_u"
 
Index: libselinux/src/get_context_list.c
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/libselinux/src/get_context_list.c,v
retrieving revision 1.15
diff -u -r1.15 get_context_list.c
--- libselinux/src/get_context_list.c	16 Apr 2004 19:22:24 -0000	1.15
+++ libselinux/src/get_context_list.c	21 May 2004 14:59:45 -0000
@@ -213,8 +213,15 @@
     int retval;           /* The return value                          */
     long buflen;
 
-    if (which == USERPRIORITY)
-    {
+    if (which == USERPRIORITY && access(_DEFCONTEXT_USER_PATH, F_OK) == 0) {
+        fname_len = sizeof(_DEFCONTEXT_USER_PATH) + strlen(user) + 1;
+        fname = malloc (fname_len);
+        if (!fname) 
+            return -1;
+        sprintf (fname, "%s/%s", _DEFCONTEXT_USER_PATH, user);
+        config_file = fopen (fname, "r");
+	free (fname);
+    } else if (which == USERPRIORITY) {
         /* Get the password structure in order to find the home directory.
 	   Use getpwnam_r to avoid clobbering any existing pwd struct obtained
 	   by the caller. */

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

end of thread, other threads:[~2004-05-26 11:57 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-05-21 16:02 [PATCH][RFC] Allow administrator control over per-user default_contexts Stephen Smalley
2004-05-21 22:13 ` Valdis.Kletnieks
2004-05-23 20:12   ` Russell Coker
2004-05-24 12:43     ` Stephen Smalley
2004-05-24 14:04       ` Timothy
2004-05-24 14:27         ` Stephen Smalley
2004-05-25  8:37           ` Luke Kenneth Casson Leighton
2004-05-25 14:51             ` Stephen Smalley
2004-05-24 14:25       ` Timothy
2004-05-24 17:25       ` Valdis.Kletnieks
2004-05-24 18:28         ` Stephen Smalley
2004-05-25 14:48       ` Stephen Smalley
2004-05-25 18:15         ` Daniel J Walsh
2004-05-26 11:57           ` Stephen Smalley

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.