-def open_aggregate_logs(options):
- warnings_logname = "/tmp/wizard-migrate-warnings.log"
- errors_logname = "/tmp/wizard-migrate-errors.log"
- if options.log_dir:
- # must not be on AFS, since subprocesses won't be
- # able to write to the logfiles do the to the AFS patch.
- try:
- os.mkdir(options.log_dir)
- except OSError as e:
- if e.errno != errno.EEXIST:
- raise
- if options.force:
- options.log_dir = os.path.join(options.log_dir, str(int(time.time())))
- os.mkdir(options.log_dir) # if fails, be fatal
- os.chmod(options.log_dir, 0o777)
- warnings_logname = os.path.join(options.log_dir, "warnings.log")
- errors_logname = os.path.join(options.log_dir, "errors.log")
- warnings_log = open(warnings_logname, "a")
- errors_log = open(errors_logname, "a")
- return warnings_log, errors_log
-
-def security_check_homedir(d):
- uid = util.get_dir_uid(d.location)
- real = os.path.realpath(d.location)
- try:
- if not real.startswith(pwd.getpwuid(uid).pw_dir + "/"):
- logging.error("Security check failed, owner of deployment and"
- "owner of home directory mismatch for %s" % d.location)
- return False
- except KeyError:
- logging.error("Security check failed, could not look up"
- "owner of %s (uid %d)" % (d.location, uid))
- return False
- return True
-