Index: configure --- configure.orig 2016-08-05 14:34:26.000000000 +0200 +++ configure 2016-08-08 19:11:57.512146404 +0200 @@ -12348,6 +12348,7 @@ for ac_header in \ + sys/types.h \ alloca.h \ arpa/inet.h \ asm/page.h \ Index: src/file.c --- src/file.c.orig 2016-08-05 14:34:11.000000000 +0200 +++ src/file.c 2016-08-08 19:16:50.172052761 +0200 @@ -101,6 +101,9 @@ Util_monitId(Run.files.id); /* Set the location of monit's state file */ if (Run.files.state == NULL) { + if (!getuid()) + snprintf(buf, STRLEN, "%s/%s", MYSTATEDIR, MYSTATEFILE); + else snprintf(buf, STRLEN, "%s/.%s", Run.Env.home, MYSTATEFILE); Run.files.state = Str_dup(buf); } @@ -133,27 +136,11 @@ char *file_findControlFile() { char *rcfile = CALLOC(sizeof(char), STRLEN + 1); - snprintf(rcfile, STRLEN, "%s/.%s", Run.Env.home, MONITRC); + snprintf(rcfile, STRLEN, "@l_prefix@/etc/monit/%s", MONITRC); if (File_exist(rcfile)) { return rcfile; } - snprintf(rcfile, STRLEN, "/etc/%s", MONITRC); - if (File_exist(rcfile)) { - return rcfile; - } - snprintf(rcfile, STRLEN, "%s/%s", SYSCONFDIR, MONITRC); - if (File_exist(rcfile)) { - return rcfile; - } - snprintf(rcfile, STRLEN, "/usr/local/etc/%s", MONITRC); - if (File_exist(rcfile)) { - return rcfile; - } - if (File_exist(MONITRC)) { - snprintf(rcfile, STRLEN, "%s/%s", Run.Env.cwd, MONITRC); - return rcfile; - } - LogError("Cannot find the Monit control file at ~/.%s, /etc/%s, %s/%s, /usr/local/etc/%s or at ./%s \n", MONITRC, MONITRC, SYSCONFDIR, MONITRC, MONITRC, MONITRC); + LogError("Cannot find the control file at %s\n", rcfile); exit(1); } Index: src/monit.h --- src/monit.h.orig 2016-08-05 14:34:11.000000000 +0200 +++ src/monit.h 2016-08-08 19:11:57.522130565 +0200 @@ -143,6 +143,7 @@ #define ARGMAX 64 #define MYPIDDIR PIDDIR +#define MYSTATEDIR PIDDIR #define MYPIDFILE "monit.pid" #define MYSTATEFILE "monit.state" #define MYIDFILE "monit.id"