[Pkg-clamav-devel] Bug#802311: clamav-daemon: Please add another restorecon to the init script for SE Linux support

Russell Coker russell at coker.com.au
Mon Oct 19 11:12:23 UTC 2015


Package: clamav-daemon
Version: 0.98.7+dfsg-0+deb8u1
Severity: normal
Tags: patch

Please include the following patch to label all directories that might be
created.

--- /etc/init.d/clamav-daemon.orig	2015-10-19 22:07:04.174298790 +1100
+++ /etc/init.d/clamav-daemon	2015-10-19 22:09:45.079895382 +1100
@@ -94,6 +94,7 @@
     ucf --three-way --debconf-ok "$sourcefile" "$configfile"
   else
     [ -d /var/lib/ucf/cache ] || mkdir -p /var/lib/ucf/cache
+    pathfind restorecon && restorecon /var/lib/ucf/cache
     cp $sourcefile $configfile
     add_to_ucf $configfile $ucffile
   fi

-- Package-specific info:
--- configuration ---
Checking configuration files in /etc/clamav

Config file: clamd.conf
-----------------------
LogFile = "/var/log/clamav/clamav.log"
StatsHostID = "auto"
StatsEnabled disabled
StatsPEDisabled = "yes"
StatsTimeout = "10"
LogFileUnlock disabled
LogFileMaxSize = "4294967295"
LogTime = "yes"
LogClean disabled
LogSyslog disabled
LogFacility = "LOG_LOCAL6"
LogVerbose disabled
LogRotate = "yes"
ExtendedDetectionInfo = "yes"
PidFile = "/var/run/clamav/clamd.pid"
TemporaryDirectory disabled
DatabaseDirectory = "/var/lib/clamav"
OfficialDatabaseOnly disabled
LocalSocket = "/var/run/clamav/clamd.ctl"
LocalSocketGroup = "clamav"
LocalSocketMode = "666"
FixStaleSocket = "yes"
TCPSocket disabled
TCPAddr disabled
MaxConnectionQueueLength = "15"
StreamMaxLength = "26214400"
StreamMinPort = "1024"
StreamMaxPort = "2048"
MaxThreads = "12"
ReadTimeout = "180"
CommandReadTimeout = "5"
SendBufTimeout = "200"
MaxQueue = "100"
IdleTimeout = "30"
ExcludePath disabled
MaxDirectoryRecursion = "15"
FollowDirectorySymlinks disabled
FollowFileSymlinks disabled
CrossFilesystems = "yes"
SelfCheck = "3600"
DisableCache disabled
VirusEvent disabled
ExitOnOOM disabled
AllowAllMatchScan = "yes"
Foreground disabled
Debug disabled
LeaveTemporaryFiles disabled
User = "clamav"
AllowSupplementaryGroups disabled
Bytecode = "yes"
BytecodeSecurity = "TrustSigned"
BytecodeTimeout = "60000"
BytecodeUnsigned disabled
BytecodeMode = "Auto"
DetectPUA disabled
ExcludePUA disabled
IncludePUA disabled
AlgorithmicDetection = "yes"
ScanPE = "yes"
ScanELF = "yes"
DetectBrokenExecutables disabled
ScanMail = "yes"
ScanPartialMessages disabled
PhishingSignatures = "yes"
PhishingScanURLs = "yes"
PhishingAlwaysBlockCloak disabled
PhishingAlwaysBlockSSLMismatch disabled
PartitionIntersection disabled
HeuristicScanPrecedence disabled
StructuredDataDetection disabled
StructuredMinCreditCardCount = "3"
StructuredMinSSNCount = "3"
StructuredSSNFormatNormal = "yes"
StructuredSSNFormatStripped disabled
ScanHTML = "yes"
ScanOLE2 = "yes"
OLE2BlockMacros disabled
ScanPDF = "yes"
ScanSWF = "yes"
ScanArchive = "yes"
ArchiveBlockEncrypted disabled
ForceToDisk disabled
MaxScanSize = "104857600"
MaxFileSize = "26214400"
MaxRecursion = "10"
MaxFiles = "10000"
MaxEmbeddedPE = "10485760"
MaxHTMLNormalize = "10485760"
MaxHTMLNoTags = "2097152"
MaxScriptNormalize = "5242880"
MaxZipTypeRcg = "1048576"
MaxPartitions = "50"
MaxIconsPE = "100"
ScanOnAccess disabled
OnAccessIncludePath disabled
OnAccessExcludePath disabled
OnAccessExcludeUID disabled
OnAccessMaxFileSize = "5242880"
DevACOnly disabled
DevACDepth disabled
DevPerformance disabled
DevLiblog disabled
DisableCertCheck disabled

