delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2023/09/22/23:11:54

X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A8E483858438
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1695438712;
bh=jRAD1raWN0ymEAyYbycWtYaHHvo2W5B/lDNtnnGt0r8=;
h=Date:Subject:To:References:In-Reply-To:List-Id:List-Unsubscribe:
List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:
From;
b=HlcSscTEgawgu2PgeL1h7SNcjGr2J12xhcX8vVBMgzdXdrrt6q6Au/98D1eRzGy77
4LSqAP4QZ3F++AcvC2aYd/Tc+fuwAGjdU1RrQK0WUg5Z8uFbORkisYE7gVh6XT9SMJ
uBvQGl/vkKRtLmd20CSam8r+xXIonOxU7gQTtF58=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4A61E3858D28
X-Authority-Analysis: v=2.4 cv=JMwoDuGb c=1 sm=1 tr=0 ts=650e574b
a=DxHlV3/gbUaP7LOF0QAmaA==:117 a=DxHlV3/gbUaP7LOF0QAmaA==:17
a=IkcTkHD0fZMA:10 a=30KeihfUasEDSKDPGhkA:9 a=QEXdDO2ut3YA:10
Message-ID: <86ff5051-58b2-818f-8989-9d9d23ef21b0@Shaw.ca>
Date: Fri, 22 Sep 2023 21:11:06 -0600
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
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>
Organization: Inglis
In-Reply-To: <905e7aef-3cbf-4a4e-a8d9-037e10691d8d@huarp.harvard.edu>
X-CMAE-Envelope: MS4xfMLT8xIMr4HykycZx6zzVyLoXKFIWet55iDiZyS7PUvN8Zgud82ELMkfwR8LOqC/MJHuY1YDQYDnpicTzS3++yYkRKUN7kcdFv6ZH1Ym74EYQFuA47hG
eUqQ5yF6fcuqrWPox5BzeI+z3jvvwA6NqGxxKWVMC3j1w7kVFrGZ0AfdbUfPaB0LA0vwNVzgh23h/THVQUbqm+PUuF4NpIozAmvP+nry2CyXq2B34pW1Dp/M
X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_SIGNED,
DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_DNSWL_LOW,
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: Brian Inglis via Cygwin <cygwin AT cygwin DOT com>
Reply-To: cygwin AT cygwin DOT com
Cc: Brian Inglis <Brian DOT Inglis AT Shaw DOT ca>
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 38N3Bs83004345

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?

-- 
Take care. Thanks, Brian Inglis              Calgary, Alberta, Canada

La perfection est atteinte                   Perfection is achieved
non pas lorsqu'il n'y a plus rien à ajouter  not when there is no more to add
mais lorsqu'il n'y a plus rien à retirer     but when there is no more to cut
                                 -- Antoine de Saint-Exupéry

-- 
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