From afee800848826ca14f3b5d46bed83996d5752822 Mon Sep 17 00:00:00 2001
From: Michael Hanselmann <hansmi@google.com>
Date: Thu, 31 Jul 2008 14:42:11 +0000
Subject: [PATCH] Allow job queue files to be uploaded through ganeti-noded

This is needed for job queue replication.

Reviewed-by: iustinp
---
 lib/backend.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/lib/backend.py b/lib/backend.py
index 16b7bb9b4..7e9f2d2c8 100644
--- a/lib/backend.py
+++ b/lib/backend.py
@@ -1019,6 +1019,9 @@ def FindBlockDevice(disk):
     return rbd
   return (rbd.dev_path, rbd.major, rbd.minor) + rbd.GetSyncStatus()
 
+def _IsJobQueueFile(file_name):
+  queue_dir = os.path.normpath(constants.QUEUE_DIR)
+  return os.path.commonprefix([queue_dir, file_name]) == queue_dir
 
 def UploadFile(file_name, data, mode, uid, gid, atime, mtime):
   """Write a file to the filesystem.
@@ -1037,10 +1040,10 @@ def UploadFile(file_name, data, mode, uid, gid, atime, mtime):
     constants.ETC_HOSTS,
     constants.SSH_KNOWN_HOSTS_FILE,
     constants.VNC_PASSWORD_FILE,
-    constants.JOB_QUEUE_SERIAL_FILE,
     ]
   allowed_files.extend(ssconf.SimpleStore().GetFileList())
-  if file_name not in allowed_files:
+
+  if not (file_name in allowed_files or _IsJobQueueFile(file_name)):
     logging.error("Filename passed to UploadFile not in allowed"
                  " upload targets: '%s'", file_name)
     return False
-- 
GitLab