Mail-MIMEDefang

 view release on metacpan or  search on metacpan

Makefile.PL  view on Meta::CPAN

\t    \$(MD_INSTALL_DATA) SpamAssassin/spamassassin.cf \\
\t        \$(DESTDIR)\$(MD_CONFDIR)/sa-mimedefang.cf; \\
\tfi
\tif test "\$(MD_IPHEADER)" = "yes" && test ! -f "\$(DESTDIR)\$(MD_CONFDIR)/mimedefang-ip-key"; then \\
\t    \$(FULLPERL) ./gen-ip-validator.pl > "\$(DESTDIR)\$(MD_CONFDIR)/mimedefang-ip-key"; \\
\t    chmod 600 "\$(DESTDIR)\$(MD_CONFDIR)/mimedefang-ip-key" 2>/dev/null || true; \\
\tfi

install_spool:
\t\$(MKPATH) \$(DESTDIR)\$(MD_SPOOLDIR) \$(DESTDIR)\$(MD_QUARANTINEDIR)
\tchown \$(MD_DEFANGUSER) \$(DESTDIR)\$(MD_SPOOLDIR) 2>/dev/null || true
\tchown \$(MD_DEFANGUSER) \$(DESTDIR)\$(MD_QUARANTINEDIR) 2>/dev/null || true
\tchmod 0700 \$(DESTDIR)\$(MD_SPOOLDIR)
\tchmod 0700 \$(DESTDIR)\$(MD_QUARANTINEDIR)

install-redhat: install
\t\$(MKPATH) \$(DESTDIR)\$(MD_SYSCONFDIR)/rc.d/init.d
\t\$(MKPATH) \$(DESTDIR)\$(MD_SYSCONFDIR)/sysconfig
\t\$(MKPATH) \$(DESTDIR)\$(MD_SYSCONFDIR)/logrotate.d
\t\$(MD_INSTALL_PROGRAM) redhat/mimedefang-init \\
\t    \$(DESTDIR)\$(MD_SYSCONFDIR)/rc.d/init.d/mimedefang
\t\$(MD_INSTALL_DATA) redhat/mimedefang-sysconfig \\

Makefile.in  view on Meta::CPAN


install: all
	$(INSTALL) -m 755 -d $(DESTDIR)${CONFDIR}
	-if test "$(IP_HEADER)" = "yes" -a ! -f "$(DESTDIR)${CONFDIR}/mimedefang-ip-key" ; then \
		$(PERL) ./gen-ip-validator.pl > $(DESTDIR)${CONFDIR}/mimedefang-ip-key ;\
		-chmod 600 $(DESTDIR)${CONFDIR}/mimedefang-ip-key > /dev/null 2>&1 ; \
	fi

	if test "$(DEFANGUSER)" != "" ; then \
		if id "$(DEFANGUSER)" > /dev/null 2>&1 ; then \
			chown "$(DEFANGUSER)" $(DESTDIR)${CONFDIR}/mimedefang-ip-key > /dev/null 2>&1 || true; \
			test ! -d $(DESTDIR)$(SPOOLDIR) && $(INSTALL) -m 750 -o $(DEFANGUSER) -d $(DESTDIR)$(SPOOLDIR) > /dev/null 2>&1 || true; \
			test ! -d $(DESTDIR)$(QDIR) && $(INSTALL) -m 750 -o $(DEFANGUSER) -d $(DESTDIR)$(QDIR) > /dev/null 2>&1 || true; \
                fi \
	else \
		echo ""; \
		echo "Please create the spool directory, '$(SPOOLDIR)',"; \
		echo "if it does not exist.  Give it mode 700 or 750, and make"; \
		echo "it owned by the user and group you intend to run MIMEDefang as."; \
		if test "$(QDIR)" != "$(SPOOLDIR)" ; then \
			echo "Please do the same with the quarantine directory, '$(QDIR)'."; \

install-sh  view on Meta::CPAN

# Set DOITPROG to "echo" to test this script.

doit=${DOITPROG-}
doit_exec=${doit:-exec}

# Put in absolute file names if you don't have them in your path;
# or use environment vars.

chgrpprog=${CHGRPPROG-chgrp}
chmodprog=${CHMODPROG-chmod}
chownprog=${CHOWNPROG-chown}
cmpprog=${CMPPROG-cmp}
cpprog=${CPPROG-cp}
mkdirprog=${MKDIRPROG-mkdir}
mvprog=${MVPROG-mv}
rmprog=${RMPROG-rm}
stripprog=${STRIPPROG-strip}

posix_mkdir=

# Desired mode of installed file.
mode=0755

# Create dirs (including intermediate dirs) using mode 755.
# This is like GNU 'install' as of coreutils 8.32 (2020).
mkdir_umask=22

backupsuffix=
chgrpcmd=
chmodcmd=$chmodprog
chowncmd=
mvcmd=$mvprog
rmcmd="$rmprog -f"
stripcmd=

src=
dst=
dir_arg=
dst_arg=

