Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7399477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:03:56+00:00 2026-05-29T04:03:56+00:00

i have written module which reads and write on /proc file and is working

  • 0

i have written module which reads and write on /proc file and is working fine but want to use permissions with it when i make the function for permissions shown below its gives me error (basically i want every one could read the file but only root could write in it).

int my_permission(struct inode *inode, int op)
{
if(op == 4||(op == 2 && current->euid = 0))  //euid is not a member of task_struct
return 0;
return -EACCES;
}
const  struct inode_operations my_iops = {
.permission = my_permission,
};

but its giving me error as follow:

/home/karan/practice/procf/testproc1.c: In function ‘my_permission’:
/home/karan/practice/procf/testproc1.c:50:32: error: ‘struct task_struct’ has no member named ‘euid’

I think there is other member in task_struct which points to user id . I am interested in solution as well as description of task_struct members field used for.

regards
karan

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T04:03:56+00:00Added an answer on May 29, 2026 at 4:03 am

    See include/linux/cred.h:

        #define current_euid()          (current_cred_xxx(euid))  
        #define current_cred_xxx(xxx)                   \
        ({                                              \
                current_cred()->xxx;                    \
        })
    

    and so current_euid() falls back on current_cred():

        /**
         * current_cred - Access the current task's subjective credentials
         *
         * Access the subjective credentials of the current task.  RCU-safe,
         * since nobody else can modify it.
         */
        #define current_cred() \
                rcu_dereference_protected(current->cred, 1)
    

    So for you problem, to do effective UID comparison, take a look at /fs/exec.c:

        if (current_euid() == current_uid() && current_egid() == current_gid())
        bprm->cred->euid = current_euid();
                bprm->cred->euid = inode->i_uid
    

    contrast with your program:

        if (current_euid() == 0)
    

    which means even if the user is not logined with UID=0, it will be treated effecively as UID==0? Sounds dangerous

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a kernel module which reads and writes /proc files, and it
I have a large module written in JS which uses Canvas to draw and
I have written a site in Prototype but want to switch to jQuery. Any
A friend and I have written an encryption module and we want to port
I have a Flex 4.5.1 application which loads another swf file (as a module
i have written a library with some classes that make use of qt object
I have written a XS based Perl module which provides access to functions in
I have a module written using XNA which polls the GamePad and the Keyboard
I have written a program which uses a SQL exception class and then use
I have a file Tools.ml which contains some common utility functions I write myself.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.