Re: [PHP] passthru() passing variables

2005-06-18 Thread Richard Lynch
On Fri, June 17, 2005 6:47 am, Jason Barnett said:
> What is a reliable cross-platform way of showing which user PHP is
> running as?

http://php.net/get_current_user

The bogus User Contributed note about REMOTE_USER is, well, bogus, almost
for sure.

If that fails, I guess you could try:



Then you have to dig out the PHP User from that.

It's possible there is a PHP Constant here that is the User:
http://php.net/manual/en/language.constants.predefined.php

If none of those work, I'm guessing even Windoze has something like
"whoami" so you could http://php.net/exec "whoami" or its equivalent,
based on the http://php.net/php_sapi_name

If all that fails, I'd just give up. :-)

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] passthru() passing variables

2005-06-17 Thread Jason Barnett
What is a reliable cross-platform way of showing which user PHP is 
running as?


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] passthru() passing variables

2005-06-16 Thread Richard Lynch
I dunno what 127 actually means, but the last time we saw it on this list,
it boiled down to:

"You can't even run your 'sh' shell, much less Perl in that shell."

Check what's in /bin/sh and what its permissions are.

Make sure it's actually a valid shell binary, and not something bogus.

If that's not it, keep digging.

Somewhere, somehow, you've got something in permissions that is not
allowing you to run a process/binary you need.

If it's not /bin/sh, look at Perl.
If it's not Perl, check your permissions on test.cgi again.

Remember that PHP does not run as "you" with all your permissions - If you
can 'su' to the user PHP runs as, this could get a lot easier to test...

Check httpd.conf "User" directive to be certain you know what user PHP
runs as, or check  output.

On Thu, June 16, 2005 11:55 am, Chris Herold said:
> I'm sorry, when I do the exec() */properly/ *I get
>
> OS Error: 127
> Content-type: text/html
>
> Source ID:
>
> Richard Lynch wrote:
>
>>On Wed, June 15, 2005 5:36 pm, Chris Herold said:
>>
>>
>>>I have been told that in order to pass variables via passthru() to
>>>another script (in my case, a perl script) one can do the following ...
>>>
>>>passthru("home/test.cgi $var")
>>>
>>>and that $var will then be passed through to the cgi.
>>>
>>>I have tried this and failed.
>>>
>>>Is this the proper format or is there something that I am missing.
>>>
>>>
>>
>>You may want to use exec first, so you can more easily capture the error
>>output and error codes.
>>
>>exec("home/test.cgi $var", $output, $error);
>>if ($error){
>>  //You should probably use error_log here in your real code...
>>  //ASSUME this is going to break some day, for whatever reason.
>>  //You'll need it logged unless you like dealing with error reports
>> like:
>>  //"Hey, the website broke yesterday."
>>  echo "OS Error:  $error\n";
>>  echo implode("", $output);
>>  exit;
>>}
>>echo $output;
>>
>>Meanwhile, odds are *REALLY* good that you're not even calling the
>>test.cgi script because you haven't provide a path that PHP can use.
>>
>>home/test.cgi would be assuming that home was in the same directory as
>>your PHP script, and even that is kinda iffy depending on where you do
>>this from the webserver or CLI...
>>
>>I would recommend using FULL PATH to *everything* in exec (and passthru)
>>
>>/full/path/to/home/test.cgi /full/path/to/any/args.txt
>>
>>Also be sure to use the escapeshellargs function to make your $var data
>>kosher if it comes from the outside world.
>>
>>
>>
>


-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] passthru() passing variables

2005-06-16 Thread Richard Lynch
On Thu, June 16, 2005 11:44 am, Chris Herold said:
> Thanks for the tips;  however, I think I am still missing something.
>
> My perl script is running when called by passthru() because within the
> body of the simple test code I have set it up to:
>
> 
> print "Content-type: text/html\n\n";
>
> print "Source ID: $source_id";
> 
>
> and when I run the php with the full address to my file (abbreviated
> here and before for brevity):
>
>
> $source_id = "test";
> passthru("/home/.../cgi-bin/passthru_test.cgi $source_id");
>
>
> it prints out
>
> Content-type: text/html Source ID:
>
> Which is what I expect although missing the printout for the source_id
> value.

Is Perl set with that Tainted mode thing where it won't *LET* you use
arguments from the outside world unless you at least pretend to scrub
them?

To test, what happens when you run "text.cgi test" from the command line
without PHP in the picture?

> Re:Exec()
>
> I have tried exec and it does not seem to be working for me in terms of
> producing an error output.
>
> I set it up for:
>
> exec("/home/httpd/vhosts/omniomix.com/cgi-bin/passthru_test.cgi
> $source_id,$out,$err");
>
> and I get no printout at all.
>
> Is there something obvious that I am doing wrong?

exec won't print anything at all.

You have to take further action to print out $out and/or $err.

Also, move the quote at the end of $err to be after $source_id

As it is now, you are passing 2 more arguments with commas to your
Perl/cgi script, not  providing 2 more arguments to exec.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] passthru() passing variables

2005-06-15 Thread Richard Lynch
On Wed, June 15, 2005 5:36 pm, Chris Herold said:
> I have been told that in order to pass variables via passthru() to
> another script (in my case, a perl script) one can do the following ...
>
> passthru("home/test.cgi $var")
>
> and that $var will then be passed through to the cgi.
>
> I have tried this and failed.
>
> Is this the proper format or is there something that I am missing.

You may want to use exec first, so you can more easily capture the error
output and error codes.

exec("home/test.cgi $var", $output, $error);
if ($error){
  //You should probably use error_log here in your real code...
  //ASSUME this is going to break some day, for whatever reason.
  //You'll need it logged unless you like dealing with error reports like:
  //"Hey, the website broke yesterday."
  echo "OS Error:  $error\n";
  echo implode("", $output);
  exit;
}
echo $output;

Meanwhile, odds are *REALLY* good that you're not even calling the
test.cgi script because you haven't provide a path that PHP can use.

home/test.cgi would be assuming that home was in the same directory as
your PHP script, and even that is kinda iffy depending on where you do
this from the webserver or CLI...

I would recommend using FULL PATH to *everything* in exec (and passthru)

/full/path/to/home/test.cgi /full/path/to/any/args.txt

Also be sure to use the escapeshellargs function to make your $var data
kosher if it comes from the outside world.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] passthru() passing variables

2005-06-15 Thread Chris Herold

Hi,

I have been told that in order to pass variables via passthru() to 
another script (in my case, a perl script) one can do the following ...


passthru("home/test.cgi $var")

and that $var will then be passed through to the cgi.

I have tried this and failed.

Is this the proper format or is there something that I am missing.

Thanks,
chris

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php