public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin@cygwin.com
Subject: Re: Getting groups you belong to in perl
Date: Fri, 14 Mar 2014 16:50:00 -0000	[thread overview]
Message-ID: <20140314163026.GB2355@calimero.vinschen.de> (raw)
In-Reply-To: <1247713652.20140314170446@yandex.ru>

[-- Attachment #1: Type: text/plain, Size: 2132 bytes --]

On Mar 14 17:04, Andrey Repin wrote:
> Greetings, PANEL Vincent (CIS/SIN)!
> 
> >>> Don't know if this list is more appropriate than the Perl one but my
> >>> question is actually about porting a Perl script to Cygwin. I need to
> >>> check if the current user running the script belongs to a pre-defined group.
> 
> >>> Under *nix, I get the list of users belonging to the group and see if
> >>> the current user is in this list.
> 
> >>How exactly you are doing this? (I hope you're not reading it from
> >>/etc/group, because that file may not exist at all, or contain exactly
> >>zero relevant
> >>information.)
> 
> > I'm using standard perl commands (getgrnam, getlogin, etc... :
> > http://perldoc.perl.org/5.14.2/functions/getgrnam.html) which are probably
> > using standard C libraries in the background (I hope). The doc explicitly
> > says "The $members value returned by getgr*() is a space-separated list of
> > the login names of the members of the group" but it's always empty under
> > Cygwin. 
> 
> The functionality you're looking for may(or may not) be available soon(tm).
> Corinna doing some rework of the core user/group handling as we speak.

No, sorry.  You don't know it yet, but you really don't want that.  The
cost to generate full gr_mem info from the Windows user DBs in terms of
performance is prohibitive.  And it's really not required information
because there are other ways to fetch this info only if it's really
required:

- For the current user, use getgroups(2):

    http://linux.die.net/man/2/getgroups

- For another account use getgrouplist(3):

    http://linux.die.net/man/3/getgrouplist

> Check the "Testers needed: New passwd/group handling in Cygwin" thread(s).
> Do note that in the light of upcoming 1.29 release, snapshots do not contain
> the code in question. You'd need to rebuild DLL from CVS to get them.

Or just use the older 2014-03-05 snapshot for the time being.


Corinna

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

[-- Attachment #2: Type: application/pgp-signature, Size: 819 bytes --]

  reply	other threads:[~2014-03-14 16:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-14 10:25 PANEL Vincent (CIS/SIN)
2014-03-14 11:37 ` Andrey Repin
2014-03-14 13:05   ` PANEL Vincent (CIS/SIN)
2014-03-14 14:00     ` Andrey Repin
2014-03-14 16:50       ` Corinna Vinschen [this message]
2014-03-14 18:45         ` Andrey Repin
2014-03-21 11:13           ` Linda Walsh

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=20140314163026.GB2355@calimero.vinschen.de \
    --to=corinna-cygwin@cygwin.com \
    --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).