A notion about saving and restoring Windows file security info

Corinna Vinschen corinna-cygwin@cygwin.com
Fri Jan 7 13:02:24 GMT 2022


On Jan  5 12:41, Eliot Moss wrote:
> On 1/5/2022 5:34 AM, Corinna Vinschen wrote:
> > On Jan  4 22:45, Eliot Moss wrote:
> >> [...]
> >> The idea is this: expose the Windows file attributes (such as system, archive,
> >> hidden, etc.) as well as security descriptors (such as managed by icacls), via
> >
> > It would be possible with not too much effort.

Reconsidered: Its a bit of effort for reasons outlined below.

> > That would need a bit
> > of discussion, for instance, do we want to show up the native ACL in
> > listxattr?
> 
> Thanks for the quick response, Corinna!
> 
> One thing I am aware of is that the intent of xattrs is to allow applications
> to attach metadata to items in a file system (inodes, essentially, right?)
> that are meaningful to the applications but that do not affect the basic file
> system semantics.  Since Windows file attributes (A, H, S, etc., bits) and
> security descriptors *do* affect semantics, this would admittedly warp things
> slightly.  Therefore, my thought is to make the presentation of these
> attributes by attr_list (is that the canonical call?) and probably also the
> special interpretation of them for get/set, controllable in some way.  The
> means of control that occurs to me is an environment variable, or a flag
> within the CYGWIN env var.  Other folks more deeply involved in Cygwin library
> code, etc., may have a more informed notion of the best way to control this,
> but it strikes me as one of those things that you would have to ask for.

No settings in that case.  *Iff* we do that, we should provide the native
ACLs in a consistent manner.

I'm a bit concerned how this is supposed to work in cases where the user
uses the tool's 'restore xattrs' flag but is missing admin rights.  There's
also a potentially confusing result if you restore ACL xattrs on another
system.  The SIDs won't match and you can easily end up with an entirely
broken permission hirarchy.

Also, to answer my own question, listxattr would have to list the xattr, of
course, otherwise backup tools wouldn't find the xattr and still not save
it.

> As a side point, I have discovered that xattrs are used by WSL to record uid,
> god, and mod information.  (While uid and gid are obvious, I am less certain
> about mod - probably chmod type mode bits, but might have to do with
> modification time?)

That's just for represent the POSIX permission bits.

> Another question to ponder is whether an interface of the kind I am suggesting
> might also present NTFS ADSs (alternate data streams) as xattrs,

See the thread starting at
https://cygwin.com/pipermail/cygwin/2022-January/250352.html

> Another design question is the names to use for these "magical" xattrs.  For
> generality, if the feature is turned on, it might be good to add a prefix to
> the names of real xattrs when getting/listing, that would be stripped off when
> setting, and would of course be different from the prefix(es) for the
> "magical" attributes.  For example, we could use:

https://man7.org/linux/man-pages/man7/xattr.7.html

Right now, all xattrs are treated by Cygwin as if they are in the "user"
namespace.  Ideally the ACL xattr would go into the "system" namespace,
but NOT use the system.posix_acl_access name.  Perhaps something like
"system.windows_acl_access"

If you want to take a stab at it, see the file winsup/cygwin/ntea.cc.
It handles reading (function "read_ea") and writing (function "write_ea")
of EAs, and it provides the external POSIXy calls {l,f}getxattr,
{l,f}listxattr, {l,f}setxattr and {l,f}removexattr.

One problem is currently that the handling of the "user" namespace
is hardcoded.  That needs a bit of mellowing.


Corinna


More information about the Cygwin mailing list