Re: The good old "permission denied", the ignored group memberships, and a proposed solution

Henrik K <[email protected]>
Newsgroups gmane.mail.virus.amavis.user
Message-ID <[email protected]>
On Sun, May 16, 2021 at 07:15:38PM +0200, Luc Pardon wrote:
> On Sun, 16 May 2021 18:57:49 +0300
> Henrik K <[email protected]> wrote:
> 
> > Well, old lazy code is also a bad thing.  I already noticed there's
> > suspect matching, $members =~ /\b$user\b/ might falsely match group
> > names containing underscores (it's a word boundary..).  Fixed it to
> > be more strict..
> > 
> 
> How about this as a one-line replacement for get_user_groups() in SA ?
> 
>    my $gids = qx/id -G $desired_user/;
> 
> The /usr/bin/id utility is part of GNU coreutils, so it's probably safe
> to take it for granted "if not (RUNNING_ON_WINDOWS)". 
> 
> The idea is not mine, I came across it when searching for a portable
> way to "get user groups" in a bash shell script. If you want, I could
> try and locate the source. I seem to recall there was a discussion
> about group names with blanks and underscores and what have you.

There is nothing portable in executing random binaries, not everyone uses
GNU compatible OS.  And some people actually post such stuff..
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.