chown file by root and execute it bye group [closed]
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Clos开发者_开发技巧ed 11 years ago.
Improve this questionthe value of a perl code is : ex.pl
system("cat /etc/shadow");
and i chown the above file to root (chown root ex.pl) . my question is if a user from groups (ex:apache) execute the above perl file then the shadow file will cated to him ? Thanks in Advance .
You should try it yourself. To understand why it doesn't work:
/etc/shadow
usually has permissions like this:
[cnicutar@fresh ~]$ ls -l /etc/shadow
-rw------- 1 root root 316 Jul 20 09:36 /etc/shadow
When you execute your script it doesn't matter who owns it (except when using setuid which you can't for scripts anyway).
The one thing that maters is who is executing it. So apache
will execute the script and it will be considered "others": no permissions.
No, because the perl code (CGI script?) will be executed with the permissions of the apache user. However if you have apache user (or the user of your webserver or whatever is executing your code, if it is a daemon) is in the sudo file then you could do system("sudo cat /etc/shadow"); and that would work.
精彩评论