Config file: freshclam.conf
---------------------------
StatsHostID disabled
StatsEnabled disabled
StatsTimeout disabled
LogFileMaxSize = "4294967295"
LogTime = "yes"
LogSyslog disabled
LogFacility = "LOG_LOCAL6"
LogVerbose disabled
LogRotate = "yes"
PidFile = "/var/run/clamav/freshclam.pid"
DatabaseDirectory = "/var/lib/clamav"
Foreground disabled
Debug disabled
AllowSupplementaryGroups disabled
UpdateLogFile = "/var/log/clamav/freshclam.log"
DatabaseOwner = "clamav"
Checks = "24"
DNSDatabaseInfo = "current.cvd.clamav.net"
DatabaseMirror = "db.local.clamav.net", "database.clamav.net"
PrivateMirror disabled
MaxAttempts = "5"
ScriptedUpdates = "yes"
TestDatabases = "yes"
CompressLocalDatabase disabled
ExtraDatabase disabled
DatabaseCustomURL disabled
HTTPProxyServer disabled
HTTPProxyPort disabled
HTTPProxyUsername disabled
HTTPProxyPassword disabled
HTTPUserAgent disabled
NotifyClamd = "/etc/clamav/clamd.conf"
OnUpdateExecute disabled
OnErrorExecute disabled
OnOutdatedExecute disabled
LocalIPAddress disabled
ConnectTimeout = "30"
ReceiveTimeout = "30"
SubmitDetectionStats disabled
DetectionStatsCountry disabled
DetectionStatsHostID disabled
SafeBrowsing disabled
Bytecode = "yes"

Config file: clamav-milter.conf
-------------------------------
LogFile = "/var/log/clamav/clamav-milter.log"
LogFileUnlock disabled
LogFileMaxSize = "1048576"
LogTime = "yes"
LogSyslog disabled
LogFacility = "LOG_LOCAL6"
LogVerbose disabled
LogRotate = "yes"
PidFile = "/var/run/clamav/clamav-milter.pid"
TemporaryDirectory = "/tmp"
FixStaleSocket = "yes"
MaxThreads = "10"
ReadTimeout = "120"
Foreground disabled
User = "clamav"
AllowSupplementaryGroups = "yes"
MaxFileSize = "26214400"
ClamdSocket = "unix:/var/run/clamav/clamd.ctl"
MilterSocket = "/var/run/clamav/clamav-milter.ctl"
MilterSocketGroup = "clamav"
MilterSocketMode = "666"
LocalNet disabled
OnClean = "Accept"
OnInfected = "Reject"
OnFail = "Defer"
RejectMsg disabled
AddHeader = "Replace"
ReportHostname disabled
VirusAction disabled
Chroot disabled
Whitelist disabled
SkipAuthenticated disabled
LogInfected = "Off"
LogClean = "Off"
SupportMultipleRecipients disabled

Software settings
-----------------
Version: 0.98.7
Optional features supported: MEMPOOL IPv6 FRESHCLAM_DNS_FIX AUTOIT_EA06 BZIP2 LIBXML2 ICONV JSON JIT

