How do I create a directory in C that will follow selinux file context rules?

Lukas Vrabec lvrabec at redhat.com
Tue Mar 24 23:46:40 UTC 2015


Hi,

On 03/24/2015 10:45 PM, Jayson Hurst wrote:
> I need to create a directory in a C binary.
>
> I am currently doing something similar to this:
>
>
> status = mkdir("/home/cnd/mod1", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
>   
> But when the directory is created it ends up with the wrong SELinux context. It inherits it's parent's context and
> not the one defined in file context.
This is right behavior.When you create some file it inherits it's 
parent's context.
> Is there a C call that can be used that understands how to correctly create and label SElinux directories?
You can define filenametransation in selinux policy related to your daemon.
More informations and tutorial how to use it, you can find here: 
http://danwalsh.livejournal.com/46018.html

If you need some help, please feel free to contact me.
>
>
> --
> selinux mailing list
> selinux at lists.fedoraproject.org
> https://admin.fedoraproject.org/mailman/listinfo/selinux

-- 

Regards.

--
Lukas Vrabec
SELinux Solutions
Red Hat, Inc.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.fedoraproject.org/pipermail/selinux/attachments/20150325/d60b9718/attachment.html>


More information about the selinux mailing list