This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: Getting groups you belong to in perl
- From: Andrey Repin <anrdaemon at yandex dot ru>
- To: Corinna Vinschen <cygwin at cygwin dot com>
- Date: Fri, 14 Mar 2014 20:38:23 +0400
- Subject: Re: Getting groups you belong to in perl
- Authentication-results: sourceware.org; auth=none
- References: <09C6BA32B7B1654B8AB0CAF234F2A1C114E65CBA at A04066 dot BGC dot NET> <1797360578 dot 20140314023749 at yandex dot ru> <09C6BA32B7B1654B8AB0CAF234F2A1C114E65FAE at A04066 dot BGC dot NET> <1247713652 dot 20140314170446 at yandex dot ru> <20140314163026 dot GB2355 at calimero dot vinschen dot de>
- Reply-to: cygwin at cygwin dot com
Greetings, Corinna Vinschen!
>> >>> 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.
I've had an itch about it, but I have no tools to check this functionality
myself. Thanks for confirmation.
> 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.
Indeed, I did mean "current snapshots". Sorry.
--
WBR,
Andrey Repin (anrdaemon@yandex.ru) 14.03.2014, <20:37>
Sorry for my terrible english...
--
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