Stop google-chrome from hijacking MIMEs

For some idiotic/evil reason Google Chrome is hijacking MIME associations in Linux (configuration that decided which applications opens a particular file type).

This happens every time Google Chrome is updated. It is absolutely idiotic for Firefox to have an image opened by Chrome, yet I have reset it numerous times to no avail (purged all mentions of chrome from /etc/mailcap and various copies of mimeapps.list).

I would not use Chrome, except I have to due to lazy Slack devs, and other corporate torture tools that only made for IE6 of `20.

My preferred solution would have been apt remove google-chrome, but alas I have to endure this piece of malware.

The “Fix” is to utilise Apparmor and prevent the chrome from ever messing with MIMEs (sorry for SELinux types, I can’t be bothered…). In my opinion if you are running chrome as a secondary browser, it should not be associated with anything, ever.

Assumptions: chrome is installed in /opt/google/chrome, The distro is running apparmor (not SELinux) and there is no existing profile already.

Create the apparmor profile:

/etc/apparmor.d/opt.google.chrome.chrome
abi <abi/3.0>,

include <tunables/global>

/opt/google/chrome/* {
  include <abstractions/base>
  #allow by default almost everything
  capability,
  file,
  network,
  dbus,
  unix,
  signal,
  ptrace,
  
  # stop behaving like malware and fucking up my MIMEs
  audit deny /**/mimeapps.list rw,
  audit deny /usr/share/applications/defaults.list rw,
  audit deny /**/xdg-mime x,

}

Note: If you have an existing profile already just add these lines:

  audit deny /**/mimeapps.list rw,
  audit deny /usr/share/applications/defaults.list rw,
  audit deny /**/xdg-mime x,

Enable the profile:

aa-enforce /etc/apparmor.d/opt.google.chrome.chrome

Restart chrome.

Warning: this apparmor profile is equivalent to almost no restrictions except for the mime related stuff, and thus cannot be used to “secure” chrome without extensive modifications.

To fix the MIMEs after google messed it up:

sudo sed -i '/google-chrome.desktop/d' /usr/share/applications/defaults.list
sudo sed -i '/google-chrome-stable/d' /etc/mailcap
sudo sed -i 's/google-chrome.desktop;//' /usr/share/applications/mimeinfo.cache 

A peculiar case of I/O errors with cheap SFF-8643 cables

This saga could also be named “Why my very expensive LSI 9305-24i drops disks?”.

I recently acquired (from ebay as I cannot justify giving $2000NZ to local scumbags) an LSI 9305-24i controller to drive a 24bay NAS.

The reason switching from LSI 9112-8i with RES2CV360 SAS2 expander is because the LSI 9112-8i is bottlenecked by the 8x PCIe 2.0, thus limiting the throughput of a 24 disk array to about ~100MB/s per disk.

The LSI 9305-24i made a significant boost in the performance, with ~200MB/s (maxing out Seagate Ironwolfs) per disk.

Continue reading A peculiar case of I/O errors with cheap SFF-8643 cables

Approximating SoC of a Lithium Ion battery using atan

I recently deep-dived into a topic of look up tables and interpolation simply because I wanted to have relatively simple representation of State of Charge for one of my projects. The difficulty I found is that the LiFePO4 batteries have a very flat discharge curve and are really hard to approximate.

Continue reading Approximating SoC of a Lithium Ion battery using atan

High Side Power Switch for a microcontroller

High Side Power Switch for a Microcontroller

Notes: The MOSFET is of a P-Channel type, can be pretty much any P-Channel as long as the On-Resistance is low and it can sustain sufficient current. The NPN transistor can also be pretty much anything with sufficient hfe (>50), and can tolerate >100mA collector current spikes.

Continue reading High Side Power Switch for a microcontroller

Remove Google’s Digital Wellbeing spyware from Android via ADB

Recently my phone has been updated to Android 10, with it I found the Digital Wellbeing spyware reinstalled and now fully baked in (no uninstall or disable option).

The prerequisite for this process: you need ADB (the installation of which will not be covered here). No root needed (yet).

Here is the ADB command you need to run:
adb shell pm uninstall -k --user 0 com.google.android.apps.wellbeing

This change is semi-permanent, if you want this nagware back, I can’t really help you (you might be able to reinstall it from the store).

I do not understand the reason one would use this app. If you think you spend too much time on your phone, you don’t need an app to tell you that. My phone is a tool, and having some lock-out and nagging (self-inflicted!) on your own device is absurd.

It is absurd to bake this app in, the only reason is to spy on its users more.

If you hate this app (and everything it stands for) as much as me give it one star on the google play store.

Viofo A119 – Beeping with the Format prompt after a long downtime

One of my A119 Cameras started to beep while presenting the “Format Yes/Cancel” prompt after long downtime. The date was also reset.

Before pandemic this was not as annoying as it would almost never do it, but with pandemic and work from home it does it pretty much every start up.

The Problem would go away once the date would be updated via GPS and the issue not come back until next very long shut down.

Continue reading Viofo A119 – Beeping with the Format prompt after a long downtime

Opus BT-C100 reverse polarity protection

I recently bought an Opus BT-C100, as unlike my other Lithium Ion chargers, has a discharge test feature. It also fairly quickly estimates internal resistance of the cell, which is a good health indicator.

Unfortunately due to A123 26650 cell being of upside down construction I released the magic smoke out of the Opus BT-C100 by reversing polarity. The smoke escaped through the battery holder slit.

Continue reading Opus BT-C100 reverse polarity protection

Dealing with data obfuscation in some Chinese dash cameras

This is post relates to the extracting GPS coordinates form Novatek based dash cameras.

About an year ago I was contacted by someone who tried to use my script on MP4 files generated by their camera, only to get garbage data out. It appeared that the camera was obfuscating the coordinates stored in MP4 (the speed and heading was recorded correctly). It was not a bug because provided player was decoding them correctly.

Continue reading Dealing with data obfuscation in some Chinese dash cameras