~ubuntu-branches/ubuntu/jaunty/monit/jaunty

« back to all changes in this revision

Viewing changes to protocols/clamav.c

  • Committer: Bazaar Package Importer
  • Author(s): Stefan Alfredsson
  • Date: 2008-08-24 23:44:46 UTC
  • mfrom: (4.1.1 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080824234446-a3k8n02f52nio5dy
Tags: 1:4.10.1-4
* Patch for config file location was not applied (Closes: #479357)
  (thanks to DVZ-Team <dv-zentrum@fh-giessen.de>)
* The relocation patch created an unneccessary "file.c.orig", this
  was removed from the patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C), 2000-2007 by the monit project group.
 
3
 * All Rights Reserved.
 
4
 *
 
5
 * This program is free software: you can redistribute it and/or modify
 
6
 * it under the terms of the GNU General Public License as published by
 
7
 * the Free Software Foundation, either version 3 of the License, or
 
8
 * (at your option) any later version.
 
9
 *
 
10
 * This program is distributed in the hope that it will be useful,
 
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 * GNU General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU General Public License
 
16
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
17
 */
 
18
 
 
19
#include <config.h>
 
20
 
 
21
#ifdef HAVE_STDIO_H
 
22
#include <stdio.h>
 
23
#endif
 
24
 
 
25
#ifdef HAVE_ERRNO_H
 
26
#include <errno.h>
 
27
#endif
 
28
 
 
29
#ifdef HAVE_STRING_H
 
30
#include <string.h>
 
31
#endif
 
32
 
 
33
#ifdef HAVE_STRINGS_H
 
34
#include <strings.h>
 
35
#endif
 
36
 
 
37
#include "protocol.h"
 
38
 
 
39
/**
 
40
 *  Send PING and check for PONG.
 
41
 *  If alive return TRUE, else, return FALSE.
 
42
 *
 
43
 *  @author Debrard Sébastien <sebastien.debrard@strange-garden.com>
 
44
 *
 
45
 *  @version \$Id: clamav.c,v 1.3 2007/07/25 12:54:32 hauk Exp $
 
46
 *
 
47
 *  @file
 
48
 */
 
49
int check_clamav(Socket_T s) {
 
50
 
 
51
  char buf[STRLEN];
 
52
  const char *ok= "PONG";
 
53
 
 
54
  ASSERT(s);
 
55
  
 
56
  if(socket_print(s, "PING\r\n") < 0) {
 
57
    LogError("CLAMAV: error sending data -- %s\n", STRERROR);
 
58
    return FALSE;
 
59
  }
 
60
 
 
61
  if(!socket_readln(s, buf, sizeof(buf))) {
 
62
    LogError("CLAMAV: error receiving data -- %s\n", STRERROR);
 
63
    return FALSE;
 
64
  }
 
65
 
 
66
  Util_chomp(buf);
 
67
  
 
68
  if(strncasecmp(buf, ok, strlen(ok)) != 0) {
 
69
    LogError("CLAMAV error: %s\n", buf);
 
70
    return FALSE;
 
71
  }
 
72
 
 
73
  return TRUE;
 
74
  
 
75
}
 
76