delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2023/08/17/22:19:15

X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2679E385E020
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1692325154;
bh=ZrD9Hr6Nf5Iep3PQZzOvKgK687Q5FZKJ1IZHlGWZmDQ=;
h=References:In-Reply-To:Date:Subject:To:Cc:List-Id:
List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe:
From:Reply-To:From;
b=o3PwknOw46LM6GBeKeHKlpqNEQAhuVmXMtUv4XkCWPcj7Erm/29gSZuOkYXQkQ+VW
DDi0DEjMWjqXmkxPyRP1b7kMdkspiIaHOTj/EVifZw0e8wHYOiA3+Mec1acU5wlMg7
zVy2yrbkqBLHgnCQcMumQbo+z9sk9/hoNemVAhBE=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4209E3854826
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20221208; t=1692325099; x=1692929899;
h=content-transfer-encoding:cc:to:subject:message-id:date:from
:in-reply-to:references:mime-version:x-gm-message-state:from:to:cc
:subject:date:message-id:reply-to;
bh=HycN+RgDq4TanNIfu1Lc8ElLr9JiKy+LMQK6Lbx6EYQ=;
b=aL3Gb0pe/0SNu4m2tYlvfYV2azzYoq80aKlh6MyfJOzVsCX4X4JGAuJ5jfQT7wS3AQ
8ODN9MxBMfFngJfHpPeD6U4K3je8usdadEK2v26rvkNPzzDjrmhu2sC/haWlCoTZro6F
Snv/UJMELOH5bsNNLrhmaw/AZ8CwN7p4GcT9K/mQK0MzrMT2I8kiIGS3aazGTsvjkaiL
Q3DdrOSRU19EQSf9Nyt/5UaNgmkCeVUPVSYflt1tFGwJY4QrhJKqIt+bmqsL4631lSV6
jAlnaHHllb1lW6f3wAu+tCVKghImC58M1pAsf+53aVZCl6wV4999CdwvFkCeBnuI95cX
jSLg==
X-Gm-Message-State: AOJu0YxHDIBt1cH8pist0dQFVZPaCvDFApV98pRvsAeJ1GpCn7sQj4bH
k8SnCfWU8mAEHen1ppKrHk3elz34Rz4ETvG489IMdCqar0j8uQ==
X-Google-Smtp-Source: AGHT+IFY8TtGzdBkvothC6csWrwa3D42WnZ701UXWxXXrbmCu8v3TmGHxdYJsDa3QqBoEDKchbGU8CyN9noW+thhY2E=
X-Received: by 2002:a17:90a:8a10:b0:26d:4312:17e5 with SMTP id
w16-20020a17090a8a1000b0026d431217e5mr609503pjn.6.1692325099244; Thu, 17 Aug
2023 19:18:19 -0700 (PDT)
MIME-Version: 1.0
References: <CANH4o6OpsvT99AeJ2uTcqyajWQHmffYJqV=RR4HBxoFaveR7sQ AT mail DOT gmail DOT com>
In-Reply-To: <CANH4o6OpsvT99AeJ2uTcqyajWQHmffYJqV=RR4HBxoFaveR7sQ@mail.gmail.com>
Date: Thu, 17 Aug 2023 19:18:11 -0700
Message-ID: <CAKwdsS_Q93_Z0E2cM2iw+DZRvB0DaR6YSi9frod_uh7aoCMxUA@mail.gmail.com>
Subject: Re: Test for Windows Administrator permissions from Cygwin
terminal|script?
To: Martin Wege <martin DOT l DOT wege AT gmail DOT com>
Cc: cygwin AT cygwin DOT com
X-Spam-Status: No, score=1.2 required=5.0 tests=BAYES_05, DKIM_SIGNED,
DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,
SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6
X-Spam-Level: *
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
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
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: Backwoods BC via Cygwin <cygwin AT cygwin DOT com>
Reply-To: Backwoods BC <completely DOT and DOT totally DOT trash AT gmail 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 37I2JETi026856

On Thu, Aug 17, 2023 at 7:01 PM Martin Wege via Cygwin
<cygwin AT cygwin DOT com> 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

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