Ignore:
Timestamp:
06/28/10 01:17:53 (3 years ago)
Author:
BrainSlayer
Message:

proftp update

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/router/proftpd/tests/t/lib/ProFTPD/Tests/Commands/MFF.pm

    r12685 r14672  
    2222  }, 
    2323 
     24  mff_chrooted_ok => { 
     25    order => ++$order, 
     26    test_class => [qw(forking rootprivs)], 
     27  }, 
     28 
    2429  mff_bug3142 => { 
    2530    order => ++$order, 
     
    5863 
    5964  undef $self; 
    60 }; 
     65} 
    6166 
    6267sub mff_ok { 
     
    6772  my $pid_file = File::Spec->rel2abs("$tmpdir/cmds.pid"); 
    6873  my $scoreboard_file = File::Spec->rel2abs("$tmpdir/cmds.scoreboard"); 
    69   my $log_file = File::Spec->rel2abs('cmds.log'); 
     74 
     75  my $log_file = File::Spec->rel2abs('tests.log'); 
    7076 
    7177  my $auth_user_file = File::Spec->rel2abs("$tmpdir/cmds.passwd"); 
     
    9399    } 
    94100 
    95     unless (chown($uid, $gid, $home_dir)) { 
    96       die("Can't set owner of $home_dir to $uid/$gid: $!"); 
     101    unless (chown($uid, $gid, $home_dir, $test_file)) { 
     102      die("Can't set owner of $home_dir, $test_file to $uid/$gid: $!"); 
    97103    } 
    98104  } 
     
    181187} 
    182188 
    183 sub mff_bug3142 { 
     189sub mff_chrooted_ok { 
    184190  my $self = shift; 
    185191  my $tmpdir = $self->{tmpdir}; 
     
    188194  my $pid_file = File::Spec->rel2abs("$tmpdir/cmds.pid"); 
    189195  my $scoreboard_file = File::Spec->rel2abs("$tmpdir/cmds.scoreboard"); 
    190   my $log_file = File::Spec->rel2abs('cmds.log'); 
     196 
     197  my $log_file = File::Spec->rel2abs('tests.log'); 
    191198 
    192199  my $auth_user_file = File::Spec->rel2abs("$tmpdir/cmds.passwd"); 
     
    199206  my $gid = 500; 
    200207 
    201   my $test_file = File::Spec->rel2abs("$tmpdir/foo bar"); 
     208  my $test_file = File::Spec->rel2abs("$tmpdir/foo"); 
    202209  if (open(my $fh, "> $test_file")) { 
    203210    close($fh); 
     
    214221    } 
    215222 
    216     unless (chown($uid, $gid, $home_dir)) { 
    217       die("Can't set owner of $home_dir to $uid/$gid: $!"); 
     223    unless (chown($uid, $gid, $home_dir, $test_file)) { 
     224      die("Can't set owner of $home_dir, $test_file to $uid/$gid: $!"); 
    218225    } 
    219226  } 
     
    230237    AuthUserFile => $auth_user_file, 
    231238    AuthGroupFile => $auth_group_file, 
     239 
     240    DefaultRoot => '~', 
    232241 
    233242    IfModules => { 
     
    260269 
    261270      my ($resp_code, $resp_msg); 
     271      ($resp_code, $resp_msg) = $client->mff('modify=20020717210715;', 'foo'); 
     272 
     273      my $expected; 
     274 
     275      $expected = 213; 
     276      $self->assert($expected == $resp_code, 
     277        test_msg("Expected $expected, got $resp_code")); 
     278 
     279      $expected = 'modify=20020717210715; foo'; 
     280      $self->assert($expected eq $resp_msg, 
     281        test_msg("Expected '$expected', got '$resp_msg'")); 
     282    }; 
     283 
     284    if ($@) { 
     285      $ex = $@; 
     286    } 
     287 
     288    $wfh->print("done\n"); 
     289    $wfh->flush(); 
     290 
     291  } else { 
     292    eval { server_wait($config_file, $rfh) }; 
     293    if ($@) { 
     294      warn($@); 
     295      exit 1; 
     296    } 
     297 
     298    exit 0; 
     299  } 
     300 
     301  # Stop server 
     302  server_stop($pid_file); 
     303 
     304  $self->assert_child_ok($pid); 
     305 
     306  if ($ex) { 
     307    die($ex); 
     308  } 
     309 
     310  unlink($log_file); 
     311} 
     312 
     313sub mff_bug3142 { 
     314  my $self = shift; 
     315  my $tmpdir = $self->{tmpdir}; 
     316 
     317  my $config_file = "$tmpdir/cmds.conf"; 
     318  my $pid_file = File::Spec->rel2abs("$tmpdir/cmds.pid"); 
     319  my $scoreboard_file = File::Spec->rel2abs("$tmpdir/cmds.scoreboard"); 
     320 
     321  my $log_file = File::Spec->rel2abs('tests.log'); 
     322 
     323  my $auth_user_file = File::Spec->rel2abs("$tmpdir/cmds.passwd"); 
     324  my $auth_group_file = File::Spec->rel2abs("$tmpdir/cmds.group"); 
     325 
     326  my $user = 'proftpd'; 
     327  my $passwd = 'test'; 
     328  my $home_dir = File::Spec->rel2abs($tmpdir); 
     329  my $uid = 500; 
     330  my $gid = 500; 
     331 
     332  my $test_file = File::Spec->rel2abs("$tmpdir/foo bar"); 
     333  if (open(my $fh, "> $test_file")) { 
     334    close($fh); 
     335 
     336  } else { 
     337    die("Can't open $test_file: $!"); 
     338  } 
     339 
     340  # Make sure that, if we're running as root, that the home directory has 
     341  # permissions/privs set for the account we create 
     342  if ($< == 0) { 
     343    unless (chmod(0755, $home_dir)) { 
     344      die("Can't set perms on $home_dir to 0755: $!"); 
     345    } 
     346 
     347    unless (chown($uid, $gid, $home_dir, $test_file)) { 
     348      die("Can't set owner of $home_dir, $test_file to $uid/$gid: $!"); 
     349    } 
     350  } 
     351 
     352  auth_user_write($auth_user_file, $user, $passwd, $uid, $gid, $home_dir, 
     353    '/bin/bash'); 
     354  auth_group_write($auth_group_file, 'ftpd', $gid, $user); 
     355 
     356  my $config = { 
     357    PidFile => $pid_file, 
     358    ScoreboardFile => $scoreboard_file, 
     359    SystemLog => $log_file, 
     360 
     361    AuthUserFile => $auth_user_file, 
     362    AuthGroupFile => $auth_group_file, 
     363 
     364    IfModules => { 
     365      'mod_delay.c' => { 
     366        DelayEngine => 'off', 
     367      }, 
     368    }, 
     369  }; 
     370 
     371  my ($port, $config_user, $config_group) = config_write($config_file, $config); 
     372 
     373  # Open pipes, for use between the parent and child processes.  Specifically, 
     374  # the child will indicate when it's done with its test by writing a message 
     375  # to the parent. 
     376  my ($rfh, $wfh); 
     377  unless (pipe($rfh, $wfh)) { 
     378    die("Can't open pipe: $!"); 
     379  } 
     380 
     381  my $ex; 
     382 
     383  # Fork child 
     384  $self->handle_sigchld(); 
     385  defined(my $pid = fork()) or die("Can't fork: $!"); 
     386  if ($pid) { 
     387    eval { 
     388      my $client = ProFTPD::TestSuite::FTP->new('127.0.0.1', $port); 
     389 
     390      $client->login($user, $passwd); 
     391 
     392      my ($resp_code, $resp_msg); 
    262393      ($resp_code, $resp_msg) = $client->mff('modify=20020717210715;', 'foo bar'); 
    263394 
Note: See TracChangeset for help on using the changeset viewer.