AntiSpam with spamtrainer on Mac OS Server – El Capitan

So I am still running Mac OS El Capitan Server Edition on my Mac Mini. Recently, the Spam that comes through, has increased again and I wondered if there is any mechanism to implement AntiSpam in Mac OS X.

The Apple Knowledge Base only gives this article:
https://support.apple.com/kb/PH22351?locale=en_US
which is not exactly what I wanted.

Looking further, I came across these links, which proved helpful at the end:

spamtrainer

According to that site the software will do this:

  • spamtrainer assists Mac OS X Server mail services administrators in updating and maintaining their SpamAssassin bayes database.
  • spamtrainer will read the designated HAM and SPAM mailboxes, update the SpamAssassin databases and delete mail that has been learned from.

After downloading the spamtrainer installation script and installing it I did the following:

Check the proper setup of junkmail / nojunkmail

sudo serveradmin settings mail:imap | grep junk

Result:

 mail:imap:junk_mail_userid = "junkmail"
 mail:imap:not_junk_mail_userid = "notjunkmail"

When running spamtrainer now right away, it complains:

Either there is no mailbox called No GUID found for user: junkmail in the mailpartition or it has never been fed with mail.

Either there is no mailbox called No GUID found for user: notjunkmail in the mailpartition or it has never been fed with mail.

So I go an create those users. Starting the Server.app plus adding the needed network accounts „junkmail“ and „notjunkmail“. Further I edit access so that these accounts only have access to the Mail service. Now I add these accounts to Mail so that I have access to them.

Now, finally, when I run

/usr/local/sbin/spamtrainer

it does what it should.

Using the install option I can also have it run as plist item.

>> /usr/local/sbin/spamtrainer -i

Checking if there is a startup item for 'learn_junk_mail' or 'spamtrainer'

There IS a plist for sa_learn.pl

... and it is ENABLED

If you want to use 'spamtrainer' it is RECOMMENDED that this be disabled

Would you like me to disable it for you (yes/no)

yes

'learn_junk_mail and/or sa_learn.pl' item has been disabled'

You can ignore 'No such process' error messages

There IS NO plist for spamtrainer

if you want to use 'spamtrainer' it is recommended that this be added

Would you like me to enable it for you (yes/no)

yes

What time would you like spamtrainer to run (24-hour format)?

Please enter the hour (1)

05

Please enter the minutes (0)

00

Would you like SPAM/HAM messages to be deleted after the learn process? (n)

y 

Would you like to log bayes stats into /var/log/spamtrainer.log? (n)

y

If you would you like to have spamtrainer mail you a report after it runs, then please enter an e-mail address. Enter for no (n)

myemail@myemaildomain.domain

Enter name of mail store with SPAM/HAM mailboxes? Enter for default (default)

Enter name of mailbox with SPAM? Enter for default (junkmail)

Enter name of mailbox with HAM? Enter for default (notjunkmail)

A plist with the following parameters for 'spamtrainer' has been prepared

/usr/local/sbin/spamtrainer -m myemail@myemaildomain.domain -d -l

It will run each day at 05:00:00

Would you like to add and enable it? (yes/no)

yes

The following launchd plist item for 'spamtrainer' has been enabled'

/usr/local/sbin/spamtrainer -m myemail@myemaildomain.domain -d -l

It will run each day at 05:00:00

That is all for installation, now let me see if it does what it should!

Sent Messages or Sent – Getting Apple Mail and Spark to work together

For my iPhone I just love Readdle’s App called Spark. On MacOS I am still clinging to Apple Mail. Since all my Mail is stored on my Mac Mini MacOS server, I also work with server based folders. Here I noted a discrepancy between Apple Mail and Spark, because both programs use different presets for saving mail on the server. Fortunately I came across this websavers article, how to get both to work together smoothly.

Apple Mail Preferences

Apple Mail defaults to a sent mailbox/folder named „Sent Messages“. If the option to „Store sent messages on the server“ is active it will create a folder called „Sent Messages“ on the server and use that folder to save copies of sent messages. This conflicts with many other applications with use the folder „Sent“ instead.

