[Nagios-checkins] nagios/base utils.c,1.90,1.91
Nagios network monitoring software is enterprise server monitoring
Brought to you by:
egalstad,
sawolf-nagios
From: Ethan G. <ega...@us...> - 2005-01-14 15:09:38
|
Update of /cvsroot/nagios/nagios/base In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24082/base Modified Files: utils.c Log Message: Added environment macro support for Solaris using putenv() Index: utils.c =================================================================== RCS file: /cvsroot/nagios/nagios/base/utils.c,v retrieving revision 1.90 retrieving revision 1.91 diff -C2 -d -r1.90 -r1.91 *** utils.c 11 Jan 2005 04:53:06 -0000 1.90 --- utils.c 14 Jan 2005 15:09:28 -0000 1.91 *************** *** 4,8 **** * * Copyright (c) 1999-2005 Ethan Galstad (na...@na...) ! * Last Modified: 01-10-2005 * * License: --- 4,8 ---- * * Copyright (c) 1999-2005 Ethan Galstad (na...@na...) ! * Last Modified: 01-14-2005 * * License: *************** *** 2450,2453 **** --- 2450,2456 ---- int set_macro_environment_var(char *name, char *value, int set){ char *env_macro_name=NULL; + #ifndef HAVE_SETENV + char *env_macro_string=NULL; + #endif #ifdef DEBUG0 *************** *** 2472,2475 **** --- 2475,2486 ---- #ifdef HAVE_SETENV setenv(env_macro_name,(value==NULL)?"":value,1); + #else + /* needed for Solaris and systems that don't have setenv() */ + /* this will leak memory, but in a "controlled" way, since lost memory should be freed when the child process exits */ + env_macro_string=(char *)malloc(strlen(env_macro_name)+strlen((value==NULL)?"":value)+2); + if(env_macro_string!=NULL){ + sprintf(env_macro_string,"%s=%s",env_macro_name,(value==NULL)?"":value); + putenv(env_macro_string); + } #endif } |