Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue when configuring windows behavior in file creation parameters #90

Open
maenpaa24 opened this issue Aug 9, 2023 · 4 comments
Open

Comments

@maenpaa24
Copy link

Hello,

From the ntfs-3g wiki (https://github.com/tuxera/ntfs-3g/wiki/File-Ownership-and-Permissions#mount-options), one can read that for
"New files are owned by creator and inherit their permissions from parent directory (Windows behavior)" the conditions are:

  • User mapping file not found No uid, gid, fmask, dmask, umask defined, permissions defined, inherit option defined. 
    

OR

  • User mapping file found inherit option defined.
    

If I am not mistaken, that means that an option for this to work is mounting with the following command:

sudo mount -t ntfs-3g -o permissions,inherit /mnt

where /mnt can be any mount point.

However, when I create a file it does not inherit the permissions from the parent folder. The permissions are set to "Everyone".

What am I missing?

@jpandre
Copy link
Collaborator

jpandre commented Aug 10, 2023

There is a bug when using Windows inheritance with no user mapping. I can provide you with a fix, but I would suggest you define the user mapping as a workaround.

Please however note that the use of Windows inheritance does not play well with Linux/Unix rules, so its usage is discouraged.

@maenpaa24
Copy link
Author

Thank you very much for your comment. Having the patch would be great. I bear in mind the caveats.

By the way, when udisks2 mounts an ntfs volume using ntfs-3g, it seems to apply inheritance.

@jpandre
Copy link
Collaborator

jpandre commented Aug 14, 2023

Below is the patch for you to try.

Inheritance applies to permissions, not to ownership, because the owner of the created file should be the owner of the current process, so when user mapping is not defined, ntfs-3g has to make guesses, and this is not always correct.

634 Fixed Windows inheritance when no user mapping is defined
--- src/lowntfs-3g.c.ref	2023-08-10 10:14:05.485679800 +0200
+++ src/lowntfs-3g.c	2023-08-10 10:14:05.539318100 +0200
@@ -2780,7 +2780,7 @@
 			 * This is not possible for NTFS 1.x, and we will
 			 * have to build a security attribute later.
 			 */
-		if (!ctx->security.mapping[MAPUSERS])
+		if (!ctx->security.mapping[MAPUSERS] && !ctx->inherit)
 			securid = const_cpu_to_le32(0);
 		else
 			if (ctx->inherit)
--- src/ntfs-3g.c.ref	2023-08-10 10:14:05.476174500 +0200
+++ src/ntfs-3g.c	2023-08-10 10:14:05.530331900 +0200
@@ -2255,7 +2255,7 @@
 			 * This is not possible for NTFS 1.x, and we will
 			 * have to build a security attribute later.
 			 */
-		if (!ctx->security.mapping[MAPUSERS])
+		if (!ctx->security.mapping[MAPUSERS] && !ctx->inherit)
 			securid = const_cpu_to_le32(0);
 		else
 			if (ctx->inherit)

@ge9
Copy link

ge9 commented Jun 2, 2024

Hi,

How about adding some option to inherit both permissions and ownership of the parent directory? I want file creation in Linux to be Windows-compatible, but don't feel like creating UserMapping with unreadable numeric SIDs. When no UserMapping is provided, we can assume the only one owner in Linux side, so may be able to set arbitrary owner under the hood.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants