<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<div>
<div style="font-family: Calibri,sans-serif; font-size: 11pt;">I resolved the problem with Dans help by adding a transition from unconfined to vasd_t<br>
<br>
Sent from my Windows Phone</div>
</div>
<div dir="ltr">
<hr>
<span style="font-family: Calibri,sans-serif; font-size: 11pt; font-weight: bold;">From:
</span><span style="font-family: Calibri,sans-serif; font-size: 11pt;"><a href="mailto:mgrepl@redhat.com">Miroslav Grepl</a></span><br>
<span style="font-family: Calibri,sans-serif; font-size: 11pt; font-weight: bold;">Sent:
</span><span style="font-family: Calibri,sans-serif; font-size: 11pt;">‎3/‎27/‎2015 2:24 AM</span><br>
<span style="font-family: Calibri,sans-serif; font-size: 11pt; font-weight: bold;">To:
</span><span style="font-family: Calibri,sans-serif; font-size: 11pt;"><a href="mailto:swazup@hotmail.com">Jayson Hurst</a>;
<a href="mailto:selinux@lists.fedoraproject.org">selinux@lists.fedoraproject.org</a></span><br>
<span style="font-family: Calibri,sans-serif; font-size: 11pt; font-weight: bold;">Subject:
</span><span style="font-family: Calibri,sans-serif; font-size: 11pt;">Re: How do I create a directory in C that will follow selinux file context rules?</span><br>
<br>
</div>
<div class="BodyFragment">
<div class="PlainText">On 03/26/2015 08:37 PM, Jayson Hurst wrote:<br>
&gt; What I don't understand is why the filetrans doesn't work in the first<br>
&gt; place?<br>
&gt;&nbsp; <br>
&gt; In my policy I define:<br>
&gt;&nbsp; <br>
&gt; filetrans_pattern(vasd_t, vasd_var_t, vasd_var_auth_t, dir )<br>
&gt;&nbsp; <br>
&gt; But when my binary that runs under the vasd_t domain as an unconfined<br>
&gt; user creates a directory in /var/opt/quest/vas/ called vasd it gets<br>
&gt; created as a vasd_var_t.<br>
&gt;&nbsp; <br>
&gt; The parent directory of /var/opt/quest/vas is labeled as vasd_var_t. <br>
&gt; Shouldn't the above filetrans_pattern label all new directories under<br>
&gt; /var/opt/quest/vas as vasd_var_auth_t when they are being created under<br>
&gt; the vasd_t domain?<br>
<br>
It should work. Are you sure you create it under vasd_t? Also you need<br>
to have<br>
<br>
manage_dirs_pattern(vasd_t, vasd_var_auth_t, vasd_var_auth_t)<br>
<br>
&gt;&nbsp; <br>
&gt;&gt; Date: Thu, 26 Mar 2015 18:24:01 &#43;0100<br>
&gt;&gt; From: mgrepl@redhat.com<br>
&gt;&gt; To: swazup@hotmail.com; selinux@lists.fedoraproject.org<br>
&gt;&gt; Subject: Re: How do I create a directory in C that will follow selinux<br>
&gt; file context rules?<br>
&gt;&gt;<br>
&gt;&gt; On 03/26/2015 04:17 PM, Jayson Hurst wrote:<br>
&gt;&gt; &gt; RHEL 6.5<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; I have tried this using a filestran pattern but it doesn't seem to work.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; Date: Wed, 25 Mar 2015 09:32:32 &#43;0100<br>
&gt;&gt; &gt;&gt; From: mgrepl@redhat.com<br>
&gt;&gt; &gt;&gt; To: swazup@hotmail.com; selinux@lists.fedoraproject.org<br>
&gt;&gt; &gt;&gt; Subject: Re: How do I create a directory in C that will follow selinux<br>
&gt;&gt; &gt; file context rules?<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; On 03/24/2015 10:45 PM, Jayson Hurst wrote:<br>
&gt;&gt; &gt;&gt; &gt; I need to create a directory in a C binary.<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt; I am currently doing something similar to this:<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt; status = mkdir(&quot;/home/cnd/mod1&quot;, S_IRWXU | S_IRWXG | S_IROTH |<br>
&gt; S_IXOTH);<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt; But when the directory is created it ends up with the wrong SELinux<br>
&gt;&gt; &gt; context. It inherits it's parent's context and<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt; not the one defined in file context.<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; What is your OS?<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt; Is there a C call that can be used that understands how to correctly<br>
&gt;&gt; &gt; create and label SElinux directories?<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt; --<br>
&gt;&gt; &gt;&gt; &gt; selinux mailing list<br>
&gt;&gt; &gt;&gt; &gt; selinux@lists.fedoraproject.org<br>
&gt;&gt; &gt;&gt; &gt; <a href="https://admin.fedoraproject.org/mailman/listinfo/selinux">https://admin.fedoraproject.org/mailman/listinfo/selinux</a><br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; --<br>
&gt;&gt; &gt;&gt; Miroslav Grepl<br>
&gt;&gt; &gt;&gt; Software Engineering, SELinux Solutions<br>
&gt;&gt; &gt;&gt; Red Hat, Inc.<br>
&gt;&gt;<br>
&gt;&gt; Ok, basically you can add a transition rule for &quot;/home/cnd/mod1&quot;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; userdom_user_home_dir_filetrans(unconfined_t, ABC_t, dir)<br>
&gt;&gt;<br>
&gt;&gt; It will create a dir in /home/cnd with ABC_t labeling for unconfined_t<br>
&gt;&gt; or for a domain defined by you.<br>
&gt;&gt;<br>
&gt;&gt; Where you are not able to use a file transition, you can use restorecond<br>
&gt;&gt; on RHEL6. It uses inotify to watch files listed in<br>
&gt;&gt;<br>
&gt;&gt; /etc/selinux/restorecond.conf<br>
&gt;&gt; /etc/selinux/restorecond_user.conf<br>
&gt;&gt;<br>
&gt;&gt; when they are created and it sets a context defined in the policy.<br>
&gt;&gt;<br>
&gt;&gt; --<br>
&gt;&gt; Miroslav Grepl<br>
&gt;&gt; Software Engineering, SELinux Solutions<br>
&gt;&gt; Red Hat, Inc.<br>
<br>
<br>
-- <br>
Miroslav Grepl<br>
Software Engineering, SELinux Solutions<br>
Red Hat, Inc.<br>
</div>
</div>
</body>
</html>