Database information
--------------------
Database directory: /var/lib/clamav
main.cvd: version 55, sigs: 2424225, built on Wed Sep 18 00:57:28 2013
bytecode.cld: version 268, sigs: 47, built on Fri Aug 21 00:50:41 2015
daily.cld: version 20983, sigs: 1613596, built on Mon Oct 19 19:38:35 2015
Total number of signatures: 4037868

Platform information
--------------------
uname: Linux 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt11-1+deb8u5 (2015-10-09) x86_64
OS: linux-gnu, ARCH: x86_64, CPU: x86_64
Full OS version: Debian GNU/Linux 8.2 (jessie)
zlib version: 1.2.8 (1.2.8), compile flags: a9
Triple: x86_64-pc-linux-gnu
CPU: k8-sse3, Little-endian
platform id: 0x0a2150500804090202040902

Build information
-----------------
GNU C: 4.9.2 (4.9.2)
GNU C++: 4.9.2 (4.9.2)
CPPFLAGS: -D_FORTIFY_SOURCE=2
CFLAGS: -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wall -D_FILE_OFFSET_BITS=64 -fno-strict-aliasing  -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
CXXFLAGS: 
LDFLAGS: -Wl,-z,relro
Configure: '--build=x86_64-linux-gnu' '--prefix=/usr' '--includedir=/usr/include' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--sysconfdir=/etc' '--localstatedir=/var' '--disable-silent-rules' '--libexecdir=/usr/lib/clamav' '--disable-maintainer-mode' '--disable-dependency-tracking' 'CFLAGS=-g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wall -D_FILE_OFFSET_BITS=64' 'CPPFLAGS=-D_FORTIFY_SOURCE=2' 'CXXFLAGS=-g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wall -D_FILE_OFFSET_BITS=64' 'LDFLAGS=-Wl,-z,relro' '--with-dbdir=/var/lib/clamav' '--sysconfdir=/etc/clamav' '--disable-clamav' '--disable-unrar' '--enable-milter' '--enable-dns-fix' '--with-libjson' '--with-gnu-ld' '-with-system-llvm=/usr/bin/llvm-config' '--with-llvm-linking=dynamic' '--with-systemdsystemunitdir=/lib/systemd/system' 'build_alias=x86_64-linux-gnu'
sizeof(void*) = 8
Engine flevel: 80, dconf: 80

--- data dir ---
total 164408
-rw-r--r--. 1 clamav clamav    407040 Aug 21 01:33 bytecode.cld
-rw-r--r--. 1 clamav clamav 103214080 Oct 19 20:10 daily.cld
-rw-r--r--. 1 clamav clamav  64720632 Nov 21  2014 main.cvd
-rw-------. 1 clamav clamav      1508 Oct 19 22:04 mirrors.dat

-- System Information:
Debian Release: 8.2
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 3.16.0-4-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_AU.UTF-8, LC_CTYPE=en_AU.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages clamav-daemon depends on:
ii  adduser                         3.113+nmu3
iu  clamav-base                     0.98.7+dfsg-0+deb8u1
iu  clamav-freshclam [clamav-data]  0.98.7+dfsg-0+deb8u1
ii  debconf [debconf-2.0]           1.5.56
ii  dpkg                            1.17.25
ii  init-system-helpers             1.22
ii  libbz2-1.0                      1.0.6-7+b3
ii  libc6                           2.19-18+deb8u1
iu  libclamav6                      0.98.7+dfsg-0+deb8u1
ii  libjson-c2                      0.11-4
ii  libncurses5                     5.9+20140913-1+b1
ii  libssl1.0.0                     1.0.1k-3+deb8u1
ii  libsystemd0                     215-17+deb8u2
ii  libtinfo5                       5.9+20140913-1+b1
ii  lsb-base                        4.1+Debian13+nmu1
ii  procps                          2:3.3.9-9
ii  ucf                             3.0030
ii  zlib1g                          1:1.2.8.dfsg-2+b1

Versions of packages clamav-daemon recommends:
pn  clamdscan  <none>

