X-Recipient: archive-cygwin AT delorie DOT com DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 79419385040B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com; s=default; t=1692348654; bh=lgM3TMV4NIY/e8cEhngWEL6HoNjoNhka+KgOkkh3E04=; h=Subject:Cc:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=voZ1YaA+BM7PF6x6RuphOWFRv4uOCRQOaJ/Jub+JoawhlJUc0o4SrifWYEDQySrkV RZv68lTTeGGlB9M2YPEaUkRiCOZiz7RANeTsE36EFEPzxxm3eNgeTT0uj5QM2rtFZK K8Q6ovFSqE/SeYwOUC0EIU0+9+2Kr+E4Fs4HdxtU= X-Original-To: cygwin AT cygwin DOT com Delivered-To: cygwin AT cygwin DOT com DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1EBB8385084A Subject: Re: Test for Windows Administrator permissions from Cygwin terminal|script? Cc: cygwin AT cygwin DOT com References: 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: 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 X-BeenThere: cygwin AT cygwin DOT com X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Mark Geisert via Cygwin Reply-To: Mark Geisert Content-Type: text/plain; charset="utf-8"; Format="flowed" Errors-To: cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com Sender: "Cygwin" Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by delorie.com id 37I8oteD014880 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 -- 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