blog.plee.me About software, technology and random things

14May/220

Windows Defender Firewall Inbound Rule for ICMPv6

Hi!

I'm getting more into IPv6 these days and found that ICMP is very important for IPv6 connectivity.

Windows Defender Firewall with Advanced Security (on Windows 10 at least) comes with some inbound ICMPv6 allow rules, but unfortunately they don't allow for quite enough.

I went ahead to create a rule by hand, but found out that you cannot set a group for the rule through the GUI, so instead I opted for creating a little PowerShell command.

You have to run it from a UAC-elevated PowerShell instance.

This rule is based on the existing default ICMPv6 rules.

Create the rule:

New-NetFirewallRule -DisplayName "Core Networking - CUSTOM - Allow Incoming ICMPv6" -Group "Core Networking" -Direction Inbound -Action Allow -Protocol ICMPv6 -Program System

Remove the rule again:

Remove-NetFirewallRule -DisplayName "Core Networking - CUSTOM - Allow Incoming ICMPv6"

Some people may want to exclude echo request for privacy or "security (through obscurity)" reasons, but I don't think it's that big of a deal.

Of course feel free to customize the command in general. The official documentation page (docs.microsoft.com) is very informative.

If you have any other firewalls between you and the sender, you may have to check their rules as well.

I tested the rules with a website like ipv6-test.com.

Thanks for reading!

3Apr/220

(Re)Setting Hyper-V Virtual Machine Client Zoom Level

Hi!

A couple of days ago I was playing around with Hyper-V virtual machines. At some point I set the "View" => "Zoom Level" to 25%.

Unfortunately, at 25% the window becomes so small that you cannot see the View menu in the menu bar any more because it gets cut off. And for some reason you cannot use the arrow keys on the keyboard to navigate the menus either.

This zoom level not only applies for a single virtual machine, but all of them, as it as a general Hyper-V client setting.

Trying to access the menu when the VM is shut down does not work because the "Zoom Level" submenu is disabled, and once the VM is booted up, the window resizes instantly.

The only reliable way to (re)set it appears to be editing the Hyper-V client configuration on the host file system:

  1. Close the Hyper-V client window (the one that opens when you connect to / double-click a VM)
  2. Open the file at %UserProfile%\AppData\Roaming\Microsoft\Windows\Hyper-V\Client\1.0\vmconnect.config and set the setting with ZoomLevel back to 100 (or something similarly usable):
    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
    <Microsoft.Virtualization.Client.InteractiveSession.InteractiveSessionConfigurationOptions>
    <setting name="ZoomLevel" type="System.UInt32">
    <value>100</value>
    </setting>
    [...]
    </Microsoft.Virtualization.Client.InteractiveSession.InteractiveSessionConfigurationOptions>
    </configuration>
  3. Save and close the file
  4. Connect to / double-click a VM again

I hope this was helpful to you.

Thanks for reading!

