public inbox for cygwin-apps@cygwin.com
 help / color / mirror / Atom feed
From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin-apps@cygwin.com
Subject: Re: ATTENTION: Tcl/Tk transition
Date: Fri, 28 Oct 2011 09:34:00 -0000	[thread overview]
Message-ID: <20111028093335.GB31017@calimero.vinschen.de> (raw)
In-Reply-To: <20111028084804.GA31017@calimero.vinschen.de>

On Oct 28 10:48, Corinna Vinschen wrote:
> On Oct 28 03:20, Yaakov (Cygwin/X) wrote:
> > On Fri, 2011-10-28 at 09:56 +0200, Corinna Vinschen wrote:
> > > > On Thu, Oct 27, 2011 at 10:11:03PM -0500, Yaakov (Cygwin/X) wrote:
> > > > >On Thu, 2011-10-27 at 10:07 +0200, Corinna Vinschen wrote:
> > > > >> Cool, thanks!  You don't want to take over ruby maintainership as well,
> > > > >> do you? :}
> > > > >
> > > > >Would your adding getgrouplist(3) be a fair price? :-)
> > > > >
> > > > >http://www.kernel.org/doc/man-pages/online/pages/man3/getgrouplist.3.html
> > > > >
> > > > >I need this for an attempt to port polkit-1, and I haven't learned that
> > > > >part of the codebase yet.  Deal? :-)
> > > 
> > > Deal!
> > 
> > Done.  ruby-1.8.7-p352 with separate ruby-tcltk package is ready.
> 
> Cool, thanks!
> 
> > > I assume you want the full group list, represented by the user's token
> > > if one would like to construct the token, right?
> > 
> > See the "spec" noted above, but if ngroups is correctly sized, all
> > groups to which the given user belongs are returned AND the given group
> > even if the user is not a member thereof.
> 
> Uh, maybe I wasn't clear.  I didn't talk about Linux or so, I was
> just refering to two possible implementations on Cygwin, one looking
> into /etc/groups only, the other fetching the information from the OS.
> But that was YA ENOCOFFEE question since I gave up on using the
> supplemetary groups from /etc/group anyway.  Only what the OS allows
> should count.
> 
> > > If so, that requires to create a SID list by fetching the information
> > > from the local SAM and AD, quite similar to the initgroups function.
> > > 
> > > On second thought, that would be practically identical to our
> > > initgroups32 function, except for the cygheap->user.groups.update_supp
> > > call, which would be replaced by filling the group list given as
> > > argument.
> > 
> > That makes sense, given that on BSD[1], initgroups(3) is basically
> > getgrouplist() followed by setgroups().  The primary difference will be
> > adding the given group if not a member and assuring proper size of
> > ngroups.  (Yes, I did look into this myself once upon a time.)
> 
> Yup, I'm comparing the implementations of glibc and FreeBSD right
> now.  The Linux getgrouplist man page doesn't tell anything of
> the handling of NULL pointers, so I had to use the source to see
> how they handle this.  FreeBSD asserts, GLibc just crashes.  FreeBSD
> also allows a NULL group pointer if *ngroups is 0.  I like FreeBSD 
> better here, so I'll do the same.

Done.  Please give it a try.  I used this STC for testing:

$ cat > ggl.c <<EOF
#include <stdio.h>
#include <grp.h>

int
main (int argc, char **argv)
{
  int ret, ngroups;
  gid_t groups[256];

  ngroups = 0;
  ret = getgrouplist (argv[1], 20000, NULL, &ngroups);
  printf ("ret = %d, ngroups = %d\n", ret, ngroups);

  ngroups = 1;
  ret = getgrouplist (argv[1], 20000, NULL, &ngroups);
  printf ("ret = %d, ngroups = %d\n", ret, ngroups);

  ngroups = 1;
  ret = getgrouplist (argv[1], 20000, groups, &ngroups);
  printf ("ret = %d, ngroups = %d\n", ret, ngroups);

  ngroups = 256;
  ret = getgrouplist (argv[1], 20000, groups, &ngroups);
  printf ("ret = %d, ngroups = %d\n", ret, ngroups);
  for (ret = 0; ret < ngroups; ++ret)
    printf ("  %d%s", groups[ret], ret < ngroups - 1 ? ", " : "\n");

  ret = getgrouplist (argv[1], 20000, groups, NULL);
  printf ("ret = %d, ngroups = %d\n", ret, ngroups);

  return 0;
}
EOF

The last getgrouplist call should always abort due to an assertion.
The first call should abort if you don't give an argument.  The group
20000 is an arbitrary group in my /etc/group file which exists, but
which no user is a member of.

Please note that getgrouplist does not always add the gid to the
group list in my implementation.  The requirement is that it must
exist in /etc/groups.  There's no good reason to add a group to
the group list if the group isn't backed by a OS SID.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

  reply	other threads:[~2011-10-28  9:34 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-26 21:02 Yaakov (Cygwin/X)
2011-10-26 21:06 ` Yaakov (Cygwin/X)
2011-10-26 21:24   ` Marco Atzeri
2011-10-26 21:29     ` Marco Atzeri
     [not found] ` <1319665558.90381.YahooMailNeo@web114712.mail.gq1.yahoo.com>
2011-10-26 21:49   ` Cary R.
2011-10-26 22:22     ` Christopher Faylor
2011-10-26 22:57       ` Cary R.
2011-10-26 23:35         ` Christopher Faylor
2011-10-27  1:26           ` Cary R.
2011-10-27  4:55             ` Christopher Faylor
2011-10-26 22:33     ` Charles Wilson
2011-10-29 23:32       ` Reini Urban
2011-10-30  4:54         ` Christopher Faylor
2011-10-31  0:44           ` Yaakov (Cygwin/X)
2011-10-31 23:40             ` Charles Wilson
2011-11-01  0:24               ` Charles Wilson
2011-10-27  0:42 ` Yaakov (Cygwin/X)
2011-10-27  8:08   ` Corinna Vinschen
2011-10-28  3:11     ` Yaakov (Cygwin/X)
2011-10-28  3:55       ` Christopher Faylor
2011-10-28  7:57         ` Corinna Vinschen
2011-10-28  8:21           ` Yaakov (Cygwin/X)
2011-10-28  8:48             ` Corinna Vinschen
2011-10-28  9:34               ` Corinna Vinschen [this message]
2011-10-27  1:31 ` Dave Korn
2011-10-27  4:52   ` Christopher Faylor
2011-11-08  1:17 ` Dr. Volker Zell
2011-11-09 23:51   ` Yaakov (Cygwin/X)
2011-11-10  1:59     ` Dr. Volker Zell
2011-11-10  2:38       ` Yaakov (Cygwin/X)
2011-11-10 23:01         ` Dr. Volker Zell
2011-12-03 23:45 ` Charles Wilson
2011-12-05  0:33   ` Yaakov (Cygwin/X)
2011-12-05  2:05     ` Charles Wilson
2011-12-05  3:03       ` Yaakov (Cygwin/X)
2011-12-05  6:25         ` Charles Wilson
2011-12-05 16:15           ` Christopher Faylor
2011-12-05  5:32 ` Yaakov (Cygwin/X)
2012-01-08  1:57   ` Samuel Thibault
2012-01-08  3:36     ` Yaakov (Cygwin/X)
2012-01-08  3:47 ` Yaakov (Cygwin/X)
2012-01-10  8:07   ` Peter A. Castro
2012-01-10 14:27   ` Jason Tishler

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=20111028093335.GB31017@calimero.vinschen.de \
    --to=corinna-cygwin@cygwin.com \
    --cc=cygwin-apps@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).