Skip to content

Category: Computer Science

Mac OS 10.12 and ssh

Yeah, I know, it’s old, but I need this mostly as a memo to self: ssh key handling changed between MacOS 10.11. and 10.12.

What you probably want is the following magic in a generic Host block of your machines .ssh/config or /etc/ssh/ssh_config:

Host *
  UseKeyChain No
  AddKeysToAgent yes

This will store your SSH Keys in the agent, entering the password only once. It will not persist the keys on the machine, requiring that you authenticate and unlock the keys once after each restart.

Getting rid of persisted keys is complicated and requires some SQLite magic.

ssh-add -D -K
for f in ~/Library/Keychains/*/keychain-2.db
do 
  sqlite3 $f "delete from genp where agrp = 'com.apple.ssh.passphrases';"
done
2 Comments

Grumpy

So Python is a beautiful language, which is also kind of slow. And the more cores you have, the worse it gets, because of the GIL in the most popular implementations.

Other languages are much better at concurrency, one of them supposedly being Go. So Geeks at Google have been pondering the problem, and came up with a Python-to-Go compiler called Grumpy. Read more about it in their blog.

In rigged benchmarks it looks awesome, and under real world load it supposedly performs quite well.

But the best part is the Logo. Which looks like this:

 

Leave a Comment

Shit geeks say

So the Geeks at Datacenter Dynamics quote this geek:

“With a market of more than 80 million people within a roundtrip delay of 30 milliseconds, covering all major cities of Northern Europe, the Baltic states and western Russia, Stockholm is an ideal location for cloud players and other major data center actors,” …

So how many million people are within 30ms of you? :-)

In other news, the more countries go renewable, the less they are charging for power (they may be charging for infrastructure, though). For data centers in Norway and Sweden, it appears that we are below 4 Cent/kWh now. Oh, and can we please use the exhaust heat from your computers to heat our capital, please?

5 Comments

PHP 7: mysql extension deprecated

In mysql() nach PHP 7 retten, Charly Kühnast explains how you can get the deprecated and disabled mysql extension back in PHP 7. You shouldn’t.

There are many reasons for this. One of them being that none of the newer features in MySQL can be used with the old mysql extensions. There is an overview in the PHP documentation that explains exactly what you are missing.

One of the things that you are missing is support for prepared statements. Prepared statements are a mechanism in which you write SQL statements with placeholders for variables, and then later bind values to the placeholders using a “bind” call or as part of the “execute” call which is actually running the statement. In any case, the variables are being escaped properly automatically, making SQL injection a lot harder.

This is not just a problem limited to PHP – a search for bind and execute other sources can be very instructive. For example, the sources of Opennebula or in older versions of Owncloud (up to and including version 7) are rich treasure troves of potential exploits.

So currently the situation is as follows:

There are three extensions at the PHP level, one of which is deprecated and disabled in PHP 7:

  • The old mysql extension is no longer available by default, and for good reasons. Do not use it, do not attempt to use code that uses it.
  • The mysqli extension has been around for very many years, and offers a procedural and an object oriented interface, and makes “newer” MySQL features available, including prepared statements.
  • The PDO_mysql extension has been around for many years, too, and offers an object oriented, and portable across databases interface. It also allows access to all “newer” MySQL features.

The wire protocol of all of these extensions is implemented by a C-level library, against which the extension can be linked. A manual page explains the choices.

  • Traditionally that has been the Oracle/MySQL C-API (“libmysqlclient”, “Connector/C”), which comes with the database server. It is available on the GPL, which is a license different from the PHP license of the rest of the PHP proper, and it has it’s own memory management, which is different from the PHP native memory management.
  • Since PHP 5.3, there is mysqlnd (the “native driver”, ND). It re-implements the MySQL wire protocol, and is available under the same license as PHP itself. It also uses the same memory management that PHP uses, which makes it faster (no copying) and more efficient (no duplication of values). It is the default on a normal PHP build these days.

What you should be using: These days, your code should not be using the mysql extension. So you will be using mysqli or PDO_mysql, depending on your needs, with the underlying implementation of the native driver doing the heavy lifting.

Do not attempt to port mysql-Extension based code to PHP 7 without refactoring it for prepared statements, please.

 

Leave a Comment