copy_on_change=false

install-sh  view on Meta::CPAN


Options:
     --help     display this help and exit.
     --version  display version info and exit.

  -c            (ignored)
  -C            install only if different (preserve data modification time)
  -d            create directories instead of installing files.
  -g GROUP      $chgrpprog installed files to GROUP.
  -m MODE       $chmodprog installed files to MODE.
  -o USER       $chownprog installed files to USER.
  -p            pass -p to $cpprog.
  -s            $stripprog installed files.
  -S SUFFIX     attempt to back up existing files, with suffix SUFFIX.
  -t DIRECTORY  install into DIRECTORY.
  -T            report an error if DSTFILE is a directory.

Environment variables override the default commands:
  CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
  RMPROG STRIPPROG

install-sh  view on Meta::CPAN

    --help) echo "$usage"; exit $?;;

    -m) mode=$2
        case $mode in
          *' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*)
            echo "$0: invalid mode: $mode" >&2
            exit 1;;
        esac
        shift;;

    -o) chowncmd="$chownprog $2"
        shift;;

    -p) cpprog="$cpprog -p";;

    -s) stripcmd=$stripprog;;

    -S) backupsuffix="$2"
        shift;;

    -t)

install-sh  view on Meta::CPAN

  # Protect names problematic for 'test' and other utilities.
  case $src in
    -* | [=\(\)!]) src=./$src;;
  esac

  if test -n "$dir_arg"; then
    dst=$src
    dstdir=$dst
    test -d "$dstdir"
    dstdir_status=$?
    # Don't chown directories that already exist.
    if test $dstdir_status = 0; then
      chowncmd=""
    fi
  else

    # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
    # might cause directories to be created, which would be especially bad
    # if $src (and thus $dsttmp) contains '*'.
    if test ! -f "$src" && test ! -d "$src"; then
      echo "$0: $src does not exist." >&2
      exit 1
    fi

