Blog

// Replacement ear-pads for Bluetooth Creative Sound Blaster JAM headset

Creative Sound Blaster JAM is a very price-friendly Bluetooth headset for home use. I use it for occasional TV watching on PC without interfering the others, and sometimes with my cellphone (the headset has a NFC tag for quick pairing) for music listening e.g. during cooking.

Most of the time it hangs on the back of the display pivot. I turn the display around a lot so it eventually damaged the ear-pads pretty fast which literally teared apart.

The manufacturer says there are no spare parts, but provides very detailed information about headset speaker dimensions. So the most difficult part is to list the offers at AliExpress, filter out bad product descriptions, and wait a month for the result. If you want to skip the search part, I can recommend this item. Ear-pads are bit loose than the original but still hold tight enough. The material is quite thinner and there is a “seam” present, but 5 pairs for less than USD is a good price.

// Sending daily digest emails from Wunderlist

For some time, I am using Wunderlist as my to-do task manager (yup, I am surfing on GTD wave now). In some aspects, it is superior to its biggest competitor, Todoist (at least it has notifications for free and cleaner design). One feature I am missing the most is some kind of automatic daily digest sent to my email address every morning (and evening).

Fortunately, they have published their API some time ago. This allows 3rd party application to access and manage the whole content of user's profile.

I wrote simple script which grabs all unfinished tasks via API and sends an email with daily overview. I call it Wudd. I do not offer it as a service (yet?) so everyone has to deploy it on their own machine (See README file).

Main features:

  • 3 sections: Today tasks, unsorted (inbox) tasks without a date, tasks to be finished in 7 days. Generic definition structure allows to add another sections easily.
  • Both HTML and plaintext version for people who remember 90's.
  • Quick summary in subject.
  • Currently it uses Czech locale but it's easy to modify it (few strings only). I18n not supported yet.
  • Sends email via local SMTP (authorization & SSL support not supported yet).

Visit my Bitbucket repo to download Wudd. Also, you can post issues there. Enjoy!

// Thunderbird LDAP via SSL with self-signed certificate

Adding a LDAP directory as a contact source for Thunderbird can be quite tricky if you have SSL-only connection and your server is using self-signed certificate. For some reason there is no Add exception dialog appearing during the first connection attempt as we got used to when connecting to a mail server.

Following will help you to to add the exception manually:

  1. Go to Config editor (aka about:config, PreferencesAdvancedGeneral, press the Config editor button).
  2. Add new (or edit existing) string key 'network.security.ports.banned.override', set value to '636'. This will disable port blocking feature for port 636 (visit http://www-archive.mozilla.org/projects/netlib/PortBanning.html for more info).
  3. Go to SettingsAdvancedCertificatesViewServersAdd exception.
  4. Type your_ldap_host:636 to the Location field, click on Get certificate, then Confirm Security Exception.
  5. Add your LDAP directory to contacts
  6. Now you can revert the config 'network.security.ports.banned.override' to previous value, it is no longer needed.

Hope that helped ;-)

// Setting up DKIM signing with Postfix on Debian Wheezy

This is a log of my setup for OpenDKIM on Debian Wheezy. Some steps (like setting the proper access rights) might be omitted.

1. Install OpenDKIM

aptitude install opendkim opendkim-tools

On some distros, content of openkim-tools is included in the first package.

2. Generate domain key

cd /etc/postfix
opendkim-genkey -s mail -d mplicka.cz
mv mail.private opendkim_mail.private
mv mail.txt opendkim_mail.txt

Publish the TXT record. Use the information in /etc/postfix/opendkim_mail.txt For selector “mail”, the DNS record path will be:

mail._domainkey.mplicka.cz.

Complete DNS record (in the mail.txt file) will look like:

mail._domainkey IN TXT "v=DKIM1; k=rsa; p=There_will_be_your_public_key_base64_encoded" 

3. Set up the opendkim daemon.

I used a unix socket for communication. On Debian, Postfix is chrooted, so create the socket inside the chroot.

Create the directory for the socket and allow postfix to access it:

mkdir /var/spool/postfix/opendkim
chown opendkim:opendkim /var/spool/postfix/opendkim
adduser postfix opendkim #add postfix user to opendkim group (to gain access to the socket)

Modify /etc/default/opendkim:

SOCKET="local:/var/spool/postfix/opendkim/opendkim.sock"

Modify /etc/opendkim.conf:

Syslog                  yes      # Log to syslog
UMask                   002      # Allow opendkim group members to access the socket
Domain                  mplicka.cz
KeyFile                 /etc/postfix/opendkim_mail.private      
Selector                mail
AutoRestart             Yes
AutoRestartRate         10/1h
Canonicalization        relaxed/relaxed  #canonize headers before signing
Mode                    s                #sign mode only
SubDomains              yes              #allow to sign emails from sub-domains

Restart the opendkim daemon and check the log

4. Set the postfix - /etc/postfix/main.cf

milter_default_action = accept
milter_protocol = 2
smtpd_milters = unix:opendkim/opendkim.sock
non_smtpd_milters = unix:opendkim/opendkim.sock

If two last lines already exist (e.g for Amavis), just append the new milter settings to the existing ones

Restart postfix and enjoy.

// Reading output of remote command with Dropbear ssh client

Today I faced strange behavior of Dropbear SSH client (dbclient) on my home OpenWRT home router. Before anything else, I would like to note that I do not have the recent version, but the version included in my OpenWRT installation. Exactly, it's Dropbear v0.53.1. But most distributions do not have recent versions so I hope this will remain usefull to others.

I have a shell script which uses ssh client to read some information from my other server. Imagine following shell code snippet:

result=`ssh -i key_file user@server remote_command` && {
  echo "Obtained information is $result"
}

This code will connect to remote machine and run remote_command which produces some output. This output will be assigned to variable $result. If remote command succeeds (returns exit code 0) the message with obtained value will be printed.

For particular reason, this snippet did not work if the whole script was run by cron. I googled a lot. I found some issues in Dropbear mailing list including quite dirty but working solution.

The reason is that script run by cron has no standard input available. Due to this, dbclient does not read any output from remote command either, so the $result variable is set empty and no error code is returned.

This behavior can be simulated from running shell as

ssh -i key_file user@server echo "foo" </dev/null

Nothing will be returned. Note that this modification does not affect OpenSSH client behavior (SSH implementation on most “big” Linux machines).

The quickest solution is to “create some stdin to ssh client”, redirect from /dev/zero is enough. Following code works:

result=`ssh -i key_file user@server remote_command </dev/zero` && {
  echo "Obtained information is $result"
}

Now the whole script works either standalone or as a cronjob.

About me
SW developer, amateur tennis player, rock'n'roll & heavy metal fan.