mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-21 04:34:43 +02:00
ExternalCommandListener: Reset umask to preserve group write permissions.
refs #4444
This commit is contained in:
parent
622471ef77
commit
e8a019d297
@ -50,7 +50,7 @@ void ExternalCommandListener::Start(void)
|
|||||||
String ExternalCommandListener::GetCommandPath(void) const
|
String ExternalCommandListener::GetCommandPath(void) const
|
||||||
{
|
{
|
||||||
if (m_CommandPath.IsEmpty())
|
if (m_CommandPath.IsEmpty())
|
||||||
return Application::GetLocalStateDir() + "/run/icinga2/icinga2.cmd";
|
return Application::GetLocalStateDir() + "/run/icinga2/rw/icinga2.cmd";
|
||||||
else
|
else
|
||||||
return m_CommandPath;
|
return m_CommandPath;
|
||||||
}
|
}
|
||||||
@ -77,6 +77,12 @@ void ExternalCommandListener::CommandPipeThread(const String& commandPath)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* process would override group write permissions
|
||||||
|
* so reset them. man 3 mkfifo: (mode & ~umask)
|
||||||
|
*/
|
||||||
|
mode_t oldMask = umask(S_IWOTH);
|
||||||
|
|
||||||
if (!fifo_ok && mkfifo(commandPath.CStr(), S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP) < 0) {
|
if (!fifo_ok && mkfifo(commandPath.CStr(), S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP) < 0) {
|
||||||
BOOST_THROW_EXCEPTION(posix_error()
|
BOOST_THROW_EXCEPTION(posix_error()
|
||||||
<< boost::errinfo_api_function("mkfifo")
|
<< boost::errinfo_api_function("mkfifo")
|
||||||
@ -84,6 +90,9 @@ void ExternalCommandListener::CommandPipeThread(const String& commandPath)
|
|||||||
<< boost::errinfo_file_name(commandPath));
|
<< boost::errinfo_file_name(commandPath));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* restore old umask */
|
||||||
|
umask(oldMask);
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user