By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,672 Members | 1,284 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,672 IT Pros & Developers. It's quick & easy.

how to setuid scripts

P: 9
please help me...
Hi i want to run a php program using linux command....
php program is stored in /var/www/html/t.php
that program is
<?php
$command='ooffice -invisible "macro:///Standard.Module4.Main()"';
print system($command);
echo"successfully converted";
?>
the above program is run in terminal....
[root@localhost html] php t.php
successfully run
But doesnot run in browzer...

somebodys told set uid .....
I dont know how to setuid in terminal ...
so please help me...
Apr 2 '08 #1
Share this Question
Share on Google+
6 Replies

micmast
100+
P: 144
if you want to run a php program in your terminal you need to add an argument I think it is -r but quickly read the manual
-> man php
Apr 2 '08 #2

P: 9
I can run in terminal easily..But i didnt run in browzer...i am using linux fedor7 ...
how i setuid....
Apr 2 '08 #3

P: 9
do u understand my question..
I was able to run a linux syatem command in browser through php like sample date function using php...
<?php
print exec('date');
?>
it was successfully run in browser....but some programs are not run in browser..
my php programs are stored in /var/www/html.......
any way is there... please tell me...
Apr 3 '08 #4

prn
Expert 100+
P: 254
prn
I just answered another question that probably overlaps a great deal with yours. As in the other question, this is almost certainly just what you suggest here: a question of the fact that the "user" running the web server is not root (or whoever) so you need to grant limited privs to the web server. The discussion below "Now here comes the warning" in that post should be the answer here too.

HTH,
Paul
Apr 4 '08 #5

P: 9
I am a root user.. and also did grant permission ...is there any possibilities here after..
Apr 9 '08 #6

prn
Expert 100+
P: 254
prn
I am a root user.. and also did grant permission ...is there any possibilities here after..
You may be root, but when you run a script from a browser, root is not (or at least should not be) running the script --- the web server user (probably www or httpd) is running the script on your behalf. To whom did you grant permission?

At least 80% of the time when one user can run something and another cannot the problem is some kind of permission problem. Virtually all the rest of the time, it is an environment problem. The first question is "who is your web server user?" For example:
Expand|Select|Wrap|Line Numbers
  1. [root@foo ~]# ps -ef | grep httpd
  2. www       2248     1  0 Jan04 ?        00:00:00 /usr/bin/perl /home/httpd/perl/bar
shows that www is the user that actually runs the webserver on host "foo". So, does www have permission to run your script. If you are root, do:
Expand|Select|Wrap|Line Numbers
  1. [root@foo ~]# su - www
(don't forget the "-" in that command!!!) and then try to run the script. Does it run properly? If yes, then we'll have to come up with another hypothesis, but I would be very surprised if it does. You are likely to get some kind of informative error message if it does not.

Let us know what happens.

HTH,
Paul
Apr 9 '08 #7

Post your reply

Sign in to post your reply or Sign up for a free account.