Re: sudo permissions trouble on RedHat 7.3
From: Kevin Collins (firstname.lastname@example.org)
From: email@example.com (Kevin Collins) Date: 10 Apr 2003 15:09:53 -0700
Kevin Rodgers <firstname.lastname@example.org> wrote in message news:<3E948A3D.email@example.com>...
> Jim Closky wrote:
> > To begin, I set up a single php page and tried to do an "ls"
> > command to see if I could return the ls results to the page. Executed manually, it
> > works, but it won't execute from the php page. Can someone tell me what I missed?
> > Here's the shell script
> > #! /bin/bash
> > /usr/bin/sudo
> > ./script
> > ls >> list.txt
> > Here's the php script:
> > <?
> > $script = 'script';
> > exec($script);
> > include ("list.txt");
> > ?>
> > Here's the sudoers file
> > ## I know this is insecure, I gave apache all permissions temporarily for testing
> > purposes.
> > apache ALL=NOPASSWD: ALL
> Perhaps the problem is that the httpd daemon runs as user nobody, not user
That is possible - but it depends on the system. My systems run under
user "apache", too.
Your PHP is could be done a lot better, and (though I am not 100%
positive) I believe the include() is processed before the exec().
>From your shell script, I assume that your system is configured to
start a shell when no options or arguments are passed? If so, I'm also
wondering if you shell script ever exits, because is starts a new
(root) shell, runs "script" and "ls", but never exits! A better way is
to call you command or script directly with sudo.
Here is some better code:
$script = '/usr/bin/sudo ls';
$lsout = `/usr/bin/sudo ls`
Hope that helps...