Spark Default Preferences

As I am not yet on Sierra, the second part of the article did it for me:

  1. Select the „Sent“ folder on the server (in the folders pane on the left) by clicking on it once. It should *not* be at the top of the page next to Inbox/Drafts/Junk/etc, nor should it be under „Local Folders“ or „On My Mac“. It will be found under a heading indicating that it’s a server-side folder. For example, my heading says „Websavers“ as it’s my Websavers email account.
    If you do not see a server-side heading in the folder list or if you do and there is no Sent folder there then you must create a new folder by choosing the Mailbox menu, then „New Mailbox“. For the Location field, you must select the correct account to create it under, then set the name to „Sent“.
  2. Chose Mailbox from the system menu at the top of the screen
  3. Choose „Use this Mailbox as“ > and then choose „Sent Mailbox“.

 

Downloading Kaspersky Internet Security for Parallels 12

Parallels comes with this awful menu entry:

Kaspersky Internet Security Install Option from Parallels Menu

„Install Antivirus for Mac“.

KIS Install DMG

Ok, if you would like to go from there – no problem. But if you would like to install this license on another Mac it gets a bit difficult to acquire the installation kit.

 

I thought I would download it from the regular Kaspersky website, but unfortunately – the Parallels license key doesn’t work with the regular download package.

I contacted Parallels about it and got a confirmation for this behaviour:

The parallels code can only be used with a Parallels versions of Kaspersky, it cannot be registered with a trial version. The Parallels version of Kaspersky can only be downloaded from Parallels‘ servers. There is no external download source.

This is also reflected in the Parallels KB article (123871).

Of course, there must be a way. So I fired up Wireshark to see, where the installation kit gets downloaded from! And voilá – here we go with the direct download link:

http://download.parallels.com//desktop/v11/is/binaries/kismac16_0_0_245mlg_de_en_es_fr_it_ja_pl_ru_zh-Hans_zh-Hant.dmg

Revealing the Download URL for Parallels KIS
Direct Download Link for Parallels Version of Kaspersky Internet Security

Apple MacOS Server and iOS don’t like StartCom Certificates

An error reading „Cannot Connect Using SSL“ on my iPhone caused me some extra grey hair: The symptoms I observed since mid of December were:

  • iOS Mail came up with a SSL error when trying to negotiate SSL/TLS through the IMAP service on my MacOS server. Adding a new mailbox was not possible, Apple Mail always suggested to turn of SSL (which I didn’t want to do for good reason).
  • My Squirrelmail webbased email reader suddenly couldn’t connect to the IMAP mailbox anymore. The error observed was: „Error connecting to IMAP server: <server_name>. 0

First I thought that there was a problem with the MacOS Server, but when I switched to a self signed certificate – things worked OK again (only with the hint that I use an untrusted cert of course).

After some more googling around for the symptoms I observed, I came across this article Lists of available trusted root certificates in iOS (in German). It clearly mentions, that from December 2016 onward, the certificates of StartCom (which were available also cost free) are not recognized anymore. Now, my MacOS Server did not throw any error in the Server Manager, but the services didn’t work as expected anymore.

And for testing Squirrelmail, I found this very nice information at James Bottomley’s random Pages:

echo 'fsockopen("tls://yourmailserver.domain",993,$errno,$errmsg,15);'|php -a

I used it to check the connection to my mailserver, and look and behold, I got to see the PHP error that I had a certificate issue!

So I decided to order a RapidSSL certificate to replace the StartCom certificate. Said and done, set it all up, and voilá – all services are running smoothly again.

While the Server App correctly changes certs for all services including the postfix Mail service, I have configured TLS manually in the postfix main.cf as this was a requirement for my outbound mail forwarder. These configuration statements I always have to change manually when updating the certificate. Now there is at the end of the file:

smtp_tls_cert_file = /etc/certificates/<hostname>.ID.cert.pem
smtp_tls_CAfile = /etc/certificates/<hostname>.ID.chain.pem
smtp_tls_key_file = /etc/certificates/<hostname>.ID.key.pem

