public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Eliot Moss <moss@cs.umass.edu>
To: cygwin@cygwin.com
Subject: Re: A notion about saving and restoring Windows file security info
Date: Wed, 5 Jan 2022 12:41:39 -0500	[thread overview]
Message-ID: <7cea7819-c03e-60c2-1acc-380b1bd0c18f@cs.umass.edu> (raw)
In-Reply-To: <YdV0KNw+hZ5iS1AC@calimero.vinschen.de>

On 1/5/2022 5:34 AM, Corinna Vinschen wrote:
 > On Jan  4 22:45, Eliot Moss wrote:
 >> Dear Cygwiners - Maybe this idea has been discussed before, and I can't say I
 >> exactly have a specific application in mind, but I was wondering about how one
 >> might achieve reliable backup/restore of files on a Windows system via a
 >> backup program written to the POSIX interface and ported to Windows via
 >> Cygwin.
 >>
 >> 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
 >> specifically named extended attributes, those read/written by get/setfattr.
 >> The Cygwin library could be enhanced to "know" the special names of these
 >> attributes and use the appropriate, different, underlying calls to get/set
 >> them.
 >>
 >> Is this a crazy idea?  A useful one?  (How useful?)  What implementation
 >> effort would be required?
 >
 > It would be possible with not too much effort.  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.

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?)

Another question to ponder is whether an interface of the kind I am suggesting
might also present NTFS ADSs (alternate data streams) as xattrs, if
requested.  The SysInternals "streams" program can manipulate them, though it
does mention that the program uses an undocumented native function to obtain
the stream information.  Cygwin cp, unsurprisingly, does not copy such
information, while cmd's copy command *does* (maybe a little surprisingly).  I
am aware that ADSs have security implications because they are so hidden from
users.  Adding this functionality would make it easy to use ordinary Cygwin
tools to find and remove any ADS of concern, etc.

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:

- POSIX_ as a prefix for each regular xattr name
- WindowsAttrs as an attribute that capture all attrs, for simplicity, though
   we could also represent each of them separately as an attribute with no
   value, present only when the indicated attribute is set
- WindowsSDs for the security descriptors, a single attribute since order
   matters
- WindowsADS_ as a prefix for each ADS

In principle, each of Attrs, SDs, and ADS_ could be separately controlled, if
we think that is important (might be).

Those are my thoughts for now.  Sorry this is longish ...  Eliot

  reply	other threads:[~2022-01-05 17:41 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-05  3:45 Eliot Moss
2022-01-05 10:34 ` Corinna Vinschen
2022-01-05 17:41   ` Eliot Moss [this message]
2022-01-06  9:03     ` Sam Edge
2022-01-07 13:02     ` Corinna Vinschen
2022-01-07 14:28       ` Eliot Moss
2022-01-07 14:53         ` Corinna Vinschen
2022-01-07 15:40       ` Andrey Repin
2022-01-10  9:59         ` Corinna Vinschen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7cea7819-c03e-60c2-1acc-380b1bd0c18f@cs.umass.edu \
    --to=moss@cs.umass.edu \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).