install-sh  view on Meta::CPAN

        # Don't fail if two instances are running concurrently.
        (umask $mkdir_umask &&
         eval "\$doit_exec \$mkdirprog $prefixes") ||
          test -d "$dstdir" || exit 1
        obsolete_mkdir_used=true
      fi
    fi
  fi

  if test -n "$dir_arg"; then
    { test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
    { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
    { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
      test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
  else

    # Make a couple of temp file names in the proper directory.
    dsttmp=${dstdirslash}_inst.$$_
    rmtmp=${dstdirslash}_rm.$$_

    # Trap to clean up those temp files at exit.
    trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0

install-sh  view on Meta::CPAN

       }
     } &&
     $doit_exec $cpprog "$src" "$dsttmp") &&

    # and set any options; do chmod last to preserve setuid bits.
    #
    # If any of these fail, we abort the whole thing.  If we want to
    # ignore errors from any of these, just make sure not to ignore
    # errors from the above "$doit $cpprog $src $dsttmp" command.
    #
    { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
    { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
    { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
    { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&

    # If -C, don't bother to copy if it wouldn't change the file.
    if $copy_on_change &&
       old=`LC_ALL=C ls -dlL "$dst"     2>/dev/null` &&
       new=`LC_ALL=C ls -dlL "$dsttmp"  2>/dev/null` &&
       set -f &&
       set X $old && old=:$2:$4:$5:$6 &&

redhat/mimedefang-init.in  view on Meta::CPAN


    # Check mimedefang-filter syntax
    configtest
    RETVAL=$?
    if [ $RETVAL != 0 ] ; then
	return $RETVAL
    fi

    # Since @SPOOLDIR@ might be tmpfs, ensure that it is properly
    # initialized.
    chown defang:defang @SPOOLDIR@
    restorecon -R @SPOOLDIR@ >/dev/null 2>&1
    if [ ! -d @SPOOLDIR@/.razor ]; then
	mkdir @SPOOLDIR@/.razor
	chown defang:defang @SPOOLDIR@/.razor
	chmod 0750 @SPOOLDIR@/.razor
    fi
    if [ ! -L @SPOOLDIR@/.razor/razor-agent.log ]; then
	# The Razor2 log is mostly useless, and we can't change its location.
	# In order to prevent it from filling up the spool, we just link it to
	# /dev/null.
	ln -sf /dev/null @SPOOLDIR@/.razor/razor-agent.log
	chown -h defang:defang @SPOOLDIR@/.razor/razor-agent.log
    fi

    echo -n "Starting $prog-multiplexor: "
    [ -e $MX_SOCKET ] && rm -f $MX_SOCKET
    # Tricky stuff below... "echo -E" won't work, hence the two-step.
    daemon $PROGDIR/$prog-multiplexor -p /var/run/$prog-multiplexor.pid \
	   -o @SPOOLDIR@/$prog-multiplexor.lock \
	   $([ -n "$FILTER" ] && echo "-f $FILTER") \
	   $([ -n "$SYSLOG_FACILITY" ] && echo "-S $SYSLOG_FACILITY") \
	   $([ -n "$SUBFILTER" ] && echo "-F $SUBFILTER") \

redhat/mimedefang-spec.in  view on Meta::CPAN


if test -d /var/spool/quarantine -a ! -d /var/spool/MD-Quarantine ; then
	mv /var/spool/quarantine /var/spool/MD-Quarantine || true
fi

# Add user
useradd -M -r -d %{dir_spool} -s /bin/false -c "MIMEDefang User" %{user} > /dev/null 2>&1 || true

%post
# Tighten permissions
chown %{user} %{dir_spool}
chgrp %{user} %{dir_spool}
chmod 750 %{dir_spool}
chown %{user} %{dir_quarantine}
chgrp %{user} %{dir_quarantine}
chmod 750 %{dir_quarantine}
chown %{user} %{dir_log}
chgrp %{user} %{dir_log}
chmod 755 %{dir_log}

cat << EOF

In order to complete the installation of mimedefang, you will need to add the 
following line to your sendmail mc file:

   INPUT_MAIL_FILTER(\`mimedefang', \`S=unix:/var/spool/MIMEDefang/mimedefang.sock, F=T, T=S:1m;R:1m;E:5m')

t/core.t  view on Meta::CPAN

  no warnings qw(redefine once);
  local *::md_syslog = sub { note $_[1] };
  use warnings qw(redefine once);
  my $conf_fname = "t/data/md.conf";
  SKIP: {
    skip "read_config test must be run as root", 1 unless ($< eq 0);
    my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
        $atime,$mtime,$ctime,$blksize,$blocks)
        = stat($conf_fname);
    # Set correct owner to config file
    chown(0, 0, $conf_fname);
    ::main::read_config($conf_fname);
    is($SALocalTestsOnly, 0);
    # Set back original owner
    chown($uid, $gid, $conf_fname);
  };
}

sub t_detect_and_load_perl_modules : Test(1)
{
  my $dnsver;
  detect_and_load_perl_modules();
  $dnsver = Net::DNS->version;
  like($dnsver, qr/([0-9]+)\.([0-9]+)/, "Net::DNS correctly loaded, version is $dnsver");
}

t/docker/dockerPostfix.sh  view on Meta::CPAN

echo ">>> dnf install..."
dnf -y install ~/rpmbuild/RPMS/x86_64/mimedefang-* || { echo "dnf install FAILED"; exit 1; }

cp t/data/mimedefang-test-filter /etc/mail/mimedefang-filter

# Ensure Postfix uses the inet milter socket (RPM %post may reset this)
postconf -e 'smtpd_milters = inet:127.0.0.1:10997'
postconf -e 'non_smtpd_milters = $smtpd_milters'
postconf -e 'milter_default_action = tempfail'

chown root t/data/md.conf
mkdir -p /root/.spamassassin
touch /root/.spamassassin/user_prefs
rm -f /var/spool/mail/defang*

# Ensure spool dir exists and is writable by defang
mkdir -p /var/spool/MIMEDefang
chown defang:defang /var/spool/MIMEDefang
chmod 750 /var/spool/MIMEDefang

# Enable Postfix file-based logging (no syslog daemon in Docker)
postconf -e 'maillog_file = /var/log/maillog'
touch /var/log/maillog

cat > /tmp/rsyslog-test.conf << 'EOF'
module(load="imuxsock" SysSock.Use="on")
*.* /var/log/messages
EOF

t/docker/dockerSendmail.sh  view on Meta::CPAN

cp "Mail-MIMEDefang-${VER}.tar.gz" ~/rpmbuild/SOURCES
make spec 1>/dev/null 2>&1 || { echo "make spec FAILED"; exit 1; }
rm -rf ~/rpmbuild/RPMS/x86_64/mimedefang-*
echo ">>> rpmbuild -bb..."
rpmbuild -bb redhat/mimedefang.spec 1>/dev/null 2>&1 || { echo "rpmbuild FAILED"; exit 1; }
echo ">>> dnf install..."
dnf -y install ~/rpmbuild/RPMS/x86_64/mimedefang-* || { echo "dnf install FAILED"; exit 1; }

cp t/data/mimedefang-test-filter /etc/mail/mimedefang-filter

chown root t/data/md.conf
mkdir -p /root/.spamassassin
touch /root/.spamassassin/user_prefs
rm -f /var/spool/mail/defang*

# Ensure spool dir exists and is writable by defang
mkdir -p /var/spool/MIMEDefang
chown defang:defang /var/spool/MIMEDefang
chmod 750 /var/spool/MIMEDefang

# Custom rsyslog config with SysSock.Use="on" (Fedora default disables /dev/log)
cat > /tmp/rsyslog-test.conf << 'EOF'
module(load="imuxsock" SysSock.Use="on")
*.* /var/log/messages
EOF
touch /var/log/messages
chmod 666 /var/log/messages



( run in 1.049 second using v1.01-cache-2.11-cpan-92ad3014f07 )