Skip to contentSkip to conversation

SELinux context patch

PATCH Daniel J Walsh 5 participants 10 messages May 18, 2009 – Jun 23, 2009 SELinux security module

lore
Share & tools
lore
#0 lore raw

This patch adds context files for virtual_domain and virtual_image, these are both being used to locat the default context to be executed by svirt.

I also included the subs patch which I submitted before. This patch allows us to substitute prefixes to matchpathcon.

So we can say /export/home == /home

and

/web == /var/www

src/selinux_config.c +25 -1
@@ -40,7 +40,10 @@
 #define SECURETTY_TYPES   18
 #define X_CONTEXTS        19
 #define COLORS            20
-#define NEL               21
+#define VIRTUAL_DOMAIN    21
+#define VIRTUAL_IMAGE     22
+#define FILE_CONTEXT_SUBS 23
+#define NEL               24
 
 /* New layout is relative to SELINUXDIR/policytype. */
 static char *file_paths[NEL];
@@ -391,3 +394,24 @@
 }
 
 hidden_def(selinux_x_context_path)
+
+const char *selinux_virtual_domain_context_path()
+{
+	return get_path(VIRTUAL_DOMAIN);
+}
+
+hidden_def(selinux_virtual_domain_context_path)
+
+const char *selinux_virtual_image_context_path()
+{
+	return get_path(VIRTUAL_IMAGE);
+}
+
+hidden_def(selinux_virtual_image_context_path)
+
+const char * selinux_file_context_subs_path(void) {
+	return get_path(FILE_CONTEXT_SUBS);
+}
+
+hidden_def(selinux_file_context_subs_path)
+
include/selinux/selinux.h +3 -0
@@ -481,8 +481,11 @@
 extern const char *selinux_file_context_path(void);
 extern const char *selinux_file_context_homedir_path(void);
 extern const char *selinux_file_context_local_path(void);
+extern const char *selinux_file_context_subs_path(void);
 extern const char *selinux_homedir_context_path(void);
 extern const char *selinux_media_context_path(void);
+extern const char *selinux_virtual_domain_context_path(void);
+extern const char *selinux_virtual_image_context_path(void);
 extern const char *selinux_x_context_path(void);
 extern const char *selinux_contexts_path(void);
 extern const char *selinux_securetty_types_path(void);
src/file_path_suffixes.h +3 -0
@@ -20,3 +20,6 @@
     S_(FILE_CONTEXTS_LOCAL, "/contexts/files/file_contexts.local")
     S_(X_CONTEXTS, "/contexts/x_contexts")
     S_(COLORS, "/secolor.conf")
+    S_(VIRTUAL_DOMAIN, "/contexts/virtual_domain_context")
+    S_(VIRTUAL_IMAGE, "/contexts/virtual_image_context")
+    S_(FILE_CONTEXT_SUBS, "/contexts/files/file_contexts.subs")
src/selinux_internal.h +3 -0
@@ -59,9 +59,12 @@
     hidden_proto(selinux_securetty_types_path)
     hidden_proto(selinux_failsafe_context_path)
     hidden_proto(selinux_removable_context_path)
+    hidden_proto(selinux_virtual_domain_context_path)
+    hidden_proto(selinux_virtual_image_context_path)
     hidden_proto(selinux_file_context_path)
     hidden_proto(selinux_file_context_homedir_path)
     hidden_proto(selinux_file_context_local_path)
+    hidden_proto(selinux_file_context_subs_path)
     hidden_proto(selinux_netfilter_context_path)
     hidden_proto(selinux_homedir_context_path)
     hidden_proto(selinux_user_contexts_path)
src/label.c +104 -1

139 lines not on this page · raw message

#1 lore raw
Quoted 4 lines · Daniel J Walsh

This patch adds context files for virtual_domain and virtual_image, these are both being used to locat the default context to be executed by svirt.

Quoted 8 lines

I also included the subs patch which I submitted before. This patch allows us to substitute prefixes to matchpathcon.

