/[Perly]/lib/Perly/Action/Run.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /lib/Perly/Action/Run.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 14 by dpavlin, Tue Jun 5 22:38:29 2007 UTC revision 15 by dpavlin, Tue Jun 5 23:23:30 2007 UTC
# Line 10  Perly::Action::Run Line 10  Perly::Action::Run
10  package Perly::Action::Run;  package Perly::Action::Run;
11  use base qw/Perly::Action Jifty::Action/;  use base qw/Perly::Action Jifty::Action/;
12    
13    use Data::Dump qw/dump/;
14    use File::Temp qw/tempdir/;
15    use File::Slurp;
16    use Cwd qw/cwd/;
17    
18  use Jifty::Param::Schema;  use Jifty::Param::Schema;
19  use Jifty::Action schema {  use Jifty::Action schema {
20    
# Line 46  sub sticky_on_failure { 1 } Line 51  sub sticky_on_failure { 1 }
51    
52  =head2 take_action  =head2 take_action
53    
54    This action is B<huge security hole>. It executes script entered over web
55    page, without any sandboxing in new shell under user running Jifty.
56    
57  =cut  =cut
58    
59  sub take_action {  sub take_action {
60      my $self = shift;      my $self = shift;
       
     # Custom action code  
       
     $self->report_success if not $self->result->failure;  
       
     return 1;  
 }  
61    
62  =head2 report_success          my $code = Perly::Model::Code->new;
63            $code->load( $self->argument_value( 'code' ) ) or die "can't load code";
64    
65  =cut          my $input = Perly::Model::Input->new;
66            if ( my $input_id = $self->argument_value( 'input' ) ) {
67                    $input->load( $input_id ) or die "can't load $input_id";
68            }
69    
70  sub report_success {          my $cwd = cwd;
71      my $self = shift;          my $dir = tempdir( '/tmp/perly-XXXX', CLEANUP => 0 );
72      # Your success message here  
73      $self->result->message('Success');          chdir( $dir ) || die "can't chdir $dir";
74    
75            write_file( $code->name, $code->source );
76            chmod 0700, $code->name;
77    
78            write_file( $input->name, $input->content ) if ( $input->content );
79    
80            my $cmd = './' . $code->name . ' ' . $input->name;
81    
82            my $output = `$cmd 2>&1`;
83            $output =~ s/^Can't ignore signal CHLD, forcing to default\.\n//s;
84    
85            my $message = '$ ' . $cmd;
86    
87            chdir( $cwd ) || die "can't return to $cwd";
88    
89        $self->result->message( $message );
90            $self->result->content( output => $output, cmd => $cmd );
91    
92        return 1;
93  }  }
94    
95  1;  1;

Legend:
Removed from v.14  
changed lines
  Added in v.15

  ViewVC Help
Powered by ViewVC 1.1.26