nagios 2 won't compile on solaris 8

Bob Cunningham bob at cdsinc.com
Thu Feb 3 19:40:25 CET 2005


Nagios 2.x uses the setenv & unsetenv functions.  Which found their
way into Linux a while back, but which aren't in Solaris.
(FYI, they aren't POSIX but are in BSD, although not SV4.)

I'll reprise what I said in a message a week or two ago re Solaris 9
(but it's the same thing with Solaris 8) ....

What I did was cut & paste those trivial functions from:

	http://article.gmane.org/gmane.network.nagios.devel/1443

... and added those into base/utils.c of nagios 2.2.

To be precise, here is a diff of base/utils.c for you:

225,236d224
< int setenv(const char *name, const char *value, int overwrite) {
<   if (!overwrite && getenv(name) != NULL)
<     return 0;
<   char* e = malloc(strlen(name) + strlen(value) + 3);
<   if (e == NULL) return -1;
<   *e = 0;
<   strcat(e, name);
<   strcat(e, "=");
<   strcat(e, value);
<   return putenv(e);
<   // should not free e, and we can't safely free any former value.
< }
238,249d225
< /* see
<  
http://viewcvs.globus.org/viewcvs.cgi/gatekeeper/source/unsetenv.c? 
rev=HEAD&content-type=text/vnd.viewcvs-markup
<  */
< static char *
< __findenv(name, offset)
<      register const char *name;
<      long *offset;
< {
<   extern char **environ;
<   register int len;
<   register const char *np;
<   register char **p, *c;
251,279d226
<   if (name == NULL || environ == NULL)
<     return (NULL);
<   for (np = name; *np && *np != '='; ++np)
<     continue;
<   len = np - name;
<   for (p = environ; (c = *p) != NULL; ++p)
<     if (strncmp(c, name, len) == 0 && c[len] == '=') {
<       *offset = (long)(p - environ);
<       return (c + len + 1);
<     }
<   return (NULL);
< }
< void
< unsetenv(name)
<      const char *name;
< {
<   extern char **environ;
<   register char **p;
<   long offset;
<
<   while (__findenv(name, &offset))        /* if set multiple times */
<     for (p = &environ[offset];; ++p)
<       if (!(*p = *(p + 1)))
<         break;
< }
<
<
<
<



-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null





More information about the Users mailing list