Redmine (1.3) is down

16 May 2016 in Redmine

Recently our redmine issue tracker stopped working responding with internal server error 500. The log file in /var/log/redmine/default/production.log was showing errors like this:

Status: 500 Internal Server Error
private method `split' called for nil:NilClass

After a google search, the solution found on the redmine forum: For some reason, the issue seems to be caused by a passenger security update from the debian-lts team on the libapache2-mod-passenger package, so I have to rollback:

# downgrade package
aptitude install libapache2-mod-passenger=2.2.11debian-2

# and pin it via
aptitude hold libapache2-mod-passenger
# or
apt-mark hold libapache2-mod-passenger

Do you know SSRF

16 May 2016 in Web application securiry

An interesting article on Server Side Request Forgery (SSRF):

In this attack, specific payloads for different ports are crafted by the attacker and sent to the server. By analyzing the errors or the time-delays in different responses for different ports, the attacker can figure out the status of the ports open on the server. And while exploiting SSRF, the attacker’s machine is not directly interacting with the target server, the vulnerable server is doing all the dirty work for the attacker.

See more at http://niiconsulting.com/checkmate/2015/04/server-side-request-forgery-ssrf.

Simulating non-SNI browsers on SSL/TLS websites

05 Apr 2016 in SNI, OpenSSL

Useful when you need to know whether the ssl/tls enabled website is accessible from ancient browsers and OS'es (taken from this stackoverflow answer):

openssl s_client -connect domain.com:443 
# ...output...
# ...proper response is something like
Verify return code: 0 (ok)
# ...invalid response is something like
Verify return code: 18 (self signed certificate)

See the wikipedia article for an explanation about SNI.

Hardening postfix for ISPConfig3

24 Mar 2016 in Postfix, SPAM

This is a set of links with instructions on how to harden a postfix installation used by ISPConfig3.

First the one from HowtoForge:

And the others from nixCraft:

My sources of information

23 Mar 2016 in Other

Recently, I was asked about how I educate myself and how I keep up with the latest news and trends in information technology, programming, etc.

So here it is, integrated on the about page.

Minimizing downtime when moving a website

22 Mar 2016 in Apache, Reverse Proxy

Situation: you move a website to another server but the dns changes propagates slowly and this causes the effect that some visitors sees the new site and some others the old.

One way to cope with this is by setting a reverse proxy. The purpose of the proxy is to direct all HTTP traffic to another server. In apache, this can be accomplished with these directives:

# A.B.C.D is the server IP that gets the traffic
ProxyPreserveHost On
ProxyPass / http://A.B.C.D/
ProxyPassReverse / http://A.B.C.D/

Don't forget to install and enable the mod_proxy mod.

Merging product attributes in Magento

21 Mar 2016 in Magento, PHP

Another magento snippet. With this you can merge product attributes:

// create product collection
$collection = Mage::getModel('catalog/product')
    ->getCollection();
// filter by attribute code
$collection->addAttributeToFilter($attributeCode, $from);
// get all product ids...
$ids = $collection->getAllIds();
// ...and update them
Mage::getSingleton('catalog/product_action')
    ->updateAttributes($ids, [$attributeCode => $to], 0);

Don't forget to initialize the following variables:

  • $attributeCode - the code of the attribute, eg color.
  • $from - the attribute value id you want to merge from, eg 145 for Cyan.
  • $to - the attribute value id you want to merge to, eg 146 for Blue.

After that, reindex and drop the old attribute value.

Using magento API to get order details

20 Mar 2016 in Magento

With the following snippet you can get order details from the magento API:

<?php
$proxy = new SoapClient('http://your-magento-site/index.php/api/soap/?wsdl=1');
$session = $proxy->login('SOAP-API-USER', 'SOAP-API-PASSWORD');
$orders = $proxy->call($session, 'sales_order.list', [
    [
        'entity_id' => [2595],                 // filter by order id
        //'status' => ['in' => ['Canceled']],  // or by status
        //'state'  => ['in' => ['canceled']],  // or by state, etc
    ]
]);
var_dump($orders);
foreach ($orders as $order) {
    // fetch information about each order
    $order = $proxy->call($session, 'sales_order.info', $order['increment_id']);
    var_dump($order);
}

You must have an api user with correct permissions in order for this to work (look under "System" > "Web Services").

Improving performance of vagrant shared folders

19 Mar 2016 in Vagrant, Development

At first, install the nfs server package on your linux host. On ubuntu this can be done with:

sudo apt-get install nfs-kernel-server

In the Vagrantfile, mount the shared folders using these options:

type: "nfs", nfs_udp: false, mount_options: ["rw", "tcp", "nolock", "noacl", "async"]

Also, you can use cachefilesd on the guest machine like this:

sudo apt-get install cachefilesd
sudo echo "RUN=yes" > /etc/default/cachefilesd

and add the "fsc" option in the mount_options above.

If you are using the chef provisioner, you can install cachefilesd by using this recipe:

package "cachefilesd" do
  action :install
end

file "/etc/default/cachefilesd" do
  content <<-EOF
RUN=yes
  EOF
  action :create
end

Patching with git diff

18 Mar 2016 in Git, Patch

If you want to create a patch file via git diff that can be applied using patch, use the following:

git diff --no-prefix > patchfile

and apply the patch with:

patch -p0 < patchfile

or, without the --no-prefix option, with:

patch -p1 < patchfile

This will ignore the default a/ b/ source prefixes.