Debian Codegraph @

tests/t/lib/ProFTPD/Tests/Config/PidFile.pm

raw
1 package ProFTPD::Tests::Config::PidFile;
2
3 use lib qw(t/lib);
4 use base qw(ProFTPD::TestSuite::Child);
5 use strict;
6
7 use File::Spec;
8 use IO::Handle;
9
10 use ProFTPD::TestSuite::FTP;
11 use ProFTPD::TestSuite::Utils qw(:auth :config :running :test :testsuite);
12
13 $| = 1;
14
15 my $order = 0;
16
17 my $TESTS = {
18 pidfile_world_writable_issue1018 => {
19 order => ++$order,
20 test_class => [qw(bug forking)],
21 },
22
23 };
24
25 sub new {
26 return shift()->SUPER::new(@_);
27 }
28
29 sub list_tests {
30 return testsuite_get_runnable_tests($TESTS);
31 }
32
33 sub pidfile_world_writable_issue1018 {
34 my $self = shift;
35 my $tmpdir = $self->{tmpdir};
36 my $setup = test_setup($tmpdir, 'config');
37
38 my $config = {
39 PidFile => $setup->{pid_file},
40 ScoreboardFile => $setup->{scoreboard_file},
41 SystemLog => $setup->{log_file},
42
43 AuthUserFile => $setup->{auth_user_file},
44 AuthGroupFile => $setup->{auth_group_file},
45 AuthOrder => 'mod_auth_file.c',
46
47 Umask => '0000',
48
49 IfModules => {
50 'mod_delay.c' => {
51 DelayEngine => 'off',
52 },
53 },
54 };
55
56 my ($port, $config_user, $config_group) = config_write($setup->{config_file},
57 $config);
58
59 server_start($setup->{config_file}, $setup->{pid_file});
60
61 my $ex;
62
63 eval {
64 my $mode = (stat($setup->{pid_file}))[2];
65 my $mode_text = sprintf("%04o", $mode & 07777);
66 if ($ENV{TEST_VERBOSE}) {
67 print STDERR "# permissions: $mode_text\n";
68 }
69 $self->assert(($mode & 002) == 0,
70 test_msg("Mode $mode_text is unexpectedly world-writable"));
71 };
72 if ($@) {
73 $ex = $@;
74 }
75
76 server_stop($setup->{pid_file});
77 test_cleanup($setup->{log_file}, $ex);
78 }
79
80 1;