Boost.Filesystem perms on Windows

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Boost.Filesystem perms on Windows

Boost - Users mailing list
Hello,

The documentation (boost version 1.68) for boost::filesystem::perms enumerator says;

"Windows: All permissions except write are currently ignored. There is only a single write permission; setting write permission for owner, group, or others sets write permission for all, and removing write permission for owner, group, or others removes write permission for all."

Does "All permissions except write are currently ignored" restriction apply to both getting permission from a file and setting permission to a file? In other words, does it apply to both boost::filesystem::status(..) and boost::filesystem::permissions(..) methods?

Why does the fileysystem have this restriction? Is this some limitation in the design or a bug or missing feature?

Kind regards, Lars

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: Boost.Filesystem perms on Windows

Boost - Users mailing list
On 6/12/2018 08:29, Lars wrote:

> /"Windows: All permissions except write are currently ignored. There is
> only a single write permission; setting write permission for owner,
> group, or others sets write permission for all, and removing write
> permission for owner, group, or others removes write permission for all."/
> /
> /
> Does "/All permissions except write are currently ignored" /restriction
> apply to both getting permission from a file and setting permission to a
> file? In other words, does it apply to both
> boost::filesystem::status(..) and boost::filesystem::permissions(..)
> methods?
>
> Why does the fileysystem have this restriction? Is this some limitation
> in the design or a bug or missing feature?

Boost.Filesystem maps the "permissions" to the read-only file attribute,
presumably because that's simpler and somewhat analogous to the Posix
permission attribute bits.

Both platforms also support more complex ACL permissions (although in
Posix it's optional) but these are not exposed via Boost.Filesystem.


The actual logic for getting the file permission on Windows is
approximately:
   - the read bits are always set
   - the write bits are set if the read-only attribute is not set
   - the execute bits are set if the file extension is one of ".exe",
".com", ".bat", or ".cmd".  (which is wrong, but probably few apps care.)

When changing the permissions, it merely sets or clears the read-only
attribute.
_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: Boost.Filesystem perms on Windows

Boost - Users mailing list
Gavin,

Appreciate the response.

In your response you say "the read bits are always set" - is that based on read-only attribute or Windows permission settings?

I appreciate this might be complicated but the Windows implementation of permissions is rather surprising and not comparable to viewing "Security" on a file in Windows Explorer.  Maybe a more visible and clearer description of permissions in the documentation is in order. I have certainly spent hours trying to use permissions with an incorrect view of its functionality šŸ˜Š

kind regards, Lars


Fra: Boost-users <[hidden email]> pƄ vegne av Gavin Lambert via Boost-users <[hidden email]>
Sendt: torsdag 6. desember 2018 03.46
Til: [hidden email]
Kopi: Gavin Lambert
Emne: Re: [Boost-users] Boost.Filesystem perms on Windows
 
On 6/12/2018 08:29, Lars wrote:
> /"Windows: All permissions except write are currently ignored. There is
> only a single write permission; setting write permission for owner,
> group, or others sets write permission for all, and removing write
> permission for owner, group, or others removes write permission for all."/
> /
> /
> Does "/All permissions except write are currently ignored" /restriction
> apply to both getting permission from a file and setting permission to a
> file? In other words, does it apply to both
> boost::filesystem::status(..) and boost::filesystem::permissions(..)
> methods?
>
> Why does the fileysystem have this restriction? Is this some limitation
> in the design or a bug or missing feature?

Boost.Filesystem maps the "permissions" to the read-only file attribute,
presumably because that's simpler and somewhat analogous to the Posix
permission attribute bits.

Both platforms also support more complex ACL permissions (although in
Posix it's optional) but these are not exposed via Boost.Filesystem.


The actual logic for getting the file permission on Windows is
approximately:
   - the read bits are always set
   - the write bits are set if the read-only attribute is not set
   - the execute bits are set if the file extension is one of ".exe",
".com", ".bat", or ".cmd".  (which is wrong, but probably few apps care.)

When changing the permissions, it merely sets or clears the read-only
attribute.
_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: Boost.Filesystem perms on Windows

Boost - Users mailing list
On 8/12/2018 02:12, Lars wrote:
> In your response you say "the read bits are always set" - is that based
> on read-only attribute or Windows permission settings?

No.  They are always set.  They are never not returned.

A file with the read-only attribute set is reported as "readable but not
writable" by Boost.Filesystem.  A file with it not set is reported as
"readable and writable".

> I appreciate this might be complicated but the Windows implementation of
> permissions is rather surprising and not comparable to viewing
> "Security" on a file in Windows Explorer.Ā  Maybe a more visible and
> clearer description of permissions in the documentation is in order. I
> have certainly spent hours trying to use permissions with an incorrect
> view of its functionality šŸ˜Š

Boost.Filesystem does not model ACL permissions at all (neither for
Windows nor for Linux).  You will have to use native APIs for that.

The "Security" tab in Windows are the ACL permissions.
_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users