Revision 360b0dc2 lib/backend.py

b/lib/backend.py
19 19
# 02110-1301, USA.
20 20

  
21 21

  
22
"""Functions used by the node daemon"""
22
"""Functions used by the node daemon
23

  
24
@var _ALLOWED_UPLOAD_FILES: denotes which files are accepted in
25
     the L{UploadFile} function
26

  
27
"""
23 28

  
24 29

  
25 30
import os
......
115 120
      utils.RemoveFile(full_name)
116 121

  
117 122

  
123
def _BuildUploadFileList():
124
  """Build the list of allowed upload files.
125

  
126
  This is abstracted so that it's built only once at module import time.
127

  
128
  """
129
  return frozenset([
130
      constants.CLUSTER_CONF_FILE,
131
      constants.ETC_HOSTS,
132
      constants.SSH_KNOWN_HOSTS_FILE,
133
      constants.VNC_PASSWORD_FILE,
134
      ])
135

  
136

  
137
_ALLOWED_UPLOAD_FILES = _BuildUploadFileList()
138

  
139

  
118 140
def JobQueuePurge():
119 141
  """Removes job queue files and archived jobs.
120 142

  
......
1460 1482
                  file_name)
1461 1483
    return False
1462 1484

  
1463
  allowed_files = [
1464
    constants.CLUSTER_CONF_FILE,
1465
    constants.ETC_HOSTS,
1466
    constants.SSH_KNOWN_HOSTS_FILE,
1467
    constants.VNC_PASSWORD_FILE,
1468
    ]
1469

  
1470
  if file_name not in allowed_files:
1485
  if file_name not in _ALLOWED_UPLOAD_FILES:
1471 1486
    logging.error("Filename passed to UploadFile not in allowed"
1472 1487
                 " upload targets: '%s'", file_name)
1473 1488
    return False

Also available in: Unified diff