This is a multi-part message in MIME format.
------=_NextPart_000_0083_01C836E0.6C2AAF10
Content-Type: multipart/alternative;
boundary="----=_NextPart_001_0084_01C836E0.6C2AAF10"
------=_NextPart_001_0084_01C836E0.6C2AAF10
Content-Type: text/plain;
charset="koi8-r"
Content-Transfer-Encoding: 7bit
Hi everybody,
Playing with coredumps, I've found that nagios gets homedir not from passwd
entry, but from $HOME env variable.
With this patch, Nagios will determine homedir of nagios user via
getpwnam(3) call, and fallback to $HOME if failed.
It would be great to see this patch (based on last CVS snapshot) in the
official source tree.
What do you think about that?
With best regards,
Andrew.
------=_NextPart_001_0084_01C836E0.6C2AAF10
Content-Type: text/html;
charset="koi8-r"
Content-Transfer-Encoding: quoted-printable
coredumps
Hi =
everybody,
Playing with =
coredumps, I've found that nagios gets homedir not from passwd entry, =
but from $HOME env variable.
With this patch, =
Nagios will determine homedir of nagios user via getpwnam(3) call, and =
fallback to $HOME if failed.
It would be great =
to see this patch (based on last CVS snapshot) in the official source =
tree.
What do you think =
about that?
=
<<...>>
With best regards,
Andrew.
------=_NextPart_001_0084_01C836E0.6C2AAF10--
------=_NextPart_000_0083_01C836E0.6C2AAF10
Content-Type: application/octet-stream;
name="nagios-homedir.patch"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="nagios-homedir.patch"
--- base/utils.c.orig Tue Nov 13 04:27:20 2007=0A=
+++ base/utils.c Wed Dec 5 01:26:56 2007=0A=
@@ -1942,7 +1942,7 @@=0A=
/************************ DAEMON FUNCTIONS ************************/=0A=
/******************************************************************/=0A=
=0A=
-int daemon_init(void){=0A=
+int daemon_init(char *user){=0A=
pid_t pid=3D-1;=0A=
int pidno=3D0;=0A=
int lockfile=3D0;=0A=
@@ -1950,13 +1950,33 @@=0A=
char buf[256];=0A=
struct flock lock;=0A=
char *homedir=3DNULL;=0A=
+ struct passwd *pw=3DNULL;=0A=
=0A=
#ifdef RLIMIT_CORE=0A=
struct rlimit limit;=0A=
#endif=0A=
=0A=
+ /* see if this is a user name */=0A=
+ if(strspn(user,"0123456789")pw_dir;=0A=
+ else=0A=
+ logit(NSLOG_RUNTIME_WARNING,TRUE,"Warning: Could not get passwd =
entry for '%s'",user);=0A=
+ }=0A=
+=0A=
+ /* else we were passed the UID */=0A=
+ else{=0A=
+ pw=3D(struct passwd *)getpwuid((uid_t)atoi(user));=0A=
+ if(pw!=3DNULL)=0A=
+ homedir=3Dpw->pw_dir;=0A=
+ else=0A=
+ logit(NSLOG_RUNTIME_WARNING,TRUE,"Warning: Could not get passwd =
entry for '%s'",user);=0A=
+ }=0A=
+=0A=
/* change working directory. scuttle home if we're dumping core */=0A=
- homedir=3Dgetenv("HOME");=0A=
+ if (homedir=3D=3DNULL)=0A=
+ homedir=3Dgetenv("HOME");=0A=
if(daemon_dumps_core=3D=3DTRUE && homedir!=3DNULL)=0A=
chdir(homedir);=0A=
else=0A=
--- base/nagios.c.orig Fri Nov 23 21:24:50 2007=0A=
+++ base/nagios.c Wed Dec
...[email truncated]...
This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]