Commit 8e5a705d authored by René Nussbaumer's avatar René Nussbaumer
Browse files

Fix queue archive creation with wrong permissions



On a master failover some of the archive dirs might have wrong
permissions in the non-root model. This is due to the nature of noded
still running as root and the job queue is synced that way. This patch
will fix this behaviour by setting the permissions accordingly.
Signed-off-by: default avatarRené Nussbaumer <rn@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent ac0abc56
......@@ -2576,7 +2576,10 @@ def JobQueueRename(old, new):
_EnsureJobQueueFile(old)
_EnsureJobQueueFile(new)
utils.RenameFile(old, new, mkdir=True)
getents = runtime.GetEnts()
utils.RenameFile(old, new, mkdir=True, mkdir_mode=0700,
dir_uid=getents.masterd_uid, dir_gid=getents.masterd_gid)
def BlockdevClose(instance_name, disks):
......
......@@ -290,7 +290,8 @@ def RemoveDir(dirname):
raise
def RenameFile(old, new, mkdir=False, mkdir_mode=0750):
def RenameFile(old, new, mkdir=False, mkdir_mode=0750, dir_uid=None,
dir_gid=None):
"""Renames a file.
@type old: string
......@@ -301,6 +302,10 @@ def RenameFile(old, new, mkdir=False, mkdir_mode=0750):
@param mkdir: Whether to create target directory if it doesn't exist
@type mkdir_mode: int
@param mkdir_mode: Mode for newly created directories
@type dir_uid: int
@param dir_uid: The uid for the (if fresh created) dir
@type dir_gid: int
@param dir_gid: The gid for the (if fresh created) dir
"""
try:
......@@ -311,7 +316,10 @@ def RenameFile(old, new, mkdir=False, mkdir_mode=0750):
# as efficient.
if mkdir and err.errno == errno.ENOENT:
# Create directory and try again
Makedirs(os.path.dirname(new), mode=mkdir_mode)
dir_path = os.path.dirname(new)
Makedirs(dir_path, mode=mkdir_mode)
if not (dir_uid is None or dir_gid is None):
os.chown(dir_path, dir_uid, dir_gid)
return os.rename(old, new)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment