From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin@cygwin.com
Cc: bug-gnulib <bug-gnulib@gnu.org>, Paul Eggert <eggert@cs.ucla.edu>
Subject: Re: [PATCH] root-uid: new module
Date: Wed, 27 Jun 2012 07:54:00 -0000 [thread overview]
Message-ID: <20120627074814.GC837@calimero.vinschen.de> (raw)
In-Reply-To: <4FEA5161.6010503@redhat.com>
On Jun 26 18:18, Eric Blake wrote:
> [adding cygwin]
>
> On 06/26/2012 06:12 PM, Paul Eggert wrote:
> > On 06/26/2012 05:01 PM, Eric Blake wrote:
> >> Rather than forcing comparison to a single value, would it be better to
> >> have a function is_privileged_uid(euid)?
Do you really need this functionality for an arbitrary uid as input? Or
do you just want to know if the current process is running with a certain
privilege?
> > Yes, that sounds better. I don't use Cygwin, though, so
> > I'm not qualified to write that.
>
> Broadening the question, does the cygwin community have advice on the
> best implementation of a function that returns true if the argument is a
> uid with full privileges (for example, if the uid is a member of the
> Administrator group, and can therefore read files in spite of chown()
> disabling all the read permissions)? We're trying to improve gnulib
> (and therefore coreutils, findutils, tar, ...) to use an
> implementation-appropriate check rather than the more traditional
> hard-coded check of uid==0, since that doesn't quite work everywhere.
Security in Windows is kind of complicated. Not even the membership in
the group "Administrators" is a sure indicator that the current process
has the approriate rights. In short, every process has a "user token"
attached which defines the permissions a process has, given as a list
of group memberships and a list of special privileges. As an additional
twist, a privilege in the token can be enabled or disabled.
Some of them, if disabled, are automatically enabled when calling
certain functions, others have to be enabled explicitely before calling
functions relying on the privilege. There are no rules to that, other
than what's defined by the documentation.
I guess, the most platform-independent approach would be to encapsulate
the whole problem into a function requesting a specific capability along
the lines of the POSIX 1.e definitions, like, say
if (has_capability (CAP_CHOWN))
...
The actual implementation of has_capability can then be defined in
a platform-specific file. The default implementation of has_capability
would be something along the lines of
int
has_capability (int cap)
{
return geteuid () == 0;
}
Systems supporting POSIX 1.e could use the appropriate functions,
Windows-based platforms would use an implementation based on the
Win32 functions to request the user token information.
As a sidenote, it would be nice if Cygwin would support the POSIX 1.e
capabilities, but nobody had the time or incentive to implement this
yet. This might be a nice project for somebody who wants to contribute
to Cygwin, since its implementation is mostly independent from the
already existing functionality.
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Project Co-Leader cygwin AT cygwin DOT com
Red Hat
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
next prev parent reply other threads:[~2012-06-27 7:54 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <4FEA4A72.8090003@cs.ucla.edu>
[not found] ` <4FEA4D53.3090409@redhat.com>
[not found] ` <4FEA4FDB.5030105@cs.ucla.edu>
2012-06-27 0:19 ` Eric Blake
2012-06-27 7:54 ` Corinna Vinschen [this message]
2012-06-27 14:13 ` Paul Eggert
2012-06-27 13:58 ` Charles Wilson
2012-06-27 14:13 ` Charles Wilson
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=20120627074814.GC837@calimero.vinschen.de \
--to=corinna-cygwin@cygwin.com \
--cc=bug-gnulib@gnu.org \
--cc=cygwin@cygwin.com \
--cc=eggert@cs.ucla.edu \
/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).