Re: system()/exec() ?

2001-08-01 Thread Aaron Kennedy

Hi,

If I'm interpreting you correctly, you'll find that your scripts are
actually executing correctly, you're simply not capturing their output,
which, presumably, is what you want.  The mod_perl docs mention that you
can solve this by recompiling your perl installation to support sfio, but
I've always found this a little extreme.
My prefered solution is to use a perl module called Apache::SubProcess
(search on CPAN) which redefines system()/exec() to work from within a
mod_perl script.

Cheers,

Aaron


 On Tue, 31 Jul 2001, Mauricio Amorim wrote:

> Hi
> I see an discussion in April by Mike Austin, about utilization of exec and 
>system commands with mod_perl.
> Anybody know if is possible to use system and exec commands, because i tried use 
>it, but the script don´t execute and apache display nothing in the logs/error_log
>
> thank you
>




Re: system()/exec() ?

2001-08-01 Thread Mauricio Amorim

I use the Apache::SubProcess, but system/exec for a script in perl,
how:
system "script.pl";

It only work if i write:
system "/usr/xxx/perl script.pl";
In this manner, occurred an error with the request method in the script
(CGI) called (script.pl).

That's right ?


- Original Message -
From: "Stas Bekman" <[EMAIL PROTECTED]>
To: "Mauricio Amorim" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Tuesday, July 31, 2001 11:50 PM
Subject: Re: system()/exec() ?


> On Tue, 31 Jul 2001, Mauricio Amorim wrote:
>
> > Hi
> > I see an discussion in April by Mike Austin, about utilization of
exec and system commands with mod_perl.
> > Anybody know if is possible to use system and exec commands, because
i tried use it, but the script don´t execute and apache display nothing in
the logs/error_log
>
> http://perl.apache.org/guide/porting.html#Output_from_system_calls
>
>
> _
> Stas Bekman  JAm_pH --   Just Another mod_perl Hacker
> http://stason.org/   mod_perl Guide  http://perl.apache.org/guide
> mailto:[EMAIL PROTECTED]   http://apachetoday.com http://eXtropia.com/
> http://singlesheaven.com http://perl.apache.org http://perlmonth.com/
>
>




Re: system()/exec() ?

2001-07-31 Thread Stas Bekman

On Tue, 31 Jul 2001, Mauricio Amorim wrote:

> Hi
> I see an discussion in April by Mike Austin, about utilization of exec and 
>system commands with mod_perl.
> Anybody know if is possible to use system and exec commands, because i tried use 
>it, but the script don´t execute and apache display nothing in the logs/error_log

http://perl.apache.org/guide/porting.html#Output_from_system_calls


_
Stas Bekman  JAm_pH --   Just Another mod_perl Hacker
http://stason.org/   mod_perl Guide  http://perl.apache.org/guide
mailto:[EMAIL PROTECTED]   http://apachetoday.com http://eXtropia.com/
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/





Re: system()/exec() ?

2001-07-31 Thread Stas Bekman

On Tue, 31 Jul 2001, Mauricio Amorim wrote:

> I tried use Apache::SubProcess, i install Apache-SubProcess-0.02 and i change the 
>script:

http://perl.apache.org/guide/modules.html#Apache_SubProcess

> use Apache qw(exit);
> use Apache::SubProcess qw(system exec);
> use CGI qw/:standard :html3/;
> +
> +
> +
> system("listarprograma.pl");
>
> The following error is displayed in the Apache error_log :
> [Tue Jul 31 21:23:43 2001] [error] (2)No such file or directory: Apache::SubProcess 
>exec of listarprograma.pl failed
> But listarprograma.pl is in the current directory of the script running.
>
> I tried put the complete PATH
> system("/home/masilva/local/apachelocal/cgi-bin/perl/ag1/listarprograma.pl");
>
> [Tue Jul 31 21:31:55 2001] [error] (2)No such file or directory: Apache::SubProcess 
>exec of /home/masilva/local/apachel
> ocal/cgi-bin/perl/ag1/listarprograma.pl failed
>
> Anybody can help-me.
>
> Thank you
>   - Original Message -
>   From: Mauricio Amorim
>   To: [EMAIL PROTECTED]
>   Sent: Tuesday, July 31, 2001 8:21 PM
>   Subject: system()/exec() ?
>
>
>   Hi
>   I see an discussion in April by Mike Austin, about utilization of exec and 
>system commands with mod_perl.
>   Anybody know if is possible to use system and exec commands, because i tried 
>use it, but the script don´t execute and apache display nothing in the logs/error_log
>
>   thank you
>



