mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kevin Qu <rofail@gmail.com>
To: dhowells@redhat.com, linux-kernel@vger.kernel.org
Subject: how to get right euid?
Date: Sat, 2 Jan 2010 21:16:42 +0800	[thread overview]
Message-ID: <78aa970c1001020516m3d2255fj38f02629e7d740c8@mail.gmail.com> (raw)

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

             reply	other threads:[~2010-01-02 13:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-02 13:16 Kevin Qu [this message]
2010-01-02 15:19 ` Jeff Epler
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=78aa970c1001020516m3d2255fj38f02629e7d740c8@mail.gmail.com \
    --to=rofail@gmail.com \
    --cc=dhowells@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®