For the correct keys just compare to the statements before, like:

smtpd_tls_key_file = /etc/certificates/<hostname>.ID.key.pem
smtpd_tls_cert_file = /etc/certificates/<hostname>.ID.cert.pem

If you run into similar troubles as described above, I suggest to get a „real“ SSL certificate which is trusted by the Apple OS. I got mine from the folks at CheapSSL.com.

Dual Monitor Setup with Two Different Backgrounds in Windows 10

Ok, this is rather a gimmick, but this was the wish behind: I have a dual screen setup in my office. Normally, the same desktop wallpaper would be shown on both displays. Now I have a list of internal telephone numbers and wanted to display those only on one of the desktops. I created two different wallpaper images, one with the phone number list, the other without. This is the way how you can display two different images without any additional software:

  1. Copy the background images into the path: C:\Windows\Web\Wallpaper\Windows.
  2. Now use the CTRL key for multiple selection to select both backgrounds.
  3. Right click on one wallpaper image -> Choose „Set as desktop background“.

The selected wallpaper images will be stored under:
%USERPROFILE%\AppData\Roaming\Microsoft\Windows\Themes
as:
Transcoded_000 and Transcoded_001 without extension

If you want to swap the images, just rename 0 to 1, 1 to 0. Sign out and sign back in or right click on desktop and select: Next desktop background.

(This solution was originally published here.)

Substitute the failing Seagate Series ST3000DM001

I love my two Promise Pegasus R4 Thunderbolt Storage Shelters. Some months ago I upgraded the Backup Storage to 3TB drives, Seagate’s ST3000DM001. Unfortunately, as Backblaze reveals, this series is very buggy and not at all recommendable. So, whenever one of the drives had failed, I would substitute it with a Seagate ST4000DM000 drive, which is a 4TB model. Backblaze shows, that this model is quite ok when it comes to error statistics. What I always thought was, that Promise Pegasus R series would only support the drive models which can be found in the Pegasus Promise compatibility listing. But No! What drives can be used with Promise Pegasus R4, R6 or R8?

Then today, when another of Seagate’s 3TB drives failed, I looked for a substitute and came across the Seagate ST4000VN000 – which is listed as proper NAS drive. I was courageous and bought one from Cyberport and hoped it would fit and work in my Pegasus Promise R4. As you can see here:

Screen Shot 2016-08-06 at 21.52.55

The RAID is being rebuilt ...
The RAID is being rebuilt …

Thus I can say with confidence:

The Seagate NAS drive ST4000VN000-1H41, which is a typical SATA drive with 4TB capacity, runs well in the Promise Pegasus R series, even though it is not listed in the compatibility list. And I am still running on firmware release 5.04.0000.36. The benefit of this slightly more expensive hard disk is a 3 year warranty (within Germany) and – as Seagate claims – some extra routines to make it work 7×24.

Kyocera M6526cidn & Scan to Folder & SMB Shares on MacOS El Capitan Server

After Upgrading to El Capitan, my Kyocera MFC didn’t want to save scans via SMB connection anymore. This brought me to google wildly after any solution, and I came across these documents, which kept enlightening me:

As I had set up a user named „scanuser“ in the Mac OS Server App, I kept looking there, why it wouldn’t work. I changed permission rights and even switched the system back to SMB v1, by entering the following in a console window:

echo "[default]" >> ~/Library/Preferences/nsmb.conf; echo "smb_neg=smb1_only" >> ~/Library/Preferences/nsmb.conf

If you need to change it back, you just enter:

rm ~/Library/Preferences/nsmb.conf

But, to no avail!

So I looked into System Preferences and Users again and thought, I might create a local user called „scanuser“. This I did, and suddenly my Kyocera printer & scanner was willing to talk to the SMB share on my Mac OS Server again.

Traffic Attack from Baidu Address Space

