Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #7158

Re: The pythonic way equal to "whoami"

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <kushal.kumaran@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.008
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'python,': 0.01; 'desired.': 0.07; 'though.': 0.07; 'readable': 0.09; 'pm,': 0.10; 'users,': 0.14; 'wrote:': 0.14; 'privileges.': 0.16; 'subject:pythonic': 0.16; 'cc:addr:python-list': 0.17; 'tue,': 0.17; 'header:In-Reply-To:1': 0.21; 'cc:2**0': 0.22; 'cc:no real name:2**0': 0.23; 'trying': 0.23; 'function': 0.25; 'sender:addr:gmail.com': 0.28; 'message-id:@mail.gmail.com': 0.28; 'cc:addr:python.org': 0.30; 'it?': 0.33; 'regardless': 0.34; 'there': 0.35; 'using': 0.35; 'received:google.com': 0.37; 'change': 0.37; 'mechanisms': 0.37; 'received:74.125.82': 0.38; 'received:74.125': 0.38; 'hello,': 0.38; 'run': 0.38; 'but': 0.38; 'subject:: ': 0.38; 'user': 0.39; 'should': 0.39; 'called': 0.39; "i'd": 0.39; 'unauthorized': 0.60; 'simply': 0.60; 'your': 0.60; 'subject:The': 0.69; 'to:addr:nobody': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:in-reply-to:references:from :date:x-google-sender-auth:message-id:subject:to:cc:content-type; bh=5hzuEV/VT6OI0eUvjH0C39CZkSDCM6ICYStZJ0SwVTA=; b=xWeUmWd1Ru4WeRDfVcmZjzTFosH+c8ynIac3ywnL8w34As7eQ+8FOQmQNZTHh9Yw7S ZyF/ymqNAocGW1HC9sIuUn+bmBRbVyvrDUad4+fhB1fUFnT+sRk9w3KzC2aVljwHwbJu gJvhMTINJ+x1PVxQUkFoFkQ85sgbesht4xyzw=
DomainKey-Signature a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type; b=MZqAP5fMFdhFC9NATkdQ0IVHMqKWkH/WdvSvoo7I0LqcPpHWZuN9rWvqvmiU7oJpr8 k+kg9lSgTundIUOKzFS7nLRE4eTgqrdg4jeBbV83go7eaoCsFaoRNLtmfzGLiMJmBCTC GR8uI7v1DudA8mvZab0/FOEmQUb8qQ1wMAuds=
MIME-Version 1.0
Sender kushal.kumaran@gmail.com
In-Reply-To <islca0$asr$1@speranza.aioe.org>
References <islca0$asr$1@speranza.aioe.org>
From Kushal Kumaran <kushal.kumaran+python@gmail.com>
Date Tue, 7 Jun 2011 20:29:00 +0530
X-Google-Sender-Auth OlwhD3RA9EaAwDkApRXfrecwJoQ
Subject Re: The pythonic way equal to "whoami"
To TheSaint <nobody@nowhere.net.no>
Content-Type text/plain; charset=UTF-8
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2533.1307458768.9059.python-list@python.org> (permalink)
Lines 19
NNTP-Posting-Host 82.94.164.166
X-Trace 1307458769 news.xs4all.nl 49174 [::ffff:82.94.164.166]:33407
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:7158

Show key headers only | View raw


On Tue, Jun 7, 2011 at 7:54 PM, TheSaint <nobody@nowhere.net.no> wrote:
> Hello,
> I was trying to find out whose the program launcher, but os.environ['USER']
> returns the user whom owns the desktop environment, regardless the program
> is called by root.
> I'd like to know it, so the program will run with the right privileges.
>
> Is there any standard function on python, that will do it?

os.geteuid

You should consider using the access control mechanisms provided by
your OS to do this, though.  If your program is readable by
unauthorized users, they can simply make a copy, and change as
desired.

-- 
regards,
kushal

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

The pythonic way equal to "whoami" TheSaint <nobody@nowhere.net.no> - 2011-06-07 22:24 +0800
  Re: The pythonic way equal to "whoami" Kushal Kumaran <kushal.kumaran+python@gmail.com> - 2011-06-07 20:29 +0530
    Re: The pythonic way equal to "whoami" TheSaint <nobody@nowhere.net.no> - 2011-06-08 21:58 +0800
      Re: The pythonic way equal to "whoami" Christopher Head <chead@is.invalid> - 2011-06-08 13:08 -0700
        Re: The pythonic way equal to "whoami" TheSaint <nobody@nowhere.net.no> - 2011-06-09 19:34 +0800
      Re: The pythonic way equal to "whoami" Nobody <nobody@nowhere.com> - 2011-06-09 03:38 +0100

csiph-web