mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-16 18:24:31 +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()) {
|
if (!ticket.IsEmpty()) {
|
||||||
String ticketPath = ApiListener::GetCertsDir() + "/ticket";
|
String ticketPath = ApiListener::GetCertsDir() + "/ticket";
|
||||||
|
AtomicFile af (ticketPath, 0600);
|
||||||
|
|
||||||
AtomicFile::Write(ticketPath, 0600, ticket);
|
if (!Utility::SetFileOwnership(af.GetTempFilename(), user, group)) {
|
||||||
|
|
||||||
if (!Utility::SetFileOwnership(ticketPath, user, group)) {
|
|
||||||
Log(LogWarning, "cli")
|
Log(LogWarning, "cli")
|
||||||
<< "Cannot set ownership for user '" << user
|
<< "Cannot set ownership for user '" << user
|
||||||
<< "' group '" << group
|
<< "' group '" << group
|
||||||
<< "' on file '" << ticketPath << "'. Verify it yourself!";
|
<< "' 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.*/
|
/* 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()) {
|
if (!ticket.IsEmpty()) {
|
||||||
String ticketPath = ApiListener::GetCertsDir() + "/ticket";
|
String ticketPath = ApiListener::GetCertsDir() + "/ticket";
|
||||||
|
AtomicFile af (ticketPath, 0600);
|
||||||
|
|
||||||
AtomicFile::Write(ticketPath, 0600, ticket);
|
if (!Utility::SetFileOwnership(af.GetTempFilename(), user, group)) {
|
||||||
|
|
||||||
if (!Utility::SetFileOwnership(ticketPath, user, group)) {
|
|
||||||
Log(LogWarning, "cli")
|
Log(LogWarning, "cli")
|
||||||
<< "Cannot set ownership for user '" << user
|
<< "Cannot set ownership for user '" << user
|
||||||
<< "' group '" << group
|
<< "' group '" << group
|
||||||
<< "' on file '" << ticketPath << "'. Verify it yourself!";
|
<< "' 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.*/
|
/* 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