SCHAPPY — 3. Juli 2023, 12:17

Solved: Net::Domain hostname FQDN contains domain suffix twice

Issue: Perl’s Net::Domain functions report full-qualified hostname incorrectly, containing domain name twice. At the same time, the output of hostname -s (just <hosname>) and hostname -f (<hostname>.<domainname> without any duplication) are working correctly. Systems tested: Debian 11 and 12.

Observed behavior Expected behavior
Host FQDN: <hostname>.<domainname>.<domainname> <hostname>.<domainname>
Hostname: <hostname> <hostname>
Hostdomain: <domainname>.<domainname> <domainame>

Reason: The perl lib tries multiple alternatives to identify the local hostname based on detected system, for Debian it was using the following branch, which calls the system function gethostname. Thus, the reported hostname of this system function is the source of the devil.
eval {
package main;
require "sys/syscall.ph"; ## no critic (Modules::RequireBarewordIncludes)
defined(&main::SYS_gethostname);
}
and $host = (syscall(&main::SYS_gethostname, $tmp, 256) == 0) ? $tmp : undef;

Solution: Please check the content of /etc/hostname, which is typically set once during system setup. It is mandatory to contain just the hostname without the domain suffix (not the FQDN) to work correctly with perl’s Net::Domain implementation. The system’s hostname is typically automatically set during boot sequence, e.g. by /etc/init.d/hostname.sh, which reads contents from /etc/hostname. After changing the content of /etc/hostname you might either run /etc/init.d/hostname.sh or just sth. like sudo hostname $(cat /etc/hostname)  Alternatively, a quick workaround / fix for Net::Domain is the following: remove everything after the first dot from the hostname, see patch (minor disadvantage: hostnames just containing an IPv4 address will be truncated to the first tuple of the IPv4 address):


--- Net::Domain.pm 2023-07-03 12:12:03.457201483 +0200
+++ Net::Domain.pm.new 2023-07-03 12:12:53.331898622 +0200
@@ -106,6 +106,7 @@
$host =~ s/[\0\r\n]+//go;
$host =~ s/(\A\.+|\.+\Z)//go;
$host =~ s/\.\.+/\./go;
+ $host =~ s/([^\.]+)\..+/\1/go;

$host;
}

SCHAPPY — 3. September 2021, 12:07

Solved: opendmarc-import stops working after Debian buster upgrade

Issue: After upgrade to Debian buster opendmarc-import reports errors during import of the history file. Even a re-creation of the database schema did not solve the issue, requests table remains empty.

Reason: Debian buster bundles a beta version, which is using uninitialized variables, e.g. $request_id.

Solution: Please apply the attached patch file, which was derived from the latest git repository code of openmarc-import to solve the issue. Please also check that you use the lastest database schema. After patching, your imports should work like charm again.

cp /usr/sbin/opendmarc-import /tmp/opendmarc-import.sav
sudo patch /usr/bin/opendmarc-import 210820_opendmarc-debian-buster.patch

210820_opendmarc-debian-buster.patch

SCHAPPY — 22. Januar 2020, 9:43

Solved: /etc/cron.daily/spamassassin: Wide character in print at /usr/bin/sa-compile line 433

Issue: When using spamassassin 3.4.2 in combination with Heinlein filter rules, you might encounter once a day  messages from running the spamassassin cronjob as follows.
Wide character in print at /usr/bin/sa-compile line 433, <$fh> line 2757.
Wide character in print at /usr/bin/sa-compile line 433, <$fh> line 3260.

Reason: Some of the Heinlein rules in 70_HS_body.cf contain UTF-8 character, which are currently not handled /usr/bin/sa-compile command. You can find the rules at /var/lib/spamassassin/3.004002/spamassassin_heinlein-support_de/ for investigation. The warning is triggered by the fixup_re function in package Mail::SpamAssassin::Plugin::BodyRuleBaseExtractor, which replaces encoded and escaped utf-8 characters by their original character if the output stream is not utf-8 compatible.

Solution: Changing the output stream encoding to UTF-8 in sa-compile will prevent the warning, because UTF-8 characters outside of ASCII range can be be sent to the stream correctly. For your convenience,  I attached the patch file sa-compile.patch.

cp /usr/bin/sa-compile /tmp/sa-compile.org
sudo patch /usr/bin/sa-compile sa-compile.patch

You can verify the successful patch, by running sa-compile as spamassassin user, e.g. debian-spamd. It should no longer output the warning.

SCHAPPY — 8. Juli 2019, 12:49

Solved: Debian 10 (buster): Upgrade MariaDB from version 10.1 to version 10.3

Issue: After upgrading Debian, you will have to remove the old version of MariaDB and install the new one (semi-manual). After installation of MariaDB 10.3 it fails to start and mysql.error log does not contain helpful hints.

/etc/init.d/mysql start
[....] Starting mysql (via systemctl): mysql.serviceJob for mariadb.service failed because the control process exited with error code.
See "systemctl status mariadb.service" and "journalctl -xe" for details.
failed!

