From: Jeff Epler <jepler@unpythonic.net>
To: Kevin Qu <rofail@gmail.com>
Cc: dhowells@redhat.com, linux-kernel@vger.kernel.org
Subject: Re: how to get right euid?
Date: Sat, 2 Jan 2010 09:19:28 -0600 [thread overview]
Message-ID: <20100102151928.GB401@unpythonic.net> (raw)
In-Reply-To: <78aa970c1001020516m3d2255fj38f02629e7d740c8@mail.gmail.com>
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
next prev parent reply other threads:[~2010-01-02 15:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-02 13:16 how to get right euid? Kevin Qu
2010-01-02 15:19 ` Jeff Epler [this message]
2010-01-05 16:00 ` David Howells
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100102151928.GB401@unpythonic.net \
--to=jepler@unpythonic.net \
--cc=dhowells@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rofail@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox