delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2023/09/23/10:02:58

X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 29EC73857B9B
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1695477777;
bh=4aI8JLdWLZJAyzcXZRRvtjTYrknQqThLzyBRb8akA1c=;
h=Date:Subject:To:References:In-Reply-To:List-Id:List-Unsubscribe:
List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:
From;
b=WXi1SY0A5Zxqo9fyzEFCzWfYu9fW3+PjpnrcsxagpLAuP7pn+meRUJ+xi+Q2/mHjw
lVdfCkp4w1J8K/CvxApgZmLmcKnfZ+dAeSmbu1ePoT8xBTmGxEyRE9Vvg282KEqMRf
IE522YZKJThgTdrhAXOJ3TOGa9duvt58fevljCGU=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 645C93858C66
Message-ID: <93b60051-0257-4417-bb12-2ad6e71db8d9@huarp.harvard.edu>
Date: Sat, 23 Sep 2023 10:02:17 -0400
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: Shell API to get Windows SID from Cygwin name?
To: cygwin AT cygwin DOT com
References: <CANH4o6Myw2==vuhFQ=5ux3vj991u3-qEofQpbTOr3CYUJBf-Gw AT mail DOT gmail DOT com>
<8ccc20eb-b921-d6d1-bc61-03aa24314ebd AT Shaw DOT ca>
<905e7aef-3cbf-4a4e-a8d9-037e10691d8d AT huarp DOT harvard DOT edu>
<86ff5051-58b2-818f-8989-9d9d23ef21b0 AT Shaw DOT ca>
In-Reply-To: <86ff5051-58b2-818f-8989-9d9d23ef21b0@Shaw.ca>
X-Spam-Status: No, score=-0.7 required=5.0 tests=BAYES_00, BODY_8BITS,
KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS,
TXREP autolearn=ham autolearn_force=no version=3.4.6
X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on
server2.sourceware.org
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.30
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
From: "Allen, Norton T. via Cygwin" <cygwin AT cygwin DOT com>
Reply-To: "Allen, Norton T." <allen AT huarp DOT harvard DOT edu>
Errors-To: cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com
Sender: "Cygwin" <cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com>
X-MIME-Autoconverted: from base64 to 8bit by delorie.com id 38NE2vAK005316

On 9/22/2023 11:11 PM, Brian Inglis wrote:
> On 2023-09-22 18:15, Allen, Norton T. via Cygwin wrote:
>> On 9/22/2023 8:07 AM, Brian Inglis via Cygwin wrote:
>>> On 2023-09-21 23:58, Martin Wege via Cygwin wrote:
>>>> Does Cygwin have a shell (e.g. bash) API to lookup the Windows SID for
>>>> a given Cygwin user or group name?
>>>> /usr/bin/getent usersid thisisausername
>>>
>>> Forget Windows! Think Unix:
>>>
>>> $ getent passwd $USER    # sanitized output:
>>> $USER:*:$UID:545:U-$HOSTNAME/$USER,S-1-5-21-...-...-...-1001:$HOME:/bin/bash 
>>>
>>>
>> According to the man page, getent passwd takes a numeric UID, not a 
>> user name. But if you don't provide a UID, it basically lists what 
>> would be in /etc/passwd, which you could parse to locate the row you 
>> want by username.
>
> [IIRC getent evolved from SunOS YellowPages/YP/NIS/+ facilities and 
> commands as LANs, sites, and orgs required more central control and 
> distribution than could easily be managed using text files 
> /etc/{hosts,protocols,services,networks,...}, while requiring 
> flexibility to allow some local setup and configurable priority 
> depending on system roles, provided by the Name Services Switch 
> /etc/nsswitch.conf.]
>
> I checked all distro man pages I can find online and have locally, and 
> from SunOS and Solaris, key lookup and other features were supported 
> from the early days, while BSDs appear to use GNU (glibc) getent (or 
> at least its man page), as does Linux.
>
> All data sources support lookup by non-numeric key get...nam....(3), 
> some by numeric key get...id(3), and some support enumeration 
> set...ent(3), get...ent(3), end...ent(3), e.g.
>
> $ man getent
> ...
> passwd    When no key is provided, use
>     setpwent(3), getpwent(3), and endpwent(3)
>     to enumerate the passwd database.
>     When one or more key arguments are provided, pass each
>     numeric key to getpwuid(3) and each
>     nonnumeric key to getpwnam(3)
>     and display the result.
>     On Cygwin the key can also be a Windows SID.
> ...
>
> Perhaps you were thinking of POSIX id(1p) which only takes a user 
> login name?
>
Sorry, you are entirely correct. I tried with my username and got 
nothing. Then I remembered I have a different username on this system.



-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019