Solution: The installation script of MariaDB assumes the systemd service to be disabled, but it might be active from older installation.

Try /etc/init.d/mysql status and investigate output. If it is similar to mine (as printed below), go on…

mariadb.service - MariaDB 10.3.15 database server
Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Mon 2019-07-08 14:37:46 CEST; 1min 25s ago
Docs: man:mysqld(8)
https://mariadb.com/kb/en/library/systemd/
Process: 5002 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=127)
Main PID: 22611 (code=exited, status=0/SUCCESS)

Let us try to disable the old systemd service as follows:

sudo systemctl disable mysql
Synchronizing state of mysql.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install disable mysql
insserv: warning: current start runlevel(s) (empty) of script `mysql' overrides LSB defaults (2 3 4 5).
insserv: warning: current stop runlevel(s) (0 1 2 3 4 5 6) of script `mysql' overrides LSB defaults (0 1 6).
Removed /etc/systemd/system/multi-user.target.wants/mariadb.service.
Removed /etc/systemd/system/mysqld.service.
Removed /etc/systemd/system/mysql.service.

Now try to start the service:
/etc/init.d/mysql start
[ ok ] Starting mysql (via systemctl): mysql.service.

SCHAPPY — 22. Mai 2019, 11:29

How to recruit good experts?

While investigating some HTTP header fields, I stumbled across the „X-hacker“ containing a job posting. Inspiring idea.

SCHAPPY — 18. Juni 2018, 20:00

Generic alternative for WMF2EPS in Windows 10

With Windows 10 WMF2EPS was no longer working for me due to some strange errors installing the printer driver. Therefore, I came up with the following alternative using more or less native Windows essentials.

  1. Install any PS printer, e.g. Universal HP PS Driver, and name it „EPS printer“.
  2. Configure printer to print to file (menu port) and to use encapsulated PS (menu advanced)
  3. Print any file to your „EPS printer“ and a save as box should occur to store your output, e.g. output.eps
  4. Use ps2eps with your output.eps to fix bounding box issues and have a optimized output.
SCHAPPY — 30. Januar 2018, 18:21

[SOLVED] Samsung TV channel list cannot be imported due to invalid country code (UExxD6xxx) 6 Series

Issue

Trying to import a channel list to a Samsung TV (re-imported) from other country. In my case, I tried to import the German channel list to a UE46D6540 non-German version. Copying the SCM file to an USB stick and trying to import it to the TV results in error message indicating that the corresponding country is invalid. However, in the country settings menu of Samsung TV I can only select some East European counties as well as OTHERS, but not Germany at all. Depending on the country version of your TV it might show up other countries, however not your preferred one in the channel settings.

Solution

Please find here a current German channel list (Berlin region) new_channel_list_UE46D6500_1101.scm for a D series TV last updates Jan 2018 for download. After downloading change the suffix to .scm, copy it to an USB stick and import it to your Samsung TV.

If you want to create your own, please follow the following steps.

    • Select OTHERS (OTH) as country in channel settings prior to continue as the remaining instructions build on this.
    • Download your current channel list for country OTHERS (A), e.g. channel_list_UE46D6500_1101.scm, from the TV to an USB stick.
    • Download your preferred channel list (B), e.g. samsung_1101.scm, either from another Samsung TV or from an online service, e.g. from https://sender-liste.de/
    • Copy both files to your Desktop and handle them as zipped archive files, e.g. rename either of the files from .scm to .scm.zip and unzip them
  • You should see a file directory as follows

  • The country information is stored in the CloneInfo file. Therefore, you have to copy your original CloneInfo from A to the directory of your desired channel list B.
  • Alternatively, you can also edit the existing CloneInfo using vim, you will find something like this: UED^@UE40D6200^@^@^@^...; the first three letters indicate the country code in inverse order, here it is UED -> DEU for Germany. You want to change it to HTO indicating OTHERS as we selected this as country at the beginning.
  • Now zip the content of the directory of B to new_samsung_1101.scm and copy the file to your USB stick and proceed to import it to your TV.

Finally, the TV will indicate a success notice and after rebooting the TV you should have your desired channel list in action. Hope this helps, have fun!

SCHAPPY — 30. November 2016, 17:24

RAM Disk for Mac OS X Sierra (10.12.) and High Sierra (10.13.)

As Apple announced that StartupItems are not longer supported, please find attached an updated version of the RamDisk script of Philipp Klaus making use of the launchctl.

Install

  • Download the code and store it in a file, e.g. ~/MoveTempFoldersToRamDisk.sh
  • Make the file executable, e.g. chmod +x ~/MoveTempFoldersToRamDisk.sh
  • Execute the file to install the launch daemon (/Library/LaunchDaemons/de.schappy.ramdisk.plist) and the RamFS script (/usr/local/bin/RamFS.sh)

