source: src/router/proftpd/tests/t/lib/ProFTPD/Tests/Config/CreateHome.pm @ 17876

Last change on this file since 17876 was 17876, checked in by BrainSlayer, 19 months ago

update proftp

File size: 20.1 KB
Line 
1package ProFTPD::Tests::Config::CreateHome;
2
3use lib qw(t/lib);
4use base qw(ProFTPD::TestSuite::Child);
5use strict;
6
7use File::Path qw(mkpath);
8use File::Spec;
9use IO::Handle;
10
11use ProFTPD::TestSuite::FTP;
12use ProFTPD::TestSuite::Utils qw(:auth :config :running :test :testsuite);
13
14$| = 1;
15
16my $order = 0;
17
18my $TESTS = {
19  createhome_ok => {
20    order => ++$order,
21    test_class => [qw(forking rootprivs)],
22  },
23
24  createhome_dirmode_ok => {
25    order => ++$order,
26    test_class => [qw(forking rootprivs)],
27  },
28
29  createhome_explicit_parent_owner_ok => {
30    order => ++$order,
31    test_class => [qw(forking rootprivs)],
32  },
33
34  createhome_user_parent_owner_ok => {
35    order => ++$order,
36    test_class => [qw(forking rootprivs)],
37  },
38
39  createhome_skel_ok => {
40    order => ++$order,
41    test_class => [qw(forking rootprivs)],
42  },
43
44  createhome_homegid_bug3503 => {
45    order => ++$order,
46    test_class => [qw(bug forking rootprivs)],
47  },
48
49  createhome_dirmode_uid_gid_ok => {
50    order => ++$order,
51    test_class => [qw(forking rootprivs)],
52  },
53
54};
55
56sub new {
57  return shift()->SUPER::new(@_);
58}
59
60sub list_tests {
61  return testsuite_get_runnable_tests($TESTS);
62}
63
64sub createhome_ok {
65  my $self = shift;
66  my $tmpdir = $self->{tmpdir};
67
68  my $config_file = "$tmpdir/config.conf";
69  my $pid_file = File::Spec->rel2abs("$tmpdir/config.pid");
70  my $scoreboard_file = File::Spec->rel2abs("$tmpdir/config.scoreboard");
71
72  my $log_file = File::Spec->rel2abs('tests.log');
73
74  my $auth_user_file = File::Spec->rel2abs("$tmpdir/config.passwd");
75  my $auth_group_file = File::Spec->rel2abs("$tmpdir/config.group");
76 
77  my $user = 'proftpd';
78  my $passwd = 'test';
79  my $home_dir = File::Spec->rel2abs("$tmpdir/foo/bar");
80  my $uid = 500;
81  my $gid = 500;
82
83  auth_user_write($auth_user_file, $user, $passwd, $uid, $gid, $home_dir,
84    '/bin/bash');
85  auth_group_write($auth_group_file, 'ftpd', $gid, $user);
86
87  my $config = {
88    PidFile => $pid_file,
89    ScoreboardFile => $scoreboard_file,
90    SystemLog => $log_file,
91
92    AuthUserFile => $auth_user_file,
93    AuthGroupFile => $auth_group_file,
94
95    CreateHome => 'on',
96
97    IfModules => {
98      'mod_delay.c' => {
99        DelayEngine => 'off',
100      },
101    },
102  };
103
104  my ($port, $config_user, $config_group) = config_write($config_file, $config);
105
106  # Open pipes, for use between the parent and child processes.  Specifically,
107  # the child will indicate when it's done with its test by writing a message
108  # to the parent.
109  my ($rfh, $wfh);
110  unless (pipe($rfh, $wfh)) {
111    die("Can't open pipe: $!");
112  }
113
114  my $ex;
115
116  # Fork child
117  $self->handle_sigchld();
118  defined(my $pid = fork()) or die("Can't fork: $!");
119  if ($pid) {
120    eval {
121      my $client = ProFTPD::TestSuite::FTP->new('127.0.0.1', $port);
122      $client->login($user, $passwd);
123    };
124
125    if ($@) {
126      $ex = $@;
127    }
128
129    $wfh->print("done\n");
130    $wfh->flush();
131
132  } else {
133    eval { server_wait($config_file, $rfh) };
134    if ($@) {
135      warn($@);
136      exit 1;
137    }
138
139    exit 0;
140  }
141
142  # Stop server
143  server_stop($pid_file);
144
145  $self->assert_child_ok($pid);
146
147  # Check that the home directory exists, and that the parent directory
148  # of $tmpdir/foo is owned by UID/GID root.
149  $self->assert(-d $home_dir,
150    test_msg("Expected $home_dir directory to exist"));
151
152  my $parent_dir = "$tmpdir/foo";
153  my ($uid_owner, $gid_owner) = (stat($parent_dir))[4,5];
154
155  my $expected = 0;
156  $self->assert($expected == $uid_owner,
157    test_msg("Expected $expected, got $uid_owner"));
158  $self->assert($expected == $gid_owner,
159    test_msg("Expected $expected, got $gid_owner"));
160
161  if ($ex) {
162    die($ex);
163  }
164
165  unlink($log_file);
166}
167
168sub createhome_dirmode_ok {
169  my $self = shift;
170  my $tmpdir = $self->{tmpdir};
171
172  my $config_file = "$tmpdir/config.conf";
173  my $pid_file = File::Spec->rel2abs("$tmpdir/config.pid");
174  my $scoreboard_file = File::Spec->rel2abs("$tmpdir/config.scoreboard");
175
176  my $log_file = File::Spec->rel2abs('tests.log');
177
178  my $auth_user_file = File::Spec->rel2abs("$tmpdir/config.passwd");
179  my $auth_group_file = File::Spec->rel2abs("$tmpdir/config.group");
180 
181  my $user = 'proftpd';
182  my $passwd = 'test';
183  my $home_dir = File::Spec->rel2abs("$tmpdir/foo/bar");
184  my $uid = 500;
185  my $gid = 500;
186
187  auth_user_write($auth_user_file, $user, $passwd, $uid, $gid, $home_dir,
188    '/bin/bash');
189  auth_group_write($auth_group_file, 'ftpd', $gid, $user);
190
191  my $config = {
192    PidFile => $pid_file,
193    ScoreboardFile => $scoreboard_file,
194    SystemLog => $log_file,
195
196    AuthUserFile => $auth_user_file,
197    AuthGroupFile => $auth_group_file,
198
199    CreateHome => 'on 711 dirmode 755',
200
201    IfModules => {
202      'mod_delay.c' => {
203        DelayEngine => 'off',
204      },
205    },
206  };
207
208  my ($port, $config_user, $config_group) = config_write($config_file, $config);
209
210  # Open pipes, for use between the parent and child processes.  Specifically,
211  # the child will indicate when it's done with its test by writing a message
212  # to the parent.
213  my ($rfh, $wfh);
214  unless (pipe($rfh, $wfh)) {
215    die("Can't open pipe: $!");
216  }
217
218  my $ex;
219
220  # Fork child
221  $self->handle_sigchld();
222  defined(my $pid = fork()) or die("Can't fork: $!");
223  if ($pid) {
224    eval {
225      my $client = ProFTPD::TestSuite::FTP->new('127.0.0.1', $port);
226      $client->login($user, $passwd);
227    };
228
229    if ($@) {
230      $ex = $@;
231    }
232
233    $wfh->print("done\n");
234    $wfh->flush();
235
236  } else {
237    eval { server_wait($config_file, $rfh) };
238    if ($@) {
239      warn($@);
240      exit 1;
241    }
242
243    exit 0;
244  }
245
246  # Stop server
247  server_stop($pid_file);
248
249  $self->assert_child_ok($pid);
250
251  # Check that the home directory exists, and that the parent directory
252  # of $tmpdir/foo is owned by UID/GID root.
253  $self->assert(-d $home_dir,
254    test_msg("Expected $home_dir directory to exist"));
255
256  my $parent_dir = "$tmpdir/foo";
257  my ($uid_owner, $gid_owner) = (stat($parent_dir))[4,5];
258
259  my $expected = 0;
260  $self->assert($expected == $uid_owner,
261    test_msg("Expected $expected, got $uid_owner"));
262  $self->assert($expected == $gid_owner,
263    test_msg("Expected $expected, got $gid_owner"));
264
265  # Make sure that the permissions on the directories match the expected modes
266  my $mode = sprintf("%04o", (stat($home_dir))[2] & 07777);
267
268  $expected = '0711';
269  $self->assert($expected eq $mode,
270    test_msg("Expected '$expected', got '$mode'"));
271
272  $mode = sprintf("%04o", (stat("$tmpdir/foo"))[2] & 07777);
273
274  $expected = '0755';
275  $self->assert($expected eq $mode,
276    test_msg("Expected '$expected', got '$mode'"));
277
278  if ($ex) {
279    die($ex);
280  }
281
282  unlink($log_file);
283}
284
285sub createhome_explicit_parent_owner_ok {
286  my $self = shift;
287  my $tmpdir = $self->{tmpdir};
288
289  my $config_file = "$tmpdir/config.conf";
290  my $pid_file = File::Spec->rel2abs("$tmpdir/config.pid");
291  my $scoreboard_file = File::Spec->rel2abs("$tmpdir/config.scoreboard");
292
293  my $log_file = File::Spec->rel2abs('tests.log');
294
295  my $auth_user_file = File::Spec->rel2abs("$tmpdir/config.passwd");
296  my $auth_group_file = File::Spec->rel2abs("$tmpdir/config.group");
297 
298  my $user = 'proftpd';
299  my $passwd = 'test';
300  my $home_dir = File::Spec->rel2abs("$tmpdir/foo/bar");
301  my $uid = 500;
302  my $gid = 500;
303
304  my $explicit_guid = 250;
305
306  auth_user_write($auth_user_file, $user, $passwd, $uid, $gid, $home_dir,
307    '/bin/bash');
308  auth_group_write($auth_group_file, 'ftpd', $gid, $user);
309
310  my $config = {
311    PidFile => $pid_file,
312    ScoreboardFile => $scoreboard_file,
313    SystemLog => $log_file,
314
315    AuthUserFile => $auth_user_file,
316    AuthGroupFile => $auth_group_file,
317
318    CreateHome => "on 711 uid $explicit_guid gid $explicit_guid",
319
320    IfModules => {
321      'mod_delay.c' => {
322        DelayEngine => 'off',
323      },
324    },
325  };
326
327  my ($port, $config_user, $config_group) = config_write($config_file, $config);
328
329  # Open pipes, for use between the parent and child processes.  Specifically,
330  # the child will indicate when it's done with its test by writing a message
331  # to the parent.
332  my ($rfh, $wfh);
333  unless (pipe($rfh, $wfh)) {
334    die("Can't open pipe: $!");
335  }
336
337  my $ex;
338
339  # Fork child
340  $self->handle_sigchld();
341  defined(my $pid = fork()) or die("Can't fork: $!");
342  if ($pid) {
343    eval {
344      my $client = ProFTPD::TestSuite::FTP->new('127.0.0.1', $port);
345      $client->login($user, $passwd);
346    };
347
348    if ($@) {
349      $ex = $@;
350    }
351
352    $wfh->print("done\n");
353    $wfh->flush();
354
355  } else {
356    eval { server_wait($config_file, $rfh) };
357    if ($@) {
358      warn($@);
359      exit 1;
360    }
361
362    exit 0;
363  }
364
365  # Stop server
366  server_stop($pid_file);
367
368  $self->assert_child_ok($pid);
369
370  # Check that the home directory exists, and that the parent directory
371  # of $tmpdir/foo is owned by UID/GID root.
372  $self->assert(-d $home_dir,
373    test_msg("Expected $home_dir directory to exist"));
374
375  my $parent_dir = "$tmpdir/foo";
376  my ($uid_owner, $gid_owner) = (stat($parent_dir))[4,5];
377
378  my $expected = $explicit_guid;
379  $self->assert($expected == $uid_owner,
380    test_msg("Expected $expected, got $uid_owner"));
381  $self->assert($expected == $gid_owner,
382    test_msg("Expected $expected, got $gid_owner"));
383
384  if ($ex) {
385    die($ex);
386  }
387
388  unlink($log_file);
389}
390
391sub createhome_user_parent_owner_ok {
392  my $self = shift;
393  my $tmpdir = $self->{tmpdir};
394
395  my $config_file = "$tmpdir/config.conf";
396  my $pid_file = File::Spec->rel2abs("$tmpdir/config.pid");
397  my $scoreboard_file = File::Spec->rel2abs("$tmpdir/config.scoreboard");
398
399  my $log_file = File::Spec->rel2abs('tests.log');
400
401  my $auth_user_file = File::Spec->rel2abs("$tmpdir/config.passwd");
402  my $auth_group_file = File::Spec->rel2abs("$tmpdir/config.group");
403 
404  my $user = 'proftpd';
405  my $passwd = 'test';
406  my $home_dir = File::Spec->rel2abs("$tmpdir/foo/bar");
407  my $uid = 500;
408  my $gid = 500;
409
410  auth_user_write($auth_user_file, $user, $passwd, $uid, $gid, $home_dir,
411    '/bin/bash');
412  auth_group_write($auth_group_file, 'ftpd', $gid, $user);
413
414  my $config = {
415    PidFile => $pid_file,
416    ScoreboardFile => $scoreboard_file,
417    SystemLog => $log_file,
418
419    AuthUserFile => $auth_user_file,
420    AuthGroupFile => $auth_group_file,
421
422    CreateHome => "on 711 uid ~ gid ~",
423
424    IfModules => {
425      'mod_delay.c' => {
426        DelayEngine => 'off',
427      },
428    },
429  };
430
431  my ($port, $config_user, $config_group) = config_write($config_file, $config);
432
433  # Open pipes, for use between the parent and child processes.  Specifically,
434  # the child will indicate when it's done with its test by writing a message
435  # to the parent.
436  my ($rfh, $wfh);
437  unless (pipe($rfh, $wfh)) {
438    die("Can't open pipe: $!");
439  }
440
441  my $ex;
442
443  # Fork child
444  $self->handle_sigchld();
445  defined(my $pid = fork()) or die("Can't fork: $!");
446  if ($pid) {
447    eval {
448      my $client = ProFTPD::TestSuite::FTP->new('127.0.0.1', $port);
449      $client->login($user, $passwd);
450    };
451
452    if ($@) {
453      $ex = $@;
454    }
455
456    $wfh->print("done\n");
457    $wfh->flush();
458
459  } else {
460    eval { server_wait($config_file, $rfh) };
461    if ($@) {
462      warn($@);
463      exit 1;
464    }
465
466    exit 0;
467  }
468
469  # Stop server
470  server_stop($pid_file);
471
472  $self->assert_child_ok($pid);
473
474  # Check that the home directory exists, and that the parent directory
475  # of $tmpdir/foo is owned by UID/GID root.
476  $self->assert(-d $home_dir,
477    test_msg("Expected $home_dir directory to exist"));
478
479  my $parent_dir = "$tmpdir/foo";
480  my ($uid_owner, $gid_owner) = (stat($parent_dir))[4,5];
481
482  my $expected = $uid;
483  $self->assert($expected == $uid_owner,
484    test_msg("Expected $expected, got $uid_owner"));
485
486  $expected = $gid;
487  $self->assert($expected == $gid_owner,
488    test_msg("Expected $expected, got $gid_owner"));
489
490  if ($ex) {
491    die($ex);
492  }
493
494  unlink($log_file);
495}
496
497sub createhome_skel_ok {
498  my $self = shift;
499  my $tmpdir = $self->{tmpdir};
500
501  my $config_file = "$tmpdir/config.conf";
502  my $pid_file = File::Spec->rel2abs("$tmpdir/config.pid");
503  my $scoreboard_file = File::Spec->rel2abs("$tmpdir/config.scoreboard");
504
505  my $log_file = File::Spec->rel2abs('tests.log');
506
507  my $auth_user_file = File::Spec->rel2abs("$tmpdir/config.passwd");
508  my $auth_group_file = File::Spec->rel2abs("$tmpdir/config.group");
509 
510  my $user = 'proftpd';
511  my $passwd = 'test';
512  my $home_dir = File::Spec->rel2abs("$tmpdir/foo/bar");
513  my $uid = 500;
514  my $gid = 500;
515
516  my $skel = File::Spec->rel2abs("$tmpdir/skel");
517  mkpath($skel);
518
519  my $skel_file = File::Spec->rel2abs("$skel/welcome.txt");
520  if (open(my $fh, "> $skel_file")) {
521    print $fh "Welcome, new user.\n";
522
523    unless (close($fh)) {
524      die("Can't write $skel_file: $!");
525    }
526
527  } else {
528    die("Can't open $skel_file: $!");
529  }
530
531  my $skel_sub = File::Spec->rel2abs("$skel/subdir");
532  mkpath($skel_sub);
533
534  $skel_file = File::Spec->rel2abs("$skel_sub/test.txt");
535  if (open(my $fh, "> $skel_file")) {
536    print $fh "More test file stuff.\n";
537
538    unless (close($fh)) {
539      die("Can't write $skel_file: $!");
540    }
541
542  } else {
543    die("Can't open $skel_file: $!");
544  }
545
546  auth_user_write($auth_user_file, $user, $passwd, $uid, $gid, $home_dir,
547    '/bin/bash');
548  auth_group_write($auth_group_file, 'ftpd', $gid, $user);
549
550  my $config = {
551    PidFile => $pid_file,
552    ScoreboardFile => $scoreboard_file,
553    SystemLog => $log_file,
554
555    AuthUserFile => $auth_user_file,
556    AuthGroupFile => $auth_group_file,
557
558    CreateHome => "on skel $skel",
559
560    IfModules => {
561      'mod_delay.c' => {
562        DelayEngine => 'off',
563      },
564    },
565  };
566
567  my ($port, $config_user, $config_group) = config_write($config_file, $config);
568
569  # Open pipes, for use between the parent and child processes.  Specifically,
570  # the child will indicate when it's done with its test by writing a message
571  # to the parent.
572  my ($rfh, $wfh);
573  unless (pipe($rfh, $wfh)) {
574    die("Can't open pipe: $!");
575  }
576
577  my $ex;
578
579  # Fork child
580  $self->handle_sigchld();
581  defined(my $pid = fork()) or die("Can't fork: $!");
582  if ($pid) {
583    eval {
584      my $client = ProFTPD::TestSuite::FTP->new('127.0.0.1', $port);
585      $client->login($user, $passwd);
586    };
587
588    if ($@) {
589      $ex = $@;
590    }
591
592    $wfh->print("done\n");
593    $wfh->flush();
594
595  } else {
596    eval { server_wait($config_file, $rfh) };
597    if ($@) {
598      warn($@);
599      exit 1;
600    }
601
602    exit 0;
603  }
604
605  # Stop server
606  server_stop($pid_file);
607
608  $self->assert_child_ok($pid);
609
610  # Check that the home directory exists, and that it contains the
611  # skeleton dirs/files.
612  $self->assert(-d $home_dir,
613    test_msg("Expected '$home_dir' directory to exist"));
614
615  $self->assert(-d "$home_dir/subdir",
616    test_msg("Expected '$home_dir/subdir' directory to exist"));
617
618  $self->assert(-f "$home_dir/welcome.txt",
619    test_msg("Expected '$home_dir/welcome.txt' file to exist"));
620
621  $self->assert(-f "$home_dir/subdir/test.txt",
622    test_msg("Expected '$home_dir/subdir/test.txt' file to exist"));
623
624  if ($ex) {
625    die($ex);
626  }
627
628  unlink($log_file);
629}
630
631sub createhome_homegid_bug3503 {
632  my $self = shift;
633  my $tmpdir = $self->{tmpdir};
634
635  my $config_file = "$tmpdir/config.conf";
636  my $pid_file = File::Spec->rel2abs("$tmpdir/config.pid");
637  my $scoreboard_file = File::Spec->rel2abs("$tmpdir/config.scoreboard");
638
639  my $log_file = File::Spec->rel2abs('tests.log');
640
641  my $auth_user_file = File::Spec->rel2abs("$tmpdir/config.passwd");
642  my $auth_group_file = File::Spec->rel2abs("$tmpdir/config.group");
643 
644  my $user = 'proftpd';
645  my $passwd = 'test';
646  my $home_dir = File::Spec->rel2abs("$tmpdir/foo/bar");
647  my $uid = 500;
648  my $gid = 500;
649
650  auth_user_write($auth_user_file, $user, $passwd, $uid, $gid, $home_dir,
651    '/bin/bash');
652  auth_group_write($auth_group_file, 'ftpd', $gid, $user);
653
654  my $home_gid = 777;
655
656  my $config = {
657    PidFile => $pid_file,
658    ScoreboardFile => $scoreboard_file,
659    SystemLog => $log_file,
660
661    AuthUserFile => $auth_user_file,
662    AuthGroupFile => $auth_group_file,
663
664    CreateHome => "on 711 homegid $home_gid",
665
666    IfModules => {
667      'mod_delay.c' => {
668        DelayEngine => 'off',
669      },
670    },
671  };
672
673  my ($port, $config_user, $config_group) = config_write($config_file, $config);
674
675  # Open pipes, for use between the parent and child processes.  Specifically,
676  # the child will indicate when it's done with its test by writing a message
677  # to the parent.
678  my ($rfh, $wfh);
679  unless (pipe($rfh, $wfh)) {
680    die("Can't open pipe: $!");
681  }
682
683  my $ex;
684
685  # Fork child
686  $self->handle_sigchld();
687  defined(my $pid = fork()) or die("Can't fork: $!");
688  if ($pid) {
689    eval {
690      my $client = ProFTPD::TestSuite::FTP->new('127.0.0.1', $port);
691      $client->login($user, $passwd);
692    };
693
694    if ($@) {
695      $ex = $@;
696    }
697
698    $wfh->print("done\n");
699    $wfh->flush();
700
701  } else {
702    eval { server_wait($config_file, $rfh) };
703    if ($@) {
704      warn($@);
705      exit 1;
706    }
707
708    exit 0;
709  }
710
711  # Stop server
712  server_stop($pid_file);
713
714  $self->assert_child_ok($pid);
715
716  # Check that the home directory exists, and that the home directory
717  # of $tmpdir/foo/bar is owned by root UID and configured GID.
718  $self->assert(-d $home_dir,
719    test_msg("Expected $home_dir directory to exist"));
720
721  my ($uid_owner, $gid_owner) = (stat($home_dir))[4,5];
722
723  my $expected = $uid;
724  $self->assert($expected == $uid_owner,
725    test_msg("Expected $expected, got $uid_owner"));
726
727  $expected = $home_gid;
728  $self->assert($expected == $gid_owner,
729    test_msg("Expected $expected, got $gid_owner"));
730
731  if ($ex) {
732    die($ex);
733  }
734
735  unlink($log_file);
736}
737
738sub createhome_dirmode_uid_gid_ok {
739  my $self = shift;
740  my $tmpdir = $self->{tmpdir};
741
742  my $config_file = "$tmpdir/config.conf";
743  my $pid_file = File::Spec->rel2abs("$tmpdir/config.pid");
744  my $scoreboard_file = File::Spec->rel2abs("$tmpdir/config.scoreboard");
745
746  my $log_file = File::Spec->rel2abs('tests.log');
747
748  my $auth_user_file = File::Spec->rel2abs("$tmpdir/config.passwd");
749  my $auth_group_file = File::Spec->rel2abs("$tmpdir/config.group");
750 
751  my $user = 'proftpd';
752  my $passwd = 'test';
753  my $group = 'ftpd';
754  my $home_dir = File::Spec->rel2abs("$tmpdir/foo/bar");
755  my $uid = 500;
756  my $gid = 500;
757
758  my $explicit_guid = 250;
759
760  auth_user_write($auth_user_file, $user, $passwd, $uid, $gid, $home_dir,
761    '/bin/bash');
762  auth_group_write($auth_group_file, $group, $gid, $user);
763
764  # Trying to debug:
765  #
766  #  http://forums.proftpd.org/smf/index.php/topic,5534.0.html
767
768  my $config = {
769    PidFile => $pid_file,
770    ScoreboardFile => $scoreboard_file,
771    SystemLog => $log_file,
772
773    AuthUserFile => $auth_user_file,
774    AuthGroupFile => $auth_group_file,
775
776    CreateHome => "on 700 dirmode 700 uid ~ gid ~",
777
778    IfModules => {
779      'mod_delay.c' => {
780        DelayEngine => 'off',
781      },
782    },
783  };
784
785  my ($port, $config_user, $config_group) = config_write($config_file, $config);
786
787  # Open pipes, for use between the parent and child processes.  Specifically,
788  # the child will indicate when it's done with its test by writing a message
789  # to the parent.
790  my ($rfh, $wfh);
791  unless (pipe($rfh, $wfh)) {
792    die("Can't open pipe: $!");
793  }
794
795  my $ex;
796
797  # Fork child
798  $self->handle_sigchld();
799  defined(my $pid = fork()) or die("Can't fork: $!");
800  if ($pid) {
801    eval {
802      my $client = ProFTPD::TestSuite::FTP->new('127.0.0.1', $port);
803      $client->login($user, $passwd);
804    };
805
806    if ($@) {
807      $ex = $@;
808    }
809
810    $wfh->print("done\n");
811    $wfh->flush();
812
813  } else {
814    eval { server_wait($config_file, $rfh) };
815    if ($@) {
816      warn($@);
817      exit 1;
818    }
819
820    exit 0;
821  }
822
823  # Stop server
824  server_stop($pid_file);
825
826  $self->assert_child_ok($pid);
827
828  # Check that the home directory exists, and that the parent directory
829  # of $tmpdir/foo is owned by UID/GID root.
830  $self->assert(-d $home_dir,
831    test_msg("Expected $home_dir directory to exist"));
832
833  my $parent_dir = "$tmpdir/foo";
834  my ($uid_owner, $gid_owner) = (stat($parent_dir))[4,5];
835
836  my $expected = $uid;
837  $self->assert($expected == $uid_owner,
838    test_msg("Expected $expected, got $uid_owner"));
839
840  $expected = $gid;
841  $self->assert($expected == $gid_owner,
842    test_msg("Expected $expected, got $gid_owner"));
843
844  # Make sure that the permissions on the directories match the expected modes
845  my $mode = sprintf("%04o", (stat($home_dir))[2] & 07777);
846
847  $expected = '0700';
848  $self->assert($expected eq $mode,
849    test_msg("Expected '$expected', got '$mode'"));
850
851  $mode = sprintf("%04o", (stat("$tmpdir/foo"))[2] & 07777);
852
853  $expected = '0700';
854  $self->assert($expected eq $mode,
855    test_msg("Expected '$expected', got '$mode'"));
856
857  if ($ex) {
858    die($ex);
859  }
860
861  unlink($log_file);
862}
863
8641;
Note: See TracBrowser for help on using the repository browser.