Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[PBCKP-159] fix false directory init#489

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
MetalDream666 wants to merge1 commit intomaster
base:master
Choose a base branch
Loading
fromPBCKP-159
Open
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletionssrc/init.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -31,6 +31,16 @@ do_init(CatalogState *catalogState)
elog(ERROR, "cannot open backup catalog directory \"%s\": %s",
catalogState->catalog_path, strerror(errno_tmp));
}
else if (results == 1)
{
/* Check whether we have all(rw) rights for directory */
if (access(catalogState->catalog_path, 6) == -1) /* == R_OK | W_OK */
{
int errno_tmp = errno;
elog(ERROR, "cannot access backup catalog directory \"%s\": %s",
catalogState->catalog_path, strerror(errno_tmp));
}
}

/* create backup catalog root directory */
dir_create_dir(catalogState->catalog_path, DIR_PERMISSION, false);
Expand Down
38 changes: 38 additions & 0 deletionstests/init.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
import os
import stat # for chmod
import unittest
from .helpers.ptrack_helpers import dir_files, ProbackupTest, ProbackupException
import shutil

if os.name == 'nt':
import win32security
import ntsecuritycon as con

module_name = 'init'

Expand DownExpand Up@@ -86,6 +90,40 @@ def test_already_exist(self):

# Clean after yourself
self.del_test_dir(module_name, fname)

# @unittest.skip("skip")
def test_no_rights_for_directory(self):
"""Failure with backup catalog existed and empty but user has no writing permissions"""
fname = self.id().split(".")[3]
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
node = self.make_simple_node(base_dir=os.path.join(module_name, fname, 'node'))
os.mkdir(backup_dir)
# changing directory rights
if os.name == 'nt': # windows block
user, domain, type = win32security.LookupAccountName("", os.getlogin())
sd = win32securityGetFileSecurity(backup_dir, win32security.DACL_SECURIRY_INFORMATION)
dacl = sd.GetSecurityDescriptorDacl()

dacl.AddAccessDeniedAce(win32security.ACL_REVISION, con.FILE_WRITE_DATA, user) # deny writing permission
sd.SetSecurityDescriptorDacl(1, dacl, 0)
win32security.SetFileSecurity(backup_dir, win32security.DACL_SECURIRY_INFORMATION, sd)
else:
os.chmod(backup_dir, stat.S_IREAD) # set read-only flag for current user
assert os.access(backup_dir, os.R_OK) and not os.access(backup_dir, os.W_OK)

self.init_pb(backup_dir)
try:
self.show_pb(backup_dir, 'node')
self.assertEqual(1, 0, 'Expecting Error due to initialization in empty directory with no rithts for writing. Output: {0} \n CMD: {1}'.format(
repr(self.output), self.cmd))
except ProbackupException as e:
self.assertIn(
"ERROR: Instance 'node' does not exist in this backup catalog",
e.message,
'\n Unexpected Error Message: {0}\n CMD: {1}'.format(repr(e.message), self.cmd))

# Clean after yourself
self.del_test_dir(module_name, fname)

# @unittest.skip("skip")
def test_abs_path(self):
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp