mail-stats-fill.c revision 8c533d1c49f47b7919de72c794abe9d2e0660ebd
/* Copyright (c) 2011-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "time-util.h"
#include "restrict-access.h"
#include "stats-plugin.h"
#include "mail-stats.h"
#include <sys/resource.h>
#define PROC_IO_PATH "/proc/self/io"
static bool proc_io_disabled = FALSE;
static int proc_io_fd = -1;
static int
{
const char *const *tmp;
return -1;
return -1;
return -1;
return -1;
}
}
return 0;
}
static int process_io_open(void)
{
if (proc_io_fd != -1)
return proc_io_fd;
if (proc_io_disabled)
return -1;
bool dumpable = restrict_access_get_dumpable();
if (!dumpable)
/* kludge: if we're running with permissions temporarily
dropped, get them temporarily back so we can open
if (seteuid(0) == 0) {
/* oops, this is bad */
}
}
}
if (!dumpable)
if (proc_io_fd == -1) {
/* ignore access errors too, certain security options can
prevent root access to this file when not owned by root */
return -1;
}
return proc_io_fd;
}
{
char buf[1024];
return;
if (ret <= 0) {
if (ret == -1)
else
/* just shouldn't happen.. */
} else {
T_BEGIN {
i_error("Invalid input in file %s",
}
} T_END;
}
}
static void
{
struct stats_transaction_context *strans;
}
{
static bool getrusage_broken = FALSE;
static struct rusage prev_usage;
/* cputime */
if (!getrusage_broken) {
i_error("getrusage() failed: %m");
}
usage = prev_usage;
/* This seems to be a Linux bug. */
}
prev_usage = usage;
}
void mail_stats_fill_global_deinit(void)
{
}