[EXTERNAL] Re: Will all SIDs fit into |SECURITY_MAX_SID_SIZE| bytes ? / was: Re: Switching groups with newgrp - how to get the new group with |GetTokenInformation()| ?

Lavrentiev, Anton (NIH/NLM/NCBI) [C] lavr@ncbi.nlm.nih.gov
Mon Feb 26 16:12:00 GMT 2024

> A robust solution which also reduces syscalls does not necessarily
> require a precise answer here.
> I suggest writing a wrapper function which has on the stack
> and calls LookupAccountNameA() passing sidbuf as Sid.
> If it succeeds, then malloc() returned cbSid value and copy sidbuf[].
> If it fails because the buffer is too small, then malloc() the returned
> cbSid value and call LookupAccountNameA() again.
> Doing the above will keep memory use to a minimum, and will generally
> call LookupAccountNameA() once per wrapper func invocation rather than
> twice.

+1 !

Anton Lavrentiev
Contractor NIH/NLM/NCBI

More information about the Cygwin mailing list