delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2015/02/05/09:19:59

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:to:from:subject:date:message-id:references
:mime-version:content-type; q=dns; s=default; b=yQLshB0fvXtdEry9
JwL3DgW5Eoi2jCBtU+JsATsUy+NTihT2ujOEAEyznhikQsodZBIfi5HprPWA5loX
9dKX9Fno1W8z3WTYSuLnM/4E1JRyBGc9Zk2P+aMznR5LEuoW/Xnm/YpdOC9Q/IJL
fs7xdCxQRAbs2njfjBwaRhf+5dQ=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:to:from:subject:date:message-id:references
:mime-version:content-type; s=default; bh=vqoG4A1iYiT9PG6ZWm1FfE
A1how=; b=OARNv/M+F6HAukFmvMJdoFldTUVn2Km4WRa3jbpaT6idIHR3X+Jpw/
oYrTJbhlg6HkwrUxXKYfOwoRJvrH3wVpBSI73pybmwmun0QABs+rND1CPtpZxDhq
ePgD0Zys6nkDK7YqkIw8tvwUzpjA0UKhbZKQr3i00KyHGTLYsc5HU=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=2.8 required=5.0 tests=AWL,BAYES_00,FSL_HELO_BARE_IP_2,RCVD_IN_DNSWL_LOW,RCVD_NUMERIC_HELO,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=no version=3.3.2
X-HELO: plane.gmane.org
To: cygwin AT cygwin DOT com
From: dboyd2 AT mmm DOT com (J. David Boyd)
Subject: Re: how to determine if a shell is running as Administrator?
Date: Thu, 05 Feb 2015 09:18:03 -0500
Lines: 33
Message-ID: <gjubtwz05tno.fsf@W0144758.usac.mmm.com>
References: <slc6da9aq8g9e7h0aegafhfa86eahfd53p AT 4ax DOT com> <20150205100349 DOT GS2635 AT calimero DOT vinschen DOT de>
Mime-Version: 1.0
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (cygwin)
X-IsSubscribed: yes

Corinna Vinschen <corinna-cygwin AT cygwin DOT com> writes:

> On Feb  5 04:43, Andrew Schulman wrote:
>> What's a reliable and efficient way to determine programmatically if the shell
>> that's running has elevated privileges?
>> 
>> Or if you prefer, how can I tell if the shell was started with "Run as
>> administrator"?
>
> id -G | grep -qE '\<544\>' && echo admin || echo luser
>
>> 2. Parse the output of groups or id -G.  I can't find any reliable way to do
>> this.  For example on my host, when I start a shell with "Run as administrator",
>> the new group I get isn't 544 (Administrators).  It's 114 (Local account and
>> member of Administrators group).  Is that at all portable or reliable?
>
> Huh?  There is no such group in Windows.  Where does it come from?
> This should always work even with old /etc/group files:
>
>   id -G | grep -qE '\<544\>|\<0\>' && echo admin || echo luser
>
>
> Corinna


This doesn't seem to tell me if my shell has been started with 'Run As
Administrator', it just tells me if my user is contained in the Administrator
group.

I can start a cygwin shell, and start a cygwin shell with run as admin, and I
get the same results from the above command.

Dave


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

- Raw text -


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