# uname -a

Switch

lundi 1 juin 2015

How to succeed in online dating

Version française

Today a blog post contrasting with the habitual common-people-dont-give-a-fuck technical articles.

I will relate my own experiences and talk about how online dating, if well taken, can be the way you finally found the Chosen One … or a neverending nightmare of frustrations and disapointment. Okay, it’s a so-worn theme that I wouldn’t have written it.

Actually, everything began when i watched this video : How I hacked online dating . It was clear for me that data analysis is not the Graal to the Perfect Boyfriend, but that it may be worth the try, as my ex-boyfriend recently broke up. And because now it has been one year since the beginning of my experiments, here are my few conclusions about online dating in the context of looking for a long-term relationship.

Note : this article is obviously gay-oriented (hey, it’s my blog so it has to be sissy-stuff), but it should apply to any male/female/boy/girl/teenager/poney starting with online dating.

Lire la suite...

samedi 23 mai 2015

Migrate an OpenVPN configuration to Debian 8 (Jessie) with systemd

This article could have been avoided if the Debian documentation was up-to-date. Actually it is not, and the solution came from Fedora documentation for OpenVPN.

Debian 8 uses systemd by default, and it implies several changes, in  particular the way you start/stop your services.

The main topic : systemd

What changes

  • A new fancy command now manage the startup : systemctl (don't mess with the sysctl command used for network configuration !)

  • The startup dependencies are no longer in the LSB headers in startup scripts (way too simple, boy), the dependencies are stored as symlinks in subdirectories located in /etc/systemd/* . Note that /etc/systemd/ contains some static configuration files, and that the real services configuration files are stored in /lib/systemd/* (this is where the symlinks from /etc/systemd/* points to).

  • Some services have been split from monolithic startup to dynamic. It means that you potentially have to enable and run multiple "services" in order to actually start the full "service". For instance, OpenVPN no longer runs every available configuration in /etc/openvpn/*.conf , you have to explicitely activate each *.conf file as a service in systemd !

What doesn't change

  • You can still start your services with service servicename start.

  • The init scripts in /etc/init.d/* still exists, and some are still usable (monolithics services).

Run your OpenVPN configuration

While you can still use the command openvpn --config /etc/openvpn/yourconfigfile.conf, you should do it with systemd. If your configuration file is /etc/openvpn/sample.conf, you should start your VPN connexion with systemctl start openvpn@sample.service .

Note that service openvpn@sample start also works.

Start your VPN at boot

Again, the auto startup was too simple. You now have to enable every *.conf file at boot. Enable you newly sample.conf at startup with the command systemctl enable openvpn@sample.service

This actually creates a symlink in /etc/systemd/system/multi-user.target.wants/openvpn@sample.service pointing to /lib/systemd/system/openvpn@.service

Ok, it's simpler for dynamic loads, but who needs to dynamically enable and disable configuration at boot ? If I want a different configuration, I simply write different files in the right folder...

Meanwhile, in Debian Apache package

You can enable and disable VirtualHosts by using the /etc/apache2/sites-available/ and /etc/apache2/sites-enabled/ folders. No hidden features, no boot startup configuration, all configuration files in /etc/programname/ . Way too simple ?

Hey, what if we had to configure a startup script for every VirtualHost ? Should be fun, don't you think ?

Sources

lundi 20 avril 2015

Owncloud 8 : manually decrypt files

Owncloud has the ability to encrypt files. You can restore your files with a complete backup/restore of your Owncloud folder, but what if you want to restore just one file from a previous backup ? Here is the code for a one-shot file decryption.

This code is the solution I posted on Github : https://github.com/owncloud/core/issues/13591

2015-08-05 : UPDATE : to make it work with binary files, use the following code instead :

<?php

// Replace these with your custom values
$datadir = '_PATH_TO_DATADIR_INCLUDING_TRAILING_SLASH_';
$filepath = 'some/directory/relative/to/datadir/myfile.txt';
$username = '_OWNCLOUD_LOGIN_';
$password = '_OWNCLOUD_PASSWORD_';

require_once '_PATH_TO_OWNCLOUD_/apps/files_encryption/lib/crypt.php';

// first get users private key and decrypt it
$encryptedUserKey = file_get_contents($datadir . $username . '/files_encryption/' . $username . '.privateKey');
$decryptedUserKey = OCA\Files_Encryption\Crypt::decryptPrivateKey($encryptedUserKey, $password);

// now we need to decrypt the file-key, therefore we use our private key and the share key
$shareKey = file_get_contents($datadir . $username . '/files_encryption/keys/' . $filepath . '/' . $username . '.shareKey');
$encryptedKeyfile = file_get_contents($datadir . $username . '/files_encryption/keys/' . $filepath . '/fileKey');
$decryptedKeyfile = OCA\Files_Encryption\Crypt::multiKeyDecrypt($encryptedKeyfile, $shareKey, $decryptedUserKey);

// finally we can use the decrypted file-key to decrypt the file
// but first, strip header block
$handle = fopen($datadir . $username . '/files/' . $filepath, 'r');

// if this block contained the header we move on to the next block
if (OCA\Files_Encryption\Crypt::isHeader($data)) {
        $header = OCA\Files_Encryption\Crypt::parseHeader($data);
        $cipher = OCA\Files_Encryption\Crypt::getCipher($header);
} else {
    die('Cannot find header');
}

// Decrypt the content block by block
$decryptedContent = '';
while ($data = fread($handle, OCA\Files_Encryption\Crypt::BLOCKSIZE)) {
    $decryptedContent .= OCA\Files_Encryption\Crypt::symmetricDecryptFileContent($data, $decryptedKeyfile, $cipher);
}
fclose($handle);

// Save the decrypted file
file_put_contents(str_replace('/', '-', $filepath), $decryptedContent);

 

vendredi 13 mars 2015

Configure sender rate limits to prevent spam, using cluebringer (policyd) with Postfix

This small how-to will show you how to configure cluebringer (aka policyd) to set a per-hour/per-user limit for sent mails. Note that sending to multiple recipient will count like multiple mails were sent.

This how-to is Debian-oriented but should apply to any unix operating system.

Lire la suite...

mercredi 25 février 2015

Drupal 7 : create your own image effect for use in image styles

Drupal comes with many predefined effects, you can combine them in image styles to get the picture you want. But what if you have to make your own effect ? Here is how.

Lire la suite...

- page 10 de 32 -