lkml.org 
[lkml]   [2010]   [Jan]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: how to get right euid?
On Sat, Jan 02, 2010 at 09:16:42PM +0800, Kevin Qu wrote:
> sudo echo "some thing" > /proc/my_file
>
> It denied. (But it works when I su to superuser and do so.)
>
> So I checked the current_euid(),
> but it returns 1000 (not 0),Why?

This may be due to a misunderstanding of how shell redirects work.
Probably current_euid() is returning exactly the right thing.

When you execute
some command line > somefile
the shell opens somefile for writing and makes it be fd 1 (stdout) using
dup2. Then it execs 'some' with the argument array being
['some', 'command', 'line'].

So consider your sudo: The shell, running as user 1000, opens
'somefile' for writing, then execs 'sudo' which happens to be setuid
root.

Jeff


\
 
 \ /
  Last update: 2010-01-02 16:21    [W:0.075 / U:0.196 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site