Versions of packages clamav-daemon suggests:
pn  apparmor     <none>
pn  clamav-docs  <none>
pn  daemon       <none>

-- Configuration Files:
/etc/init.d/clamav-daemon changed:
PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/clamd
NAME="clamd"
DESC="ClamAV daemon"
CLAMAVCONF=/etc/clamav/clamd.conf
SUPERVISOR=/usr/bin/daemon
SUPERVISORNAME=daemon
SUPERVISORPIDFILE="/var/run/clamav/daemon-clamd.pid"
SUPERVISORARGS="--name=$NAME --respawn $DAEMON -F $SUPERVISORPIDFILE"
DATABASEDIR="/var/lib/clamav"
[ -x "$DAEMON" ] || exit 0
[ -r /etc/default/clamav-daemon ] && . /etc/default/clamav-daemon
to_lower()
{
  word="$1"
  lcword=$(echo "$word" | tr A-Z a-z)
  echo "$lcword"
}
is_true()
{
  var="$1"
  lcvar=$(to_lower "$var")
  [ 'true' = "$lcvar" ] || [ 'yes' = "$lcvar" ] || [ 1 = "$lcvar" ]
  return $?
}
is_false()
{
  var="$1"
  lcvar=$(to_lower "$var")
  [ 'false' = "$lcvar" ] || [ 'no' = "$lcvar" ] || [ 0 = "$lcvar" ]
  return $?
}
ucf_cleanup()
{
  # This only does something if I've fucked up before
  # Not entirely impossible :(
  configfile=$1
  if [ `grep "$configfile" /var/lib/ucf/hashfile | wc -l` -gt 1 ]; then
    grep -v "$configfile" /var/lib/ucf/hashfile > /var/lib/ucf/hashfile.tmp
    grep "$configfile" /var/lib/ucf/hashfile | tail -n 1  >> /var/lib/ucf/hashfile.tmp
    mv /var/lib/ucf/hashfile.tmp /var/lib/ucf/hashfile
  fi
}
add_to_ucf()
{
  configfile=$1
  ucffile=$2
  if ! grep -q "$configfile" /var/lib/ucf/hashfile; then
    md5sum $configfile >> /var/lib/ucf/hashfile
    cp $configfile $ucffile
  fi
}
ucf_upgrade_check()
{
  configfile=$1
  sourcefile=$2
  ucffile=$3
  if [ -f "$configfile" ]; then
    add_to_ucf $configfile $ucffile
    ucf --three-way --debconf-ok "$sourcefile" "$configfile"
  else
    [ -d /var/lib/ucf/cache ] || mkdir -p /var/lib/ucf/cache
    pathfind restorecon && restorecon /var/lib/ucf/cache
    cp $sourcefile $configfile
    add_to_ucf $configfile $ucffile
  fi
}
slurp_config()
{
  CLAMAVCONF="$1"
  
  if [ -e "$CLAMAVCONF" ]; then
    for variable in `egrep -v '^[[:space:]]*(#|$)' "$CLAMAVCONF" | awk '{print $1}'`; do
      case "$variable" in
        DatabaseMirror)
        if [ -z "$DatabaseMirror" ]; then
          for i in `grep ^$variable $CLAMAVCONF | awk '{print $2}'`; do
            value="$value $i"
          done
        else
          continue
        fi
        ;;
        DatabaseCustomURL)
        if [ -z "$DatabaseCustomURL" ]; then
          for i in `grep ^$variable $CLAMAVCONF | awk '{print $2}'`; do
            value="$value $i"
          done
        else
          continue
        fi
        ;;
        IncludePUA)
        if [ -z "$IncludePUA" ]; then
          for i in `grep ^$variable $CLAMAVCONF | awk '{print $2}'`; do
            value="$i $value"
          done
        else
          continue
        fi
        ;;
        ExcludePUA)
        if [ -z "$ExcludePUA" ]; then
          for i in `grep ^$variable $CLAMAVCONF | awk '{print $2}'`; do
            value="$i $value"
          done
        else
          continue
        fi
        ;;
        ExtraDatabase)
        if [ -z "$ExtraDatabase" ]; then
          for i in `grep ^$variable $CLAMAVCONF | awk '{print $2}'`; do
            value="$value $i"
          done
        else
          continue
        fi
        ;;
        VirusEvent|OnUpdateExecute|OnErrorExecute|RejectMsg)
        value=`grep ^$variable $CLAMAVCONF | head -n1 | sed -e s/$variable\ //`
        ;;
        *)
        value=`grep "^$variable[[:space:]]" $CLAMAVCONF | head -n1 | awk '{print $2}'`
        ;;
      esac
      if [ -z "$value" ]; then 
        export "$variable"="true"
      elif [ "$value" != "$variable" ]; then
        export "$variable"="$value"
      else
        export "$variable"="true"
      fi
      unset value
    done
  fi
}
pathfind() {
  OLDIFS="$IFS"
  IFS=:
  for p in $PATH; do
    if [ -x "$p/$*" ]; then
      IFS="$OLDIFS"
      return 0
    fi
  done
  IFS="$OLDIFS"
  return 1
}
set_debconf_value()
{
prog=$1
name=$2
eval variable="\$${name}"
if [ -n "$variable" ]; then
  db_set clamav-$prog/$name "$variable" || true
fi
}
make_dir()
{
  DIR=$1
  if [ -d "$DIR" ]; then
    return 0;
  fi
  [ -n "$User" ] || User=clamav
  mkdir -p -m 0755 "$DIR"
  chown "$User" "$DIR"
  pathfind restorecon && restorecon "$DIR"
}
isdigit ()
{
  case $1 in
    [[:digit:]]*)
    ISDIGIT=1
    ;;
    *)
    ISDIGIT=0
    ;;
  esac
}
inputdigit ()
{
  ISDIGIT=0
  while [ "$ISDIGIT" = '0' ]; do
    db_input "$1" "$2" || true
    if ! db_go; then
      return 30
    fi
    db_get $2 || true
    isdigit $RET
    if [ "$ISDIGIT" = '0' ]; then
      db_input critical clamav-base/numinfo || true
      db_go
    fi
  done
  return 0
}
StateGeneric()
{
  PRIO=$1
  QUESTION=$2
  NEXT=$3
  LAST=$4
  db_input $PRIO $QUESTION || true
  if db_go; then
    STATE=$NEXT
  else
    STATE=$LAST
  fi
}
StateGenericDigit()
{
  PRIO=$1
  QUESTION=$2
  NEXT=$3
  LAST=$4
  inputdigit $PRIO $QUESTION || true
  if db_go; then
    STATE=$NEXT
  else
    STATE=$LAST
  fi
}
.. /lib/lsb/init-functions
if [ ! -f "$CLAMAVCONF" ]; then
  log_failure_msg "There is no configuration file for Clamav."
  log_failure_msg "Please either dpkg-reconfigure $DESC, or copy the example from"
  log_failure_msg "/usr/share/doc/clamav-base/examples/ to $CLAMAVCONF and run"
  log_failure_msg "'/etc/init.d/clamav-daemon start'"
  if [ "$1" = "status" ]; then
    # program or service status is unknown
    exit 4;
  else
    # program is not configured
    exit 6;
  fi