Source: How to restore auto zoom level in Hyper-V VM window (answers.microsoft.com) - Answer by Trond.R. on November 27, 2020 (Sorry, apparently you can't link to answers directly)

3May/200

Uploading a Snapshot to a Fresh Home Assistant OS Instance

Hi!

After finding that my previously running Home Assistant OS instance was no longer working let alone starting properly, I decided to wipe it and simply install from a fresh image today. In order to pick up where I left off, I wanted to restore from a snapshot that I made a short while ago.

Out of the box, Home Assistant OS does not seem to come with any way to upload snapshots (or any other kind of files) onto the instance. Usually, this would not be a problem, because I had previously used the Samba share add-on from the official add-on repository, but since updating it to the new repository website, the Samba share add-on seems to have disappeared.

My first alternate approach using the SSH access did not work either, as I could not use SFTP because it is not effectively using proper SSH/SFTP but an intermediate wrapper for the Home Assistant console.

The quickest way I found that had minimal impact on the system in terms of creating a mess was to use Docker and download my latest snapshot from a web server hosted somewhere else via cURL. In this case I was using a self-hosted Nextcloud instance with a shared file link, but your mileage may of course vary.

Prerequisites / Assumptions

  1. You are using the Home Assistant OS official image on a device in headless mode, so you have a minimal system without neat tools like curl or wget pre-installed.
  2. You have uploaded the snapshot file to a web server that is accessible from the Home Assistant OS system (in terms of network connectivity).

Steps

  1. Enable SSH access by following the official documentation on how to enable SSH access to the host.
    • Update from 2020-05-21: They seem to have restructured the documentation and the original instructions are no longer on that page. It used to say:
      Use a USB drive formatted with FAT, ext4, or NTFS and name it CONFIG (case sensitive). Create an "authorized_keys" file (no extension) containing your public key, and place it in the root of the USB drive. File needs to be ANSI encoded (not UTF-8) and must have Unix line ends (LF), not Windows (CR LF). [...] From the UI, navigate to the Supervisor system page and choose "Import from USB". You can now access your device as root over SSH on port 22222. Alternatively, the file will be imported from the USB when the Home Assistant OS device is rebooted.
  2. Log into the Home Assistance OS instance via SSH.
  3. Type the command "login" to enter the actual shell.
  4. Use the following command to download the snapshot file:
    docker run --rm curlimages/curl https://my.server.local/a1b2c3d4.tar > /mnt/data/supervisor/backup/a1b2c3d4.tar
    (Change URL and file names of course. The destination directory should be fine.)
  5. You might want to check file integrity for the file via md5sum or sha512sum etc.
  6. If you want to be extra tidy, you can remove the cURL Docker image again by executing
    docker image rm curlimages/curl
  7. Close the SSH session and open a new one.
  8. Do not enter the actual shell but instead execute this command to get Home Assistant to notice the newly uploaded snapshot:
    snapshots reload
  9. Now log into the Home Assistant web interface or just keep using the console and restore what you need.
  10. Done!

I hope this saved you a bunch of research because I myself could not find anything quick and practical on this topic.

Thanks for reading!

23Jun/190

Missing Credentials in Dropdown for Jenkins Build Configuration

Hello!

Recently I updated my Jenkins installation including all of the plugins. One of them must have brought somewhat breaking changes because when I tried to create a new build configuration for a new old project of mine, I could not select the proper credentials in the dropdown. I only had the option to add new ones even though I had added the corresponding credentials in the global scope (as per usual), so they must have been visible across the entire Jenkins instance. None of them were showing up. And even when I tried adding new ones through the build configuration page, they ended up not being active / selected either.

When I went back to check with an existing build configuration I had configured over a year before, I could confirm the same behavior. For build parameters the credentials dropdowns were empty and for the VCS credentials it said

Cannot find any credentials with id <ID>

I spent a couple of hours looking for solutions and I did find some cases that popped up around 1 or 2 years ago, but nothing that fit this exact scenario. My suspicion was that this might be a bug, so I tried rolling back the SSH credentials and credentials plugins to the previous versions, but that did not fix anything.

I decided to wait for a week in the hopes of potential bug fix releases to come out for either some of the plugins or Jenkins itself, but a week later in spite of a couple of updates here and there, nothing about the problem had changed.

And then I found a comment in the discussion thread of a GitHub issue of the "GitHub Pull Request Builder Plugin" (which I am not even using). In it, the following solution was proposed:

  1. Navigate to "Jenkins" (main menu) => "Manage Jenkins" => "Configure Global Security"
  2. Go to the "Access Controls for Builds" section
  3. Under "Project default Build Authorization" check if the "Strategy" is set to "Run as anonymous" (which was the case for me)
  4. If yes, try changing it to "Run as User who Triggered Build" (it might also work with another setting if that suits you better)
  5. Save and reload the build configuration settings

That was it! The credentials showed up again and I could execute the build successfully.

I know this seems to be a niche problem and there might only be a handful of people that have encountered the same issue, but I hope it was helpful nonetheless.

Thank you for reading!

24Oct/180

Disable Autoplay For Videos in Firefox 63

Hi!

Just after updating to Mozilla Firefox 63 (on Windows), I found that my setting to disable autoplaying media / videos was no longer effective - at least for HTML5 videos.

Apparently one of the changes for this release was to include an autoplay video blocker, but I could not find anything definitive about this in the settings.

I decided to disable autoplay for all videos (which is my preferred setting anyway) once again by doing the following:

  1. Open the config editor by entering about:config in the navigation bar.
  2. Enter the "autoplay" as a filter.
  3. Find the entry "media.autoplay.default", double-click it and set it to "1" to disable media autoplay browser-wide.

I just left the old setting "media.autoplay.enabled" as "false", even though it does not seem to be relevant any more.

After reloading the website with the video (in this case YouTube), once more it showed the play icon on top of the video instead automatically starting playback.

Source: https://www.linuxliteos.com/forums/on-topic/firefox-63-0-unable-to-stop-html5-videos-from-auto-playing-in-this-release/

I hope this was helpful.

Thanks for reading!

31May/180

Using Git Bash With Custom Installation Of GPG / GnuPG

Hi!

You have probably noticed that Git for Windows comes with MinGW64, which enables you to use programs (or to be more precise: Windows versions of these programs) that are usually only available to Linux users. One of the programs that MinGW64 / Git for Windows ships with is GPG / GnuPG. The current version of Git for Windows (2.17.1) for example comes with GPG version 1.4.22.

If you prefer using a custom installation of GPG / GnuPG by default, which is probably much more current than the one you installed manually (2.x), you can achieve this by doing the following:

  1. Install GPG as you normally would
  2. Make sure it is executable in the command line / PowerShell (as in: make sure the bin/ subdirectory of the GPG program directory is included in the PATH environment variable)
  3. Go to the Git for Windows program directory (e.g. C:\Program Files\Git\)
  4. Navigate to the usr/bin/ subdirectory and rename gpg.exe to something else (like gpg_disabled.exe)
  5. Close any open Git Bash instances and start a fresh one
  6. Check the GPG version via
    gpg --version

The way that Git Bash works is that is has its own set of directories which have a higher priority when looking for executable files than the ones in Windows' PATH environment variable. So in order to have your own GPG executable working as the "gpg" command, you have to get the included gpg.exe out of the way so it keeps looking in Windows' PATH environment variable.

You can still access the old GPG executable by using the new name (e.g. "gpg_disabled").

Unfortunately you have to do these steps every time you install or update Git for Windows, but at least now you know where to look!

The upside is that now Git (executed from the Git Bash) also uses your own version of GPG for its GPG-related operations.

I hope this was helpful.

Thanks for reading!

4Jan/180

Using OpenVPN For All Network Traffic Except For LAN

Hi!

Recently I noticed that my Android smartphone was not able to connect to YouTube via third-party apps. I narrowed it down to the issue with it being able to resolve hostnames to the correct IPv6 addresses but not being able to connect to them (somehow the IPv6 part of my internet connection is broken. A problem for a different time).

In order to work around the problem I am using an OpenVPN connection which automatically forces all outgoing connections to use IPv4, not IPv6. The only problem was that internal LAN connections did not work any more.

In the .ovpn configuration file I am using

redirect-gateway local def1

(because it is a WiFi connection), but I was also using

redirect-gateway def1

before that, which did not make any difference in that regard.

If add a route directive like the following one after the redirect-gateway directive, you can add a route to the routing table, directing all traffic for the specified route to the WiFi connection instead of the VPN connection:

redirect-gateway local def1
route 192.168.0.0 255.255.255.0 net_gateway

You will probably have to adjust the network address and maybe even the subnet mask to match your network.

The routing table is basically a prioritized table which lets the operating system decide which network adapter it should use for a specific connection. With the above entry you add a rule with a higher priority, overriding the generic one(s) from the OpenVPN connection configuration. These ones are added because of redirect-gateway def1 and tell the operating system to send all traffic via the virtual VPN network adapter, effectively sending it all over the VPN.

If you are configuring this from the OpenVPN server side, of course you can still use these directives, but in the context of the push directive. I am not doing that, however, so I saved both directives in the client configuration.

Now I can watch / listen to YouTube videos with third-party apps AND connect to LAN devices!

I hope this was helpful to you.

Thank you for reading!

7Dec/170

Rewrite MySQL / MariaDB Database Dump Create View Statements For Current User

Hi!

If you would like to import a database dump file created by MySQL's or MariaDB's mysqldump executable, but it contains statements to create views, the import process may abort with an error when it comes to creating views.

When creating a view, MySQL wants to know who created it, and for that it needs a username and the host. If the user who is executing the import does not have sufficient privileges or the original user referenced in the dump does not exist (for example when importing the dump into a fresh database for a migration), this leads to an error.

Usually when I import a dump, I don't care so much about the "SQL Security Definer", so I just want to set it to the importing user.

You can generate a new, modified SQL dump file very easily with the following shell command:

$ sed -r 's#^(/\*!50013 DEFINER=).+?( SQL SECURITY DEFINER \*/)$#\1CURRENT_USER\2#' input_file.sql > output_file.sql

This command simply scans through the entire dump, looking for the statement created by mysqldump which triggers the database to create the view if it doesn't exist already. It then sets the user information to CURRENT_USER which refers to the user that is currently executing the import.

Please note that because the search pattern is so specific, it will probably require some modification in the future, depending on the version of mysqldump you're using and if / how they change this particular statement. On the upside the chance that it will accidentally modify something it shouldn't is pretty low.

I hope this is helpful to you!

Thanks for reading!

18Oct/170

High DPI / Font Scaling Display Problem With LibreOffice

Hello!

When I installed LibreOffice on my Windows 10 notebook with 125% font scaling, I immediately noticed that the menu bar was somehow hiding behind the title bar and everything I clicked was recognized as clicked a couple dozen pixels above what I was actually pointing at.

This seems to be a known problem for LibreOffice with OpenGL and high DPI / high font scaling, maybe specifically in conjunction with my Intel HD Graphics / IGPU.

The fix is fairly easy but difficult to find out on your own:

  1. Make sure that no LibreOffice application is running.
  2. Open the LibreOffice OpenGL blacklist configuration file with a text editor, usually found at C:\Program Files\LibreOffice 5\share\opengl\opengl_blacklist_windows.xml.
  3. Inside the block enclosed by the <blacklist> tag, add the following block:
    <entry os="all" vendor="intel">
        <device id="all"/>
    </entry>
  4. Save and start a LibreOffice application to check.

This should do it!

Thanks for reading!

Source: https://ask.libreoffice.org/en/question/125453/libreoffice-dpi-is-off/