Unintall

  • sudo launchctl unload -w /Library/LaunchDaemons/de.schappy.ramdisk.plist
  • Optional remove launch daemon and script (paths see above)

Code of MoveTempFoldersToRamDisk.sh


#!/bin/bash

# +----------------------------------------------------------------------+
# | |
# | Set up Mac OS X >10.12 to store temp folders on RAM disk. |
# | |
# | By Matthieu Schapranow Nov 11, 2017 |
# | |
# | Originally by Ricardo Gameiro
|
# | Changes by Daniel Jenkins |
# |
|
# | and Philipp Klaus
|
# | |
# +----------------------------------------------------------------------+

cat < < "EOF" | sudo tee /usr/local/bin/RamFS.sh > /dev/null
#!/bin/sh
# Create a RAM disk with same perms as mountpoint

RAMDisk() {
mntpt=$1
rdsize=$(($2*1024*1024/512))
echo "Creating RamFS for $mntpt"
# Create the RAM disk.
dev=`hdik -drivekey system-image=yes -nomount ram://$rdsize`
# Successfull creation...
if [ $? -eq 0 ] ; then
# Create HFS on the RAM volume.
newfs_hfs $dev
# Store permissions from old mount point.
eval `/usr/bin/stat -s $mntpt`
# Mount the RAM disk to the target mount point.
mount -t hfs -o union -o nobrowse $dev $mntpt
# Restore permissions like they were on old volume.
chown $st_uid:$st_gid $mntpt
chmod $st_mode $mntpt
fi
}

# Test for arguments.
if [ -z $1 ]; then
echo "Usage: $0 [start|stop|restart] "
exit 1
fi

# Source the common setup functions for startup scripts
test -r /etc/rc.common || exit 1
. /etc/rc.common

StartService () {
ConsoleMessage "Starting RamFS disks..."
RAMDisk /private/tmp 512
RAMDisk /var/run 128
#RAMDisk /var/db 1024
#mkdir -m 1777 /var/db/mds
}
StopService () {
ConsoleMessage "Stopping RamFS disks, nothing will be done here..."
diskutil unmount /private/tmp /private/var/run
diskutil unmount /private/var/run
}

RestartService () {
ConsoleMessage "Restarting RamFS disks, nothing will be done here..."
}

RunService "$1"
EOF
sudo chown root:wheel /usr/local/bin/RamFS.sh
sudo chmod u+x,g+x,o+x /usr/local/bin/RamFS.sh

sudo launchctl unload -w /Library/LaunchDaemons/de.schappy.ramdisk.plist
cat < < EOF | sudo tee /Library/LaunchDaemons/de.schappy.ramdisk.plist > /dev/null
< ?xml version="1.0" encoding="UTF-8"?>
< !DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
Label
de.schappy.ramdisk
ProgramArguments

/usr/local/bin/RamFS.sh
start

RunAtLoad
EOF

sudo chown root:wheel /Library/LaunchDaemons/de.schappy.ramdisk.plist
sudo chmod 644 /Library/LaunchDaemons/de.schappy.ramdisk.plist
sudo launchctl load -w /Library/LaunchDaemons/de.schappy.ramdisk.plist

SCHAPPY — 13. Juli 2015, 12:15

[Fixed] Photos from Photos.app are not synced through iTunes

Issue: After migration from iPhoto.app to Photos.app in Mac OS X Yosemite 10.10.4, photos are no longer synced to mobile Apple devices, e.g. iPod, iPad, iPhone, through iTunes 12.2.0.

Solution:

  1. Quit any running iTunes instances
  2. Open iPhoto.app (look into /Applications/iPhoto.app)
  3. Quit iPhoto, which results in updating the photo library
  4. Open Photos.app
  5. Preferences -> General: Click on the button „Use as System Photo Library“ if highlighted
  6. Close Photos.app
  7. Open iTunes and navigate to Sync Photos: the options to sync from Photos.app and iPhoto.app now appears in the drop-down menu as usual
     

itunes-iphoto-photos-sync

SCHAPPY — 21. Mai 2015, 11:14

[FIXED] After dist-upgrade from wheezy to jessie php scripts are not executed anymore

Situation: I upgraded a debian distribution wheezy to jessie with no significant issues. After upgrading I experienced that some of the already installed and formerly working php scripts stopped working. Content of some included php scripts, e.g. wordpress configuration, were printed as HTML content instead of being evaluated.

Reason: The updated php.ini disables short open tags by default. Check your affected php files whether they use the long php open tags [code]<?php[/code] instead of (my preferred) short open tags [code]<?[/code].

Solution: Either you replace all short php open tags by long php open tags or you can enable the use of short php open tags system-wide. The latter was more comfortable in my case, as I do not know how many files would be affected. To do so, check the installed php.ini used by your apache installation (typically located at /etc/apache2/php.ini) for [code]short_open_tag = On[/code] and restart your apache server [code]apache2ctrl restart[/code].