diff -x .hg -ur monit-5.3.2/libmonit/src/system/Command.c monit-5.3.2-check-program/libmonit/src/system/Command.c
--- monit-5.3.2/libmonit/src/system/Command.c	2011-12-20 11:40:30.000000000 -0900
+++ monit-5.3.2-check-program/libmonit/src/system/Command.c	2012-03-15 17:38:07.278188871 -0800
@@ -476,14 +476,14 @@
                                 _exit(errno);
                         }
                 }
-                if (C->uid)
-                        P->uid = (setuid(C->uid) != 0) ? ERROR("Command: Cannot change process uid to '%d' -- %s\n", C->uid, System_getLastError()), getuid() : C->uid;
-                else
-                        P->uid = getuid();
                 if (C->gid)
                         P->gid = (setgid(C->gid) != 0) ? ERROR("Command: Cannot change process gid to '%d' -- %s\n", C->gid, System_getLastError()), getgid() : C->gid;
                 else
                         P->gid = getgid();
+                if (C->uid)
+                        P->uid = (setuid(C->uid) != 0) ? ERROR("Command: Cannot change process uid to '%d' -- %s\n", C->uid, System_getLastError()), getuid() : C->uid;
+                else
+                        P->uid = getuid();
                 setsid(); // Loose controlling terminal
                 setupChildPipes(P);
                 // Close all descriptors except stdio
diff -x .hg -ur monit-5.3.2/src/monit.h monit-5.3.2-check-program/src/monit.h
--- monit-5.3.2/src/monit.h	2011-12-20 11:40:30.000000000 -0900
+++ monit-5.3.2-check-program/src/monit.h	2012-03-15 16:53:58.834905706 -0800
@@ -762,7 +762,8 @@
         Timestamp_T timestamplist;                       /**< Timestamp check list */
         Uid_T       uid;                                            /**< Uid check */
         Program_T   program;              /**< Status (of program execution) check */
-        
+        uid_t       programuid;                   /**< UID to run program check as */
+        gid_t       programgid;                   /**< GID to run program check as */
         
         EventAction_T action_PID;                      /**< Action upon pid change */
         EventAction_T action_PPID;                    /**< Action upon ppid change */
diff -x .hg -ur monit-5.3.2/src/p.y monit-5.3.2-check-program/src/p.y
--- monit-5.3.2/src/p.y	2011-12-20 11:40:30.000000000 -0900
+++ monit-5.3.2-check-program/src/p.y	2012-03-15 18:12:51.536512133 -0800
@@ -180,6 +180,8 @@
   static char * htpasswd_file = NULL;
   static int    digesttype = DIGEST_CLEARTEXT;
   static int    hassystem = FALSE;
+  static uid_t  proguid = 0;
+  static gid_t  proggid = 0;
 
 #define BITMAP_MAX (sizeof(long long) * 8)
 
@@ -221,6 +223,8 @@
   static void  addgid(Gid_T);
   static void  addeuid(uid_t);
   static void  addegid(gid_t);
+  static void  progadduid(uid_t);
+  static void  progaddgid(gid_t);
   static void  addeventaction(EventAction_T *, int, int);
   static void  seteventaction(EventAction_T *, int, int);
   static void  prepare_urlrequest(URL_T U);
@@ -485,6 +489,8 @@
                 | group
                 | depend
                 | exitvalue
+                | uid
+                | gid
                 ; 
 
 setalert        : SET alertmail formatlist reminder {
@@ -864,6 +870,29 @@
                         check_exec($4);
                         createservice(TYPE_PROGRAM, $<string>2, $4, check_program);
                   }
+                 | CHECKPROGRAM SERVICENAME PATHTOK PATH puseroptionlist {
+		        /* store a local copy of the uid/gid */
+   		        uid_t luid = proguid;
+  		        gid_t lgid = proggid;
+
+                        /* Immediately reset static global variables back to 0
+                           before an error */
+                        proguid = 0;
+                        proggid = 0;
+
+                        check_exec($4);
+                        createservice(TYPE_PROGRAM, $<string>2, $4, check_program);
+
+                        /* store uid in current service if non-zero */
+                        if (luid) {
+                          progadduid( luid );
+                        }
+
+                        /* store gid in current service if non-zero */
+                        if (lgid) {
+                          progaddgid( lgid );
+                        }
+                  }
                 ;
 
 start           : START argumentlist exectimeout {
@@ -1752,6 +1781,17 @@
                 | REMINDER NUMBER CYCLE { mailset.reminder = $<number>2; }
                 ;
 
+puseroptionlist : puseroption
+                | puseroptionlist puseroption
+                ;
+
+/* Setting static global variables because the service isn't available yet */
+puseroption     : UID STRING { proguid = get_uid($2, 0); FREE($2); }
+                | GID STRING { proggid = get_gid($2, 0); FREE($2); }
+                | UID NUMBER { proguid = get_uid(NULL, $2); }
+                | GID NUMBER { proggid = get_gid(NULL, $2); }
+                ;
+
 %%
 
 
@@ -2970,6 +3010,25 @@
     yyerror("gid statement requires root privileges");
 }
 
+/*
+ * Add uid for "check program" to current service
+ */
+static void progadduid(uid_t uid) {
+  if (!getuid()) {
+    current->programuid = uid;
+  } else
+    yyerror("uid statement requires root privleges");
+}
+
+/*
+ * Add gid for "check program" to current service
+ */
+static void progaddgid(gid_t gid) {
+  if (!getuid()) {
+    current->programgid = gid;
+  } else
+    yyerror("gid statement requires root privileges");
+}
 
 /*
  * Reset the logfile if changed
diff -x .hg -ur monit-5.3.2/src/validate.c monit-5.3.2-check-program/src/validate.c
--- monit-5.3.2/src/validate.c	2011-12-20 11:40:30.000000000 -0900
+++ monit-5.3.2-check-program/src/validate.c	2012-03-15 17:29:34.981685138 -0800
@@ -457,6 +457,16 @@
                         return FALSE;
                 }
                 s->program->C = Command_new(s->path, NULL);
+
+                DEBUG("check program uid %i, gid %i", s->programuid, s->programgid);
+
+                if (s->programuid) {
+                  Command_setUid(s->program->C, s->programuid);
+		}
+
+         	if (s->programgid) {
+                  Command_setGid(s->program->C, s->programgid);
+                }
         }
         
         if (P) {