So we can say /export/home == /home

and

/web == /var/www

I'm surprised that the subs patch didn't get much discussion before. Any thoughts on this? Any worries that it might not meld well with the work currently being done to integrate FCGlob?

Thanks,
Chad

--
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
Quoted 13 lines · Chad Sellers
Quoted 11 lines · Daniel J Walsh

This patch adds context files for virtual_domain and virtual_image, these are both being used to locat the default context to be executed by svirt.

I also included the subs patch which I submitted before.  This patch allows us to substitute prefixes to matchpathcon.

So we can say /export/home == /home

and

Quoted 9 lines
Quoted 1 line

/web == /var/www

I'm surprised that the subs patch didn't get much discussion before. Any thoughts on this? Any worries that it might not meld well with the work currently being done to integrate FCGlob?

Thanks,
Chad

I don't think it will adversely affect FCGlob integration.

It is going to make it harder to understand what a file will get labeled though.

Might be useful for genhomedircon to generate a .subs file and for refpolicy to provide labeling on a selinux user basis for home directories:

/root
/home/unconfined_u
/home/sysadm_u
...

with a .subs:

/home/bob /home/unconfined_u
/home/sally /home/sysadm_u
...

It doesn't support directories with spaces in them.

--
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 3 lines · Caleb Case

I don't think it will adversely affect FCGlob integration.

Very good.

<snip>

Quoted 2 lines

It doesn't support directories with spaces in them.

An excellent point, though it looks like file_contexts doesn't support spaces right now either.

Thanks,
Chad

--
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
Quoted 13 lines · Chad Sellers
Quoted 3 lines · Caleb Case

I don't think it will adversely affect FCGlob integration.

Very good.

<snip>

Quoted 2 lines

It doesn't support directories with spaces in them.

An excellent point, though it looks like file_contexts doesn't support spaces right now either.

Quoted 8 lines

Thanks,
Chad

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

Directories with spaces, are satanic.

Just say no to spaces in Directory names.

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

Acked-by
#8 lore raw
In reply to Daniel J Walsh
Quoted 4 lines · Daniel J Walsh

This patch adds context files for virtual_domain and virtual_image, these are both being used to locat the default context to be executed by svirt.

Quoted 8 lines

I also included the subs patch which I submitted before. This patch allows us to substitute prefixes to matchpathcon.

So we can say /export/home == /home

and

/web == /var/www

The only problem I see with the patch is:

+ sub->dst=strdup(dst);
+ if (! sub->dst) {

+                               free(sub);
+                               free(sub->src);
+                               return -1;

+ }

the free()'s should be reversed in order. Other than that the patch looks fine. I'll fix this in the merge.

--
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
In reply to Caleb Case
Quoted 43 lines · Caleb Case
Quoted 13 lines · Chad Sellers
Quoted 11 lines · Daniel J Walsh

This patch adds context files for virtual_domain and virtual_image, these are both being used to locat the default context to be executed by svirt.

I also included the subs patch which I submitted before. This patch allows us to substitute prefixes to matchpathcon.

So we can say /export/home == /home

and

Quoted 9 lines
Quoted 1 line

/web == /var/www

I'm surprised that the subs patch didn't get much discussion before. Any thoughts on this? Any worries that it might not meld well with the work currently being done to integrate FCGlob?

Thanks,
Chad

I don't think it will adversely affect FCGlob integration.

It is going to make it harder to understand what a file will get labeled though.

Might be useful for genhomedircon to generate a .subs file and for refpolicy to provide labeling on a selinux user basis for home directories:

/root
/home/unconfined_u
/home/sysadm_u
...

with a .subs:

/home/bob /home/unconfined_u
/home/sally /home/sysadm_u
...

Quoted 7 lines

It doesn't support directories with spaces in them.

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

I would like genhomedircon to just go away totally. Or make it voluntary, not run in every policy update. getpw() is not guaranteed to return all users in a Directory and setting up labeling for 100,000 users is just kooky.

