Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #7156 > unrolled thread
| Started by | TheSaint <nobody@nowhere.net.no> |
|---|---|
| First post | 2011-06-07 22:24 +0800 |
| Last post | 2011-06-09 03:38 +0100 |
| Articles | 6 — 4 participants |
Back to article view | Back to comp.lang.python
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
| From | TheSaint <nobody@nowhere.net.no> |
|---|---|
| Date | 2011-06-07 22:24 +0800 |
| Subject | The pythonic way equal to "whoami" |
| Message-ID | <islca0$asr$1@speranza.aioe.org> |
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? -- goto /dev/null
[toc] | [next] | [standalone]
| From | Kushal Kumaran <kushal.kumaran+python@gmail.com> |
|---|---|
| Date | 2011-06-07 20:29 +0530 |
| Message-ID | <mailman.2533.1307458768.9059.python-list@python.org> |
| In reply to | #7156 |
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
[toc] | [prev] | [next] | [standalone]
| From | TheSaint <nobody@nowhere.net.no> |
|---|---|
| Date | 2011-06-08 21:58 +0800 |
| Message-ID | <isnv5p$gla$1@speranza.aioe.org> |
| In reply to | #7158 |
Kushal Kumaran wrote: > os.geteuid This return 0 for *root* . I don't know if it's a standard for all distro. Mine is Archlinux. I'd just like to avoid error caused by wrong access by user -- goto /dev/null
[toc] | [prev] | [next] | [standalone]
| From | Christopher Head <chead@is.invalid> |
|---|---|
| Date | 2011-06-08 13:08 -0700 |
| Message-ID | <20110608130845.250b0950@kruskal.chead> |
| In reply to | #7235 |
On Wed, 08 Jun 2011 21:58:17 +0800 TheSaint <nobody@nowhere.net.no> wrote: > Kushal Kumaran wrote: > > > os.geteuid > This return 0 for *root* . I don't know if it's a standard for all > distro. Mine is Archlinux. > I'd just like to avoid error caused by wrong access by user > It is. Until Linux capabilities, EUID==0 used to be special-cased in the kernel as being the test for binding to network ports <1024, bypassing filesystem access control, changing the system time, and so on. Since Linux caps, it's theoretically possible to use a different UID, but for compatibility and convenience, as well as because PID 1 (/sbin/init) is still invoked by the kernel as UID 0, everyone still does that. Chris
[toc] | [prev] | [next] | [standalone]
| From | TheSaint <nobody@nowhere.net.no> |
|---|---|
| Date | 2011-06-09 19:34 +0800 |
| Message-ID | <isqb52$vtn$1@speranza.aioe.org> |
| In reply to | #7253 |
Christopher Head wrote: > It is. Until Linux capabilities, EUID==0 used to be special-cased in the > kernel Thank you all, I got a good learning *and* something to rememeber. -- goto /dev/null
[toc] | [prev] | [next] | [standalone]
| From | Nobody <nobody@nowhere.com> |
|---|---|
| Date | 2011-06-09 03:38 +0100 |
| Message-ID | <pan.2011.06.09.02.38.42.922000@nowhere.com> |
| In reply to | #7235 |
On Wed, 08 Jun 2011 21:58:17 +0800, TheSaint wrote: >> os.geteuid > This return 0 for *root* . I don't know if it's a standard for all distro. UID 0 is the "superuser". The name "root" is conventional, but it's the EUID (effective UID) which is used in permission checks; the kernel doesn't care about names.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web