From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from m0.truegem.net (m0.truegem.net [69.55.228.47]) by sourceware.org (Postfix) with ESMTPS id 1EBB8385084A for ; Fri, 18 Aug 2023 08:49:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1EBB8385084A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=maxrnd.com Authentication-Results: sourceware.org; spf=none smtp.mailfrom=maxrnd.com Received: (from daemon@localhost) by m0.truegem.net (8.12.11/8.12.11) id 37I8nRBn099823 for ; Fri, 18 Aug 2023 01:49:27 -0700 (PDT) (envelope-from mark@maxrnd.com) Received: from 50-1-247-226.fiber.dynamic.sonic.net(50.1.247.226), claiming to be "[192.168.4.101]" via SMTP by m0.truegem.net, id smtpdP17r0i; Fri Aug 18 01:49:17 2023 Subject: Re: Test for Windows Administrator permissions from Cygwin terminal|script? Cc: cygwin@cygwin.com References: From: Mark Geisert Message-ID: Date: Fri, 18 Aug 2023 01:49:18 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0 SeaMonkey/2.49.4 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00,KAM_DMARC_STATUS,KAM_LAZY_DOMAIN_SECURITY,MISSING_HEADERS,NICE_REPLY_A,SPF_HELO_NONE,SPF_NONE,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 List-Id: Backwoods BC via Cygwin wrote: > On Thu, Aug 17, 2023 at 7:01 PM Martin Wege via Cygwin > wrote: >> How can I find out whether the current Cygwin terminal has >> Administrator rights? I want to safeguard our admin scripts with a >> simple test and bail out with an error if someone wants to do admin >> stuff (say: regtool) without admin privileges. >> >> Thanks, >> Martin > > I don't know if this is the official method, but it works for me: > > ##### Shell Options > # Elevated privilege windows have $SESSIONNAME set > if [ "$SESSIONNAME" == "" ] ;then > printf -v adminPmt '[\u2022Admin\u2022] ' > else > export adminPmt="" > fi I see the opposite on my machine. Admin window has empty $SESSIONNAME, non-Admin window has "Console". What I do locally is check the output of the 'id' command. If group 544(Administrators) is present, that's a window with Admin rights. Inside .bashrc I have a simple grep test on the output of 'id' to set PS1 (shell prompt) appropriately. ..mark