~ubuntu-branches/ubuntu/wily/clamav/wily-proposed

« back to all changes in this revision

Viewing changes to .pc/0008-Add-upstream-systemd-support-for-clamav-daemon-and-c.patch/clamd/localserver.c

  • Committer: Package Import Robot
  • Author(s): Scott Kitterman, Sebastian Andrzej Siewior, Andreas Cadhalpun, Scott Kitterman, Javier Fernández-Sanguino
  • Date: 2015-01-28 00:25:13 UTC
  • mfrom: (0.48.14 sid)
  • Revision ID: package-import@ubuntu.com-20150128002513-lil2oi74cooy4lzr
Tags: 0.98.6+dfsg-1
[ Sebastian Andrzej Siewior ]
* update "fix-ssize_t-size_t-off_t-printf-modifier", include of misc.h was
  missing but was pulled in via the systemd patch.
* Don't leak return codes from libmspack to clamav API. (Closes: #774686).

[ Andreas Cadhalpun ]
* Add patch to avoid emitting incremental progress messages when not
  outputting to a terminal. (Closes: #767350)
* Update lintian-overrides for unused-file-paragraph-in-dep5-copyright.
* clamav-base.postinst: always chown /var/log/clamav and /var/lib/clamav
  to clamav:clamav, not only on fresh installations. (Closes: #775400)
* Adapt the clamav-daemon and clamav-freshclam logrotate scripts,
  so that they correctly work under systemd.
* Move the PidFile variable from the clamd/freshclam configuration files
  to the init scripts. This makes the init scripts more robust against
  misconfiguration and avoids error messages with systemd. (Closes: #767353)
* debian/copyright: drop files from Files-Excluded only present in github
  tarballs
* Drop Workaround-a-bug-in-libc-on-Hurd.patch, because hurd got fixed.
  (see #752237)
* debian/rules: Remove useless --with-system-tommath --without-included-ltdl
  configure options.

[ Scott Kitterman ]
* Stop stripping llvm when repacking the tarball as the system llvm on some
  releases is too old to use
* New upstream bugfix release
  - Library shared object revisions.
  - Includes a patch from Sebastian Andrzej Siewior making ClamAV pid files
    compatible with systemd.
  - Fix a heap out of bounds condition with crafted Yoda's crypter files.
    This issue was discovered by Felix Groebert of the Google Security Team.
  - Fix a heap out of bounds condition with crafted mew packer files. This
    issue was discovered by Felix Groebert of the Google Security Team.
  - Fix a heap out of bounds condition with crafted upx packer files. This
    issue was discovered by Kevin Szkudlapski of Quarkslab.
  - Fix a heap out of bounds condition with crafted upack packer files. This
    issue was discovered by Sebastian Andrzej Siewior. CVE-2014-9328.
  - Compensate a crash due to incorrect compiler optimization when handling
    crafted petite packer files. This issue was discovered by Sebastian
    Andrzej Siewior.
* Update lintian override for embedded zlib to match new so version

[ Javier Fernández-Sanguino ]
* Updated Spanish Debconf template translation (Closes: #773563)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 *  Copyright (C) 2007-2009 Sourcefire, Inc.
3
 
 *
4
 
 *  Authors: Tomasz Kojm
5
 
 *
6
 
 *  This program is free software; you can redistribute it and/or modify
7
 
 *  it under the terms of the GNU General Public License version 2 as
8
 
 *  published by the Free Software Foundation.
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, write to the Free Software
17
 
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18
 
 *  MA 02110-1301, USA.
19
 
 */
20
 
 
21
 
#if HAVE_CONFIG_H
22
 
#include "clamav-config.h"
23
 
#endif
24
 
 
25
 
#include <stdio.h>
26
 
#include <string.h>
27
 
#include <sys/types.h>
28
 
#ifndef _WIN32
29
 
#include <sys/socket.h>
30
 
#include <sys/un.h>
31
 
#endif
32
 
#include <sys/stat.h>
33
 
#include <errno.h>
34
 
#ifdef HAVE_UNISTD_H
35
 
#include <unistd.h>
36
 
#endif
37
 
 
38
 
#include "libclamav/clamav.h"
39
 
 
40
 
#include "shared/optparser.h"
41
 
#include "shared/output.h"
42
 
 
43
 
#include "others.h"
44
 
#include "server.h"
45
 
#include "localserver.h"
46
 
 
47
 
#ifdef _WIN32
48
 
int localserver(const struct optstruct *opts)
49
 
{
50
 
    logg("!Localserver is not supported on this platform");
51
 
    return -1;
52
 
}
53
 
 
54
 
#else
55
 
 
56
 
int localserver(const struct optstruct *opts)
57
 
{
58
 
        struct sockaddr_un server;
59
 
        int sockfd, backlog;
60
 
        STATBUF foo;
61
 
        char *estr;
62
 
 
63
 
    memset((char *) &server, 0, sizeof(server));
64
 
    server.sun_family = AF_UNIX;
65
 
    strncpy(server.sun_path, optget(opts, "LocalSocket")->strarg, sizeof(server.sun_path));
66
 
    server.sun_path[sizeof(server.sun_path)-1]='\0';
67
 
 
68
 
    if((sockfd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
69
 
        estr = strerror(errno);
70
 
        logg("!LOCAL: Socket allocation error: %s\n", estr);
71
 
        return -1;
72
 
    }
73
 
 
74
 
    if(bind(sockfd, (struct sockaddr *) &server, sizeof(struct sockaddr_un)) == -1) {
75
 
        if(errno == EADDRINUSE) {
76
 
            if(connect(sockfd, (struct sockaddr *) &server, sizeof(struct sockaddr_un)) >= 0) {
77
 
                logg("!LOCAL: Socket file %s is in use by another process.\n", server.sun_path);
78
 
                close(sockfd);
79
 
                return -1;
80
 
            }
81
 
            if(optget(opts, "FixStaleSocket")->enabled) {
82
 
                logg("#LOCAL: Removing stale socket file %s\n", server.sun_path);
83
 
                if(unlink(server.sun_path) == -1) {
84
 
                    estr = strerror(errno);
85
 
                    logg("!LOCAL: Socket file %s could not be removed: %s\n", server.sun_path, estr);
86
 
                    close(sockfd);
87
 
                    return -1;
88
 
                }
89
 
                if(bind(sockfd, (struct sockaddr *) &server, sizeof(struct sockaddr_un)) == -1) {
90
 
                    estr = strerror(errno);
91
 
                    logg("!LOCAL: Socket file %s could not be bound: %s (unlink tried)\n", server.sun_path, estr);
92
 
                    close(sockfd);
93
 
                    return -1;
94
 
                }
95
 
            } else if(CLAMSTAT(server.sun_path, &foo) != -1) {
96
 
                logg("!LOCAL: Socket file %s exists. Either remove it, or configure a different one.\n", server.sun_path);
97
 
                close(sockfd);
98
 
                return -1;
99
 
            }
100
 
        } else {
101
 
            estr = strerror(errno);
102
 
            logg("!LOCAL: Socket file %s could not be bound: %s\n", server.sun_path, estr);
103
 
            close(sockfd);
104
 
            return -1;
105
 
        }
106
 
    }
107
 
 
108
 
    logg("#LOCAL: Unix socket file %s\n", server.sun_path);
109
 
 
110
 
    backlog = optget(opts, "MaxConnectionQueueLength")->numarg;
111
 
    logg("#LOCAL: Setting connection queue length to %d\n", backlog);
112
 
 
113
 
    if(listen(sockfd, backlog) == -1) {
114
 
        estr = strerror(errno);
115
 
        logg("!LOCAL: listen() error: %s\n", estr);
116
 
        close(sockfd);
117
 
        return -1;
118
 
    }
119
 
 
120
 
    return sockfd;
121
 
}
122
 
#endif