public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: "PANEL Vincent (CIS/SIN)" <Vincent.Panel@belgacom.be>
To: "cygwin@cygwin.com" <cygwin@cygwin.com>
Subject: RE: Getting groups you belong to in perl
Date: Fri, 14 Mar 2014 13:05:00 -0000	[thread overview]
Message-ID: <09C6BA32B7B1654B8AB0CAF234F2A1C114E65FAE@A04066.BGC.NET> (raw)
In-Reply-To: <1797360578.20140314023749@yandex.ru>

From: Andrey Repin[]
Sent: Thursday 13 March 2014 23:38
To: PANEL Vincent (CIS/SIN);
Subject: Re: Getting groups you belong to in perl

>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.

>> Cygwin doesn't allow this way of working.

>Oh... ?

Yes indeed, the standard perl functions work but they always return an empty list of group members, similar to mkgroup.

>> I found out by reading the thread "Why mkgroup does not list group members?"
>> on this mailing list (1 message on Mon, 13 May 2013 20:29:52, for instance).

>> I would like to use perl commands without launching external
>> commands, if possible. The way I've found until now is by using the output of the "id"
>> command but I was wondering if there was another way to do it. How is "id"
>> command working by the way ?

>You can check the sources of it, it's really a very simple tool.
>(It's coreutils, by the way.
>http://mirrors.kernel.org/sourceware/cygwin/x86/release/coreutils/ )

I will do it.

--
WBR,
Andrey Repin () 14.03.2014, <02:12>

Sorry for my terrible english...


________________________________

***** Disclaimer *****
http://www.belgacom.be/maildisclaimer

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

  reply	other threads:[~2014-03-14 12:03 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) [this message]
2014-03-14 14:00     ` Andrey Repin
2014-03-14 16:50       ` Corinna Vinschen
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=09C6BA32B7B1654B8AB0CAF234F2A1C114E65FAE@A04066.BGC.NET \
    --to=vincent.panel@belgacom.be \
    --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).