c - determine the user who run the current process -


this question has answer here:

i wonder, how can determine if current process running root or not. after searching on google, found out linux has field called "current" can use determine running particular process. try use

current->uid == 0 

however, when try compile code error

struct task_structâ has no member named âuidâ 

did wrong? additionally, true if process run root, uid equal zero? thanks

for process ,it have 3 kind of user id:

1.actual user id

--> of time are, man login , while root process has way change it.

use getuid() user id.

2.effective user id

-->this id decide access limits. exce function can set id ,and if didn't, user id same actual user id.

use geteuid() id

3.saved settings user id

--> copyed effective user id exec function. no function id's current value.at least , don't know.

so

how can determine if current process running root or not 

if mean running as root ,use geteuid() == 0 better, opinion.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

.htaccess - Matching full URL in RewriteCond -