monit-general
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Wierd monit/sshd interaction


From: Mark Ferlatte
Subject: Re: Wierd monit/sshd interaction
Date: Mon, 5 Aug 2002 11:48:39 -0700
User-agent: Mutt/1.4i

On Mon, Jul 29, 2002 at 12:10:23AM +0200, Martin Pala wrote (1.00):
> Hi,

Hello.  Sorry for the delayed response.

> tried to reproduce this failure, but on redhat 7.3 it works good.

Interesting.

> I think that your problem could be in umask (maybe system-wide), while in

Based on this, I did a little more investigation, and it appears that
monit is setting the umask to 0122 before starting applications.  The
umask of monit's startup script is 0022, and the umask at boottime is
also 0022.

0122 is PIDMASK (in monit.h), and is set at startup in
files.c:create_pidfile().

create_pidfile() doesn't save away the original umask and restore
afterwards, which is where this bug is coming from.

I've created a patch against files.c that fixes this problem, and fixes
another minor problem with the pidfile (Unix pidfiles are traditionally
%d\n, whereas monit's was just %d).

Anyway, the patch is against monit 2.5, and inlined below.

M

--- files.c.orig        Fri Jun 28 14:20:49 2002
+++ files.c     Mon Aug  5 11:44:16 2002
@@ -161,8 +161,9 @@
 int create_pidfile(char *pidfile) {
   
   FILE *F= NULL;
+  mode_t saved;
 
-  umask(PIDMASK);
+  saved = umask(PIDMASK);
   
   if ((F= fopen(pidfile,"w")) == (FILE *)NULL) {
     
@@ -173,9 +174,9 @@
     
   }
   
-  fprintf(F, "%d", (int)getpid());
+  fprintf(F, "%d\n", (int)getpid());
   fclose(F);
-
+  umask(saved);
   return TRUE;
   
 }

Attachment: pgp6knGaEP50Q.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]