TotalRequests and stores the average request duration. The remainder of the
RPN expression handles the divide by zero case.
+=head1 SECURITY
+
+Note that new rrd files will have the permission 0622 regarless of your
+umask setting. If a file with the same name previously exists, its
+permission settings will be copied to the new file.
+
=head1 AUTHORS
Tobias Oetiker E<lt>tobi@oetiker.chE<gt>, Peter Stamfest E<lt>peter@stamfest.atE<gt>
* rrd_create.c creates new rrds
*****************************************************************************/
+#include "mutex.h"
#include <stdlib.h>
#include <time.h>
#include <locale.h>
return rc;
}
+
int write_rrd(const char *outfilename, rrd_t *out) {
int rc = -1;
char *tmpfilename = NULL;
- mode_t saved_umask;
/* write out the new file */
#ifdef HAVE_LIBRADOS
strcpy(tmpfilename, outfilename);
strcat(tmpfilename, "XXXXXX");
- /* fix CWE-377 */
- saved_umask = umask(S_IWGRP|S_IWOTH);
+ /* this is 0600 according to the manual page */
int tmpfd = mkstemp(tmpfilename);
- umask(saved_umask);
+
+
if (tmpfd < 0) {
rrd_set_error("Cannot create temporary file");
goto done;
stat_buf.st_mode = _S_IREAD | _S_IWRITE; // have to test it is
#else
/* an error occurred (file not found, maybe?). Anyway:
- set the mode to 0666 using current umask */
- stat_buf.st_mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
-
- mode_t mask = umask(0);
- umask(mask);
-
- stat_buf.st_mode &= ~mask;
+ set the mode to 0644 using current umask */
+ stat_buf.st_mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
#endif
}
if (chmod(tmpfilename, stat_buf.st_mode) != 0) {