fi
slurp_config "$CLAMAVCONF"
if [ -n "$Example" ]; then
  log_failure_msg "Clamav is not configured."
  log_failure_msg "Please edit $CLAMAVCONF and run  '/etc/init.d/clamav-daemon start'"
  if [ "$1" = "status" ]; then
    # program or service status is unknown
    exit 4;
  else
    # program is not configured
    exit 6;
  fi
fi
if is_true "$Foreground"; then
  if [ ! -x "$SUPERVISOR" ] ; then
     log_failure_msg "Foreground specified, but $SUPERVISORNAME not found"
    if [ "$1" = "status" ]; then
      # program or service status is unknown
      exit 4;
    else
      # program is not configured correctly
      exit 6;
    fi
  else
     RUN_SUPERVISED=1
  fi
fi
[ -n "$User" ] || User=clamav
[ -n "$DataBaseDirectory" ] || DataBaseDirectory=/var/run/clamav
make_dir "$DataBaseDirectory"
make_dir $(dirname "$SUPERVISORPIDFILE")
if [ -z "$RUN_SUPERVISED" ]; then
	THEPIDFILE="$PidFile"
	THEDAEMON="$NAME"
	RELOAD="1"
else
	THEPIDFILE="$SUPERVISORPIDFILE"
	THEDAEMON="$SUPERVISORNAME"
	RELOAD="0"
