Working with Windows Junctions in Python

I had to detect Windows junctions (similar but not identical to symbolic links) in Python. On I read the following Python code given by a user named eryksun for handling them, as os.islink() does not work for junctions.

The routines access Windows functions CreateFileW(), DeviceIoControl(), CloseHandle() in kernel32.

Continue reading

Suppressing Advertisement on Web-Pages a.k.a. Ad-Blocking

Advertisements on web-pages is ubiquitous. Without advertisement even this blog could not be offered free of charge. But advertisement can be a real nuisance with its blinking, flickering, moving, and distracting appearance. Sometimes they even contain malware.

There are two simple remedies for this problem:

  1. use an adblocker plug-in for your browser
  2. modify your /etc/hosts file

The first one is easy to accomplish, but sometimes web-pages no longer work as expected. The second approach is in some ways more direct and more brutal, and leaves visual clues on the web-pages that brute force has been applied.

Editing /etc/hosts on your Linux desktop is easy. On Android you connect via adb shell, switch to root user with su, then

mount -o remount,rw /system

i.e., remount the /system directory from read-only to write-enabled, then edit /etc/hosts. Either reboot your smartphone, or

mount -o remount,ro /system

I use the following list of hosts in my /etc/hosts, which has a somewhat German felling: Continue reading

Upgrading from OxygenOS 1.0.0 to 1.0.3 on the OnePlus One Smartphone

I upgraded my OnePlus One smartphone from Oxygen 1.0.0 to 1.0.3, see Installing OxygenOS 1.0 on the OnePlus One Smartphone.

Download OxygenOS 1.0.3 from OxygenOS 1.0.3 with the latest Stagefright patches, and check MD5. Then upload the zip-file.

adb push ~/Download/ /sdcard/

It is stated in Oxygen 1.0.2 Release with Stagefright security patches that “If you are already on OxygenOS, this update does not require a reset.” I had to factory reset my phone as TWRP didn’t recognize the system partition; it was encrypted, although encryption in my previous efforts never worked. It looks like it worked for TWRP only.

Shut down phone, and reboot with power-button and volume-down pressed, boot into TWRP, select your image on /sdcard. That’s it.

These are the versions displayed:

  1. Android version 5.0.2
  2. OxygenOS version 1.0.3
  3. Kernel version 3.4.0-perf-g2e81366, #1
  4. Build date 27-Aug-2015
  5. Build number A0001_12_150827

Using OxygenOS 1.0.3 I noticed the following:

  1. Battery consumption is still high.
  2. It is no longer possible to initiate SIP calls with the build-in telephone application, although you may still receive SIP calls, see also shahazadkm in OnePlus forum.
  3. Apps apparently no longer install automatically after factory default.
  4. I didn’t try encryption as this was a fiasco in OxygenOS 1.0.0.

For an answer as why not update to a higher OxygenOS version see OxygenOS 2.0 Q&A:

As for all of you wondering when the OnePlus One will get an update to the latest OxygenOS version, the answer is that we are working on it but the official date is not quite set yet. Since 2.0 is optimized for Snapdragon 810, it will take us a bit of time to port things over. In the meantime, the OnePlus One will still be officially supported by CM.

The OnePlus One has a Snapdragon 801.

See also Marshmallow upgrade schedule for OnePlus devices:

For the OnePlus One, Cyanogen OS will be updating to Marshmallow in the first quarter of 2016. We created a community build of OxygenOS for the OnePlus One, but this isn’t what the product officially ships with. We will be updating the community build of OxygenOS for the OnePlus One when time allows.

Update 23-Jan-2016: Oxygen 2.1.4 for the OnePlus One is out, see

See also Upgrading from OxygenOS 1.0.3 to 2.1.4 on the OnePlus One Smartphone.

Linux pam and /etc/shells

I learned the hard way that a user in /etc/passwd not having a shell specified in /etc/shells is not able to log-on.

On Ubuntu /etc/shells looks like this:


On Arch it looks like this:


So if you provide a user with shell /usr/bin/bash, he cannot log-in, thanks to

See man shells, man pam_shells, and authentication error with shell=/usr/bin/bash.

Also see Creating User Account With Empty Password on Linux.