Yesterday I noticed that one of my servers was seeing more traffic than usual. The hourly traffic limit I had set was reached and my mailbox filled with traffic warning messages. I wanted to look into the matter but wondered: how can I quickly see which IP connections exist? Fortunate to be on a Debian Linux, I decided to install the package iptraf. This IP LAN monitor generates various network statistics and showed me that most of the new connections came from one particular IP range: 180.76.0.0/16. WHOIS DB shows, that this range belongs to BAIDU, the famous search enterprise in China. Generating several hundred Megabytes of traffic per hour was too much for me. You can see the traffic line here:

Graph showing the Baidu Traffic Attack
Start of the Baidu traffic phenomenon
Graph showing the Baidu Traffic Attack
Trying to counter the Baidu traffic phenomenon.

First of all I thought it might be the indexing work of many Baidu spiders, or of spiders claiming to be Baidu. In this regard, I found a very helpful post by the folks at Perishablepress, which explains how to block the Baidu spidering process through the .htaccess file.

This did not really solve the problem, so I took more serious measures and blocked the whole address space of Baidu via iptables Firewall. This is the command you need (please be root before using it):

iptables -A INPUT -s 180.76.0.0/16 -j DROP

Just remember, that this statement really blocks all the traffic from the Baidu network. So if your servers are meant to reach Chinese visitors, you might want to think twice before you block it all!

Movable Type goes WordPress

Finally: Jahrelang lief auf meinem Root-Server bei IBH halb versteckt der Blog Äppeltexte auf einer Installation von Movable Type. Da es MT ja nicht mehr als OpenSource gibt, ist eine WordPress-Installation das naheliegendste. Daher heute Abend mal fix die Installation angeworfen, die wirklich supereinfach auf einem Debian GNU/Jessie durchzuführen ist. Dann half Google weiter, um etwas über die Migration von Movable Type zu WordPress nachzulesen. Ich empfehle den Beitrag Importing from Movable Type to WordPress. Jetzt freue ich mich, hier auf WordPress-Basis weiterbloggen zu können!

Diese Datei ist durch einen anderen Benutzer geöffnet …

In meiner gemischten Umgebung von Mac OS Systemen und ein oder zwei Windows Rechnern arbeiten wir u.a. mit einem Excel-Dokument, welches es immer wieder zu aktualisieren gilt. Das mache ich manchmal mit Excel auf einem Windows-System und manchmal mit dem Office auf meinem Mac. Zuletzt kam allerdings auf dem Mac immer die Fehlermeldung, dass diese XLSX-Datei von einem anderen Benutzer zur Bearbeitung gesperrt ist. Nach 3 Sekunden da man das Dokument offen hatte kam dann die Meldung, dass es jetzt frei geworden sei, und sobald man auswählte, dass man es nun zur Bearbeitung erneut öffnen möchte, kam wieder derselbe Fehler: Die XLS-Datei ist von einem anderen Benutzer geöffnet und gesperrt.

Hier die Lösung des Problems: Sehr wahrscheinlich gibt es in dem Verzeichnis, wo die Datei gespeichert ist, eine temporäre Datei die eigentlich automatisch hätte gelöscht werden müssen, was aber nicht passiert ist. Man kann sich wie folgt behelfen:
– Mac Terminal öffnen
– In das Verzeichnis wechseln, wo die Datei liegt (wenn es ein Netzlaufwerk ist findet man es, in dem man auf dem Mac zunächst cd /Volumes eingibt und dann z.B. auf das angeschlossene Promise Pegasus Laufwerk wechselt)
– Im Verzeichnis lässt man sich mit „ls -rtl“ alle Dateien anzeigen, einschliesslich der versteckten Dateien
– man wird fündig, denn es gibt Dateien die heißen z.B. „~$account-overview.xlsx“, beginnen also mit „~$“ und werden im Standard im Finder nicht angezeigt.
– mit „rm ~$*“ lassen sich sofort alle temporären Dateien löschen, oder löscht nur die eine, die gerade gestört war.
Soeben probiert: Danach lässt sich die Datei wieder problemlos im Mac Office / Excel öffnen und bearbeiten.