Revision 88828491
b/lib/bootstrap.py | ||
---|---|---|
79 | 79 |
""" |
80 | 80 |
(fd, tmp_file_name) = tempfile.mkstemp(dir=os.path.dirname(file_name)) |
81 | 81 |
try: |
82 |
# Set permissions before writing key |
|
83 |
os.chmod(tmp_file_name, 0600) |
|
84 |
|
|
85 |
result = utils.RunCmd(["openssl", "req", "-new", "-newkey", "rsa:1024", |
|
86 |
"-days", str(validity), "-nodes", "-x509", |
|
87 |
"-keyout", tmp_file_name, "-out", tmp_file_name, |
|
88 |
"-batch"]) |
|
89 |
if result.failed: |
|
90 |
raise errors.OpExecError("Could not generate SSL certificate, command" |
|
91 |
" %s had exitcode %s and error message %s" % |
|
92 |
(result.cmd, result.exit_code, result.output)) |
|
93 |
|
|
94 |
# Make read-only |
|
95 |
os.chmod(tmp_file_name, 0400) |
|
96 |
|
|
97 |
os.rename(tmp_file_name, file_name) |
|
82 |
try: |
|
83 |
# Set permissions before writing key |
|
84 |
os.chmod(tmp_file_name, 0600) |
|
85 |
|
|
86 |
result = utils.RunCmd(["openssl", "req", "-new", "-newkey", "rsa:1024", |
|
87 |
"-days", str(validity), "-nodes", "-x509", |
|
88 |
"-keyout", tmp_file_name, "-out", tmp_file_name, |
|
89 |
"-batch"]) |
|
90 |
if result.failed: |
|
91 |
raise errors.OpExecError("Could not generate SSL certificate, command" |
|
92 |
" %s had exitcode %s and error message %s" % |
|
93 |
(result.cmd, result.exit_code, result.output)) |
|
94 |
|
|
95 |
# Make read-only |
|
96 |
os.chmod(tmp_file_name, 0400) |
|
97 |
|
|
98 |
os.rename(tmp_file_name, file_name) |
|
99 |
finally: |
|
100 |
utils.RemoveFile(tmp_file_name) |
|
98 | 101 |
finally: |
99 |
utils.RemoveFile(tmp_file_name)
|
|
102 |
os.close(fd)
|
|
100 | 103 |
|
101 | 104 |
|
102 | 105 |
def _InitGanetiServerSetup(): |
Also available in: Unified diff