fi
if [ -z "$THEPIDFILE" ]
then
  # Set the default PidFile.
  THEPIDFILE='/run/clamav/clamd.pid'
fi
make_dir $(dirname "$THEPIDFILE")
chown $User $(dirname "$THEPIDFILE")
case "$1" in
  start)
  # Check for database existance (start will fail if it's missing)
  for db in main daily; do
    if [ ! -e "$DATABASEDIR"/"$db".cvd ] && [ ! -d "$DATABASEDIR"/"$db".inc ] && [ ! -e "$DATABASEDIR"/"$db".cld ]; then
      log_failure_msg "Clamav signatures not found in $DATABASEDIR"
      log_failure_msg "Please retrieve them using freshclam"
      log_failure_msg "Then run '/etc/init.d/clamav-daemon start'"
      # this is expected on a fresh installation
      exit 0
    fi
  done
  if [ -z "$RUN_SUPERVISED" ] ; then
    log_daemon_msg "Starting $DESC" "$NAME "
    start-stop-daemon --start --oknodo -c $User --exec $DAEMON --pidfile $THEPIDFILE -- -c $CLAMAVCONF --pid=$THEPIDFILE
    ret=$?
  else 
    log_daemon_msg "Starting $DESC" "$NAME (supervised) "
    $SUPERVISOR $SUPERVISORARGS
    ret=$?
  fi
  log_end_msg $ret
  ;;
  stop)
  log_daemon_msg "Stopping $DESC" "$NAME"
  start-stop-daemon --stop --oknodo --name $THEDAEMON --pidfile $THEPIDFILE --retry TERM/30/KILL/5
  log_end_msg $?
  ;;
  status)
  start-stop-daemon --status --name $THEDAEMON --pidfile $THEPIDFILE
  # start-stop-daemon returns LSB compliant exit status codes
  ret=$?
  if [ "$ret" = 0 ]; then
      log_success_msg "$NAME is running"
  else
      log_failure_msg "$NAME is not running"
      exit "$ret"
  fi
  ;;
  restart|force-reload)
  $0 stop
  $0 start
  ;;
  reload-database)
  if [ "$RELOAD" = "1" ]; then
    log_daemon_msg "Reloading database for $DESC" "$NAME"
    pkill -USR2 -F $THEPIDFILE $THEDAEMON 2>/dev/null
    log_end_msg $?
  else
    log_failure_msg "reload-database does not work in supervised mode."
    # unimplemented feature
    exit 3
  fi
  ;;
  reload-log)
  if [ "$RELOAD" = "1" ]; then
    log_daemon_msg "Reloading log file for $DESC" "$NAME"
    pkill -HUP -F $THEPIDFILE $THEDAEMON 2>/dev/null
  else
    log_failure_msg "reload-log does not work in supervised mode."
    # unimplemented feature
    exit 3
  fi
  log_end_msg $?
  ;;
  *)
  log_action_msg "Usage: $0 {start|stop|restart|force-reload|reload-log|reload-database|status}" >&2
  # invalid arguments
  exit 2
  ;;
esac
exit 0


-- debconf information excluded



More information about the Pkg-clamav-devel mailing list