Ever wondered why mkfifo accepts group write permissions, but file gets created with 0644? umask is the root of all evil. Once reset, don’t forget to save the old mask and restore it later on. Details on the issue in Icinga2 #4444

        /*
         * 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) {
                BOOST_THROW_EXCEPTION(posix_error()
                    << boost::errinfo_api_function("mkfifo")
                    << boost::errinfo_errno(errno)
                    << boost::errinfo_file_name(commandPath));
        }

        /* restore old umask */
        umask(oldMask);
%d bloggers like this: