2020-04-11 12:24:31 +02:00
OT_VER ?= 0.55
OT_SUBVER ?=
2019-07-07 14:03:26 +02:00
OT_TARBALL = oletools-$( OT_VER) .tar.gz
OT_URL = https://github.com/decalage2/oletools/releases/download/v$( OT_VER) $( OT_SUBVER) /$( OT_TARBALL)
2020-06-28 10:47:29 +02:00
OF_COMMIT ?= 738079cbc1fda7db85917ee3764222d55f5b1b3c
2019-07-07 14:03:26 +02:00
OF_TARBALL = $( OF_COMMIT) .tar.gz
OF_URL = https://github.com/HeinleinSupport/olefy/archive/$( OF_TARBALL)
2020-06-28 10:47:29 +02:00
RF_COMMIT ?= 93f31400f1a6a02d69d9ddcf16a589ac54cad58e
RF_TARBALL = $( RF_COMMIT) .tar.gz
RF_URL = https://github.com/HeinleinSupport/razorfy/archive/$( RF_TARBALL)
2018-02-23 10:50:08 +01:00
preinstall :
2019-07-07 14:03:26 +02:00
# hardcoded users and groups
$( inroot) useradd --system --comment= "created from appliance building - zabbix user" --home-dir= "/var/lib/zabbix/home" --shell= "/sbin/nologin" --no-create-home --uid 600 --user-group zabbix
$( inroot) useradd --system --comment= "created from appliance building - clamav user" --home-dir= "/dev/null" --shell= "/sbin/nologin" --no-create-home --uid 601 --user-group clamav
$( inroot) useradd --system --comment= "created from appliance building - rspamd user" --home-dir= "/var/lib/rspamd" --shell= "/sbin/nologin" --no-create-home --uid 602 --user-group rspamd
$( inroot) useradd --system --comment= "created from appliance building - olefy user" --home-dir= "/dev/null" --shell= "/sbin/nologin" --no-create-home --uid 603 --user-group olefy
2020-06-28 10:47:29 +02:00
$( inroot) useradd --system --comment= "created from appliance building - razorfy user" --home-dir= "/dev/null" --shell= "/sbin/nologin" --no-create-home --uid 608 --user-group razorfy
2018-02-23 10:50:08 +01:00
# switch to hardened, build hardened toolchain, rebuild everything
mkdir -p $( CHROOT) /etc/portage/profile
echo "-hardened" >> $( CHROOT) /etc/portage/profile/use.mask
$( inroot) $( EMERGE) $( USEPKG) --oneshot gcc
$( inroot) $( EMERGE) $( USEPKG) --oneshot binutils virtual/libc
-$( gcc_config)
$( inroot) $( EMERGE) $( USEPKG) --emptytree @world
$( inroot) bash -c 'yes YES | etc-update --automode -9'
2019-07-07 14:03:26 +02:00
install_oletools :
$( inroot) test -f /usr/portage/distfiles/$( OT_TARBALL) || \
$( inroot) wget -P /usr/portage/distfiles $( OT_URL)
$( inroot) sh -c 'tar xf /usr/portage/distfiles/$(OT_TARBALL) -C /tmp && cd /tmp/oletools-$(OT_VER) && python setup.py install'
install_olefy :
$( inroot) test -f /usr/portage/distfiles/$( OF_TARBALL) || \
$( inroot) wget -P /usr/portage/distfiles $( OF_URL)
$( inroot) sh -c 'tar xf /usr/portage/distfiles/$(OF_TARBALL) -C /tmp && cd /tmp/olefy-$(OF_COMMIT) && cp olefy.py /usr/bin && cp olefy.conf /etc && cp olefy.service /etc/systemd/system'
2020-04-11 12:24:31 +02:00
sed -i 's#/usr/local/bin/#/usr/bin/#' $( CHROOT) /usr/bin/olefy.py
sed -i 's#/usr/local/bin/#/usr/bin/#' $( CHROOT) /etc/olefy.conf
sed -i 's#/usr/local/bin/#/usr/bin/#' $( CHROOT) /etc/systemd/system/olefy.service
2019-07-07 14:03:26 +02:00
2020-06-28 10:47:29 +02:00
install_razorfy :
$( inroot) test -f /usr/portage/distfiles/$( RF_TARBALL) || \
$( inroot) wget -P /usr/portage/distfiles $( RF_URL)
$( inroot) sh -c 'tar xf /usr/portage/distfiles/$(RF_TARBALL) -C /tmp && cd /tmp/razorfy-$(RF_COMMIT) && cp razorfy.pl /usr/bin && cp razorfy.conf /etc && cp razorfy.service /etc/systemd/system'
sed -i 's#/usr/local/bin/#/usr/bin/#' $( CHROOT) /etc/systemd/system/razorfy.service
2020-04-11 12:24:31 +02:00
postinstall : base /timesyncd .conf base /firstboot .start
2018-02-23 10:50:08 +01:00
# Konfigurationen anpassen
2020-04-11 12:24:31 +02:00
cp base/timesyncd.conf $( CHROOT) /etc/systemd/timesyncd.conf
2019-01-27 09:43:27 +01:00
mkdir -p $( CHROOT) /etc/local.d
2020-04-11 12:24:31 +02:00
cp base/firstboot.start $( CHROOT) /etc/local.d/firstboot.start
2018-02-23 10:50:08 +01:00
touch $( CHROOT) /firstboot
sed -i 's/# %wheel ALL=(ALL) ALL/%wheel ALL=(ALL) ALL/' $( CHROOT) /etc/sudoers
2020-04-11 12:24:31 +02:00
sed -i 's#^auth.*$$#auth [success=2 default=ignore] pam_ssh_agent_auth.so file=~/.ssh/authorized_keys\nauth include system-auth#' $( CHROOT) /etc/pam.d/sudo
echo "Defaults env_keep += SSH_AUTH_SOCK" > $( CHROOT) /etc/sudoers.d/ssh_auth_sock
$( inroot) useradd -m -G users,wheel -s /bin/bash --comment= "virtual appliance admin" --uid 2000 admin
2018-02-23 10:50:08 +01:00
$( inroot) passwd -d admin; $( inroot) passwd -e admin
2019-07-07 14:03:26 +02:00
$( inroot) systemctl enable tmux@root.service
2020-04-11 12:24:31 +02:00
cp base/tmux.conf $( CHROOT) /root/.tmux.conf
2018-02-23 10:50:08 +01:00
# Beispiel feste IP-Adresse
2020-04-11 12:24:31 +02:00
cp base/00-eth0.network $( CHROOT) /00-eth0.network.example
2018-02-23 10:50:08 +01:00
# MariaDB-Konfiguration
2020-04-11 12:24:31 +02:00
# MariaDB-Konfiguration ($$, weil make ein $ entfernt)
sed -i " s/^character-set-server.* $$ /character-set-server = utf8mb4/ " $( CHROOT) /etc/mysql/mariadb.d/50-distro-server.cnf
echo >> $( CHROOT) /etc/mysql/mariadb.d/50-distro-server.cnf
echo "collation-server = utf8mb4_general_ci" >> $( CHROOT) /etc/mysql/mariadb.d/50-distro-server.cnf
echo "transaction_isolation = READ-COMMITTED" >> $( CHROOT) /etc/mysql/mariadb.d/50-distro-server.cnf
echo "binlog_format = ROW" >> $( CHROOT) /etc/mysql/mariadb.d/50-distro-server.cnf
echo "expire_logs_days = 3" >> $( CHROOT) /etc/mysql/mariadb.d/50-distro-server.cnf
echo "innodb_buffer_pool_size = 256M" >> $( CHROOT) /etc/mysql/mariadb.d/50-distro-server.cnf
echo "innodb_file_per_table = 1" >> $( CHROOT) /etc/mysql/mariadb.d/50-distro-server.cnf
echo "innodb_large_prefix = on" >> $( CHROOT) /etc/mysql/mariadb.d/50-distro-server.cnf
2018-02-23 10:50:08 +01:00
cp mariadb/my.cnf.root $( CHROOT) /root/.my.cnf
chmod 0600 $( CHROOT) /root/.my.cnf
rm -rf $( CHROOT) /var/lib/mysql/*
$( inroot) bash -c 'yes gentoo | emerge --config dev-db/mariadb'
2020-06-28 10:47:29 +02:00
# Wegen razorfy muß Perl mit USE=ithreads gebaut werden.
# Deswegen müssen auch alle Module neu erstellt werden.
$( inroot) perl-cleaner --reallyall
2019-07-07 14:03:26 +02:00
# oletools zur Office-Macro-Erkennung in rspamd
$( MAKE) install_oletools
$( MAKE) install_olefy
2018-02-23 10:50:08 +01:00
2020-06-28 10:47:29 +02:00
# razorfy zur Razor-Einbindung in rspamd
$( MAKE) install_razorfy
2019-07-07 14:03:26 +02:00
# Anpassungen
$( inroot) usermod -a -G clamav rspamd
2018-02-23 10:50:08 +01:00
clean :