Index: configure
--- configure.orig	2005-03-29 21:34:56 +0200
+++ configure	2005-03-30 09:48:57 +0200
@@ -4004,6 +4004,7 @@
 
 
 for ac_header in  \
+	sys/types.h \
         alloca.h \
 	arpa/inet.h \
 	asm/page.h \
Index: file.c
--- file.c.orig	2005-01-28 21:19:14 +0100
+++ file.c	2005-03-30 09:55:42 +0200
@@ -93,6 +93,9 @@
   }
   /* Set the location of the programs state file */
   if(Run.statefile == NULL) {
+    if(!getuid())
+        snprintf(statefile, STRLEN, "%s/%s", MYSTATEDIR, MYSTATEFILE);
+    else
     snprintf(statefile, STRLEN, "%s/.%s", Run.Env.home, MYSTATEFILE);
     Run.statefile= xstrdup(statefile);
   }
@@ -155,12 +158,7 @@
     return (rcfile);
   }
   memset(rcfile, 0, STRLEN);
-  snprintf(rcfile, STRLEN, "/etc/%s", MONITRC);
-  if(File_exist(rcfile)) {
-    return (rcfile);
-  }
-  memset(rcfile, 0, STRLEN);
-  snprintf(rcfile, STRLEN, "/usr/local/etc/%s", MONITRC);
+  snprintf(rcfile, STRLEN, "@l_prefix@/etc/monit/%s", MONITRC);
   if(File_exist(rcfile)) {
     return (rcfile);
   }
@@ -170,8 +168,8 @@
     return (rcfile);
   }
   log("%s: Cannot find the control file at "
-      "~/.%s, /etc/%s, /usr/local/etc/%s or at ./%s \n",
-      prog, MONITRC, MONITRC, MONITRC, MONITRC);
+      "~/.%s, @l_prefix@/etc/monit/%s, or at ./%s \n",
+      prog, MONITRC, MONITRC, MONITRC);
   exit(1);
   
 }
Index: monit.1
--- monit.1.orig	2005-03-29 21:34:53 +0200
+++ monit.1	2005-03-30 09:56:45 +0200
@@ -301,8 +301,8 @@
 .IX Header "HOW TO MONITOR"
 monit is configured and controlled via a control file called
 \&\fBmonitrc\fR. The default location for this file is ~/.monitrc. If
-this file does not exist, monit will try /etc/monitrc, then
-/usr/local/etc/monitrc and finally ./monitrc.
+this file does not exist, monit will try @l_prefix@/etc/monit/monitrc, then
+finally ./monitrc.
 .PP
 A monit control file consists of a series of service entries and
 global option statements in a free\-format, token-oriented syntax.
@@ -445,7 +445,7 @@
 .PP
 .Vb 2
 \&  # Run monit in standard run\-levels
-\&  mo:2345:respawn:/usr/local/bin/monit \-Ic /etc/monitrc
+\&  mo:2345:respawn:@l_prefix@/bin/monit \-Ic @l_prefix@/etc/monit/monitrc
 .Ve
 .PP
 After you have modified init's configuration file, you can run
@@ -3219,7 +3219,7 @@
 .IX Item "4. monit starts the node group"
 .PD
 .PP
-\&\fBMonit: \f(BI/etc/monitrc\fB\fR
+\&\fBMonit: \f(BI@l_prefix@/etc/monit/monitrc\fB\fR
 .PP
 This example describes a cluster with 2 nodes. Services running
 on Node 1 are in the group \fInode1\fR and Node 2 services are in
@@ -3386,9 +3386,9 @@
 \&\fI~/.monitrc\fR  
    Default run control file
 .PP
-\&\fI/etc/monitrc\fR
+\&\fI@l_prefix@/etc/monit/monitrc\fR
    If the control file is not found in the default 
-   location and /etc contains a \fImonitrc\fR file, this
+   location and @l_prefix@/etc/monit contains a \fImonitrc\fR file, this
    file will be used instead.
 .PP
 \&\fI./monitrc\fR  
@@ -3401,14 +3401,10 @@
    Lock file to help prevent concurrent runs (non\-root
    mode).
 .PP
-\&\fI/var/run/monit.pid\fR
+\&\fI@l_prefix@/var/monit/monit.pid\fR
    Lock file to help prevent concurrent runs (root mode,
    Linux systems).
 .PP
-\&\fI/etc/monit.pid\fR
-   Lock file to help prevent concurrent runs (root mode,
-   systems without /var/run).
-.PP
 \&\fI~/.monit.state\fR  
    monit save its state to this file and utilize 
    information found in this file to recover from 
Index: monitor.h
--- monitor.h.orig	2005-02-24 21:44:00 +0100
+++ monitor.h	2005-03-30 09:49:22 +0200
@@ -76,6 +76,7 @@
 #define MYPIDMASK          0122
 #define MYPIDDIR           PIDDIR
 #define MYPIDFILE          "monit.pid"
+#define MYSTATEDIR         PIDDIR
 #define MYSTATEFILE        "monit.state"
 
 #define LOCALHOST          "localhost"
Index: process/sysdep_LINUX.c
--- process/sysdep_LINUX.c.orig	2005-02-20 10:23:50 +0100
+++ process/sysdep_LINUX.c	2005-03-30 09:49:22 +0200
@@ -74,6 +74,8 @@
 #include <glob.h>
 #endif
 
+#include <errno.h>
+
 #include "monitor.h"
 #include "process.h"
 #include "process_sysdep.h"
Index: sendmail.c
--- sendmail.c.orig	2005-02-20 00:52:19 +0100
+++ sendmail.c	2005-03-30 09:49:22 +0200
@@ -140,7 +140,7 @@
     do_send(&S, "\r\n");
     do_send(&S, "%s\r\n", m->message);
     if(m->opt_message) {
-      do_send(&S, "%s\r\n", m->opt_message);
+      do_send(&S, "\r\n%s\r\n", m->opt_message);
     }
     do_send(&S, ".\r\n");
     do_status(&S);