_
Stas Bekman  JAm_pH --   Just Another mod_perl Hacker
http://stason.org/   mod_perl Guide  http://perl.apache.org/guide
mailto:[EMAIL PROTECTED]   http://apachetoday.com http://eXtropia.com/
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/





Re: system()/exec() ?

2001-07-31 Thread Mauricio Amorim



I tried use Apache::SubProcess, i install 
Apache-SubProcess-0.02 and i change the 
script:
 
use Apache qw(exit);use Apache::SubProcess 
qw(system exec);use CGI qw/:standard :html3/;
+
+
+
system("listarprograma.pl");
 
The following error is displayed in the Apache 
error_log :
[Tue Jul 31 21:23:43 2001] [error] (2)No such file 
or directory: Apache::SubProcess exec of listarprograma.pl failed
But listarprograma.pl is in the current directory 
of the script running.
 
I tried put the complete PATH
system("/home/masilva/local/apachelocal/cgi-bin/perl/ag1/listarprograma.pl");
 
[Tue Jul 31 21:31:55 2001] [error] (2)No such file 
or directory: Apache::SubProcess exec of 
/home/masilva/local/apachelocal/cgi-bin/perl/ag1/listarprograma.pl 
failed
 
Anybody can help-me.
 
Thank you

  - Original Message -
  From: 
  Mauricio 
  Amorim 
  To: [EMAIL PROTECTED] 
  Sent: Tuesday, July 31, 2001 8:21 
PM
  Subject: system()/exec() ?
  
      Hi
      I see an discussion in April 
  by Mike Austin, about utilization of exec and system commands with 
  mod_perl.
      Anybody know if is possible to 
  use system and exec commands, because i tried use it, but the 
  script don´t execute and apache display nothing in the 
  logs/error_log
   
      thank 
you


Re: system(), exec()?

2001-04-05 Thread Stas Bekman

On Thu, 5 Apr 2001, Mike Austin wrote:

> On Thu, 5 Apr 2001, Stas Bekman wrote:
>
> > httpd.conf:
> > PerlSetEnv PERL5OPT -Mops=system
>
> Doesn't work.  I'm still able to use the system() call.
>
> Here's the stanza I used:
>
> 
> PerlSetEnv PERL5OPT -M-ops=system
> SetHandler perl-script
> PerlHandler Apache::Registry
> Options +ExecCGI
> PerlSendHeader On
> 

True, I've played with -Mop:subprocess, which works from the command line,
but not if you set it from the httpd.conf... I guess you need to dive into
Opcode.pm to find out the fine details.

I was lucky to sit next to Nat here at ApacheCon, so here is one way to
hack it:

