75 |
|
|
76 |
|
ihost_config_t ihost_config; |
77 |
|
|
78 |
+ |
extern int errno; |
79 |
+ |
|
80 |
+ |
/* Taken from the OpenSSH code. Its licence included in function.*/ |
81 |
+ |
#ifndef HAVE_STRLCAT |
82 |
+ |
|
83 |
+ |
/* |
84 |
+ |
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com> |
85 |
+ |
* All rights reserved. |
86 |
+ |
* |
87 |
+ |
* Redistribution and use in source and binary forms, with or without |
88 |
+ |
* modification, are permitted provided that the following conditions |
89 |
+ |
* are met: |
90 |
+ |
* 1. Redistributions of source code must retain the above copyright |
91 |
+ |
* notice, this list of conditions and the following disclaimer. |
92 |
+ |
* 2. Redistributions in binary form must reproduce the above copyright |
93 |
+ |
* notice, this list of conditions and the following disclaimer in the |
94 |
+ |
* documentation and/or other materials provided with the distribution. |
95 |
+ |
* 3. The name of the author may not be used to endorse or promote products |
96 |
+ |
* derived from this software without specific prior written permission. |
97 |
+ |
* |
98 |
+ |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, |
99 |
+ |
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY |
100 |
+ |
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL |
101 |
+ |
* THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
102 |
+ |
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
103 |
+ |
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
104 |
+ |
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
105 |
+ |
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
106 |
+ |
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
107 |
+ |
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
108 |
+ |
*/ |
109 |
+ |
|
110 |
+ |
/* |
111 |
+ |
* Appends src to string dst of size siz (unlike strncat, siz is the |
112 |
+ |
* full size of dst, not space left). At most siz-1 characters |
113 |
+ |
* will be copied. Always NUL terminates (unless siz <= strlen(dst)). |
114 |
+ |
* Returns strlen(src) + MIN(siz, strlen(initial dst)). |
115 |
+ |
* If retval >= siz, truncation occurred. |
116 |
+ |
*/ |
117 |
+ |
size_t |
118 |
+ |
strlcat(dst, src, siz) |
119 |
+ |
char *dst; |
120 |
+ |
const char *src; |
121 |
+ |
size_t siz; |
122 |
+ |
{ |
123 |
+ |
register char *d = dst; |
124 |
+ |
register const char *s = src; |
125 |
+ |
register size_t n = siz; |
126 |
+ |
size_t dlen; |
127 |
+ |
|
128 |
+ |
/* Find the end of dst and adjust bytes left but don't go past end */ |
129 |
+ |
while (n-- != 0 && *d != '\0') |
130 |
+ |
d++; |
131 |
+ |
dlen = d - dst; |
132 |
+ |
n = siz - dlen; |
133 |
+ |
|
134 |
+ |
if (n == 0) |
135 |
+ |
return(dlen + strlen(s)); |
136 |
+ |
while (*s != '\0') { |
137 |
+ |
if (n != 1) { |
138 |
+ |
*d++ = *s; |
139 |
+ |
n--; |
140 |
+ |
} |
141 |
+ |
s++; |
142 |
+ |
} |
143 |
+ |
*d = '\0'; |
144 |
+ |
|
145 |
+ |
return(dlen + (s - src)); /* count does not include NUL */ |
146 |
+ |
} |
147 |
+ |
|
148 |
+ |
#endif |
149 |
+ |
/* End strlcat function taken from OpenSSH */ |
150 |
+ |
|
151 |
|
void log_msg(int level, char *format, ...){ |
79 |
– |
extern int errno; |
152 |
|
int cur_errno; |
153 |
|
va_list ap; |
154 |
|
|
163 |
|
}else{ |
164 |
|
fprintf(ihost_config.log, "\n"); |
165 |
|
} |
166 |
+ |
fflush(ihost_config.log); |
167 |
|
} |
168 |
|
} |
169 |
|
|
223 |
|
|
224 |
|
if((get_host_addr(hostname, &haddr))!=0){ |
225 |
|
log_msg(LOG_CRIT, "Failed to lookup name for %s", hostname); |
226 |
+ |
close(sock); |
227 |
|
return NULL; |
228 |
|
} |
229 |
|
|
235 |
|
log_msg(LOG_DEBUG, "Creating a tcp connection"); |
236 |
|
if(connect(sock, (struct sockaddr *)&addr, sizeof(addr)) !=0){ |
237 |
|
log_msg(LOG_CRIT, "Failed to connect to hostname %s on port %d", hostname, port); |
238 |
+ |
close(sock); |
239 |
|
return NULL; |
240 |
|
} |
241 |
|
|
296 |
|
time_t config_ttl=0; |
297 |
|
|
298 |
|
if((tcp_con=create_tcp_connection(ihost_state->filtermanager_host, ihost_state->filtermanager_port))==NULL){ |
299 |
< |
goto error; |
299 |
> |
return -1; |
300 |
|
} |
301 |
|
|
302 |
|
if(ihost_state->file_list!=NULL || ihost_state->last_modified!=NULL){ |
313 |
|
} |
314 |
|
|
315 |
|
if((tcp_comm(tcp_con, ihost_state->last_modified, &response, "OK"))==0){ |
316 |
< |
if((tcp_comm(tcp_con, "END", &response, "OK"))==0){ |
316 |
> |
if((tcp_comm(tcp_con, "END", &response, "OK"))!=0){ |
317 |
|
goto error; |
318 |
|
} |
319 |
|
fclose(tcp_con); |
581 |
|
y=page_stats->pages_pageout; |
582 |
|
} |
583 |
|
snprintf(tmp, size, \ |
584 |
< |
"<pages><swapins>%lld</swapins><swapouts>%lld</swapouts></pages>", \ |
584 |
> |
"<pages><pageins>%lld</pageins><pageouts>%lld</pageouts></pages>", \ |
585 |
|
x, \ |
586 |
|
y); |
587 |
|
|
592 |
|
/* get diskio stats */ |
593 |
|
|
594 |
|
if((diskio_stats=get_diskio_stats_diff(&diskio_entries))==NULL){ |
595 |
< |
log_msg(LOG_CRIT, "Fahttp://www.cs.ukc.ac.uk/teaching/02/modules/CO/6/17/rdl/criteria.pdfiled to get diskio statistics"); |
595 |
> |
log_msg(LOG_CRIT, "Failed to get diskio statistics"); |
596 |
|
}else{ |
597 |
|
strlcat(xml, "<diskio>", size); |
598 |
|
for(counter=0;counter<diskio_entries;counter++){ |