Connecting Tech Pros Worldwide Forums | Help | Site Map

how to setuid scripts

Newbie
 
Join Date: Feb 2008
Posts: 9
#1: Apr 2 '08
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...

micmast's Avatar
Familiar Sight
 
Join Date: Mar 2008
Location: Belgium
Posts: 136
#2: Apr 2 '08

re: how to setuid scripts


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
Newbie
 
Join Date: Feb 2008
Posts: 9
#3: Apr 2 '08

re: how to setuid scripts


I can run in terminal easily..But i didnt run in browzer...i am using linux fedor7 ...
how i setuid....
Newbie
 
Join Date: Feb 2008
Posts: 9
#4: Apr 3 '08

re: how to setuid scripts


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...
prn's Avatar
prn prn is offline
Expert
 
Join Date: Apr 2007
Location: Muncie, IN
Posts: 237
#5: Apr 4 '08

re: how to setuid scripts


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
Newbie
 
Join Date: Feb 2008
Posts: 9
#6: Apr 9 '08

re: how to setuid scripts


I am a root user.. and also did grant permission ...is there any possibilities here after..
prn's Avatar
prn prn is offline
Expert
 
Join Date: Apr 2007
Location: Muncie, IN
Posts: 237
#7: Apr 9 '08

re: how to setuid scripts


Quote:

Originally Posted by thirusvga

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
Reply


Similar Unix / Linux / BSD bytes