Search code examples
clinuxsecuritywinapiacl

How to create files with specific security permissions in Linux? (i.e. the equivalent of Win32 CreateFile+SECURITY_ATTRIBUTES)


With Windows' Win32 API it's possible to create files and assign to them proper security permissions (e.g. some users can read from and write to the file, other users in another group can only read but not write, etc.), using CreateFile() and its SECURITY_ATTRIBUTES parameter.

Does Linux offer something similar? Which functions and data structures should be used for that purpose?
(I can be missing something, but the classical C fopen() does not seem to offer a similar security permission setting feature...)

EDIT
Just to clarify, I'm looking for something like Windows ACL.


Solution

  • Most recent file systems under Linux support ACL.

    However ACL support needs to be enabled via the according entry to /etc/fstab, when mounting the file-system.

    To get and set ACL from the command line use

    On how to access ACL programmatically see man 5 acl.