X-Recipient: archive-cygwin@delorie.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:mime-version:in-reply-to:references:date
	:message-id:subject:from:to:content-type; q=dns; s=default; b=j3
	5rSrIrQUs9pkDbLWarHFqBeWQL6isIpwYa189DRuol3ShxUxcYO+Q59zMW8iGoGg
	C75tvUMIjC5PEd/f1SAdDUW2yAxtLci4D/8+v9GPoDGe4tSdPNu41P3WqnJ2C89X
	FURbjagztY6ydxR2kq6Ny1qZ9HICtw24BNLVA36z8=
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:mime-version:in-reply-to:references:date
	:message-id:subject:from:to:content-type; s=default; bh=NM8W9261
	qBzdxhlb7bCzLVcHmto=; b=C2zTzUj7QGYu80Ol9nXpWRUWYlv8R5tek1xLHxjP
	XwtQ65YA9WD5J9kzDbfwOKzLaGtBmIc3RxJFPUx3aTo/yNr9sgIsgs6MN0tjVTMY
	W3G9wGxcBheP4LUPoFW6c9/WYQZ2N84nS3v682bkifZE1u+sPiddtdboTuRf5htd
	meg=
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=2.3 required=5.0 tests=AWL,BAYES_50,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2
X-HELO: mail-pb0-f50.google.com
MIME-Version: 1.0
X-Received: by 10.68.202.38 with SMTP id kf6mr2272114pbc.43.1382613726932; Thu, 24 Oct 2013 04:22:06 -0700 (PDT)
In-Reply-To: <21085.47545.572257.639431@consult.pretender>
References: <21085.47545.572257.639431@consult.pretender>
Date: Thu, 24 Oct 2013 12:22:06 +0100
Message-ID: <CAFO6C=w=JYbEdGpaqM_f9GE=_=542q8a+VVCJVbYkEvf=Z=gMA@mail.gmail.com>
Subject: Re: Root/Administrator privileges from cygwin terminal
From: Anthony Geoghegan <anthony.geoghegan@gmail.com>
To: cygwin@cygwin.com
Content-Type: text/plain; charset=UTF-8
X-IsSubscribed: yes

>    The only solution I have now is to open a new bash window as administrator.
>    So is there a way to elevate (or change) privileges from with a bash shell?

A while ago, I researched a Cygwin equivalent for sudo but that's what
I ended up doing, myself.

> 2. Is there any better way to determine that one has Administrator
>    privileges than to run something like:
>                 id -G | grep -Eq '<\544\>'
>    Or:
>                 [[ `id -G` =~$(echo "\<544\>") ]]
>
>         (note the 'echo' is used to get around incompatibilities in
>         various versions of bash on how word separators are recognize.)

I use something similar:  [[ $(groups) == *Administrators* ]]
It's more readable and it works on pretty much every version of Bash.

For POSIX compatibility, you could probably use something like:
case $(groups) in
  *Administrators*) echo Member of Administrators group;;
  *) echo Not a member of Administrators group;;
esac

This approach has worked well enough for me in the past but I don't do
anything too unusual other than stopping / starting Windows services.

Regards,
Anthony Geoghegan

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

