mirror of
https://github.com/Icinga/icinga2.git
synced 2025-04-08 17:05:25 +02:00
Include Utility::SetFileOwnership() inside FS transactions
to make them even more atomic.
This commit is contained in:
parent
d22fdf2a7a
commit
fd93feaec7
@ -524,15 +524,17 @@ int NodeSetupCommand::SetupNode(const boost::program_options::variables_map& vm,
|
||||
|
||||
if (!ticket.IsEmpty()) {
|
||||
String ticketPath = ApiListener::GetCertsDir() + "/ticket";
|
||||
AtomicFile af (ticketPath, 0600);
|
||||
|
||||
AtomicFile::Write(ticketPath, 0600, ticket);
|
||||
|
||||
if (!Utility::SetFileOwnership(ticketPath, user, group)) {
|
||||
if (!Utility::SetFileOwnership(af.GetTempFilename(), user, group)) {
|
||||
Log(LogWarning, "cli")
|
||||
<< "Cannot set ownership for user '" << user
|
||||
<< "' group '" << group
|
||||
<< "' on file '" << ticketPath << "'. Verify it yourself!";
|
||||
}
|
||||
|
||||
af << ticket;
|
||||
af.Commit();
|
||||
}
|
||||
|
||||
/* If no parent connection was made, the user must supply the ca.crt before restarting Icinga 2.*/
|
||||
|
@ -553,15 +553,17 @@ wizard_global_zone_loop_start:
|
||||
|
||||
if (!ticket.IsEmpty()) {
|
||||
String ticketPath = ApiListener::GetCertsDir() + "/ticket";
|
||||
AtomicFile af (ticketPath, 0600);
|
||||
|
||||
AtomicFile::Write(ticketPath, 0600, ticket);
|
||||
|
||||
if (!Utility::SetFileOwnership(ticketPath, user, group)) {
|
||||
if (!Utility::SetFileOwnership(af.GetTempFilename(), user, group)) {
|
||||
Log(LogWarning, "cli")
|
||||
<< "Cannot set ownership for user '" << user
|
||||
<< "' group '" << group
|
||||
<< "' on file '" << ticketPath << "'. Verify it yourself!";
|
||||
}
|
||||
|
||||
af << ticket;
|
||||
af.Commit();
|
||||
}
|
||||
|
||||
/* If no parent connection was made, the user must supply the ca.crt before restarting Icinga 2.*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user