The beauty of this patch is it allows admin to take back control of labeling of homedir. If they want to put home dirs in a random location and have symlinks from the HOMEDIR labeled in /etc/passwd This will work. I have had bug reports where people setup different HOMEDIR links depending on where the machine is at home or in the office or if they have a remove NFS and a local files.

--
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
In reply to Caleb Case
Quoted 37 lines · Caleb Case
Quoted 13 lines · Chad Sellers
Quoted 11 lines · Daniel J Walsh

This patch adds context files for virtual_domain and virtual_image, these are both being used to locat the default context to be executed by svirt.

I also included the subs patch which I submitted before. This patch allows us to substitute prefixes to matchpathcon.

So we can say /export/home == /home

and

Quoted 9 lines
Quoted 1 line

/web == /var/www

I'm surprised that the subs patch didn't get much discussion before. Any thoughts on this? Any worries that it might not meld well with the work currently being done to integrate FCGlob?

Thanks,
Chad

I don't think it will adversely affect FCGlob integration.

It is going to make it harder to understand what a file will get labeled though.

Might be useful for genhomedircon to generate a .subs file and for refpolicy to provide labeling on a selinux user basis for home directories:

/root
/home/unconfined_u
/home/sysadm_u
...

Quoted 5 lines

with a .subs:

/home/bob /home/unconfined_u
/home/sally /home/sysadm_u
...

Substituting the entire home dir root, like Dan's example /export/home == /home above, makes sense to me. However, I do not like the idea of adding dummy file context entries to the policy like the above example (/home/unconfined_u and /home/sysadm_u) to make substitution usable for creating file contexts for individual home dirs.

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.
#7 lore raw
Quoted 44 lines · Christopher J. PeBenito
Quoted 37 lines · Caleb Case
Quoted 13 lines · Chad Sellers
Quoted 11 lines · Daniel J Walsh

This patch adds context files for virtual_domain and virtual_image, these are both being used to locat the default context to be executed by svirt.

I also included the subs patch which I submitted before. This patch allows us to substitute prefixes to matchpathcon.

So we can say /export/home == /home

and

Quoted 9 lines
Quoted 1 line

/web == /var/www

I'm surprised that the subs patch didn't get much discussion before. Any thoughts on this? Any worries that it might not meld well with the work currently being done to integrate FCGlob?

Thanks,
Chad

I don't think it will adversely affect FCGlob integration.

It is going to make it harder to understand what a file will get labeled though.

Might be useful for genhomedircon to generate a .subs file and for refpolicy to provide labeling on a selinux user basis for home directories:

/root
/home/unconfined_u
/home/sysadm_u
...

Quoted 5 lines

with a .subs:

/home/bob /home/unconfined_u
/home/sally /home/sysadm_u
...

Quoted 5 lines

Substituting the entire home dir root, like Dan's example /export/home == /home above, makes sense to me. However, I do not like the idea of adding dummy file context entries to the policy like the above example (/home/unconfined_u and /home/sysadm_u) to make substitution usable for creating file contexts for individual home dirs.

The purpose of genhomedircon is to create these types of entries. I don't think we want file contexts in the policy that aren't actually intended to be used.

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.
#9 lore raw
In reply to Chad Sellers
Quoted 24 lines · Chad Sellers
Quoted 4 lines · Daniel J Walsh

This patch adds context files for virtual_domain and virtual_image, these are both being used to locat the default context to be executed by svirt.

Quoted 8 lines

I also included the subs patch which I submitted before. This patch allows us to substitute prefixes to matchpathcon.

So we can say /export/home == /home

and

/web == /var/www

The only problem I see with the patch is:

src/label.c +6 -0
+                       sub->dst=strdup(dst);
+                       if (! sub->dst) {
+                               free(sub);
+                               free(sub->src);
+                               return -1;
+                       }
Quoted 5 lines

the free()'s should be reversed in order. Other than that the patch looks fine. I'll fix this in the merge.

Merged in libselinux 2.0.82

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