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


Groups > comp.lang.python > #7271

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 <cameron@cskk.homeip.net>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'received:edu.au': 0.07; 'stuff,': 0.07; 'suggestion.': 0.09; 'variables,': 0.09; 'pm,': 0.10; 'wrote:': 0.14; 'from:addr:cs': 0.16; 'from:addr:zip.com.au': 0.16; 'from:name:cameron simpson': 0.16; 'message-id:@cskk.homeip.net': 0.16; 'nitin': 0.16; 'privileges.': 0.16; 'received:202.125.174': 0.16; 'received:202.125.174.133': 0.16; 'received:boardofstudies.nsw.edu.au': 0.16; 'received:cskk.homeip.net': 0.16; 'received:harvey.boardofstudies.nsw.edu.au': 0.16; 'received:homeip.net': 0.16; 'received:nsw.edu.au': 0.16; 'subject:pythonic': 0.16; 'cc:addr:python-list': 0.17; 'tue,': 0.17; 'cheers,': 0.19; 'header:In-Reply-To:1': 0.21; 'science.': 0.22; 'cc:no real name:2**0': 0.23; 'trying': 0.23; 'import': 0.29; 'cc:addr:python.org': 0.30; 'environment': 0.30; 'it.': 0.31; 'regardless': 0.34; 'header:User-Agent:1': 0.35; 'cc:2**1': 0.35; 'charset:us-ascii': 0.36; 'received:au': 0.37; 'run': 0.38; 'but': 0.38; 'subject:: ': 0.38; 'user': 0.39; 'called': 0.39; "i'd": 0.39; 'dangerous': 0.65; 'received:202': 0.66; 'subject:The': 0.69; 'database.': 0.72; 'cameron': 0.73; 'username': 0.73
Date Thu, 9 Jun 2011 14:28:22 +1000
From Cameron Simpson <cs@zip.com.au>
To Nitin Pawar <nitinpawar432@gmail.com>
Subject Re: The pythonic way equal to "whoami"
MIME-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Disposition inline
Content-Transfer-Encoding quoted-printable
In-Reply-To <BANLkTikvt1tr+Ov8sVi3LdzOoxxHKiTQeQ@mail.gmail.com>
User-Agent Mutt/1.5.20 (2009-06-14)
References <BANLkTikvt1tr+Ov8sVi3LdzOoxxHKiTQeQ@mail.gmail.com>
Cc python-list@python.org, TheSaint <nobody@nowhere.net.no>
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.41.1307594067.11593.python-list@python.org> (permalink)
Lines 27
NNTP-Posting-Host 82.94.164.166
X-Trace 1307594067 news.xs4all.nl 49044 [::ffff:82.94.164.166]:49804
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:7271

Show key headers only | View raw


On 07Jun2011 20:22, Nitin Pawar <nitinpawar432@gmail.com> wrote:
| import getpass
| user = getpass.getuser()
| 
| On Tue, Jun 7, 2011 at 7:54 PM, TheSaint <nobody@nowhere.net.no> wrote:
| > 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.
[...]

From the getuser() doco:

  Get the username from the environment or password database.
  First try various environment variables, then the password database

So, no, wrong suggestion.

Cheers,
-- 
Cameron Simpson <cs@zip.com.au> DoD#743
http://www.cskk.ezoshosting.com/cs/

Dangerous stuff, science.  Lots of us not fit for it.
        - H.C. Bailey, _The Long Dinner_

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


Thread

Re: The pythonic way equal to "whoami" Cameron Simpson <cs@zip.com.au> - 2011-06-09 14:28 +1000

csiph-web