return 0;
}
+int verifylogaccess(void)
+{
+ FILE *logfile;
+
+ /* only logfile logging can be verified */
+ if (cfg.uselogging==1) {
+ if ((logfile = fopen(cfg.logfile, "a")) == NULL) {
+ return 0;
+ }
+ fclose(logfile);
+ }
+ return 1;
+}
+
int dmonth(int month)
{
static int dmon[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
/* common functions */
int printe(PrintType type);
int logprint(PrintType type);
+int verifylogaccess(void);
int dmonth(int month);
uint32_t mosecs(void);
uint64_t countercalc(const uint64_t *a, const uint64_t *b);
setsid(); /* obtain a new process group */
- if (cfg.uselogging) {
- snprintf(errorstring, 512, "vnStat daemon %s started. (uid:%d gid:%d)", getversion(), (int)getuid(), (int)getgid());
- if (!printe(PT_Info)) {
- printf("Error: Unable to use logfile. Exiting.\n");
- exit(EXIT_FAILURE);
- }
+ if (!verifylogaccess()) {
+ printf("Error: Unable to use logfile. Exiting.\n");
+ exit(EXIT_FAILURE);
}
/* lock / pid file */
}
s.running = 1;
- snprintf(errorstring, 512, "vnStat daemon %s running with pid %d.", getversion(), (int)getpid());
+ snprintf(errorstring, 512, "vnStat daemon %s started. (pid:%d uid:%d gid:%d)", getversion(), (int)getpid(), (int)getuid(), (int)getgid());
printe(PT_Info);
/* main loop */