public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* how to get right euid?
@ 2010-01-02 13:16 Kevin Qu
  2010-01-02 15:19 ` Jeff Epler
  2010-01-05 16:00 ` David Howells
  0 siblings, 2 replies; 3+ messages in thread
From: Kevin Qu @ 2010-01-02 13:16 UTC (permalink / raw)
  To: dhowells, linux-kernel

I wrote a kernel module and it create a "file" in /proc.
The "file" permission is set to 644.
When check access permission, I use :

if( op == 4 || (op ==2 && current->euid == 0) )
        return 0;

But it does not work on 2.6.29,
so I changed it like below:

if( op & 0x4 || (op & 0x2 && current_euid() == 0) )
        return 0;

It works when read from the "file" in /proc,
but when write to it with sudo, like:

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?

Thanks for help.

Rofail Qu

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-01-05 16:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-02 13:16 how to get right euid? Kevin Qu
2010-01-02 15:19 ` Jeff Epler
2010-01-05 16:00 ` David Howells

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox