Why you should use Mozilla Firefox

Recently, Microsoft announced that it will base future versions of its Edge browser on the Chromium web engine (Blink, which also powers Google Chrome). The linked blog post states:

Making the web better through more open source collaboration

blogs.microsoft.com

I will not argue against open source collaboration being a good thing, but the web will not be a better place with less browser diversity on the market. Instead, it will likely give Google Chrome an even more dominating position, because Edge will just become another boring Chrome clone. The situation gives much power to just one browser engine, which in turn will cause web development to focus more on this single implementation and less on compatibility and standards-compliance. I think standards are hugely important to keeping the web open and accessible for all, and I strongly dislike browser engine monopolies. Web publishing needs diversity in applications which consume, process and present the data, as a force that pulls it towards agreed upon and open standards.

Sometimes I encounter web applications and sites which are developed solely to work with Chrome, because “everybody uses Chrome” (or it’s just pure developer ignorance). That’s very unfortunate and takes us right back to the Internet Explorer web domination period, years ago. Now it’s called Chrome instead. Future Edge users will be using the Chrome engine under the hood, not even realising they will be giving more power to Google.

I’ve used the Mozilla Firefox browser for many years on the desktop, and in recent years also on mobile devices. It’s a personal preference based mostly on the fact that I really appreciate its features, and I dislike Chrome and its close ties to Google. I’ve also realized the importance in supporting diversity through my choices, and supporting independent market players as forces against monopoly.

If you’re a Chrome or Edge user, I encourage you to try Mozilla Firefox, or any other Firefox-based browser. It has a healthy focus on user privacy, and it is not developed by Google or Microsoft. It works great on mobile platforms as well. By using it, you are contributing to keeping the web open and accessible.

Final note, I am not in any way sponsored by the Mozilla Foundation, the opinions expressed here are solely my own.

Wasteful coinputing

The Bitcoin network consumes a significant portion of world’s energy to produce nothing but hot air and lucky winners. What a waste.

Stop right there, OMG block chain is cool right ?! Sure, I find the concept of a transparent distributed block chain, cryptographic verification and decentralized consensus interesting theoretically, but this post has less to do with theory and more to do with unfortunate consequences of applying the tech in practice. The system just isn’t good enough when a huge energy waste is an important aspect of maintaining network trust, security and integrity.

So, what’s up with all those electrons driving the Bitcoin* business ? In short, Bitcoin mining nodes compete to produce the next valid global block of transactions by hashing some random number along with other permutable details. There are specific requirements to what makes the resulting hash number valid (level of difficulty), which makes the process computationally expensive. In other words, making a valid next block that the network can accept requires effort and time (typically a fixed average amount of time is targeted). So when a miner presents her shiny new block, its validity is proof of work (and proof of wasted energy). Checking for validity is easy, producing a valid block is hard. This throttles the rate at which new transaction blocks can be created, which is important to prevent hostile take-overs, spamming, etc. Defining the next block of facts cannot be free, otherwise, anyone could claim to hold the truth in a much too easy manner.

*..or whatever-coin with similar properties, really.

So, for the network to agree on new blocks, a lot of energy is required.  Clean energy ? Hardly, with over half of the world’s energy production coming from coal, oil and gas. Bitcoin mining is consuming power at the scale of entire countries. Terawatt-hours worth per year. Close to 500 kilowatt-hours per transaction, at the time of writing. And transactions are slow. And most of the computation being performed just goes to waste, as only one valid block will be the next on the chain, and all the losers just get a higher electricity bill.

A Norwegian company was called out in the media for terrorizing a whole neighbourhood with cooling machinery noise from a mining operation data center. Statements given by this useless business showed little respect for the people living nearby, a business driven by prospects of financial gain in the crypto coin market using subsidized electrical power. The same business is of course complaining about the Norwegian government considering exclusion of coin mining activities from data center power subsidization. The government absolutely should stop subsidizing such operations.

Stop the madness. If you’re in participating in this crypto currency scheme in the hope of becoming rich and “happy”, think about all the negative consequences and evident shortcomings of current applications.

Just /quit #Bitcoin.

References

  • https://digiconomist.net/bitcoin-energy-consumption
  • https://en.wikipedia.org/wiki/World_energy_consumption


Run shell script as different user with proper argument handling

So you have a shell script which needs to drop or modify its privileges by switching to an appropriate system user before continuing its execution.

Here are some alternatives to accomplish this while preserving all original command line arguments properly. Privileges are dropped by switching to the nobody user, adapt the RUN_AS variable as desired.

Alternative 1 – using only su, requires being root (uid 0) or the target user to run
#!/bin/sh

# This script must run as
RUN_AS=nobody

if [ `id -nu` != $RUN_AS ]; then
    if [ `id -u` -ne 0 ]; then
        echo >&2 "Sorry, you must be either root or $RUN_AS to run me."
        exit 1
    fi

    # This environment variable is just a safe guard for endless re-exec loop
    # and something the script can use to test up to this point if it has
    # dropped privileges by re-executing itself
    if [ "$EXEC_SU" ]; then
        echo >&2 "Re-exec loop circuit breaker engaged, something is wrong"
        exit 1
    fi

    exec su $RUN_AS -s /bin/sh -c "EXEC_SU=1 \"$0\" \"\$@\"" -- "$0" "$@"
fi

# At this point, we can be sure we are running as the desired user.
echo Running as `id -nu`
for arg in "$@"; do
    echo Argument $((n=n+1)): $arg
done

This alternative requires being root or the target user when invoking the script. Command line arguments are preserved after switching.

Alternative 2 – using sudo
#!/bin/sh

# This script must run as
RUN_AS=nobody

if [ `id -nu` != $RUN_AS ]; then
    if [ -z "$SUDO_EXEC" ]; then
        exec sudo -u $RUN_AS SUDO_EXEC=1 "$0" "$@"
    else
        echo >&2 'Re-exec loop circuit breaker engaged, something is wrong'
        exit 1
    fi
fi

# At this point, we can be sure we are running as the desired user.
echo Running as `id -nu`
for arg in "$@"; do
    echo Argument $((n=n+1)): $arg
done

Unlike alternative 1, this method does not require the script to be invoked by root or the target user directly, if switching to a system user that typically has no password set on its own. (Su will also prompt for password automatically, but that requires the target user password.)

Alternative 3 – when a clean login environment is required

If you require the script to run in a clean login environment for the target user, then things become slightly more complicated. It can be accomplished by combining sudo with su:

#!/bin/sh

# This script must run as
RUN_AS=nobody

if [ `id -nu` != $RUN_AS ]; then
    if [ -z "$SUDO_SU_EXEC" ]; then
        exec sudo su -s /bin/sh - $RUN_AS -c "SUDO_SU_EXEC=1 \"$0\" \"\$@\"" -- "$0" "$@"
    else
        echo >&2 'Re-exec loop circuit breaker engaged, something is wrong'
        exit 1
    fi
fi

# At this point, we can be sure we are running as the desired user.
echo Running as `id -nu`
echo USER=$USER HOME=$HOME 
for arg in "$@"; do
    echo Argument $((n=n+1)): $arg
done

Note that since the example above switches to nobody, which is a system user that by default does not have a shell configured, we explicitly set the shell using su argument "-s /bin/sh".