package My::Override;
require Exporter;
@ISA = 'Exporter';
@EXPORT_OK = qw(GLOBAL_system system);
sub import {
my $pkg = shift;
return unless @_;
my $sym = shift;
my $where = ($sym =~ s/^GLOBAL_// ? 'CORE::GLOBAL' : caller(0));
$pkg->export($where, $sym, @_);
}
sub system {
warn "cannot run @_";
}
1;

then in your code:

  my $r = shift;
  $r->send_http_header("text/plain");
  $r->print("Hello $$\n");
  $ENV{PATH} = '';

  use My::Override qw(system);
  system("/bin/echo", "hello");

prints:

  cannot run /bin/echo hello at /home/httpd/perl/My/Override.pm line 13.

Since you want to override this for the whole interpreter you do this in
the startup.pl:

  use My::Override qw(GLOBAL_system);

the only problem is that people can still call CORE::system() and get the
original function.

Philip told me that he has hacked Apache::Registry to use Safe.pm, and it
works well for him.

_
Stas Bekman  JAm_pH --   Just Another mod_perl Hacker
http://stason.org/   mod_perl Guide  http://perl.apache.org/guide
mailto:[EMAIL PROTECTED]   http://apachetoday.com http://logilune.com/
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/






Re: system(), exec()?

2001-04-05 Thread Mike Austin

On Thu, 5 Apr 2001, Stas Bekman wrote:

> httpd.conf:
> PerlSetEnv PERL5OPT -Mops=system

Doesn't work.  I'm still able to use the system() call.

Here's the stanza I used:


PerlSetEnv PERL5OPT -M-ops=system
SetHandler perl-script
PerlHandler Apache::Registry
Options +ExecCGI
PerlSendHeader On


Thoughts?

Thanks,
mga.




Re: system(), exec()?

2001-04-05 Thread Stas Bekman

On Thu, 5 Apr 2001, Mike Austin wrote:

> On Thu, 5 Apr 2001, Stas Bekman wrote:
>
> > % perldoc ops
> > % perldoc Opcode
>
> But this appears to be a global change, correct?
>
> Can I restict access to these commands for most directories, but still
> enable them for a few, trusted directories?
>
> " Since the ops pragma currently has an irreversible global
>  effect, it is only of significant practical use with the
>  `-M' option on the command line."

Mike, I've not tried this one yet. I've just read the docs :) So if you
get down on actually trying it, please share your finding with the rest of
us. Thanks!

> I can't trust my users to enter -Mopts syntax in their scripts.  Can I
> pass the ops inside the  stanzas in the Apache config file?

httpd.conf:
PerlSetEnv PERL5OPT -Mops=system


_
Stas Bekman  JAm_pH --   Just Another mod_perl Hacker
http://stason.org/   mod_perl Guide  http://perl.apache.org/guide
mailto:[EMAIL PROTECTED]   http://apachetoday.com http://logilune.com/
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/





Re: system(), exec()?

2001-04-05 Thread Mike Austin

On Thu, 5 Apr 2001, Stas Bekman wrote:

> % perldoc ops
> % perldoc Opcode

But this appears to be a global change, correct?

Can I restict access to these commands for most directories, but still
enable them for a few, trusted directories?

" Since the ops pragma currently has an irreversible global
 effect, it is only of significant practical use with the
 `-M' option on the command line."

I can't trust my users to enter -Mopts syntax in their scripts.  Can I
pass the ops inside the  stanzas in the Apache config file?

Thanks again,
mga.




Re: system(), exec()?

2001-04-05 Thread Robin Berjon

At 18:52 05/04/2001 -0700, Stas Bekman wrote:
>On Thu, 5 Apr 2001, Mike Austin wrote:
>> I'm used to mod_php4, and we use "safe_mode" to allow our developers to
>> write applications, but restrict their access to files they don't own, and
>> to stop them from using system() or exec() type calls.
>>
>> Is there anything like this with mod_perl?  I'd like to offer them the
>> ability to develop with Perl, but I don't really want to give them access
>> to system() or exec() calls, or the ability to include files that they
>> don't own.
>
>% perldoc ops
>% perldoc Opcode

Is PerlOpMask in limbo or is it going to leave experimental status at some
point ?

___
Robin Berjon <[EMAIL PROTECTED]> -- CTO
k n o w s c a p e : // venture knowledge agency www.knowscape.com
--
Change is inevitable except from a vending machine.




Re: system(), exec()?

2001-04-05 Thread Stas Bekman

On Thu, 5 Apr 2001, Mike Austin wrote:

>
> Hi, I'm new to mod_perl, but I haven't been able to find an answer to this
> question.
>
> I'm used to mod_php4, and we use "safe_mode" to allow our developers to
> write applications, but restrict their access to files they don't own, and
> to stop them from using system() or exec() type calls.
>
> Is there anything like this with mod_perl?  I'd like to offer them the
> ability to develop with Perl, but I don't really want to give them access
> to system() or exec() calls, or the ability to include files that they
> don't own.

% perldoc ops
% perldoc Opcode

> For instance, I don't want them to be able to pop up an xterm display from
> our restricted web server to their display.
>
> Any thoughts?
>
> Thanks,
> mga.
>



_
Stas Bekman  JAm_pH --   Just Another mod_perl Hacker
http://stason.org/   mod_perl Guide  http://perl.apache.org/guide
mailto:[EMAIL PROTECTED]   http://apachetoday.com http://logilune.com/
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/