Commit 833391a0 authored by René Nussbaumer's avatar René Nussbaumer
Browse files

Merge branch 'devel-2.4' into stable-2.5


Signed-off-by: default avatarRené Nussbaumer <rn@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parents 69f78cf7 8e5a705d
......@@ -2662,7 +2662,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):
......
......@@ -295,7 +295,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
......@@ -306,6 +307,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:
......@@ -316,7 +321,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