question about set_umask

12 views
Skip to first unread message

Ethan

unread,
Apr 16, 2025, 3:36:48 AMApr 16
to WinFsp

Hi, I have a question about create_umask. In the following code:

https://github.com/winfsp/winfsp/blob/4fdec4d37fb4e56b6d810714f5a201e275211aaf/src/dll/fuse/fuse_intf.c#L936

---

Mode = 0777;

if (0 != SecurityDescriptor)

{

    Result = FspPosixMapSecurityDescriptorToPermissions(SecurityDescriptor,

        &Uid, &Gid, &Mode);

    if (!NT_SUCCESS(Result))

        goto exit;

}

Mode &= ~context->umask;

if (CreateOptions & FILE_DIRECTORY_FILE)

{

    if (f->set_create_dir_umask)

        Mode = 0777 & ~f->create_dir_umask;

    else if (f->set_create_umask)

        Mode = 0777 & ~f->create_umask;

}

else

{

    if (f->set_create_file_umask)

        Mode = 0777 & ~f->create_file_umask;

    else if (f->set_create_umask)

        Mode = 0777 & ~f->create_umask;

}

---


As you can see, when create_umask is set, the permission calculated from SecurityDescriptor (for example, 0555) is later overridden by 0777 & ~create_umask.


Is this an intentional behavior? Because in my understanding, it might make more sense if the logic was:

Mode = Mode & ~create_umask;

Thanks in advance!

Bill Zissimopoulos

unread,
Apr 16, 2025, 10:28:56 AMApr 16
to Ethan, WinFsp

This applies the default umask as is applied in FUSE. However if there is a create_umask (see the set_create_umask check) it applies that *instead*.

 

For the original rationale for create_umask see this thread:

 

https://github.com/winfsp/sshfs-win/issues/14

Later people argued that we really need separate create_umasks for files and directories and so create_file_umask/create_dir_umask were also added.

 

Thanks.

 

Bill

--
You received this message because you are subscribed to the Google Groups "WinFsp" group.
To unsubscribe from this group and stop receiving emails from it, send an email to winfsp+un...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/winfsp/697fb713-69cc-440f-801a-6fc24818b129n%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages