Switching groups with newgrp - how to get the new group with |GetTokenInformation()| ?

Dan Shelton dan.f.shelton@gmail.com
Fri Apr 19 23:44:51 GMT 2024


On Mon, 11 Mar 2024 at 17:57, Corinna Vinschen via Cygwin
<cygwin@cygwin.com> wrote:
>
> On Mar 11 02:28, Dan Shelton via Cygwin wrote:
> > On Wed, 6 Mar 2024 at 14:01, Corinna Vinschen via Cygwin
> > <cygwin@cygwin.com> wrote:
> > > On Mar  5 23:38, Dan Shelton via Cygwin wrote:
> > > > Always editing /etc/nsswitch.conf
> > > > forth and back is not a elegant solution, aside from race conditions
> > > > with other users on a system
> > >
> > > So, here we go again.
> > >
> > > - What exactly are you trying to accomplish by enumerating the accounts?
> > >   Maybe you won't actually need it for your task at hand.
> >
> > We're trying to do several things, including but not limited to:
> > - Finding which local groups exist. Part of our customer software
> > expects that certain groups exist. Unfortunately the group names vary
> > between installations, and sometimes names are prefixed with site
> > names. Trying to do all permutations with just getent passwd
> > $iteration means too many combinations (>= 4000000). So just
> > enumerating all local groups with getent group would be the way to go.
>
> Then just change /etc/nsswitch.conf to enumerate "local" as well
> and be done with it.

That file is read-only for some customer installations, and we are not
allowed to touch it.

>
> You can even go so far as to use the Windows enumerator, i.e.,
>
>   $ net localgroup
>
> and than script it to use its output as input to getent group
> for only the groups you really need info for.

net localgroup changes layout and messages per system locale. That
might be nice to watch as a human user, but impossible to write a
parser. That damn thing does not honor LC_ALL, and I am now basically
forced to write custom parsers for each customers language.

Dan
-- 
Dan Shelton - Cluster Specialist Win/Lin/Bsd


More information about the Cygwin mailing list