Re: How can a program know whether it is running in superuser mode?

new topic     » goto parent     » topic index » view thread      » older message » newer message
ChrisB said...

Hi

in euphoria

 
sequence env 
env = getenv("USER") 
puts(1, env & "\n") 
 
--and 
if equal(env, "ROOT") = 1 then 
  --do stuff 
else 
  --don't do stuff 
end if 
 

Chris

This is a BAD idea. I believe any user can set the USER variable to whatever they want.

This is actually not as dangerous as changing the USER variable won't change the permissions, so there is not really a security violation, but this method isn't very accurate to determine if you really are root or not.

On bash, UID is a read-only variable, but a simple C program could override the value of the UID environment variable as well. (But again, if done this is not a security breach.)

There is no way in Euphoria to do this. The only chance is to use dll.e and wrap the "getuid()" and "geteuid()" functions from the C library.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu