Linux Magazine USA - Issue 266 January 2023
Linux Magazine USA - Issue 266 January 2023
FR D
+
DV
EE
Go wireless with Bluetooth
Generative
Adversarial
Networks
Forged art and imaginary
faces: Computers teach
computers to lie
ON THE COVER
23 Overlay Networks 46 Lynis
The TOR network isn’t the only game in Check for vulnerabilities from the
town. We round up some popular tools command line.
for safer surfing.
62 ReportLab and Panda3D
37 catgets We show you how to build your own
Add foreign language support to your 3D game.
Linux application.
70 Bluetooth LE
40 Logseq Wireless communication with your
Keep your thoughts and notes in good order. Raspberry Pi.
78 LibreWolf
LibreWolf, a modified Firefox-based web browser,
simplifies configuration and stops malware and spying.
IN-DEPTH
82 RustDesk
46 Lynis For a long time, TeamViewer and AnyDesk dominated
The complexity of modern Linux distributions offers many the remote maintenance software market. Recently, a
potential attack vectors. Lynis lets you find these new player entered the scene in the form of the free
vulnerabilities before an attacker does. and GPL-licensed RustDesk.
MakerSpace
62 ReportLab and Panda3D
A game of bingo illustrates how to use the ReportLab
toolkit and Panda3D real-time 3D engine.
70 Bluetooth LE
Bluetooth Low Energy is ideal for networking battery-powered
sensors. We show you how to use it on the Raspberry Pi. TWO TERRIFIC DISTROS
SEE PAGE 6 FOR DETAILS
DOUBLE-SIDED DVD!
95 Back Issues | 96 Events | 97 Call for Papers | 98 Coming Next Month
The good news is, i486 hardware is pretty irrelevant at this point and anyone still
depending on such hardware is on borrowed time anyway. In fact, i486 hardware is
pretty much considered a relic of days gone by. However, that doesn’t mean it’s
completely vanished from sight.
Torvalds received a bit of pushback from the statement, as such hardware is still
being shipped. And given that i486 is still the listed minimum requirement for most
Linux distributions and is well accepted by lightweight Linux distributions such as
Tiny Core Linux, the idea might get enough flack that it could be set aside for an-
other year.
However, if Torvalds has his way, the writing is definitely on the wall and i486
support in the Linux kernel will eventually be dropped.
This all might well come down to cmpxchg8b, which is directly tied to the Pentium
F00F bug. The issue might simply become a matter of security. And given how
much work goes into the Linux kernel (and how complicated it has become), it
wouldn’t surprise me in the least if i486 hardware is dropped for this reason alone.
This release also has better support for Intel’s new Gaudi2 AI accelerator chip,
EUFI support for LoongArch CPUs, and more.
However, Linus Torvalds hasn’t been 100 percent happy with how things have
been going. Prior to the RC release, he made a very pointed statement about devel-
opers pulling all-nighters to meet deadlines.
On that issue, Torvalds said, “that should have gone out the window after high
school. Not for kernel development.”
Read more about the announcement in a message from Linus Torvalds on the Linux
Kernel mailing list (https://lkml.iu.edu/hypermail/linux/kernel/2210.2/00359.html).
“WARN() Should never be used just be- returning an error like -ENOSYS for that
cause of laziness. If it is, then that’s a case, for example, but at the same time
bug. Let’s not use that as an excuse to you are ‘If somebody uses this, we should
shoot down this proposal. WARN() perhaps react to it’.
should only be used to test assumptions “In many cases, a ‘pr_warn()‘ is much
where you do not believe something can better. But if you are unsure just _how_
happen. I use it all the time when the the situation can happen, and want a
logic prevents some state, and have the call trace and information about what
WARN() enabled if that state is hit. Be- process did it, and it really is a ‘this
cause to me, it shows something that shouldn’t ever happen’ situation, a
shouldn’t happen happened, and I need WARN_ON() or a WARN_ON_ONCE() is
to fix the code. certainly not wrong.
“Basically, WARN should be used just “So think of WARN_ON() as basically
like BUG. But Linus hates BUG, because an assert, but an assert with the inten-
in most cases, these bad areas shouldn’t tion to be able to continue so that the as-
take down the entire kernel, but for sert can actually be reported. BUG_ON()
some people, they WANT it to take down and friends easily result in a machine
the system.” that is dead. That’s unacceptable.
From this point, the discussion de- “And think of ‘panic-on-warn’ as peo-
scended into implementation details, ple who can deal with their own prob-
with everyone chiming in about ex- lems. It’s fundamentally not your issue.
actly what the behavior should be They took that choice, it’s their problem,
under circumstances X, Y, and Z. At a and the security arguments are pure BS –
certain point, Linus Torvalds offered because WARN_ON() just shouldn’t be
his analysis: something you can trigger anyway.”
“There are only two valid uses for And regarding Alexander’s patch,
panic-on-warn: Linus said “Honestly, I don’t see the
(a) test boxes (particularly VM’s) that point. […] I’d like to hear of an actual
are literally running things like syzbot _use_ case. That’s different. That’s
and want to report any kernel warnings somebody actually _using_ that pkill to
(b) the ‘interchangeable production good effect for some particular load.
machinery’ fail-fast kind of situation […] That said, I don’t much care in the
“So in that (a) case, it’s literally that end. But it sounds like a pointless op-
you consider a warning to be a failure tion to just introduce yet another be-
case, and just want to stop. Very useful havior to something that should never
as a way to get notified by syzbot that happen anyway.”
‘oh, that assert can actually trigger’. The discussion continued briefly. But
“And the (b) case is more of a ‘we without support from Linus, the issue
have 150 million machines, we expect petered out after a short time.
about a thousand of them to fail for any This is a very common occurrence in
random reason any day _anyway_ – kernel development and probably quite
perhaps simply due to hardware failure, common throughout the open source
and we’d rather take a machine down world: Someone has an idea that seems
quickly and then perhaps look at why to address something significant, and
only much later when we have some pat- the only way to raise the issue is to ac-
tern to the failures’. tually code it up and send it out for re-
“You shouldn’t expect panic-on-warn to view. But then having done all that
ever be the case for any actual production work to enable others to join in the con-
machine that _matters_. If it is, that pro- versation, it turns out the true situation
duction maintainer only has themselves is slightly different, and the idea ends
to blame if they set that flag. up being discarded.
“But yes, the expectation is that
warnings are for ‘this can’t happen, Revision Control Theory
but if it does, it’s not necessarily fatal, I Not everyone remembers that Linus Tor-
want to know about it so that I can valds wrote the Git revision control sys-
think about it’. tem like they remember he wrote Linux.
“So it might be a case that you don’t The Git backstory is pretty amazing, but
handle, but that isn’t necessarily _ it’s current story is ongoing. Recently
wrong_ to not handle. You are ok Linus made some comments comparing
Git to other revision control systems and “Again, it’s not that the git model is al- directory and all synchronisation will be
specifically to Darcs – a powerful Git al- ways right – you can obviously have handled on the final server. This helps
ternative by David Roundy. changes that do *not* overlap at all, but hide latency on link from client to server.”
The subject came up when Greg still have a very fundamental semantic Daire Byrne replied with exuberant
Kroah-Hartman submitted a massive conflict, and git will happily merge those enthusiasm, thanking Neil for his work
pull request for a giant pile of kernel things and think it is all good. on this. Daire said, “I’m probably the
driver code coming from dozens of other “So the git model is basically practical main beneficiary of this (NFSD) effort
developers. In submitting the pull re- and straightforward (also ‘stupid’, but in atm so I feel extra special and lucky!”
quest, Greg remarked, “Note, you will a good way – do the common truly obvi- He ran some tests and reported up to a
have a merge conflict in the drivers/net/ ous 3-way merges, don’t try to do any- 40-fold increase in the number of file
wireless/silabs/wfx/sta.c file, please just thing clever when that fails). There’s no creations per second he could achieve,
take the change that came in from the ‘theory’ behind it that might turn out to from 2.4 per second, to up to 121 per
wifi tree. We thought as I had pulled the be completely wrong.” second. He posted some additional
same merge point from the wifi develop- To which Greg replied, “That makes numbers. There were some problems
ers this type of conflict wouldn’t have more sense now, git is being ‘safe’ by remaining, but Daire concluded, “all in
happened, but for some reason git flags asking for the developer to look and re- all, the performance improvements in
it as something to pay attention to and solve it themselves. Thanks for the the knfsd re-export case is looking
couldn’t resolve it itself.” explanation.” great and we have real world use cases
Linus replied: And that was the end of the that this helps with.” In addition, he
“That ‘some reason’ is because the net- conversation. offered to do more testing for the re-
working tree made other changes to the maining difficult cases.
file since (ie commit 2c33360bce6a: ‘wfx: Concurrent Directory Neil was very happy for the feedback
use container_of() to get vif’). Updates and posted some updated patches to ad-
“So both branches had done the same The Virtual Filesystem (VFS) is the cen- dress some of the problems Daire’s tests
change (the merge), but one branch had tral, core, generic filesystem code within had uncovered.
then done other changes on top of that the kernel, around which all other file- Anna Schumaker and Daire both
same change. systems revolve. All filesystems interact started testing the new patches on their
“Broken SCM thinking then thinks that with the VFS to provide their special systems, and both reported some further
means that ‘oh, then we obviously have data-storing features, and all applica- timing data. Neil was thrilled to have
to take the extra change’ (eg darcs ‘patch tions interact with the VFS to access all more testers and posted additional
algebra’), and make that the basis of that stored data. patches addressing the issues they had
their resolution strategy. It’s not actually A major goal of the VFS is to provide uncovered.
a valid model, because it just assumes as fast as possible communication be- At one point, Daire said, “This patch
that the additional patches were right. tween applications and the data on the does the job for me – no more stack
Maybe there was a _reason_ that extra underlying filesystems. Recently, Neil traces and things have been stable all
patch wasn’t done in the other branch? Brown asked folks to discuss an issue he day. I’m going to run some production
The extra patch might have been due to had noticed in the VFS: loads over the weekend and then I’ll do
particular issues in that branch, you “VFS currently holds an exclusive lock some more artificial scale testing next
can’t just make the darcs assumption of on a directory during create, unlink, re- week. Thanks again for this work! Im-
reordering patches and taking some name. This imposes serialisation on all proving the parallelism anywhere we
union of them (which is an over-simplifi- filesystems though some may not benefit can for single clients and then nfsd is
cation of the patch algebra rules). from it, and some may be able to provide great for reexport servers (especially
“Now, that’s not to say that git can’t finer grained locking internally, thus re- once you add some ‘cloud’ latency).”
get things wrong too when resolving ducing contention. There was no further discussion, just
things. But at least it doesn’t make some “This series allows the filesystem to re- a few more test results. This does not
fundamental mistake like that. quest that the inode lock be shared rather necessarily mean the code will go into
“The git rules are basically that it will than exclusive. In that case an exclusive the kernel – it still has to pass through
resolve changes that aren’t overlapping, lock will be held on the dentry instead, Al Viro’s gauntlet because he main-
using the traditional 3-way model (it much as is done for parallel lookup. tains the VFS code and will want to be
then has that whole ‘recursion and re- “The NFS filesystem can easily support sure there are no new problems intro-
name detection’ thing, but that’s more of concurrent updates (server does any duced by the patches. In any event,
a higher-level metadata thing separate needed serialisation) so it is converted. Neil isn’t actually submitting the code
from the actual code merge). “This series also converts nfsd to use yet; he’s just requesting comments.
“So git doesn’t assume any ‘seman- the new interfaces so concurrent incom- However, it does seem very likely that
tics’ to the changes. If it sees that two ing NFS requests in the one directory can this code or something like it will go
branches changed the same code in dif- be handled concurrently. into the VFS at some point in the near
ferent ways, git will go ‘this is a con- “As a net result, if an NFS mounted file- future, just because there are filesys-
flict’, and leave it to human (or system is reexported over NFS, then multi- tems like NFS that do seem to show a
scripted) intervention. ple clients can create files in a single significant benefit from it. Q Q Q
M
achine learning models that could recognize objects His plan required two networks, the generator and the dis-
in images – and even create entirely new images – criminator, interacting as counterparts. The best way to under-
were once no more than a pipe dream. Although stand this idea is to consider an analogy. On one side is an art
the AI world discussed various strategies, a satisfac- forger (generator). The art forger wants to, say, paint a picture
tory solution proved illusive. Then in 2014, after an animated in the style of Vincent van Gogh in order to sell it as an original
discussion in a Montreal bar, Ian Goodfellow came up with a to an auction house. On the other hand, an art detective and a
bright idea. real van Gogh connoisseur at the auction house try to identify
At a fellow student’s doctoral party, Goodfellow and his forgeries. At first, the art expert is quite inexperienced, but the
colleagues were discussing a project that involved mathe- detective immediately recognizes that it is not a real van Gogh.
matically determining everything that makes up a photo- Nevertheless, the counterfeiter does not even think of giving
graph. Their idea was to feed this information into a ma- up. The forger keep practicing and trying to foist new and bet-
chine so that it could create its own images. At first, Good- ter paintings off on the detective. In each round, the painting
fellow declared that it would never work. After all, there looks more like an original by a famous painter, until the detec-
were too many parameters to consider, and it would be hard tive finally classifies it as genuine.
to include them all. But back home, the problem was still on This story clearly describes the idea behind GANs. Two neural
Goodfellow’s mind, and he actually found the solution that networks – a generator and a discriminator – play against each
same night: Neural networks could teach a computer to cre- other and learn from each other. Initially, the generator receives
ate realistic photos. a random signal and generates an image from it.Combined with
earlobes that do not really match. Sometimes irregularities ap- datasets. The GAN can then mime new movements on the ac-
pear in the background, too. The AI doesn’t really care about tors’ faces to match the lip-synched speech.
the background because it is trained to create faces. But this is just a small teaser of what GANs could do in the
context of movies. In various projects, researchers are working
GANs and Moving Images on resurrecting the deceased through AI. For example, develop-
Faces are also the subject in another still fairly unexplored ap- ers at MIT resurrected Richard Nixon in 2020, letting him be-
plication for GANs, the movie industry. Experts have long rec- moan a failed moon mission in a fake speech to the nation [7].
ognized the potential of GAN technology for film. It is used, for The same method could theoretically be applied to long-de-
example, to correct problematic blips in lip-synched series or ceased Hollywood celebrities.
movies. The actors’ facial expressions and lip movements often
do not match the dialog spoken in another language, and the GANTheftAuto
audience finds this dissonance distracting. The traditional way to develop computer games is to cast them
GANs and deep fakes solve the problem. Deep fakes replace in countless lines of code. Programming simple variants does
the facial expressions and lip movements from the original re- not pose any special challenges for AI. A set of training data
cording. To create deep fakes, application developers need to and NVIDIA’s GameGAN generator[8], for example, is all you
feed movies or series in a specific language into training need for a fully interactive game world to emerge at the end.
The Pacman version by an NVIDIA AI, or an Intel model that
can be used to implement far more realistic scenes in video
games demonstrate how far the technology has advanced.
However, this by no means marks the limits of what is possi-
ble. In 2021, AI developers Harrison Kinsley and Daniel Kukiela
reached the next level with GANTheftAuto [9] (Figure 5). With
the help of GameGAN, they managed to generate a playable
demo version of the 3D game Grand Theft Auto (GTA) V. To do
this, the AI – as in NVIDIA’s Pacman project – has to do exactly
one thing: play, play, and play again.
Admittedly, the action-adventure classic game is far more
complex with its racing and third-person shooter influences.
The training overhead increases massively with this complex-
ity, which is why Kinsley and Kukiela initially concentrated on
a single street. They had their AI run the course over and over
again in numerous iterations, collecting the training material it-
self. While doing so, GameGAN learned to distinguish between
the car and the environment.
The bottom line: GANTheftAuto is still far removed from the
Figure 4: NVIDIA’s StyleGAN delivers such good graphical precision of full-fledged video games, but it is worth
results that viewers often can’t tell if it’s a real per- watching and likely to be trendsetting. At least the AI managed
son or not (Source: thispersondoesnotexist.com). to correctly copy details such as the reflection of sunlight in the
rear window or the shadows cast by the
car from GTA V. And it reproduced them
correctly, as Kinsley explains in a demo
video on YouTube [10].
Resources
As you can probably guess, a system of
two adversarial neural networks is a
complex thing, and programming one
from scratch is a difficult road unless
you have considerable experience with
AI. Still, several resources are available
for those who wish to further explore
this fascinating field.
First of all, Ian Goodfellow’s original
GAN code is still available on GitHub
[11], and you are free to download it
yourself and experiment. The code is
mostly in Python, and the authors in-
Figure 5: By running through a road section in GTA V over and over clude the following note: “We are an ac-
again, the AI generates a visually realistic demo (Source: YouTube). ademic lab, not a software company,
Puppy Linux
L
ast issue, I described the com- examining how the sub-projects differ might help users trying to decide which
plexities of Puppy Linux [1], with from each other. This month, I am rem- one to use.
help from project members. Un- edying that lack with a brief look at All the Puppy distributions on the
like most distributions, Puppy is a some of the most popular Puppy distri- home page [2] share certain features:
collection of sub-projects, and explain- butions and how they differ from each • They all are built with woof-CE, which
ing the structure left no room for other. My hope is that this information builds a distribution using another dis-
tribution’s binary. Several official
Puppy distributions are based on long-
term suport (LTS) releases of Ubuntu,
but are quite different from each other
in their selection of desktops and
packages.
• They all use a standard installer that
allows a Frugal install, to a single di-
rectory, or a Full install, which uses an
entire filesystem. A Frugal install is
recommended because it allows Puppy
to coexist with other operating sys-
tems on the same partition.
• They all load system files into RAM.
• They all encrypt personal files.
Photo by Nicole Romero on Unsplash
BionicPup
BionicPup (Figure 3) is another variant
of FossaPup. Besides being based on
Ubuntu 18.04, its main difference is that
it features a dock on the desktop. Like
XenialPup, BionicPup is supposed to be
for severe video problems, but in prac-
tice, it seems less erratic than XenialPup.
The default apps include several larger
Figure 2: At first boot, XenialPup offers to create a root password. apps such as Inkscape. As you log out
for the first time, BionicPup also offers
installer. To keep the memory used to a the Boot Manager, BeeDiff, and Pup- an experimental option of enabling a
minimum, many also provide a link for Save are well worth investigating. regular user account called finn – some-
installing LibreOffice in the menu thing that is not done automatically on
rather than installing it by default. Be- XenialPup most Puppy distributions.
sides the choice of widgets, themes, XenialPup resembles FossaPup, al-
and desktops, the selection of applica- though it is built with Ubuntu 16.04 Slacko Puppy 7.0
tions is often one of the major differ- (Xenial Xerus). It shares FossaPup’s Two versions of Slacko Puppy are
ences between Puppy distributions. arrangement of desktop icons, but it among Puppy’s official distributions,
The Puppy Linux distributions covered does not include the system widgets with the Slacko Puppy 7.0 being the
here are all official distributions main- on the desktop. Unlike FossaPup, Xe- most recent. Built on Slackware 14.2,
tained by the project [2], with the ex- nialPup has a crowded bottom panel. Slacko runs a MATE/Gnome 2 desktop.
ception of Vanilla Dpup [3], which is At first login, XenialPup offers the op- Although its default browser is Firefox,
an unofficial distribution (or puplet) tion to create a root password Slacko Puppy’s menu contains links for
maintained by the community.
FossaPup
FossaPup receives a lot of attention be-
cause it is the first distribution listed
on Puppy’s home page. Usually, a re-
view of Puppy is actually a review of
FossaPup, even though it is not partic-
ularly representative of the rest. Built
with Ubuntu 20.4 (Focal Fossa) and
using Joe’s Window Manager (JWM),
FossaPup installs with icons on the
desktop, grouped together in related
rows. A widget on the right of the
desktop shows system information
(Figure 1). FossaPup’s selection of
apps favors those with a small foot-
print, such as Gnumeric and AbiWord.
While LibreOffice Writer and Calc are
installed by default, Draw, Impress,
and Math are not. Many other default
apps are probably new to the users of
major distributions, although ones like Figure 3: BionicPup offers to set up a root and single-user account.
Info
[1] “Distro Walk – Puppy Linux: Running with the Pack” by
Bruce Byfield, Linux Magazine, issue 265, December
2022, pp. 30-32
Figure 4: Slacko Puppy is perfect for those who want to [2] Puppy Linux: https://puppylinux-woof-ce.github.io
heavily customize their installation. [3] Vanilla Dpup: https://vanilla-dpup.github.io
Tahrpup
With a desktop resembling FossaPup’s,
Tahrpup is based on Ubuntu 14.4 (Trusty
Tahr). It installs a moderate number of
default applications, many of which are
not found outside of Puppy distributions.
Like XenialPup, Tahrpup’s mouse is er-
ratic before being adjusted (Figure 5).
Figure 5: Like many Puppy distributions, Tahrpup is built using an
Vanilla Dpup Ubuntu LTS release.
Vanilla Dpup is built on Debian 11 and
uses a modified MATE/Gnome 2 desktop
environment. It installs a minimum of
default applications, which includes
Firefox, but leans towards utilities and
lighter tools like the Sylpheed email
browser. The first thing you will proba-
bly want to do after installing Vanilla
Dpup is to open the Default Applications
Chooser and select your preferred word
processor, spreadsheet, and utilities from
the drop-down lists (Figure 6).
Adopting a Puppy
The Puppy home page would benefit from
brief descriptions like these to give new-
comers some guidance. Instead, the gen-
eral attitude is that newcomers should just
jump in and try different Puppy variants. Figure 6: Based on Debian, Vanilla Dpup is an unofficial Puppy distribu-
However, that outlook is not as indifferent tion that leaves the selection of packages largely up to the user.
Keeping Secrets
An overlay network will help you block unwanted eavesdroppers on the Internet. We show you
some of the leading open source options. By Erik Bärwaldt
G
overnment surveillance, attacks on VPNs, depend on peer-to-peer con- log any user data. In addition, eVenture
by criminals, and tracking by nections that do not require centralized has had security audits performed by in-
the advertising industry are servers, which makes it far more diffi- dependent third-party vendors [2]. On
raising concerns about the secu- cult for attackers and authorities to ac- Linux, hide.me uses the modern Wire-
rity and anonymity of user data. These cess user data. Guard protocol by default in combina-
concerns are amplified in professions tion with fast ChaCha20-Poly1305 en-
where the user is legally responsible for hide.me cryption. In addition, you can download
securing communication. Several free The hide.me [1] VPN solution originates the hide.me source code for free on
projects have addressed these concerns from Malaysia. The provider, eVenture GitHub.
by offering innovative technical ap- Ltd., offers several subscription models The free hide.me variant offers limited
proaches to anonymizing data. We de- for using the service and makes clients functionality. For example, your choice
cided to take a look at a few of the lead- available for download across platforms. is limited to five server locations, and
ing solutions. For Linux, there is currently only a CLI the data volume is limited to 10GB per
Anonymized networks establish tun- client. On top of this, hide.me can also month. In addition, the free account
neled and encrypted connections be- be used as a browser extension for only allows you one VPN connection.
tween individual nodes, ruling out typi- Firefox and Chrome-based web brows- The commercial offering eliminates
cal attack vectors, such as man-in-the- ers. The VPN network consists of more these restrictions, offers a static IP ad-
middle attacks. In the process, these an- than 2,000 servers in over 75 interna- dress option, and also supports stream-
Lead Image © kanokpol prasankhamphaibun, 123RF.com
onymization solutions build a two-way tional locations. To use the service, you ing services like Netflix. A kill switch
point-fixed overlay network through first need to register. All you need is a and split tunneling are available on
which the participants exchange data. valid email address, which you can use Linux. (Split tunneling allows access to
These solutions support common trans- to create and activate an account. You the Internet beyond the VPN tunnel.)
port protocols, such as UDP or TCP, as can define the username and password To install the Linux app, go to hide.
well as the Internet layer protocols IPv4 individually. me’s GitHub page and download the
and IPv6. In some cases, BitTorrent and Hide.me attaches great importance to TAR.XZ archive intended for your hard-
blockchain technologies are also used to security features. For example, eVenture ware architecture. Hide-me supports 32-
enable distribution of data blocks. operates its own DNS servers, avoiding and 64-bit PCs, as well as ARM-based
All solutions for anonymized Internet the kind of DNS leaks that you otherwise systems. Unpack the downloaded ar-
are based on decentralized structures. occasionally encounter. eVenture also chive, and install the client in a termi-
Many of the solutions, with the excep- adheres to a strict no-log policy and, ac- nal window with root privileges using
tion of the Tor network and those based cording to its own statement, does not the ./install.sh command (Figure 1).
During the install, the routine prompts applications, such as email clients or as a proxy between applications and the
you for your registration data, so you messengers, are not. I2P network. The Java application re-
need to register with the provider up quires an appropriate runtime environ-
front. After the install, start the VPN I2P ment on the system, although it also
manually by setting it up as a systemd The Invisible Internet Project (I2P) [3] works with the free OpenJDK Java im-
service using the commands in Listing 1. network uses a peer-to-peer approach to plementation.
Replace the Server placeholder with a lo- connect computers. This method in- On Ubuntu, Debian, and their deriva-
cation such as amsterdam-1 or a country volves establishing one-way, tunneled tives, you can install I2P directly from
suffix such as nl. After that, hide.me will overlay connections over the Internet. the repositories; this immediately en-
create the tunnel, and you will be able to Data packets are transported between ables a script to start I2P automatically
use the Internet through the VPN. client computers via routers (known as at system boot time. In addition, you can
Because hide.me is integrated with nodes), with each client having its own integrate your own repository into the
systemd, the VPN is automatically en- cryptographic identifier. The I2P network system; this will be used for automatic
abled whenever you reboot your com- uses its own DNS server to distribute updates later. The developers explain the
puter. You can use the stop and disable content on the network. The individual exact procedure on the project page.
systemctl parameters to disable the VPN connections are end-to-end encrypted, I2P can also run in headless mode –
tunnel at any time. which prevents third parties from view- without a graphical interface. This op-
Although a graphical desktop client is ing the data. tion is especially useful for servers. For
available for other operating systems, Traffic to the regular Internet is han- container environments, a Docker pack-
Linux has so far had to make do with the dled by proxy servers operated by volun- age is available from Docker Hub. The
command-line client. This unnecessarily teers. These proxies are the only central- I2P source code is available for down-
complicates operation, because the con- ized components on the I2P network. All load from the website.
venient server change feature in the routers have their own cryptographic To connect the computer to the I2P
graphical front end is not available. identity. Routing and contact informa- network, enter the i2prouter start com-
Other convenient features are also miss- tion is maintained with the help of a net- mand at the prompt after installation.
ing from the Linux client, which is still work database, which special routers You don’t need administrative rights.
in beta. The hide.me installation script called floodfill routers distribute on the The routine now launches a web
additionally generates private and public network. The I2P network is self-con- browser and opens the I2P router’s con-
keys and manages the key exchange tained and is not used to pass data pack- figuration interface in it. When you get
using HTTPS. Only the client offered by ets to and from public servers. to the interface, first change a couple of
the manufacturer can be used with the For operation within the network, you settings; the I2P Router Console then
hide.me VPN. will find applications like the i2psnark starts up (Figure 2).
However, hide.me does at least sup- BitTorrent client and the I2P messenger, The I2P Router Console has three
port use in web browsers like Firefox, which also do without a server. With the panes: On the far left, you will find
Chrome, and their derivatives. The dis- help of an embedded application, tradi- some statistical data on the the network
advantage of this solution is that, al- tional TCP/IP applications such as SSH access status, the available bandwidth,
though all activities in the web browser or IRC can be tunneled via I2P. and the established tunnel. Bottom right
are then secured by the VPN tunnel, To integrate a client into the I2P net- is a list of the various applications on
data transfers originating from other work, install the I2P router, which acts the I2P network, as well as a list of vari-
ous community sites, some of which
also provide support. Top right, an info
segment shows you the further steps for
configuring the router. In the back-
ground, the system has already found
some other I2P routers.
It is a good idea to adjust the existing
bandwidth first, because it is very low
by default. Click the configuration page
link at the top of the Info section. You
will now be taken to a page with nu-
merous options; the Bandwidth dialog
is already open. Click on the Band-
width Test link to discover the band-
width of the Internet connection, and
Figure 2: The I2P Router Console allows for convenient graphical administration.
then set the optimal bandwidth for I2P contacted and the subscriber tunnels on the I2P network. However, following
(Figure 3). Once you have adjusted the that the system has established. Band- the links on the router console – and the
bandwidth and saved it by pressing width classes are also specified for links that let you search for other avail-
Save Changes bottom right, the changes each connection. able programs – only generates error
you have made will appear at the top of In the I2P services category, you can messages. You need to install the I2P
the window. call the services handled directly by the messenger client manually.
More detailed links will now also ap- I2P network. Apart from BitTorrent, this To harmonize your web browser with
pear in the bar on the far left; you can also includes the integrated web server, the I2P network, you need to change its
use them to customize various addi- which you can use to create and distrib- proxy settings. To do this, adjust the
tional options. For example, shared cli- ute anonymized web pages. HTTP proxy in Firefox’s settings dialog
ents in the Local Tunnels category There are two email clients in the form (Figure 4). Then go to the advanced set-
gives you detailed information about of Susimail and I2P messenger that let tings, which you can access by typing
the floodfill routers your system has you send and receive anonymized emails about:config in the URL bar, and change
Figure 3: The I2P network lets you manually configure the bandwidth to use for your node.
the value for media.peerconnection.ice. of files and web pages [4]. IPFS, estab- browser add-on that makes IPFS data
proxy_only from false to true. lished in 2015, relies on the peer-to-peer available. The browser extension only
principle and is free software. Central- acts as a gateway without providing the
IPFS ized services such as DNS or individual full functionality of the overlay network.
The InterPlanetary File System (IPFS) is web servers do not exist, making distrib- Some Linux distributions already have
primarily used for decentralized storage uted denial-of-service (DDoS) attacks on IPFS binary packages in their reposito-
these services im- ries. You can also obtain a precompiled
possible on an binary package for the IPFS desktop
IPFS network. from GitHub [5]. In addition to RPM and
IPFS stores files DEB packages, AppImage and Snap ar-
and web pages in chives are also available. Development
a decentralized work on these packages is very active, so
way as blocks on it makes sense to get the latest package.
numerous individ- After completing the install, you will
ual nodes, which find a launcher for the IPFS desktop in
protects the infor- the menu of your desktop environment.
mation against Clicking on the launcher opens a native
censorship and de- graphical front end for managing your
letion attempts. own IPFS instance and, at the same
The data is named time, establishes access to the IPFS net-
using hashes that work. The graphical interface (Figure 5),
also change when with its state-of-art design, displays sta-
a file is modified. tistics for your own IPFS node in the
You can use IPFS main area of the window.
either by installing Once the Status window confirms the
software packages connection to IPFS, you can check out
that connect your the world map (Figure 6) to see the other
computer to the IPFS peers across the globe that your
Figure 4: You need to manually prepare the web IPFS network or node is connected to in the Peers group.
browser for use with I2P. opt for a web The client updates the numbers, the
table, and the bandwidth indicators on most popular search engines for the IPFS transferred data completely hidden from
the Status page more or less in real time. network include Almonit, [6] IPFS- third parties. You can also use Retro-
To post your own files on the IPFS net- Search [7], and IPSE [8]. share over the Tor or I2P network, so
work, click on Files in the sidebar on the even neighboring nodes will not see
left. In the dialog that opens, click Im- Retroshare your IP address.
port and select one of the options listed Retroshare [9], which has been in devel- Retroshare relies on friend lists. The
in the drop-down menu. opment for more than 15 years, is pri- local node with a user’s account can
To add data from the IPFS network, marily used for
you need to know and specify the Con- decentralized file
tent Identifier (CID). To keep data perma- sharing and en-
nently available by mirroring it to other crypted communi-
network nodes, you additionally need to cation. Besides file
pin the data. To pin the data, press the sharing, the pro-
button with the three dots. In the context gram focuses on
menu, select the Set pinning option. services such as
To pin the data to your local mass stor- email, instant
age, check the box to the left of the Local messaging, and
node option and then press Apply. The feed readers.
file is now on your local mass storage All of these ser-
and can be retrieved via the known CID vices do without
after shutting down and restarting the central servers
daemon. Alternatively, you can keep and use OpenSSL
data available at all times using a pin- and asymmetric
ning service like Eternum or Pinata. encryption based
There are special search engines to on OpenPGP. This
help you find data on the IPFS network. end-to-end en-
They are still under construction, but cryption keeps the Figure 7: When Retroshare launches for the first
they already provide useful results. The contents of the time, a profile is generated.
connect to another node only if the re- envelope on a blue background appears Please note that participating nodes
mote node is entered in the friend list. in the system tray, which gives you must use the latest version 0.6.6 Retro-
Arch Linux, Slackware, Solus, and quick access to the Retroshare window share, which is the first release in which
Void Linux come with Retroshare in at the push of a button. the Retroshare ID replaces the conven-
their package sources. On Retroshare’s At first glance, Retroshare’s interface tional certificates used up to now. Mix-
website, you will find additional in- resembles a conventional email pro- ing old certificates and new retroshare
structions for installation on many gram: A small pane contains various IDs will not work and will result in an
other Linux derivatives, as well as a folders and below that is a quick view error message.
cross-distribution AppImage package. with different attributes for labeling the After adding your friends to your Ret-
You can also pick up a Flatpak from inputs. Messages received appear in roshare instance, there are unlimited
Flathub. In addition, Retroshare runs on two large window segments on the possibilities for communicating through
the Raspberry Pi. Provided you install right, and a buttonbar below contains the system. Retroshare automatically
with a binary package customized for controls and a view field for the mes- transfers any registered friends to the re-
your choice of distribution, the routine sages. A status bar at the very bottom spective contact lists. One specific ad-
will create a starter in the menu of the provides information about the received vantage of Retroshare is that, unlike cen-
desktop environment. and uploaded data. tralized, web-based forums, the forum
Retroshare comes with a sophisticated The buttonbar located horizontally at function lets you compose your posts of-
graphical interface and an initial setup the top of the screen opens up the full fline. They are automatically displayed
wizard. For the setup wizard, you first functionality of the application. You can in the forum after logging in again.
need to specify whether the machine use it to access the various communica- The file-sharing feature works in a
will act as a default node or as a hidden tion modules such as chat, email, data similar way to the BitTorrent service,
node within the Retroshare network on transfer, forums, and contacts. with Retroshare transferring files across
the Tor network. You also create a user To use Retroshare, you need to invite multiple nodes in blocks. This makes it
account in the start-up screen. The bar friends who are also part of the Retro- easy to share even very large files, and
in the lower part of the window shows share network by exchanging Retro- the individual nodes do not have to be
the progress (Figure 7). share IDs. directly connected to each other. But
Press the Go! button to start Retro- Pressing Home in the user interface re- when a transfer relies on multiple nodes,
share. Two separate windows then open. veals your own identifier; below that all of the nodes need to be running or
In addition to the application window, you can add a friend to your installation the file transfer will fail.
Retroshare displays an information win- by clicking on Add friend. The friend However, you can also use the chat or
dow telling you how to get started. At must have sent you their Retroshare ID the email function for file transfer – as
the same time, an icon with a white (by email, for example). long as the files are not too large. In both
chat and email, you will find a paper clip
icon, which opens a file manager from
which you can select the files you want
to attach. Retroshare then attaches the
files to the content for dispatch.
Tor Network
The Tor network is the best known net-
work for anonymized communication
[10], dating back to the 1990s. At the
end of 2002, the Tor network was re-
leased for general use for the first time.
Its now very high profile due in no small
part to the Tor Browser, which is based
on Mozilla Firefox and uses the Tor net-
work for Internet access. In addition, the
Tor network provides access to the Deep
Web and also to the Dark Web.
The Tor network operates with thou-
sands of servers through which it routes
all traffic. Data packets pass through
three servers, known as relays. The re-
lays work in a similar way to proxies,
with the data path constantly changing.
Instead of fixed cascades, variable paths
are used. In addition, the data is fully
Figure 8: You can view and modify the routes your data takes in the Tor encrypted.
Browser.
Due to the encryption mechanism, would with any regular web browser. files with the greatest possible anonym-
which cryptographically processes the You can see the specific route taken by ity, others focus on anonymous browsing
data multiple times, this type of data the web pages opened in the browser by on the conventional Internet. Others
transfer is also called onion routing. clicking the icon with the padlock on have embraced truly anonymous com-
Step-by-step encryption prevents track- the left in the URL bar. In an overlap- munication using conventional technolo-
ing of data packets, because each node ping small window, you will then see gies such as email, chat, or IRC.
only performs one encryption step. Un- the three nodes through which the data What all overlay networks have in
less additional end-to-end encryption is routed (Figure 8), with the entry common is that they actually make it
of the data is enabled, only the last server highlighted as the guard. This more difficult to inject malicious or spy
node sees the transported data packets server remains the same for a few code into the individual applications
in the clear [11]. months, while the other two relays thanks to free licenses and the resulting
The Tor Browser further increases the change for each new web page you ac- free availability of the source code. As a
user’s anonymity by providing different cess. However, if necessary, you can user, however, you need to investigate in
levels of security. By default, the HTTPS switch the last two relays for each open detail each overlay network in advance,
Everywhere and NoScript add-ons are web page on the fly by clicking the New especially if you are using the Dark Web,
also enabled. Moreover, the Tor Browser Circuit for this Site button. in order to be sure of obtaining a com-
isolates every web page visited and also The Tor Browser also gives you access munications solution that is truly hard-
blocks the Flash video format, which is a to content hosted on the Tor network. ened against a wide variety of attack sce-
security risk. Besides this, the Tor This content available on the Deep Web narios through a combination of differ-
Browser lets you switch data transfer [12] is not accessible for conventional ent security mechanisms. Q Q Q
routes at the push of a button to provide Firefox variants or other web browsers.
additional security. Although the Tor The Deep Web contains only non-in- Info
Browser is based on and compatible dexed web pages that conventional [1] hide.me: https://hide.me/en/
with Firefox ESR, the developers advise search engines do not list. [2] hide.me transparency reports:
against integrating other plugins into the The often-cited Dark Web forms just a https://hide.me/en/blog/leon-juranic-
browser, as they may contain security small part of the Deep Web, which is dis- certifies-hide-me-as-one-of-the-most-
vulnerabilities. tinguished from it by special additional private-vpn-provider/
The Tor Browser comes with the client cryptographic mechanisms. In this case, [3] I2P network: https://geti2p.net/en/
infrastructure required to connect to the the transmission of hosted data is en- [4] IPFS: https://ipfs.tech
Tor network. You will find countless lan- crypted, and the channels involved for
[5] IPFS on GitHub:
guage variants of it on the project’s web- communication are established through
https://github.com/ipfs/ipfs
site. For all the individual variants, 32- various servers on the Tor network using
[6] Almonit: http://almonit.club/#/
and 64-bit versions are available. hashes. This means that the computers
[7] IPFS Search:
Unpack the downloaded tarball in any involved in the communication remain
https://ipfs-search.com/#/
folder. You will then find the Tor Browser completely anonymous.
launcher in the newly created folder There are various search engines such [8] IPSE: https://www.ipse.io
tor-browser_en/ (for the English lan- as Torch [13] or Candle [14] to help you [9] Retroshare: https://retroshare.cc
guage variant). Double-clicking on it find Deep Web pages on the Tor net- [10] Tor project:
opens the browser and displays a con- work. By default, however, the Tor https://www.torproject.org
nection dialog. In the dialog, press the Browser uses DuckDuckGo, which is [11] Info on onion routing: https://en.
Connect button to connect to the Tor net- also Deep Web-enabled. wikipedia.org/wiki/Onion-Routing
work. Checking the Always connect au- [12] Notes on the Deep Web: https://en.
tomatically option lets you automate the Conclusions wikipedia.org/wiki/Deep_Web
process of opening the connection for fu- Overlay networks on the Internet con- [13] Torch:
ture use of the browser. tribute significantly to anonymous com- https://torchsearch.wordpress.com
The browser opens the DuckDuckGo munication. They target different audi- [14] Candle: https://freedeepweb.
search engine as the home page. You can ences here. While some P2P networks blogspot.com/2019/03/candle-search-
now work with the Tor Browser as you are simply about transferring individual engine.html
QQQ
Detective Work
The MITRE ATT&CK website keeps information on attackers and intrusion techniques. We’ll show
you how to use that information to look for evidence of an attack. By Franciszek Pokryszko
S
ecurity has many facets and an- gain access for crypto mining [2][3][4][5]. attack is not as easy as it might seem, but
gles, and if you really want to be This group has been operating since 2018 luckily, you can turn to the MITRE
safe, you need to be aware of and is dynamically developing its arsenal. ATT&CK framework. Some of the tech-
them all. One important skill is The group evolves quickly and changes niques that MITRE ATT&CK associates
to become familiar with the logfiles on its techniques. Analysis of a Rocke group with the Rocke group include:
your system and the information they
might reveal (see the box entitled “All About Logs
About Logs”). But the attackers have
Linux systems store data in logfiles. You twists in the Bash shell. Text processing
become increasingly sophisticated in re- commands like grep and awk are popular
can specify four main categories of logs:
cent years, and to stay ahead of them, applications, events, services, and sys- tools for searching out log information.
you need all the help you can get. An- tems. Most logs are stored as text. Entries These tools are especially useful for
other important source of information is typically include important information quick, one-liner queries. The use of
the MITRE ATT&CK website [1]. MITRE such as: time, type, and severity levels of scripts will save time and make it easier
ATT&CK is a structured, globally avail- the event, as well as the name of the pro- to extract valuable data from logs.
able knowledge base describing tactics cess and the Process ID (PID). Of course, An example of a simple uniform script is:
and attackers. In addition to tracking the there are also exceptions, such as wtmp or
various attack methods used in the wild, lastlog which have a binary format. Gen- grep -E -r -o "([0-9]{1,3}\.)U
MITRE ATT&CK also provides clues that erally, files with logos are available in the {3}[0-9]{1,3}" | sort | uniq | U
will help you look for evidence. /var/log directory, but not always. It hap- grep -E -o "([0-9]{1,3}\.)U
Photo by Volodymyr Hryshchenko on Unsplash
pens that some programs save their diary {3}[0-9]{1,3}" > our-data.txt
files in other places.
Searching for Evidence
It’s best to learn from examples. One In the event that systemd operates on The grep command uses a regular ex-
threat facing users today is attacks related your Linux system, many users reach for pression (the -e switch allows you to
to stealing system resources for the pur- the journalctl command, which displays search with regex) to search data in the
the messages of the systemd recorder. catalogs recursively (switch -R) and then
poses of mining cryptocurrency. The
techniques that hackers use are quite in- When diagnosing problems or errors, displays the matched data parts in a sep-
teresting and sometimes unconventional. the first thing you need to do is to check arate line. The sort command sorts data,
The Rocke group is a good example. the logs. Searching for something in logs and the uniq command deletes dupli-
can be boring and time consuming. That cates. Then the result of this operation is
Rocke is a Chinese group of cyber crimi-
is why many users prefer to use simple saved to the our-data.txt file.
nals who specialize in malware attacks to
• T1036.005 – Masquerading: Match to be. The following command will find netstat -tupln
Legitimate Name or Location every executable file and check its con-
• T1053.003 – Scheduled Task/Job: Cron trol sum (SHA256), and the results will This command will return information
• T1574.006 – Hijack Execution Flow: be saved to the list.txt file: on connections (port and IP address) to
Dynamic Linker Hijacking and from the system. You can trace the
The following sections takes a closer find -type f -exec sha256sum U connections that are set and then track
look at these techniques and what to do '{}' \; > list.txt down the most undesirable ones.
about them, but before delving into the Another way to check for a masked
details, remember that it is always a T1036.005: Masquerading process is with the ps command:
good idea to look for suspicious files. Suppose the group downloads a payload
Malware often creates files in the fol- using the curl or wet command. The ps auxf
02 ##"
03
05 ##"
QQQ
Coming of Age
Age, a modern encryption tool, could soon replace PGP
and GPG when it comes to file encryption. By Bruce Byfield
I
f you encrypt, you are probably fa- PGP and GPG require numerous choices, in PGP have gone unaddressed for over
miliar with Pretty Good Privacy including the encryption method, the key a decade because of this.” Because of
(PGP) [1] or its clone GNU Privacy size, and how long the key is valid. Even all these problems, PGP and GPG most
Guard (GPG). Most likely, you have a moderately skilled user can be hard- likely lack what cryptography experts
used one of these tools to generate pub- pressed to answer such questions intelli- called “forward secrecy” – the ability
lic and private keys and to encrypt email gently. As a result, users may simply fall to function today in the way in which
and files. The Free Software Foundation back on the defaults, although ignorance they were originally intended. In fact,
explains these tools in its Email Self-De- and security are hardly compatible. Many John Hopkins cryptographer Matthew
fense Guide as a first step towards pri- users, too, complain about having to Green declared as early as 2014 that
vacy [2]. However, despite PGP and GPS move the cursor around to generate suffi- “It’s time for PGP to die” [5].
being ubiquitous when it comes to pri- cient randomness – and, the longer the Age is designed as a partial replace-
vacy, some people believe that these key, the longer it takes to generate the ment for PGP and GPG. It is not a com-
tools are counter-productive and little randomness. To further add to the confu- plete replacement, because it lacks a wiz-
more effective than the feeble default sion, PGP and GPG do too many things, ard and does not manage keyrings or
protection available for PDF files when it such as signing services and key manage- many other aspects of encryption. Rather,
comes to modern computing. Ironically, ment, that many users have no interest in keeping with the Unix philosophy that
as PGP and GPG become more widely in, which can add to the confusion. a command should do one thing very
used, some security experts are advocat- Even more important, PGP and GPG well, age only creates keys and encrypts
ing for their replacement with Actual were first written in 1991, and they are files. Age offers a few other advantages:
Good Encryption (age), at least for file showing their age. They come from an • Functions are kept simple by using
encryption [3]. era in which cryptography was in its only default configurations
Why do some security experts claim infancy. The Latacora corporate blog • Small keys
that PGP and GPG are obsolete? To begin [4] complains about the “absurd com- • No configuration options to under-
with, PGP and GPG have long public keys plexity” that includes eight different stand
that can be difficult to work with when ways of encoding the length of a • Public and private key pairs and pass-
space is limited, and copying them accu- packet and three different compression words, with multiple recipients
rately by hand is difficult. In particular, formats, as well as “keys and subkeys. • The option for encrypted identity files
they can be difficult to configure, even Key IDs and key servers and key signa- • Encryption via PEM-encoded, ASCII-
when the simple configuration wizard is tures. Sign-only and encrypt-only. Mul- armored format (the current industry
used (Figure 1). When generating a key, tiple ‘key rings’. Revocation certifi- standard) [6]
cates.” Likening PGP and GPG to a • Encryption for SSH keys, including
Author Swiss army knife that has multiple GitHub .keys support
Lead Image © photonphoto, 123RF.com
Bruce Byfield is a computer journalist and functions but does few of them well, The result is a simpler, easier to under-
a freelance writer and editor specializing the blog states baldly, “No competent stand approach to encryption that meets
in free and open source software. In crypto engineer would design a system the highest modern standards.
addition to his writing projects, he also that looked like PGP today, nor tolerate
teaches live and e-learning courses. In his
spare time, Bruce writes about Northwest
most of its defects in any other design. Using Age
Coast art (http://brucebyfield.wordpress.
Serious cryptographers have largely Age is available in most modern distri-
com). He is also co-founder of Prentice given up on PGP and don’t spend butions. Compared to PGP, it is radi-
Pieces, a blog about writing and fantasy at much time publishing on it any- cally simple, with no options for key
https://prenticepieces.com/. more (…). Well-understood problems size or choice of algorithms (Figure 2).
A Payload Without a
Delivery System
In its current state, age might be com-
pared to a missile, whose payload is
ready, but whose delivery system is
still in development. Age offers a sim-
ple and advanced means of encryption,
but it remains largely unknown and
unused. This state of affairs is very ob-
vious: When you make a mistake, age
responds with “Did age not do what
you expected? Could an error be more
useful? Tell us: https://filippo.io/age/
report.” Moreover, current documenta-
tion is minimal, and age leaves the lo-
cation of key files and the entry of re-
cipients up to users to decide. In addi-
tion, it does not yet provide any key
management.
Another obstacle to age’s adoption is
that while its advantages are well-known
to many cryptographers, desktop and
distribution developers are still focused
on making PGP accessible to average
users. This basic disconnect among de-
Figure 1: PGP can be difficult for non-cryptographers to configure intel- velopers still needs to be bridged.
ligently. For this reason, if you choose to use
age, you need to be prepared to work out
Before using age, all you must do is cre- age -r RECIPIENT-KEY U the delivery system by yourself. While
ate a public and private key. The keys INPUT-FILE OUTPUT-FILE.age not difficult, this approach is a little
can be stored in a plain text file, but rough and ready, so if you want modern
you should, of course, add a passphrase All these elements must be present for the and secure encryption, be prepared.
to the file, or else you have compro- command to function. To send to more When using age, you are using a com-
mised the keys from the beginning. To than one recipient, add multiple -r options mand still in rapid development. Q Q Q
do this, enter: or else store a list of recipients in a file and
add the path to the file using the -R option Info
age-keygen | age -p > KEY-FILE.age if you are using a recent version of age. [1] PGP: https://en.wikipedia.org/wiki/
Note that the -R option may not be avail- Pretty_Good_Privacy
If you choose an auto-generated pass- able in some distributions’ repositories.
[2] Email Self-Defense Guide:
phrase, age provides an xkcd-style pass- Similarly, to decrypt a file, enter:
https://emailselfdefense.fsf.org/en/?
phrase [7] consisting of a series of ran-
pk_campaign=fsfhome
domly generated words, which is easier age -d -i KEY-FILE.txt U
to remember than a random set of upper -o OUTPUT-FILE ENCRYPTED-FILE [3] age: https://github.com/FiloSottile/age
and lowercase letters, numerals, and [4] Latacora blog: https://latacora.singles/
special characters. Age does not support ssh-agent, but it 2019/07/16/the-pgp-problem.html
Each file to encrypt can be given its does work with sh-rsa and ssh-ed25519 [5] Mathew Green:
own xkcd-style passphrase. However, to SSH public keys. Using curl and a key
https://blog.cryptographyengineering.
avoid unnecessary complication, you listed in a GitHub profile, age can also
com/2014/08/13/
only reference the file that the key is send an encrypted file to a GitHub user,
whats-matter-with-pgp/
stored in. To add the key for a recipient as follows:
who has your public key, the file to be [6] age: https://github.com/C2SP/C2SP/
encrypted, and the name of the output $ curl https://github.com/benjojo.keys | U blob/main/age.md
file, enter: age -R - example.jpg > example.jpg.age [7] xkcd passwords: https://xkcd.com/936/
Figure 2: In contrast to PGP, age only needs to be configured by generating public and private keys.
Translator
To make programs useful to a worldwide audience, you need to build in support for multiple
languages. Catgets is a tool that helps you reach beyond your mother tongue. By Jim Hall
O
ne way that programmers can program needs to print. The basic usage path, then catopen() will open that file.
help others use their software is is to open the catalog, fetch messages If not, then catopen() will look for the
to add multi-language support. from the catalog and print them, and message catalog file in the directories
I’m not talking about program- then close the catalog. specified with the NLSPATH environment
ming languages; I mean spoken lan- variable.
guages. For example, you may have writ- Opening and Closing a Programs can open multiple catalogs at
ten your open source program to print in- Catalog once, such as one catalog for error mes-
formation and error messages in English, Before you can use a message catalog, you sages, another for debugging information,
but what if your user speaks only Span- first need to open it. The catopen() func- and so on. Each new message catalog re-
ish? Does your open source program also tion opens a message catalog and returns a quires a separate call to catopen() to open
“speak” Spanish? What about German, catalog descriptor, which is similar to a file the catalog and get a descriptor. But most
French, Italian, and all the other lan- pointer. You’ll use this descriptor when you programs typically use just one message
guages spoken around the world? retrieve messages later using catgets(). catalog file and divide the messages into
To make programs truly useful, pro- The function call to catgets() asks for the message sets. I recommend using just one
grammers should support internationaliza- filename of a message catalog, plus a flag message catalog unless your program is
tion. An easy way to do that is with the that indicates if catgets() should use the really big and needs to organize a lot of
catgets library [1], the original Unix current language locale value. If the flag is different messages.
method for a program to retrieve messages set to NL_CAT_LOCALE, then catgets() will For example, to open a message cata-
Photo by Leonardo Toshiro Okubo on Unsplash
and other strings in the user’s preferred use the current language locale, which you log file called hello.cat, you would use
spoken language. The GNU library also in- might set with setlocale(). Otherwise, catopen() as follows:
cludes a similar function called gettext, catgets() will use the value from the LANG
which uses a different lookup method. environment variable. nl_catd cat;
set, and the message number), gettext uses nl_catd catopen(const char *catalog,U NL_CAT_LOCALE);
Catgets provides an interface to fetch The catopen() function returns the cata-
strings from a special file called a catalog The catalog indicates the message cata- log descriptor as type nl_catd, or -1 to
[2] that contains all the messages your log you want to open. If this contains a indicate an error.
When you don’t need the message cat- #include <nl_types.h> print it:
alog anymore, you can close it with the int catclose(nl_catd cat); char msg;
catclose() function:
Fetching Messages with msg = catgets(cat, 2, 1, "Hello");
using the catalog, a call to the cat- Extending the Program With this change, when you compile
close() function closes it. In this article, I have described a sim- and run the new program, you can let
Now when you compile and run the ple example with a hard-coded path to the NLSPATH environment variable de-
program, you will see the Klingon text the catalog file. To make this example termine where catopen() will find the
nuqneH instead of the default text Hello. more flexible, and to support multiple message catalog file. The NLSPATH vari-
spoken languages, you can omit the able uses certain flags to stand in for
$ gcc -o hello hello.o path to the message catalog in the ca- other values, such as %N for “the file it-
$ ./hello topen() function call and allow the self.” Let’s say you set the NLSPATH vari-
nuqneH program to look for a catalog file in able as NLSPATH=/path/to/messages/%N.
some location defined by the system When you run the program, it will look
Listing 3: Omitting the Path (Listing 3). for the hello.cat message file as /path/
#include <stdio.h>
to/messages/hello.cat. Q Q Q
#include <nl_types.h>
Info
[1] catgets() – Retrieve a Message from a Author
Message Catalog: Jim Hall is an open
int
https://www.ibm.com/docs/en/i/7.3? source software advo-
main()
topic=functions-catgets-retrieve- cate and developer,
{
message-from-message-catalog
char *msg;
best known for usabil-
[2] The message catalog files (the GNU C ity testing in Gnome
nl_catd cat;
Library): https://www.gnu.org/
and as the founder and
software/libc/manual/html_node/The-
/* open the catalog */ project coordinator of FreeDOS. At work,
message-catalog-files.html
Jim is CEO of Hallmentum, an IT executive
[3] The gencat program (the GNU C Li-
cat = catopen brary): https://www.gnu.org/software/ consulting company that provides hands-
("hello.cat", NL_CAT_LOCALE); on IT Leadership training, workshops, and
libc/manual/html_node/The-gencat-
program.html coaching.
IN-DEPTH
Logseq
Networked
Logseq, a knowledge database note-taking app, emulates its better-known competitor
Roam Research and even outperforms it in some instances. By Ferdinand Thommes
I
f you are looking for an open images, playing back audio and video, In addition to Emac Org mode, Log-
source note-taking app, the Inter- and viewing tables or web content. seq cites TiddlyWiki [6] and Roam Re-
net abounds with options ranging And then there are proprietary net- search as its influences. Logseq can be
from simple, plain text apps to worked knowledge bases such as Roam connected to the Excalidraw [7] virtual
ones that let you display a wide variety Research and Obsidian. whiteboard and the Zotero [8]
of media. Some users, who consider Logseq [2], licensed under the
special applications superfluous, find AGPL 3.0, offers an open source al- FUSE
editors such as Vim, Kate, or gedit to- ternative to Roam Research and Ob-
When you launch the AppImage under
tally up to the task. Fans of open sidian. It describes itself as an open
a recent Ubuntu 22.04 LTS, the system
source alternatives to the proprietary source knowledge management and col-
reports that the filesystem in userspace
top dog Evernote, currently in beta for laboration platform that puts privacy
(FUSE) is missing. This message is typi-
Linux [1], want apps that offer ad- first. In this article, I put Logseq through cally misleading, because modern dis-
vanced functions such as displaying its paces to see how it compares to its tributions have FUSE as part of their de-
proprietary competitors (see the “Alter- fault installation. The only thing missing
Alternatives natives” box). is an older library as an interface. If you
mistakenly run the command:
Obsidian, released under a proprietary
license, is the pioneer of networked
Logseq at Work
Logseq goes far beyond simply storing sudo apt install fuse
knowledge storage. In the open source
community, Roam Research [3] has a notes. Logseq saves notes written in
the package manager will remove a
Markdown or Emacs Org mode [5] as
Lead Image © prat kitchatorn, 123RF.com
Figure 1: The Logseq desktop app is similar to the web version. The sidebar on the left displays the hamburger
menu, while the sidebar on the right shows content, graphs, and help (both sidebars can be hidden).
literature manager (you must be work- officially on Android. Logseq’s underly- “FUSE” box). Logseq saves all your en-
ing in Zotero for the connection to ing Electron framework [9] results in the tries as separate files on your hard
work). application weighing in at around disk, where they remain under your
150MB. Such a large chunk of disk space control (Figure 2). Whether you run
Local Knowledge is a potential disadvantage, even for a Logseq as a web app or as a locally in-
Management tool with Logseq’s functionality. stalled application, the first order of
Logseq can be used as a web service or Logseq is quickly deployed, either as the day is to create a local folder in
as a desktop application (Figure 1) on an installation from the website, a your home directory to store all your
Linux, macOS, Windows, and soon Flatpak, or an AppImage (see the files. You can specify the same home
Figure 2: Each page or journal entry is saved as a text file in Logseq. You can open and edit the entries with a
Markdown app or any text editor.
You can also search at the word level. months in parallel to my long-time favor- its secrets. The documentation, FAQ, and
To do this, either use the search mask ite local wiki Zim, and I still feel very an option for defining keyboard short-
(Ctrl+K) or hold down the Shift key and much like a Logseq novice. It takes a few cuts are all hidden behind the Help link
click on the title of a page in the sidebar months of use for Logseq to fully reveal at the top of the right sidebar.
or a linked term in an entry. The respec-
tive page with its links then appears in
the right sidebar.
Linking with square brackets or
hashtags in Logseq proves to be a pow-
erful tool. To create connections, create a
new bullet point in an entry and type the
title of an existing or yet-to-be-created
page in double square brackets. Depend-
ing on your preference, you can use a
hashtag instead to create the link. Back-
links or hashtags form the links in the
graph.
Learning Curve
Logseq may seem a little confusing at
first until you find your workflow –
sometimes this takes several tries. I
start each morning with a journal entry
that summarizes the day’s tasks. It has
a header of Tasks in double square
brackets, which means that it can be
linked to an existing page on the topic,
or I can create a new page with that Figure 5: A Git-style feature supports versioning and reverting to previ-
name. If I then click on the Tasks page, ous versions of the entry.
I will see a continuous list of daily
tasks with their respective dates. Com-
bining this with the to-do function, I
quickly have an overview of what I
have done and what I still need to
work on.
This work approach saves a great
deal of time, because you can work
with shortcuts instead of folders. You
don’t have to think about where to
store entries or how useful a heading
is: The meaning is derived from the
links. You can write about a wide vari-
ety of topics in a daily journal entry
and then link them meaningfully to
other pages that already exist or you
plan to create.
As a result, you generally don’t have
to worry about finding entries in Log-
seq. However, if you want to use graphs
productively, you should think about a
sensible structure in advance and test
it. When doing so, start by looking at
the Graph view from the left sidebar
after making changes to the entries and
then decide if this makes sense for your
use case. Figure 6: Right-clicking on a block’s bullet point opens a list of format-
In this article, I can only hope to pres- ting options. You can color code the block, convert it to a template,
ent a fraction of Logseq’s feature set. I open the entry in the sidebar, copy its references, or create a flashcard
have only been using Logseq for two with its content.
Info
[1] Evernote Linux:
https://evernote.com/earlyaccess
[2] Logseq:
https://github.com/logseq/logseq
[3] Roam Research:
https://roamresearch.com/
[4] Notion: https://en.wikipedia.org/wiki/
Notion_(productivity_software)
[5] Org mode:
https://en.wikipedia.org/wiki/
Org-mode
[6] TiddlyWiki: https://tiddlywiki.com
[7] Excalidraw: https://github.com/
excalidraw/excalidraw
[8] Zotero:
https://en.wikipedia.org/wiki/Zotero
[9] Electron: https://en.wikipedia.org/wiki/
Electron_(software_framework)
[10] FUSE for AppImage:
https://github.com/AppImage/
Figure 7: The Graph view visualizes the links between pages and jour-
AppImageKit/wiki/FUSE
nal entries.
[11] Bottom up:
Conclusions https://en.wikipedia.org/wiki/
things better, such as PDF integra-
Top-down_and_bottom-up_design
Logseq’s reception in the open source tion. Although the application is still
community is evident from the 120 or in the beta phase, the software’s po- [12] Mind map:
so contributors on GitHub and a Dis- tential is already becoming apparent. https://en.wikipedia.org/wiki/Mindmap
cord chat with 1,300 active participants An Android app is in the testing [13] Data privacy:
at the time of testing. phase and can be found as an APK on https://logseq.com/blog/privacy-policy
The only negative point I noticed in the GitHub page. A Pro version of [14] Donating to Logseq:
testing is that Logseq collects teleme- Logseq with synchronization is in https://opencollective.com/logseq
try data without asking the user. If in the planning stage. The developers
doubt, you may want to check out the just received about $4 million in Author
relatively brief privacy policy [13]. venture capital, but you can also Ferdinand Thommes lives and works as a
Logseq has gleaned many features support Logseq by donating on Linux developer, freelance writer, and tour
from Roam Research and made some OpenCollective [14]. Q Q Q guide in Berlin.
QQQ
Professional
Hardening
The complexity of modern distributions offers many potential attack vectors for malware.
Lynis lets you find these vulnerabilities before an attacker does. By Erik Bärwaldt
V
irtually nobody uses a computer approach because you will always find on the intranet. The self-hosted Enter-
without Internet access. Unfor- the latest version there [2]. CISOfy (lo- prise variant also includes all of the ad-
tunately, the network of net- cated in Vlijmen, Netherlands) offers the ditional packages and is suitable for ser-
works is teeming with malicious community variant of Lynis free of vices that provide security audits for
programs that exploit vulnerabilities in charge. The download contains the actual other companies [3].
operating systems, firmware, and appli- application, but some additional pro-
cation programs looking to inject mal- grams and the Collector are missing. At Your Command
ware or steal personal data. Lynis comes with some community pl- You will find detailed instructions for in-
Sys admins protect their systems ugins out of the box. stalling the Lynis community variant on
against these attacks as part of their various distributions [4] on the CISOfy
daily grind. Home users also need to Lynis Enterprise website. You then execute the program
protect their systems by keeping their For companies that need to monitor by typing lynis <parameter> in a termi-
computers up to date and running an oc- more than 10 workstations, CISOfy offers nal window. To access the available
casional security scan to detect any vul- Lynis Enterprise, which is available as a command parameters, type lynis show.
nerabilities. Lynis [1], a free software software as a service (SaaS, a licensing The central command for auditing the
tool from CISOfy, covers a wide range of and sales model where the provider op- local system is lynis audit system. The
problem scenarios and lets you perform erates software on their own infrastruc- application now runs over 200 test pa-
regular system checks in no time at all. ture and offers a subscription model for rameters and displays the results in a
use). Lynis Enterprise comes with nu- simple table after a short wait (Figure
First Launch merous plugins and additionally gener- 1). To the right of each test category,
Lynis, a command-line program, comes ates web-based reports in line with vari- the results appear in green, yellow, or
with a collection of scripts for Unix- ous standards. The Enterprise variant red. If the results are displayed in yel-
style systems. These scripts check vari- also lets you check Docker files in con- low, you need to check the setting, but
ous vulnerable system components for tainer environments and monitor remote if the text color is red, you will want to
insecure settings and display color- computer systems. reconfigure the service in question.
Photo by FLY:D on Unsplash
coded results. CISOfy offers the SaaS version of Lynis Lynis grays out components that are not
You will find Lynis in the repositories of Enterprise as a subscription for $3 per available on the system, provided that
many distributions and can install it using month. For larger organizations that re- their absence does not affect the secu-
any of the popular package management quire monitoring of more than 100 work- rity of the system as a whole.
tools. You also can download Lynis from stations, a self-hosted package is avail- The individual tests are divided into
the CISOfy website. I recommend this able for setting up a local Lynis instance categories. If you launch the software as a
Logger
Lynis generates multiple logs. Besides a
profile containing the respective test sce-
nario, it generates a logfile and a report.
Lynis shows you the search paths for the
individual files after starting the tests.
The report is the most important of
these files. It not only contains a detailed
list of all loaded kernel modules, data on
the network interfaces, and the directory
structures, but it also includes all of the
installed packages, cron jobs, and the
tests that have been run. These do not
appear in plain text like in the program
output, but with their internal designa-
tions. Lynis also outputs detailed infor-
mation about the services loaded by the Figure 1: Lynis displays the color-coded test results in groups on the
init system. terminal.
The report also contains several sug-
gestions on how to harden the current
system against attacks. However, these
suggestions are somewhat cluttered and
unstructured in the report. The sugges-
tion tag at the beginning of each line
marks the individual suggestions.
Profiles
Lynis supports the use of different pro-
files. You can view a list of all existing
profiles with lynis show profiles. The
preset profile uses all available options.
If you only want to test certain compo-
nents or services, you can create an ad-
ditional profile for this purpose. There
are no restrictions on the number of
profiles.
The profiles are simple text files,
which can be managed with any text ed-
itor. However, be careful not to modify
the original profile. To use a specific pro-
file during a test run, specify its name as
an option when calling Lynis. To per-
form a test run with a specific profile,
type the following at the prompt:
Figure 2: Lynis suggests potential improvements to the configuration in
lynis audit --profile <profile> the form of URLs (shown in gray).
When you assign names to new profiles option to use the --upload parameter to the existing logs on each new run with-
that you generate from the default profile send the report to their own Lynis in- out further ado.
as a template, you should include the stance for auditing and documentation
components to be tested in the name. purposes [5]. Add-Ons
For example, you can create specific pro- Thanks to its modular structure, Lynis
files for different installations, but also Color Scheme can easily be extended with plugins to
group different server services, such as When you run Lynis, depending on the help you retrieve additional data from
web or mail servers, into separate pro- background color selected, the contrast the systems you scan. Because Lynis’s
files. The security level can also be taken of the console output can be too low, check routines consist of shell scripts,
into account in individual profiles. making the results difficult to read. To savvy administrators have the option of
avoid this, start the application using the writing any plugins they need them-
Regular Scanning --reverse-colors parameter. This tells selves. The developers provide detailed
Especially in a corporate environment, the tool to adapt the output to light ter- instructions for this [6].
you will want to run security scans regu- minal backgrounds. Color highlighting Provided the plugins are explicitly en-
larly. A cron job gives you the ability to can also be turned off completely with abled in the individual profiles, Lynis
run Lynis at fixed intervals. To do this, the parameter --no-colors (Figure 3). automatically processes any plugins you
the application offers the --cronjob call add during scans. By default, these ex-
parameter, which does a complete scan Problems tensions reside in the /usr/share/lynis/
of the system. You also need to generate By default, Lynis always saves the re- plugins/ directory. During a test run,
a matching script and create the associ- ports it generates in the /var/log/ direc- they can be called at two phases; the re-
ated paths to be able to save the report. tory, creating the lynis.log and ly- sults are displayed on the standard out-
Automated tests will then run at regu- nis-report.dat files. If you need the test put and stored in the report file.
lar intervals without any user interac- reports for documentation purposes CISOfy also maintains a database of
tion. The software also removes all spe- over the long term, you should copy plugins that can be individually down-
cial characters from the report to facili- them to a separate data carrier or to an- loaded and integrated into a Lynis instal-
tate processing downstream. Users of other directory immediately after the lation. However, to access these exten-
the Enterprise variant also have the test run. Otherwise, Lynis overwrites sions, you first need to register with the
provider and be an Enterprise customer.
Conclusions
Lynis is a powerful tool for finding vul-
nerabilities on computer systems. The
Community version is suitable for home
users and admins with a manageable
number of computers, while the Enter-
prise version is recommended for larger
installations. The Enterprise version also
comes with additional features, such as
a web-based control panel and plugins
that let you check file integrity. With the
help of an extension for pentesting,
Lynis is also suitable for playing out at-
tack scenarios like the ones that occur in
real life. Every security-conscious user
should have Lynis in their toolbox. Q Q Q
Info
[1] Lynis: https://cisofy.com/lynis/
[2] Lynis download:
https://cisofy.com/downloads/lynis/
[3] Variants: https://cisofy.com/pricing/
[4] Installation instructions: https://cisofy.
com/documentation/lynis/get-started/
[5] Cron jobs:
https://cisofy.com/documentation/
lynis/configuration/#lynis-cronjob
[6] Create your own plugins:
Figure 3: Lynis lets you customize the colors in the text output, includ- https://cisofy.com/documentation/
ing turning off the color highlighting. lynis/plugins/development/
At a
Glance
Using extensions in Go and Ruby, Mike Schilli
adapts the WTF terminal dashboard tool to
meet his personal needs. By Mike Schilli
I
actually wanted to write a terminal extended with new widgets. Huz-
user interface (UI) for this issue that zah, I’ll just jump on the WTF
would show me important data re- bandwagon this time!
lating to the system status and world To talk the terminal dashboard
events using widgets. But what a shock WTF into filling its tiles with
when I saw online that there is already various widgets, as shown in Figure 1, various
an open source tool named WTF [1] (or you first need to drop the compiled wt- tiles. When done, call
wtfutil, as it was originally called) that futil Go program into a bin directory wtf on the command line to marvel at
has been able to do all this for a long as wtf and configure a YAML file with the tiles freshly filled with content in
time. Written in Go, WTF can be easily the individual WTF modules in the your terminal.
Figure 1: A fully configured installation of the WTF terminal dashboard (Source: GitHub).
© Chris Cummer, https://wtfutil.com
You’ll find installation instructions for row and column indexes to 0, with a Go path below ~/go/bin/p0d after a
the tool on a wide variety of operating widget height and width of 1. while. You can convert this to an execut-
systems on GitHub, but ultimately all The sizes and positions of tiles in WTF able path for later use.
that is needed on Linux is a git clone of are determined by the global tile width Called at the command line, p0d clut-
the repository followed by make build in and height in the grid section, which is ters the terminal with ASCII art and
the newly created subdirectory. Then, measured in terminal characters. A wid- wildly incrementing counters (Figure 4).
watch the Go compiler fetch all the de- get’s position is then set by reference to I don’t want that in my widget, so the
pendent libraries from GitHub and bun- the offset of a tile in the horizontal (left wrapper script from Listing 2, written in
dle the whole thing into a binary in bin/ to right) and the vertical (top to bottom) Ruby, calls p0d but intercepts the output
wtfutil/ (Figure 2). position. For example, if you initially di- and focuses only on the JSON file cre-
By the way, if you think go build vided the terminal into four columns ated (thanks to the -O option), which
would be a good idea, you will find and two rows, top=0 left=0 addresses contains some key data with the results
out that you are wrong shortly before the top left tile and top=1 left=3 ad- from the bandwidth measurement.
the end of the compilation, because go dresses the bottom right tile. Tiles can The shortest configurable runtime for
build instructs Go to store the result- occupy more space than just a column p0d seems to be three seconds; by de-
ing binary in a file named wtf – but or row, depending on their individual fault, it goes on for 10 seconds. This is
there is already a directory of that width and height settings, defining multi- why line 7 of Listing 2 sets a value of 3
name in the repository, and alarm ples of the base unit. in the third parameter to the call for Ru-
bells go off instead. The makefile, on Figure 3 shows the terminal after in- by’s external command executor
the other hand, ensures that the gener- voking WTF with the ~/.config/wtf/con- popen3() from the Open3 package. The
ated binary is named wtfutil and ends fig.yml configuration file from Listing 1.
up in the bin/ directory without any Just as the doctor ordered: The upper Listing 1: config.yml
collisions. left tile shows my current IPv4 address wtf:
and the geolocation in my adopted colors:
Tool Belt at the Ready hometown, San Francisco. A nice, useful
background: black
WTF already comes with a well-filled standard widget – but now it’s time to
border:
tool belt of predefined widgets that only expand WTF with my creations.
focusable: darkslateblue
need to be activated if required. For ex-
focused: orange
ample, I quite liked the ipinfo widget Script One, Two, Three
normal: gray
because my computer’s official IP ad- Next up is a widget that measures the
grid:
dress frequently changes due to all speed at which my Internet provider
columns: [32, 32, 32]
kinds of VPN configurations. It is help- moves data in and out over my home
ful to know what the Internet services I line. Precisely measuring the available rows: [10, 10, 10]
The YAML configuration from List- but luckily there’s already a tool for that ipinfo:
ing 1 drops the ipinfo module onto the on GitHub, called p0d [2]. p0d is written colors:
dashboard. The settings enable WTF’s in Go, and the repo can simply be cloned name: "lightblue"
internally-defined ipinfo module. For the and compiled from source. Following the value: "white"
widget to land in the top left corner of go install command gleaned from the enabled: true
the terminal, the mods section sets the readme, the p0d binary lands in the local position:
top: 0
left: 0
height: 1
width: 1
refreshInterval: 150
JSON data is output to the temporary file starting in line 14. The first sub-array nonsensical number of decimal places
previously created in line 5. (index 0) below the OS key contains the in the keys InetUlSpeedMBits and Inet-
After error checking, the Ruby script two Mbps values I’m looking for, rep- DlSpeedMBits. Ruby’s to_i() string-to-
then rewinds the generated Tempfile to resenting the upload and download integer converter rounds these values
the beginning in line 13, and the JSON speeds. They are returned by p0d as meaningfully to the nearest integer
parser uses parse() to parse the data floating-point numbers with a (lines 17 and 18).
The settings in Listing 3 add the
wrapped tool to the WTF configuration
as a widget in config.yml. Because WTF
does not inherently support p0d, the
type: "cmdrunner" directive specifies that
the widget expects a command-line ar-
gument with parameters, which it then
executes. The widget collects the stan-
dard output and copies it onto the tile on
the dashboard. Figure 5 shows the new
widget in action, below the IP widget
that I described earlier. The dashboard
now has two useful dials, but there is
enough space for a few more, so what’s
next?
Figure 4: Called from the command line, p0d quickly fills the terminal
with output.
04 require 'json'
Listing 3: p0d Widget Definition
p0d:
05 out = Tempfile.new('p0d')
08 stdin.close colors:
12 end position:
13 out.rewind top: 1
DIY
Widgets on the WTF dashboard can do
more than just display dynamically re-
trieved data line-by-line. They also offer
power users the ability to select lines
from the window contents and run ac-
tions on the active line.
The custom widget on the right in Fig-
ure 6 is an example of this. It retrieves a
list of the latest issues of the “Program-
ming Snapshot” column you’re reading
right now. It fetches them from the
world-famous Perlmeister.com portal and
displays their titles and publication
dates. If you select one of the columns in
this widget, it even launches a web
browser to show you this specific issue
from the Linux Magazine website. Let’s
look behind the scenes at this magic. Figure 6: A third window displays the latest “Programming Snapshot”
To interact with a particular widget as columns.
a WTF user, such as in the terminal UI in
Figure 6, type the digit displayed next to
the header (2 for the custom widget in
this case). This tells the UI to focus on
the selected widget. Pressing K and J
subsequently moves the selection (high-
lighted in green) up and down within
the selected widget, just like in the vi ed-
itor. Hidden away in the depths of the
extension’s Go code, each entry has a
URL associated with it. When you press
the Enter key, the widget fires up a web
browser and loads the selected item from
the web (Figure 7).
WTF does not support advanced fea-
tures like this out of the box, but you can
help it out with some Go code. To do
this, you need to clone WTF’s GitHub re-
pository and modify the code. Then re- Figure 7: Items selected in the list are opened in the web browser.
compile with make build to make new
widgets available, such as the snapshot Listing 5: widget_maker.go (Excerpt)
widget created in Listings 5 through 8. package app
The new binary then supports the import (
//...
Listing 4: Snapshot Configuration "github.com/wtfutil/wtf/modules/snapshot"
snapshot: // ...
)
enabled: true
// MakeWidget creates and returns instances of widgets
colors:
func MakeWidget(
rows:
// ...
even: "black" switch moduleConfig.UString("type", moduleName) {
odd: "black" case "snapshot":
position: // ...
settings := snapshot.NewSettingsFromYAML(moduleName, moduleConfig, config)
top: 0
widget = snapshot.NewWidget(tviewApp, redrawChan, pages, settings)
left: 1
// ...
height: 2
}
width: 2 return widget
refreshInterval: 86400 }
snapshot widget type, which you can in- ScrollableWidget basic type, as shown in the Widget structure with the required
clude in the YAML configuration as line 10 of Listing 6. This ensures that you content registers the widget with the ren-
shown in Listing 4. can navigate to the widget and browse derer, which later draws it in the termi-
its content. The code in Listing 7 initial- nal UI. Lines 23 to 25 specify the key-
Customized izes the new widget with the YAML con- board functions that make the currently
To do this, Listing 5 first needs to in- figuration data. As a result, the snapshot- selected entry in the widget move up
clude the newly created WTF snapshot specific Widget structure (Listing 6, and down when you press K and J, while
module in the WTF source code of the line 9) can include additional YAML data Enter selects the highlighted entry (along
widget_maker.go file. You will need a afterwards, which is a no-op (no opera- with the default browser action for the
new import statement that drags in the tion) in this case because the widget stored URL).
code from Listing 6, as well as an addi- does not require any additional configu- The Refresh() function starting in
tional case statement that calls the New- ration. In addition to the YAML data, line 28 gets called whenever the terminal
Settings() and NewWidget() functions however, the Widget structure includes UI redraws the widget. Using scrape-
from the Go snapshot package when the internal data in the form of the “Pro- Links() in line 29, it fetches the links for
program is initialized. Listing 6 shows gramming Snapshot” columns fetched current and past “Programming Snap-
what goes on behind the scenes in the from the web, along with their headings shot” columns from the Perlmeister web-
process. You need to copy Listing 6 to and URLs on the Linux Magazine site. site, as detailed below in the web scraper
the modules/snapshot/ directory of the Later on, Listing 8 defines the corre- in Listing 8, and breaks them down for
open source project, along with its sponding Link structure to hold these displaying in a compact format for indi-
counterparts in Listing 7 and Listing 8, values starting in line 11. vidual selection.
before recompiling. The NewWidget() function in Listing 6 Triggered by the Render() command in
The new snapshot widget on the right starting in line 15 creates the new snap- Listing 6, the UI displays the current con-
in Figure 6 is derived from the view. shot widget in the WTF universe. It fills tent of the snapshot widget on the screen.
Listing 6: widget.go
01 package snapshot 28 func (widget *Widget) Refresh() {
11 settings *Settings 37 }
14 } 40 content := ""
15 func NewWidget(tviewApp *tview.Application, redrawChan 41 for idx, link := range widget.links {
chan bool, pages *tview.Pages, settings
42 row := fmt.Sprintf(`[%s]%2d. %s`,
*Settings) *Widget {
24 widget.SetKeyboardChar 52 if sel >= 0 && widget.links != nil && sel < len
("k", widget.Prev, "Select previous item") (widget.links) {
25 widget.SetKeyboardKey
53 url := widget.links[sel].url
(tcell.KeyEnter, widget.openLink, "Open story in
browser") 54 utils.OpenFile(url)
26 return widget 55 }
27 } 56 }
The content() function collects the con- actually exist on the Linux Magazine published in the past 25 years on the
tent from line 38. It winds its way through website? To find out, the data grabber Perlmeister.com site. The Go goquery
the “Programming Snapshot” columns in Listing 8 scans the complete list of scraper has an easy task with the sim-
stored in the links instance variable and all “Programming Snapshots” ple HTML of the article links published
inserts them into the rows of the widget
one by one with color highlighting. Listing 7: settings.go
Line 25 defines what happens when package snapshot
you press Enter after selecting a “Pro- import (
gramming Snapshot” column, carried "github.com/olebedev/config"
out by the openLink() function, which "github.com/wtfutil/wtf/cfg"
starts in line 50. Using the index number )
of the entry in question in sel, line 53 re- const (
trieves the URL for the entry, which is defaultFocusable = true
stored in the links data structure, and )
uses utils.OpenFile() to open it. This // Settings contains the settings for the snapshot view
fires up the default web browser and type Settings struct {
tells it to display the contents of the arti- *cfg.Common
cle page on the Linux Magazine website. }
Nothing really exciting is required in // NewSettingsFromYAML creates the settings for this module from a YAML file
the YAML settings of the configuration func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig
file for the snapshot widget; only the *config.Config) *Settings {
}
Data Hog
return &settings
But how does the widget know which
}
“Programming Snapshot” columns
IN-DEPTH
Programming Snapshot – Terminal Dashboard
under the URL defined in line 18. Its to be displayed in the selection along Info
Find() function goes through all the with the corresponding link to the article [1] WTF:
links in the web document art_eng. on the Linux Magazine website. Based on https://github.com/wtfutil/wtf
html starting in line 34, only keeping this list, the code uses the title fields of [2] p0d:
track of the ones that have an Issues each element to generate the displayed https://github.com/simonmittag/p0d
string in their path. These are typically list. When you press Enter to select an
links to “Programming Snapshot” arti- entry, the code grabs the url attribute of Author
cles on the Linux Magazine site. the entry and brings up the external Mike Schilli works as a
Depending on the value defined in the browser for your reading pleasure. software engineer in the
variable maxHits (line 31), the function San Francisco Bay Area,
California. Each month
collects the URLs of a maximum of five Outlook in his column, which has
articles, extracts the year and issue num- All done! Obviously, however, you can been running since 1997,
ber of the publication from their paths, teach the WTF tool many more new he researches practical
applications of various programming
and appends them to the array of link tricks. It goes without saying that there
languages. If you email him at mschilli@
structures in links. Each entry also fea- are virtually no limits to what creative perlmeister.com he will gladly answer
tures a title field containing the headline programmers can do with this tool. Q Q Q any questions.
Listing 8: goquery.go
01 package snapshot 24 return links, errors.New("Fetch failed")
02 import ( 25 }
06 "regexp" 29 }
07 "strings" 30
09 ) 32 daterx := regexp.MustCompile(`\d{4}/\d{3}`)
10 33
14 } 37 if strings.Contains(link, "Issues") {
15 38 rs := daterx.FindStringSubmatch(link)
html") 41 maxHits--
19 if err != nil { 42 }
21 } 44 })
23 if res.StatusCode != 200 { 46 }
QQQ
Mixology
A little caution can save you hours of frustrating work (plus, gives the illusion of safety, if you over-
look the additional testing the deriva-
options for mixing gone awry). By Bruce Byfield tives do. Besides, occasionally a bug oc-
D
curs in stable and the quickest fix is in
ebian package repositories are backports and security updates. But set up testing and unstable. For any of these
organized along two axes. The the testing and unstable repositories in- reasons, mixing will happen.
first axis controls the degree of tended primarily for developers, and noth- If you must mix, take the verbosity of
software freedom in the instal- ing is guaranteed. A single careless step, apt-get/apt seriously. In particular, pay
lation. Newly installed, a Debian sys- and you could lose your desktop environ- attention to the dependencies updated
tem includes only packages from the ment, the ability to work with packages, or with testing and unstable packages. As
main section of the repository, which some other basic part of the installation, a rule, the more dependencies or the
contains only free-licensed packages. and find yourself condemned to hours more important the dependencies, the
However, you can enable the contrib of futile efforts to recover. Too often, a greater the risk. If you don’t know what
section, which houses free packages reinstall [1] is the quickest solution. a dependency does, take the time to
that depend on non-free packages, and If any of these misfortunes occur, you learn. The best odds for successful mix-
non-free, which houses packages with have only yourself to blame. The reposi- ing are packages with no dependencies
restrictive licenses, by editing the URLs tory names alone are a warning – espe- or no shared ones. The command
for repositories in /etc/apt/sources. cially if you venture beyond the three
list (Figure 1). Little harm can come basic repositories to others such as the apt-cache rdepends PACKAGENAME
from this editing, and, in fact, it is nec- experimental repository.
essary if you want to use the advanced Still, let’s face it: Users will mix re- will show the other packages that use a
Lead Image © Andrey-Kiselev, 123RF.com
proprietary hardware drivers. The sec- positories despite any warning. Many dependency, indicating the possible ex-
ond axis, though, is another matter. Tin- users crave the latest apps, and while tent of any consequences – although
kered with carelessly, it causes more re- stable may be reliable, it can be several not all packages react the same way
installs than any other aspect of Debian. releases behind the latest applications, (Figure 2). You might also run
This second axis is the main Debian re- especially near the end of the general
positories themselves. By default, a Debian release cycle. Sometimes, that means apt-get---simulate install PACKAGE
system enables only the stable repository. that its apps lack a needed feature. Be-
Stay with stable and you enjoy the full sides, Debian derivatives borrow from or even try a proposed action in a virtual
support of the distribution, including testing and unstable all the time, which machine first. As well, you might use the
Figure 1: The sources.list file contains the addresses of all repositories used by a Debian system. Note that
the cdrom used to install is disabled by commenting out, and that all three sections of repositories are listed.
Only the stable and testing repositories are listed.
option --no-install-recommends and Package: * would never be used. You might also
avoid --install-suggests to keep the mix Pin: release a=stable add other repositories, as well as entries
as simple as possible. Pin-Priority: 900 for individual packages with stand-
alone dependencies, or packages that
Ways to Mix Repositories Package: * your system depends upon or of which
Debian systems install from the reposito- Pin: release a=testing you always want to have the latest ver-
ries list in /etc/apt/sources.list. If you Pin-Priority: 600 sion. The preference file can be a work
want packages from contrib or non-free, in progress or kept as simple as in the
you will need to add the sections to each Package: * example above and promptly ignored.
source in a text editor and then run apt Pin: release a=unstable The command apt-cache policy will
update to enable the new sources. By de- Pin Priority: 300 display your current preferences. Figure
fault, the most recent sources are used 3 shows the default preferences, which
when installing, so testing is used in pref- This file will choose any package from give all the repositories from stable
erence to stable, and unstable is used in stable first, then from testing if a stable equal priority, assuring that the latest
preference to testing. version is unavailable, and then from version is always used.
Repositories can be mixed after you unstable if a testing version is unavail- The preferred method for many ex-
add testing and unstable repositories able. Any repository with a priority of 0 perts is to enable all three basic
to sources.list; then run apt update.
However, given Debian’s priorities,
that alone will leave your system wide
open to disaster. A more reasonable
approach is to comment out testing
and unstable until you need them, and
re-comment the entries as soon as you
are finished. The only weakness with
this method is that you might forget to
comment out a repository when tem-
porarily finished with it.
Another method is to create a preference
file in /etc/apt, setting a three-digit prior-
ity for each repository or package. Priori- Figure 2: It is often useful to see which other packages depend on the
ties can be set for all packages or for indi- one you are going to mix. Shown here is the start of the reverse depen-
vidual packages. A simple preference file dencies for GCC – which are so numerous that GCC is a poor candidate
would be: for mixing because the chances are high that something can go wrong.
Table 1: apt-get options to recover from mixing backup, or when all else fails, to do a
Warning: These options can make a broken system worse. Consult the apt-get complete reinstall.
man page to be sure you know what you are doing.
--fix-broken (-f) Instruct apt-get to attempt repair on its own. Other Mixes
I have been talking about mixes within
--ignore-missing, --fix-missing (-m) Ignore missing or corrupted packages and try to
Debian. However the same problem can
install the rest.
arise from borrowing from a Debian deriv-
--allow-downgrades Attempts to install an earlier version of packages.
ative. In its earliest days, a derivative dis-
--purge Remove all mentions of removed packages. tribution can often be added successfully
to a Debian system, but over time, deriva-
repositories in /apt/etc/sources.list, bullseye-security or bullseye-updates. tives often diverge. This is especially true
use apt-get with the option --target-re- But note that neither are available for of Ubuntu today. Other derivatives, such
lease or --default-release (-t), and apt, only apt-get. As long as you remem- as Linux Mint Debian Edition, may be
specify the repository you want, either ber to use the option, these methods are more compatible but are still a gamble.
by its code name, as testing, or by its sta- the simplest method of mixing. DEB packages from developers can also
tus as testing or unstable. For example: cause problems, making a Flatpak or Snap
Recovering from Mixing package, or another installer like Home-
apt-get --target-release install xchat If your mixing results in a broken sys- brew, a wiser choice. Just because a pack-
tem, apt-get/apt will suggest possible age is in a compatible format is not a guar-
Alternatively, you can use the structure: solutions, starting with an automatic at- antee that it is problem-free. Take the time
tempt to find a solution. If that fails, do to be cautious, and you can save yourself
apt-get install xchat/unstable not reboot your system before you have hours of frustration. Q Q Q
exhausted your efforts at recovery.
Either structure overrides a preference Table 1 shows the options that apt-get – Info
file and can also be used to favor any but not apt – offer to help recovery. An- [1] Reinstall: https://forums.debian.net/
other repository, such as other option is to restore a current viewtopic.php?&t=114130
Figure 3: The default priorities for repositories for bullseye, the stable version of Debian 11, assure that the
latest version is used.
QQQ
MakerSpace
Program a game of bingo with ReportLab
and Panda3D for Python
Bingo!
A game of bingo illustrates how to use the ReportLab toolkit and Panda3D real-time
3D engine. By Scott Sumner
P
ython is great for a number of else. In Python, that is usually done by elements to the document. Line 15
computing tasks: rapid proto- adding import lines to bring in the librar- starts a loop that iterates through each
typing, quick calculations, and ies you want to use. ReportLab is a very of 25 pages of the PDF so that, when
data formatting, just to name a large library, so its main functions have it's done, you will have 100 bingo
few. If the output of your perfect project been divided into smaller modules. This cards (four per page). Each page has
needs to be more polished or ready to re- way, you can import just what you need. the four grids, header rows for each
view immediately, you can use two librar- The syntax is card, and random numbers in all
ies to generate unique outputs directly spaces except the labeled free space in
from Python. The ReportLab [1] toolkit from [library] import [module] the center (lines 16-19). I explore each
generates PDF files, and Panda3D [2] of these functions more later. Finally,
creates a Python-controllable 3D world (lines 1-4, 6, 7). Line 5
for dynamic computer graphics. disables some warn-
For the purposes of this project, I will ings when loading
use the game of bingo as an example. To fonts, and lines 6 and 7
begin, a set of bingo cards is generated import the font librar-
with Python and ReportLab (Figure 1), ies, whereas lines 8
then a bingo caller is put together with and 9 actually import
Python and Panda3D. the fonts with pdfmet-
rics.registerFont by-
Bingo Card passing a TTFont ob-
In the US, the bingo card is traditionally ject. The first argu-
a 5x5 grid with the center space “free” ment is an internal
or automatically marked. The card has name that is used to
75 possible numbers, 15 available in refer to the font later.
each column. Listing 1 prints four cards The second argument
per page that can be cut apart. is the TTF filename.
The task of creating a bingo card has To create a PDF,
been divided into several steps – drawing you have to start
with a canvas
Photo by Josh Redd on Unsplash
Listing 1: bingo.py
01 from reportlab.pdfgen import canvas 52 return card
02 from reportlab.lib.pagesizes import letter 53
03 from reportlab.lib.units import inch 54 def freeSpace ( self ):
04 import reportlab.rl_config
55 self.doc.setFont ( "Bebas" , 24 )
05 reportlab.rl_config.warnOnMissingFontGlyphs = 0
56 self.doc.drawString
06 from reportlab.pdfbase import pdfmetrics
( 1.95 * inch , 7.55 * inch , "FREE" )
07 from reportlab.pdfbase.ttfonts import TTFont
57 self.doc.drawString
08 pdfmetrics.registerFont(TTFont('Bebas',
( ( 1.95 + 4.1 ) * inch , 7.55 * inch , "FREE" )
'BebasNeue-Regular.ttf'))
58 self.doc.drawString ( ( 1.95 ) * inch ,
09 pdfmetrics.registerFont ( TTFont ( 'Titan' ,
'TitanOne-Regular.ttf' ) ) ( 7.55 - 4.9 ) * inch , "FREE" )
12 class bingo: 60
13 def __init__ ( self ): 61 def numbers ( self ):
14 self.doc = canvas.Canvas ( "bingoCards.pdf" , 62 card1 = self.makeCard()
pagesize = letter )
63 card2 = self.makeCard()
15 for i in range ( 25 ):
64 card3 = self.makeCard()
16 self.grid()
17 self.titles() 65 card4 = self.makeCard()
19 self.freeSpace() 67
20 self.doc.showPage() 68 y = 9.05
21 self.doc.save() 69 for i in range ( 25 ):
22
70 if i == 12:
23 def grid ( self ):
71 y -= .7
24 self.doc.setStrokeColorRGB ( 0 , 0 , 0 )
72 continue
25 for x in range ( 12 ):
26 for y in range ( 14 ): 73
31 81 else: spacing = 0
32 def titles ( self ): 82 self.doc.drawString ( ( x + .57 + spacing ) *
33 self.doc.setFont ( "Titan" , 50 ) inch , ( y - .25 ) * inch , str ( card1 [ i ] ) )
34 self.doc.drawString 83
( .60 * inch , 9.5 * inch , "B I N G O" )
84 if card2 [ i ] < 10: spacing = .15
35 self.doc.drawString
( 4.68 * inch , 9.5 * inch , "B I N G O" ) 85 else: spacing = 0
36 self.doc.drawString 86 self.doc.drawString
( .60 * inch , 4.6 * inch , "B I N G O" ) ( ( x + 4.65 + spacing ) * inch , ( y - .25 )
37 self.doc.drawString * inch , str ( card2 [ i ] ) )
( 4.68 * inch , 4.6 * inch , "B I N G O" )
87
38
88 if card3 [ i ] < 10: spacing = .15
39 def makeCard ( self ):
89 else: spacing = 0
40 card = list()
90 self.doc.drawString
41 for i in range ( 25 ):
( ( x + .57 + spacing ) * inch , ( y - 5.1 ) *
42 while 1:
inch , str ( card3 [ i ] ) )
43 if i < 5: number = random.randint ( 1 , 15 )
91
44 elif i < 10: number = random.randint ( 16 ,
30 ) 92 if card4 [ i ] < 10: spacing = .15
48 96 y -= .7
51 break 98 bingo()
call self.doc.showPage (line 20) to add cards per page, those numbers are dou- the parameters are different, in order to
the page to the PDF and reset for the bled. Adding an empty row and column label each center square "FREE".
next page. Line 21 calls self.doc.save, between each card gives a total of 11 col-
which writes everything to disk. umns and 13 rows. The makeCard Function
To start drawing, set the line color with The makeCard function doesn’t actually
The Grid self.doc.setStrokeColorRGB, which will draw the card; rather, it creates the list of
With the bingo grid being five rows tall stay the same until changed again. Then numbers in the appropriate ranges for
and five columns wide, it also needs a lines 25 and 26 set up two loops: one for x each column. Line 40 initializes card as a
header row, for a total of six rows. By and one for y. Note that the loop ranges list, then line 41 sets up a loop that
creating a 2x2 “grid of grids” for four are 12 and 14 instead of 11 and 13 because runs 25 times, once for each square in
in Python range stops one below the pro- the grid. The next line starts an infinite
Units and Dimensions vided number. Lines 27 and 29 check the x loop until lines 43-47 find a number not
and y values, respectively, and skip the currently on the card.
ReportLab is inherently unitless. The
internal numbers used to generate center and end rows and columns. This Each if … random.randint line picks
PDFs only correspond to themselves. way you have four cards rather than one numbers in the right range for each col-
Those numbers translate into recogniz- big grid. Lines 28 and 30 draw a line umn. Line 49 checks that the number is
able units with the reportlab.lib.units from calculated values with self.doc. not on the card already, adds it to the list
library, which defines several constants
line, which expects the parameters start- (line 50), and then exits the infinite loop
(e.g., inch and millimeter) that make
any number passed in to a ReportLab ing x, starting y, ending x, and ending y, (line 51). Finally, line 52 returns card,
function scale to the proper real-world in that order. You will also notice * inch in which now has a unique set of numbers
size. Any time you pass a numerical di- every coordinate. See the sidebar “Units for the bingo card.
mension to ReportLab, it is multiplied and Dimensions” for more about this.
by the appropriate constant – for exam-
ple, 8.5 * inch.
The numbers Function
Similarly, the reportlab.lib.pagesizes
titles and freeSpace The numbers function draws the cards to the
library has common paper sizes. Functions document. To begin, it calls self.makeCard
Whereas letter is common in the US at The header row of each card is the first four times to get the numbers for each card.
8.5 inches wide and 11 inches tall, in place a font is needed, so the titles sec- Then, self.doc.setFont (line 66) assigns
other parts of the world, A4 is the stan- tion starts with self.doc.setFont in line 33, the font to be used to draw the numbers.
dard at 210mm wide and 297mm tall.
asking ReportLab to use a font previously Line 68 sets y = 9.05. The origin of the
Similarly, the terms “portrait” and
“landscape” in the US refer to the ori- loaded – on line 9 in this case. The first pa- document is the lower left of the page,
entation of the paper. Portrait lays out rameter is the internal name of the font to so this location is near the top.
the longer dimension vertically, be used (as provided when it was loaded), On line 69, the for loops over a range
whereas landscape lays out the longer and the second parameter is its size. of 25, one for each space on the grid. If i
dimension horizontally.
For each self.doc.drawString, you pro- == 12 (line 70), then this is the free
As you can see, ReportLab gives you vide the x and y coordinates and the text space. All you do is move down to the
the tools to create nice PDFs with just
to be drawn. In this case, BINGO, with next square (line 71) then continue with
about any content you might use. You
can put this to use in data processing, extra spaces between the letters so the font the next iteration of the loop (line 72).
batch scripts, or just about anything will line up inside the grid. This command Lines 74-78 determine the x offset for
else to create an easy-to-read report is repeated four times, once for each card. the column. This value will be added to
that is generated as your files or data The freeSpace function (lines 54-59) a hard-coded x value for each of the four
are being processed.
works exactly the same as titles. Only cards on the page.
Listing 2: bingoCaller.py
001 from direct.showbase.ShowBase import ShowBase 016 import os
Bingo Caller
As with any Python program, you have
to import the appropriate libraries. Pan-
da3D splits all of its functions into subli-
braries, so you will have a number of
imports just for those (Table 1).
As with any Python program, __init__
is called automatically when a class is in-
stantiated. Here it is used to set up the
Panda3D environment, starting with call-
ing ShowBase.__init__ ( self ) (line 22),
which gives the bingo class all of the vari-
ables, functions, and set up associated
with ShowBase or Panda3D.
By default Panda3D opens a normal
desktop window. To get the application to
run fullscreen, though, you need to do a
Figure 2: The initial layout of the bingo caller display. Tiles on the left little bit of setup. Line 23 creates a Win-
have not yet been called. dowProperties object, which allows you to
call wp.setFullscreen (line 24) to request
Lines 80 and 81 handle character spac- working on a computer, most of us are a fullscreen window and wp.setSize to re-
ing. If the index i is less than 10, the only worried about two dimensions quest the screen resolution.
number on the card will be a single digit. when trying to get something to show As mentioned earlier, Panda3D opens
In this case, spacing is set to .15 so the up in the right place onscreen. In three a window by default, but in this case,
number is centered; otherwise, the num- dimensions, though, you add depth you need to force it to open now with
ber is two digits, so spacing is 0. (the distance from the camera or view- base.openMainWindow (line 26) and then
Line 82 uses drawString with the cal- point) and height off the ground. apply the WindowProperties object cre-
culated x and y positions to fill in the Think of your 3D canvas like your ated above with base.win.requestProper-
card with the number. Lines 80-82 are living room. Imagine you are sitting on ties (line 27). Finally, you ask the
reproduced for each of the four cards a couch, viewing a coffee table, a TV, graphics engine to draw the windows
in lines 84-94. and all of the decorations that make up onscreen with base.graphicsEngine.open-
Line 96 moves the y value down for the your home. If you move to a different Windows (line 28).
next row, and line 97 checks to see if the place in the room, the objects look dif- The next line calls base.disable-
bottom of a column has been reached. If ferent. You can also put objects on a Mouse. Panda3D includes by default a
so, then y is reset to the top of the page. shelf or table to change their height. set of built-in controls to let you ex-
All of these factors have to be consid- plore the Panda3D world. The mouse
Panda3D ered when working in a 3D environ- controls your orientation (where you
Now that you have a set of bingo ment. Luckily Panda3D hides a lot of are looking), and keyboard keys move
cards, it’s time to play the game. How- the inner workings and makes it easy you forward, back, left, and right. In
ever, it’s no fun choosing one of your to set everything up. this case, though, you want to control
friends to sit out and
call the numbers, so I Table 1: bingoCaller.py Imports
created an auto-
Line No. Import Function
mated, visually inter-
1 ShowBase Main Python interface to Panda3D
esting bingo caller
3-7 panda3d.core
(Figure 2) that uses
3 WindowProperties Controls the window showing the Panda3D project
the Panda3D library,
4 TextNode Creates text objects
a 3D rendering and
5 NodePath Panda3D internal object references
graphics environment
6 Point3 Represents a 3D point
(Listing 2). The pro-
7 DynamicTextFont Loads TTF fonts
gram also uses the
9 direct.interval.LerpInterval Lerps are the Panda3D movement controllers
eSpeak speech syn-
10 direct.interval.IntervalGlobal Allows things to happen over a period of time
thesizer to call the
12 direct.task Recurrent tasks after a specific period of time
numbers.
14 pprint Prints nicely formatted strings (mainly for debugging)
When you are
15 random Gets numbers in an arbitrary order
working in a 3D envi-
16 os Calls functions in the underlying operating system
ronment, you have to
17 sys Used for sys.exit to close the program on request
shift your thinking a
18 thread Runs multiple portions of the program concurrently
little bit. When
the camera position automatically. If render with setText (line 39). The set- doMethodLater (line 57) sets up a func-
you do not disable the mouse, the cam- TextColor in line 40 is what it sounds tion to be called in the future. The argu-
era commands will be ignored. like, but its arguments are a little differ- ment list is how long to wait (five sec-
If you were writing an interactive ent: Instead of arguments for red, onds), what to call (self.callTile), an
game, you could allow the player to trig- green, blue, and alpha being mapped internal label (Call Bingo), and any
ger an in-game animation sequence to from 0 to 255, they are mapped from 0 extra arguments (empty list=none).
introduce the next level. Once you dis- to 1. All 1 entries get you white. Finally Lines 59 and 60 stop the auto calling by
able the mouse, you can do whatever self.text.font = font assigns the font setting self.auto to False.
you want to move the user around, make loaded on line 35.
them look in a certain direction, and so So far this is only a 2D text object. The Enable Mouse
on. Once you have told your part of the next set of lines puts it in three dimen- When setting up a 3D world it is often
story, you use enableMouse to return con- sions. A node is an object in Panda 3D’s just easier to drive the camera around
trol and allow the user to keep exploring. internal library, so NodePath(self.text) and find the object you are looking for.
Lines 30 and 31 set some variables (line 43) gets the address of the text node To do so, remove the disableMouse on
that are used later: self.auto is a flag just created. On line 44, then, the re- line 29 so you can use the built-in cam-
that indicates whether numbers are cur- parentTo assigns it to self.render. In Pan- era controls. Once you have found
rently being called, and self.calledTiles da3D anything attached to self.render is your object, call getCam, which uses
is a list of bingo numbers that have been rendered as a 3D object. Now that it is in pprint (line 63) to output the camera
called. More on these a little later. the 3D realm, a setScale (line 45) sets the position, which can then be added to
Line 33 sets the initial camera posi- text size, and setPos (line 46) positions it the code as needed.
tion with base.camera.setPos. Just like in the 3D world in front of the camera.
setting up a camera in the real world, Line 48 calls initTiles, which creates Tiles
the coordinates are relative to the ob- the numbers that fly around the screen, The initTiles section (lines 65-103) cre-
jects set in the scene. You need the but more on that a little further along. ates all of the 3D objects that represent
camera to be a little ways back so that The last section is lines 49-53, where a bingo numbers and shuffles them to pre-
it can see everything. few self.accept lines set up keyboard pare for calling. To start, self.tiles (line
Line 35 loads the custom font; loader. input. The first argument is the key to 66) is a list of strings that represent the
loadFont makes a TTF file available for trigger a response, and the second argu- tiles, and self.tiles3d (line 67) is a dic-
converting into a 3D object. The internal ment is the function to call when it is tionary of 3D objects. The key is the
resolution of the font just loaded is set pressed. The optional third argument is string from the self.tiles list.
by setPixelsPerUnit on line 36. By de- a list of parameters to pass to the func- Bingo tiles start with one letter from the
fault, the resolution is a fairly low value tion when the key is pressed. Line 50 word “BINGO” and then one of 15 num-
(Figure 3), which is fine if the text will says, “watch for the c key to be pressed, bers. Column 1 (B) goes from 1 to 15, col-
be far away. However, the text will be and when it is, run self.callTile and umn 2 (I) from 16 to 30, and so on.
moved very close to the camera, so the give it the parameter True”. Line 69 creates bingoWord = "BINGO", and
value needs to be turned up to get a line 70 initializes total to 0. Line 71 loops
sharper line when up close. Automatic Calling over each character in bingoWord and cre-
To create a 3D text object, in this case The autoCall function enables auto- ates 15 tiles for each (line 72). The next
“BINGO” for the top of the screen, matic bingo calling. To start, self.auto line then creates the tile by starting with
TextNode (line 38) contains the text to is set to True (line 56), then taskMgr. char, the current character from bingoWord,
and appending a number created by the
loop counter i plus the accumulated total
plus 1 (otherwise it would start at 0). Once
that is done, total increments by 15 before
the loop moves on to the next column.
Lines 76 and 77 are identical to the
earlier code in __init__ to load a font.
Although the same font loads here, it is
included again so that the tiles can be a
different font from the title.
Now that you have a list of tiles, they
are all turned into 3D objects. Line 79
initializes oldLetter to blank, then line
80 starts the loop over self.tiles. Lines
81-88 create a 3D text object the same
way as in __init__, then lines 89-93
check which column a tile is in from its
Figure 3: This text was rendered with a pixels-per-unit size of 8. As first letter (tile [ 0 ]) and assigns the x
you can see, the tile number N40 is barely recognizeable. for each column.
Line 95 checks to see whether oldLetter (Figure 4) and say the name of the tile with the same y and z coordinates calcu-
has changed (have you moved to the next before it flies back down to the other lated on line 112.
column?), and if so, lines 96 and 97 set side of the screen to show what is now After that, the lerps (linear interpola-
z=20 and update oldLetter. Once that is a called number (Figure 5). tions) need to be set up. The lerps' job
done, line 99 sets the calculated x and z Line 106 checks self.auto and manual is, for any slice of time, to calculate
values with setPos (line 99). The y coor- to see whether auto calling is currently where the object is located between
dinate is hard-coded at -50 because every- active or whether this was called manu- two positions. By default, a lerp starts
thing is the same distance from the cam- ally. If neither are true, then nothing with the object’s current position, but
era. The setTwoSided line (100) makes it should be done and the line returns. you can override that if needed. The
so that if a letter is flipped around back- Then, len ( self.tiles) > 0 checks to lerp also wants to know where to go
ward it will still look right, before decre- make sure tiles are available. If a tile is and how long it takes to get there. You
menting z (line 101) and adding the tile to available, it is stored in tile; otherwise, can optionally provide arguments to
the self.tiles3d dictionary. it encounters the return (lines 108, 109). change the starting position or starting
Finally, random.shuffle on line 103 Now a couple of things need to be set and ending behavior, or even to pro-
makes sure the tiles are in a random up to move the tile around. Because this vide a function to calculate movement
order. Now it’s time to play bingo! function works on all 60 tiles, the first on the fly.
thing you need to know is the location Line 114 is the lerp to move the bingo
Play Bingo! the tile starts, which you find out by call- number up close to the camera over two
The callTile section (lines 105-121) ing getPos on the 3D tile object stored in seconds. Line 115 uses the newly calcu-
calls the tile, which will fly up close to self.tiles3d (line 111). The new position lated x position and flies the number
the camera so it appears really big of the tile will be the x position plus 17, from right in front of the camera down
to a position on the right-hand side of
the screen.
So far you have told the tile how to
move, but you haven’t actually moved it
yet. You can think of lerps as dance
moves. You can learn how to do each
step, but then you have to put them to-
gether in the right order to perform the
whole dance. That is where Sequence
comes in. It takes a set of lerps and exe-
cutes them in the order provided, so line
117 starts with the lerp i that moves
from the initial position up to the cam-
era. Then the special Wait function de-
lays for the provided number of seconds,
and park finishes in the position on the
right side of the screen where you want
Figure 4: When a number is called, it flies close to the camera and is the tile to land. If this sequence were to
announced by eSpeak. be used repeatedly, you could store it in
a variable, but here, just call start so the
movement begins.
Line 118 calls self.speak in a new
thread, which lets the speech and the
movement happen at the same time.
eSpeak
eSpeak is an open source text-to-
speech engine that you can install with
your distribution’s package manager.
Once installed, open a terminal and
type:
espeak "Hello World!"
To wrap up, append tile to self. self.tiles (line 134) makes sure the • If all tiles are on the right side, the
calledTiles (line 120) and then, if auto tiles are called in a different order in the player has won! Press r to reset the
calling is on (self.auto == True), call next game. board and begin another game.
self.autoCall again (line 121) to sched- Lines 136 and 137 run the program • If the person who called bingo is not a
ule callTile to be run in five seconds. with the bingo instance (line 136) and winner, the player is out and the other
the call to run (line 137), which starts players can continue. Pressing a starts
Speak and Reset Panda3D’s main loop. calling numbers again where you left off.
The speak section (lines 123, 124) uses I trust the two examples in this article
os.system to pass a call to the underlying Bingo! demonstrate how easily both PDFs and
operating system. In this case, it calls Now that you have the software, it’s 3D data can be visualized with the help
espeak to say the name of the tile by pass- time to play a game of Bingo! Here’s of free Python libraries. Now use this
ing in the tile text. (See the “eSpeak” box.) what to do: new knowledge to format your favorite
Once the game is over, you need to • Run bingo.py, then open the generated data in new and exciting ways! Q Q Q
reset everything so you are ready for the PDF and print a page for each player.
next game. Parallel is similar to Se- • Run bingoCaller.py. Once it appears Info
quence, but here everything happens at on your screen, press a to start the [1] ReportLab docs:
the same time (line 127). Then, for auto caller. https://docs.reportlab.com/reportlab/
every tile in self.calledTiles (line 128), • As each number is called, mark it off if userguide/ch1_intro/
you get its position (line 129), calculate it appears on your card. [2] Panda3D: https://www.panda3d.org
its original position (x minus -17; line • When someone has filled in five spaces
130), and append it to Parallel (line horizontally, vertically, or diagonally, Author
131). Finally, you add the tile name they yell “bingo!” and press the space- Scott Sumner has worked in the museum
back to self.tiles so it is available to bar on the computer. The player should and non-profit industry for most of his
be called again. Once all of the tiles then announce each of the five tiles professional career. He enjoys exploring
have been added to Parallel, you start marked on their bingo card while the technology solutions with Arduinos,
it (line 133) – which makes the move- other players make sure they appear on Raspberry Pis, Microcontrollers, and
ment happen on screen. Next, shuffle the right side of the screen. Linux systems.
MAKERSPACE Bluetooth LE
MakerSpace
Bluetooth Low Energy for the
Raspberry Pi
Wireless Saver
Bluetooth Low Energy is ideal for networking battery-
powered sensors. We show you how to use it on the
Raspberry Pi. By Bernhard Bablok
B
luetooth LE, or BLE for short,
getting started with some practical ex-
comes with a whole new amples, I first need to discuss the theo-
world of terms on top of the
retical background. Without all of this
new technology. Before BLE speak, you can’t evaluate the many
application examples avail-
able on the web and adapt
them to your needs.
Bluetooth is a short-range
technology for use between
two devices [1]. Before a con-
nection is established, a sys-
tem can be either a peripheral
device or a central device.
Powerful devices such as PCs,
tablets, and laptops can as-
sume both roles, while less
powerful devices are limited
to the peripheral role.
Each peripheral sends ad-
vertisements at regular inter-
vals, such as “I am sensor
ABC and provide heart rate
data.” Alternatively, the mes-
sage could be: “I am sensor
Lead Image © Teerapat Seedafong, 123RF.com
as the Generic Access Profile (GAP), Device Information Service (Figure 2).
which I’ll cover here briefly. The corresponding standard also defines You will also want to download the
Once connected, it is all about data two roles: Collector (client) and Sensor source code (including examples) from
exchange between the two devices. (server). In addition, it specifies other Bleak’s GitHub repo [4]. You’ll find the
The standard for this is the Generic At- more or less important details (e.g., that examples very useful as templates for
tribute Profile (GATT), which regulates the sensor’s device name can optionally your applications.
which bytes one device sends to the be overwritten). CircuitPython via Blinka is an alter-
other device via the wireless link. Even Within a service, there are several logi- native to Bleak. Installed on the Rasp
though the connection is always estab- cal attributes or functions known as Pi along with the appropriate BLE li-
lished from the central device to the characteristics in BLE speak. The Heart braries (Listing 1), this combination fa-
peripheral, this does not mean that Rate Service contains the mandatory cilitates communication with custom
data only flows in one direction. A bi- Heart Rate Measurement characteristic microcontrollers that also run Circuit-
directional data flow is also possible, and, optionally, the Body Sensor Loca- Python. While it will probably not
for example, using the universal asyn- tion characteristic, among others. Each cause you problems in many scenarios,
chronous receiver/transmitter (UART) characteristic in turn includes named Blinka does pose some limitations: The
service. BLE defines the terms server fields with the actual data. Raspberry Pi can only adopt the central
and client for this purpose. The client role with Blinka. The source code for
has read or write access to the server, Scan Me! the BLE libraries for CircuitPython can
which in turn can send data (with or After all of this theory, it’s time for also be found on GitHub, below the
without a response) to the client. In some simple examples. On the Rasp-
this case, the server has the definition berry Pi, you only need Python for Listing 1: Blinka with BLE
of the resources. this. The Bleak library provides an ab- $ sudo apt-get update
The heart rate sensor from the previ- straction layer that greatly simplifies $ sudo apt-get install python3-pip
ous example would be an example of a the application. Bleak stands for BLE
$ pip3 install \
server. The peripheral device that asks Platform Agnostic Klient (ouch), a nod
adafruit-blinka-bleio \
for the current time, on the other hand, to the fact that the package runs on
adafruit-circuitpython-ble
would have a client role after opening Linux, macOS, and Windows. So for
the connection. For its part, the client
can only hope that a central unit will Listing 2: Simple BLE Scanner
adopt the server role. 01 #!/usr/bin/python3
02 import time
Profiles and More 03 import _bleio
The service, a central concept in the BLE 04 import adafruit_ble
world, defines the data and behavior. 05 from adafruit_ble.advertising.standard import Advertisement
Each service has a universally unique ID 06 ble = adafruit_ble.BLERadio()
(UUID). The services standardized by 07 while True:
the Bluetooth SIG have 16-bit UUIDs, 08 print("Scanning...")
while private services use 128-bit UUIDs. 09 for adv in ble.start_scan(timeout=5):
An official document [3] defines all stan- 10 print(adv.address,adv.complete_name)
dardized UUIDs. For example, the Heart 11 time.sleep(10)
Rate Service has the UUID 0x180D.
import board
i2c = board.I2C()
#BME280 sensor:
bme280 = adafruit_bme280.Adafruit_BME280_
I2C(i2c,address=0x76)
[...]
BLERadio.name = "BME280_Sensor"
ble = BLERadio()
uart = UARTService()
advertisement = ProvideServicesAdvertisement(uart)
while True:
print("starting advertisement")
ble.start_advertising(advertisement)
pass
print("connected")
while ble.connected:
measurement = "{0:0.1f},{1:0.1f},{2:0.1f}\n".format(
bme280.temperature,
bme280.humidity,
bme280.pressure/alt_fac
print(measurement,end='')
uart.write(measurement.encode("utf-8"))
Figure 4: The signal strength is measured by nRF time.sleep(10)
Connect.
documents, tools, and software on the is a great choice for entry-level applica-
topic on its website [5]. tions because it is inexpensive and sup-
Another useful app is Bluefruit LE ports all common languages.
Connect by Adafruit. In addition to hard- The code turns out to be very compact
ware, Adafruit offers a very large collec- thanks to the CircuitPython libraries, but
tion of tutorials on all sorts of hardware- even with other programming languages
related IT topics. Bluefruit LE Connect the whole thing is unlikely to be much
and its practical application are very well more complicated. The logic is similar
documented. on the client side. Instead of advertise-
Special Bluetooth microcontrollers by ments, the control panel scans for UART
Adafruit, such as the Feather nRF52840 services, connects to the sensor, and
Express, are a great choice for interac- reads from the serial port. The complete
tion with the Bluefruit app. The app re- code for the server and client can be
ceives data and can also control the found in my project repository [6].
MCU, provided a suitable program is You may encounter some disadvan-
running there. tages of the UART
procedure if other
UART devices on the
The serial interface is one of the oldest network offer
interfaces in the IT world and has man- NUS. The client
aged to survive for many generations on program gets
continually evolving carrier technolo- around this by
gies. The UART service for BLE is the querying the ad-
Nordic UART Service (NUS). For many vertisement name
applications, UART plays the role of an BME280_Sensor, but
intermediate protocol. This is not ex- this is not an ele-
actly what the inventors of Bluetooth gant approach. It
had in mind, but it is simple. In particu- would make more
lar, developers can easily port existing sense to have a
applications. separate service
Listing 3 shows an example of trans- that defines the
ferring sensor data with UART. A micro- data structure.
controller reads a connected BME280 Figure 5 shows
sensor, bundles the results into a string, the advantage of
and writes the string to the serial inter- using UART, on the
face. An XIAO nRF52840 microcontroller other hand.
02 import board
04 import adafruit_ble_broadcastnet
06 i2c = board.I2C()
07 #BME280 sensor:
08 bme280 = adafruit_bme280.Adafruit_BME280_
I2C(i2c,address=0x76)
09 [...]
10 while True:
11 measurement = adafruit_ble_broadcastnet.
AdafruitSensorMeasurement()
12 measurement.temperature = bme280.temperature
13 measurement.relative_humidity = bme280.humidity
14 measurement.pressure = bme280.pressure/alt_fac
15 print(measurement)
16 adafruit_ble_broadcastnet.broadcast(measurement)
Figure 5: The UART output as a plot with Bluefruit
17 time.sleep(10)
LE Connect.
QQQ
One of the principles of the open source movement is “don’t reinvent the
wheel.” If an application does what you need to do, use it. Thousands of
free applications are available within the open source community, and if
you look around, you can probably find a tool that does exactly what you
want. But what if you can’t find a tool that does what you want? Another
principle of the open source movement is
“do it yourself.” This month’s tutorial on
converting a homegrown SQL database Doghouse – AI 76
to the more versatile JSON document Jon “maddog” Hall
format will give you some practical +HCPCTVKƒEKCNKPVGNNKIGPEGRTQFWEGUUQOGVJKPI
experience with data formats, as PGYYJQQYPUVJGPGYETGCVKQP!
well as Python APIs. Also in this
month’s Linux Voice, we LibreWolf 78
Erik Bärwaldt
introduce you to the LibreWolf
.KDTG9QNHCOQFKƒGF(KTGHQZDCUGFYGD
alternative web browser and
DTQYUGTUKORNKƒGUEQPƒIWTCVKQPCPFUVQRU
dust off the RustDesk remote
OCNYCTGCPFUR[KPI
access app.
RustDesk 82
Thomas Leichtenstern
Image © Olexandr Moroz, 123RF.com
(QTCNQPIVKOG6GCO8KGYGTCPF#P[&GUM
FQOKPCVGFVJGTGOQVGOCKPVGPCPEGUQHVYCTG
OCTMGV4GEGPVN[CPGYRNC[GTGPVGTGFVJG
UEGPGKPVJGHQTOQHVJGHTGGCPF)2.
NKEGPUGF4WUV&GUM
FOSSPicks 86
Graham Morrison
6JKUOQPVJ)TCJCOTGXKGYU6WPKPI9QTMDGPEJ
5[PVJ5VGNNCTKWOUCMG9QPFGT5JCRGTCPF
5CORNGDTCKP
Tutorial – SQL Database Migration 92
John Cofield
7UGC2[VJQP#2+VQOKITCVGCOWUKENKDTCT[
HTQO53.VQC0Q53.FQEWOGPVFCVCDCUG
MADDOG’S
Jon “maddog” Hall is an author,
educator, computer scientist,
DOGHOUSE
and free software pioneer
who has been a passionate If an artificial intelligence produces something new, who owns
advocate for Linux since 1994
when he first met Linus Torvalds the new creation? BY JON “MADDOG” HALL
and facilitated the port of
Linux to a 64-bit system. He
serves as president of Linux
International®. Artificial Intelligence and Ownership
ome free software people do not believe in intellectual The creation of new and unique code, by itself, should not
Snoop Guard
LibreWolf, a modified Firefox-based web browser, simplifies configuration and
puts a stop to malware and spying.
ozilla Firefox is a web browser that options [2]. If you install from the repositories
M
BY ERIK BÄRWALDT
can be configured with great granu- and use the Flatpak, you will find a launcher in
larity, while respecting a user’s pri- your desktop menu when you are done.
vacy, unlike Google Chrome. This is why the Tor
Browser is also based on Firefox. If you don’t Getting Started
want to use the Tor network, but still want your At first startup, you will not notice much of a
privacy to be protected, setting this up involves difference from the original Firefox. The inter-
some fairly complex Firefox configuration work. face design does not show any serious differ-
Alternatively, you can let the LibreWolf [1] web ences at first glance. Of course, the preinstalled
browser, a modified Firefox, do the work for you. uBlock Origin extension, which filters unwanted
It does away with gimmicks in the default set- ads out of websites, located in the top right cor-
tings and has been thoroughly hardened by its ner of the program window next to the address
developers. bar, might catch your the eye.
LibreWolf is available for various Linux distribu- In addition, the default search engine is Duck-
tions, but also for macOS, OpenBSD, and other DuckGo instead of Google, which the original Firefox
operating systems. On Linux, various packages uses. DuckDuckGo is one of those search engines
are required for the install depending on the dis- that values its users’ privacy and blocks trackers. Li-
tribution. You also can use an AppImage or breWolf lacks the Pocket web application, operated
Flatpak package. In addition, you will find hints by Mozilla Corporation, which lets you save web
on the project page for all of the installation pages and articles on remote servers.
If you need to ad-
Figure 1: LibreWolf dialogs will be familiar to Firefox users, with a few variations. just LibreWolf’s lo-
cale, click on the
hamburger menu to
the right of the ad-
dress bar and select
Settings from the
drop-down menu that
opens. A configura-
tion dialog opens
that differs signifi-
cantly from its
Firefox counterpart.
Click on General in
the sidebar on the
left and then scroll
down the page on
the right to the Lan-
guage option. US
English is the default
language here.
If you are not
happy with that, you
can click on the Set
Alternatives button to open a small dialog with typical tracking methods on websites, such as
the available languages. Click Select a language canvas fingerprinting.
to add, choose, say, Spanish as the language The options for managing cookies and web-
from the drop-down menu that appears, and site data are also stricter in LibreWolf than in
then click Add to the right. This puts the Span- the original: This data is automatically deleted
ish localization at the top of the selection dia- when the browser is closed, and there is no disk
log, and LibreWolf will use it as the default lan- cache in which the browser could cache sensi-
guage for menus and notifications in the future. tive data. LibreWolf does not save access cre-
A final mouse click on OK closes the overlap- dentials and passwords for individual websites
ping window. or form data by default, and therefore does not
automatically fill in the corresponding fields on
Protective Measures web pages. However, these options can be en-
The Settings dialogs available under General vary abled by checking the box, just like in Firefox. Li-
only slightly compared with Firefox (Figure 1). breWolf also deletes the history of websites vis-
However, LibreWolf does not let you customize ited during a session by default when the
the appearance of web pages in this dialog, browser is closed. This means that the history
some of which modify their color schemes to from previous sessions cannot be retrieved
display content. The browser makes this restric- when the browser is opened again.
tion due to the default security options, where
the ResistFingerprinting module is enabled. Re- Special Options
sistFingerprinting keeps users from being tracked The Synchronization category, where Firefox of-
based on specific web browser settings. fers data synchronization between multiple end-
Under Startup, LibreWolf only shows an Internet points, does not exist in LibreWolf. Instead, the
search on the startup screen. Shortcuts and ac- Firefox fork integrates a separate LibreWolf sec-
tivities, as well as notices from Mozilla (which tion into the configuration dialog, where you can
Firefox enables by default), are left out here. If re- make numerous security-specific adjustments
quired, further options can also be restricted: You (Figure 2).
can prevent sponsored links being displayed on Localization is still lacking here: The browser
the LibreWolf startup page – this is common currently only lists the options in this category in
practice in Firefox. In addition, pages saved to English. However, you can understand them even
Pocket do not show up on the startup page, be- with a limited knowledge of English. To the right
cause the developers have completely removed of each option, there is a link in the form of a
Pocket from LibreWolf. In the Search dialog, all question mark in a circle. Clicking on a the ques-
commercial offerings have been removed from tion mark link for an option opens a small
the search engine se-
lection, including the Figure 2: LibreWolf comes with its own configuration dialog where many security-related
Microsoft and Google options can be customized.
search engines.
The LibreWolf pro-
grammers have
made even more sig-
nificant adjustments
in the Privacy & Secu-
rity category. The En-
hanced Activity Pro-
tection group does
not have three op-
tions like Mozilla
Firefox does; instead
there is only the strict
protection variant.
Firefox only offers
standard protection
in this group by de-
fault. Activity tracking
protection in Libre-
Wolf also extends to
social network
scripts and various
explanation below the option and often also automatic playback of multimedia content pro-
shows you optional settings. The parameters can vided on numerous websites by default. LibreWolf
be activated or deactivated by checking or un- also relentlessly blocks sponsored content and
checking the boxes to the left of each option. VPN ads from Mozilla. In addition, you are pro-
For savvy browser users, there are two inter- tected against pop-up windows and what can often
esting options at the end of the settings list. be annoying suggestions and advertisements
Clicking All advanced settings opens the manual when you enter search keys in the address bar. This
configuration console, which you can otherwise means that you can focus on the actual content.
only access by typing about:config in the brows- The LibreWolf project explicitly advises against
er’s address bar. Clicking Open user profile direc- using the software instead of the Tor Browser in
tory opens the file manager with the user profile the context of the Tor network. Although both web
directory. The root directory with all files and browsers are based on Mozilla Firefox, the Tor
subdirectories appears. Experienced users can Browser has some settings explicitly adapted to
use these files to repair damaged profiles. the Tor network. The different configuration of Li-
You can access the profile manager, like in breWolf, in conjunction with the Tor network, can
Firefox, by typing about:profiles in the browser’s open security holes that allow attackers to remove
address bar. The profile manager that opens gives the anonymity of the respective user and spy on
you an easy option for creating, deleting, and their browsing behavior.
modifying user profiles.
Conclusions
Cryptography LibreWolf removes a lot of tedious configura-
Besides the options you can manage as a user in tion work for users who value security and pri-
the Settings dialogs, LibreWolf also comes with vacy. The browser already enables most of the
some improvements under the hood compared to security options in the default settings, whereas
Firefox. For example, the browser disables SHA-1 you have to enable them manually in Firefox in
certificates because the underlying algorithm has various settings dialogs. The developers have
known security vulnerabilities. By default, Libre- also completely removed other options in Libre-
Wolf also uses HTTPS-only mode, so that strong Wolf from the outset, such as telemetry set-
transport encryption is always enabled when call- tings, which security-conscious users must
ing up web pages. first disable in Firefox. Users won’t miss out on
Additionally, the software integrates protection new features, because the browser follows
against homographic attacks, where attackers Mozilla in terms of updates, and extensions are
use similar-looking characters in domain names fully compatible. All told, LibreWolf is a far bet-
to lure users to fake websites. The browser blocks ter choice for security-conscious friends of the
content that uses a certificate and fails digital sig- Mozilla browser. Q Q Q
nature validation with an OCSP responder. How-
ever, this setting can be modified in the LibreWolf Info
category of the Settings dialog [3].
[1] LibreWolf: https://librewolf.net/
QQQ
Universal Connector
For a long time, TeamViewer and AnyDesk dominated the remote maintenance
software market. Recently, a new player entered the scene in the form of the free
and GPL-licensed RustDesk. BY THOMAS LEICHTENSTERN
SH has been considered the gold standard The project, which was launched only about one
Installation
The project provides clients for openSUSE, Man-
jaro, Fedora, and Ubuntu, among other Linux sys-
tems, on its website [3].
After downloading the right version for your
system, you can install the software using your
distribution’s package manager. On Ubuntu, just
download and a click on the DEB file to start the
install. It is noticeable that the package manager
drags in quite a large number of dependencies
from the repositories.
The software sets up an auto-starter during the
install. This means that it loads automatically
each time the computer reboots, and you can ac-
cess the computer externally. RustDesk always
runs with the rights of the user who uses it.
First Launch
After successful installation, you can launch the
Figure 1: When first launched, RustDesk comes up with a clear-cut and tidy interface. program on Ubuntu via Others | RustDesk. Other
Figure 3: The left column shows the local folders and files, the right column the ones on the remote computer. The transfer status is shown on the far right.
window, which you can drag to make it larger or makes working with it more diffi-
smaller as desired. cult. The web client does not
The same menu lets you set the balance be- have a file transfer mode unlike
tween the response time and image quality. The the desktop variant.
Custom option gives you a free hand: You can set
the weighting of the bitrate and the quantizer using Own Server
slide tools. Besides the many client variants,
To display the window contents full screen, click the project also offers its own
on the small rectangle in the menu at the top. In relay server. It includes both hbbs
this mode, RustDesk will then show the menubar (RustDesk ID/Rendezvous
again as soon as you touch the top of the screen Server) and hbbr (RustDesk
with the mouse pointer. Relay Server) components lo-
Clicking on the speech bubble icon opens a cated in the same archive. How-
message window that works like a messenger. ever, the documentation of this
The other person can read what you type and re- software is limited to the bare
spond if necessary. essentials, which makes config-
uration difficult. Basically, you
Extended Configuration just need to launch the two com-
You can access the advanced configuration by ponents (Listing 1).
clicking on the three vertical dots next to ID (Fig- On the client side, enter the cor-
ure 5). This lets you specify, for example, whether responding IP address in ID/Con-
the connection partner can use the keyboard, nection Server. The project recom-
transfer files, or if a shared clipboard is available. mends using PM2 to manage the
On the local network you also have the option server components. For step-by- Figure 6: The Android app supports remote
of addressing remote computers by IP address step instructions on basic client control of other computers as well as access to
instead of by their IDs. To do this, select Enable and server configuration, see the the device itself.
Direct IP Access. If you click on the pencil next RustDesk documentation [7].
to the dot, then a field appears where you can
specify a separate port. By default, RustDesk Conclusions
uses port 21118. In daily operation, there were no issues with Rust-
Desk during the test phase. The software per-
Building Bridges forms the basic functions just as well as AnyDesk
Like I mentioned earlier, RustDesk not only or TeamViewer. Transferring the desktop required
gives you software for desktop systems, but about the same transfer rates as the other candi-
also for mobile devices running Android and iOS dates, and no crashes or software errors oc-
via the respective providers’ app stores. The curred. However, there is one point of criticism
apps can act as a client or server, allowing con- that the project needs to deal with: The documen-
nection to remote PCs and access to the mobile tation, especially for the server, leaves much to be
devices from them (Figure 6). In testing, this desired in many places. Q Q Q
worked smoothly in both directions, although
operating a remote PC via the Android app does
take some practice. Info
Alternatively, the project also offers a web cli- [1] RustDesk: https://rustdesk.com
ent [6] for establishing a connection. The soft-
[2] RustDesk on GitHub:
ware, which is still beta, supports access to the
https://github.com/rustdesk/rustdesk
corresponding devices in a web browser. The re-
mote desktop appears after logging in, just like [3] RustDesk download: https://github.com/
it does using the local program. To access the rustdesk/rustdesk/releases
settings, click on the small arrow bottom right in [4] Xorg Server dummy configuration:
the display. After doing so, a bar appears where https://techoverflow.net/2019/02/23/how-to-
you can adjust the screen display, among other run-x-server-using-xserver-xorg-video-
things, just like with the desktop client. In test- dummy-driver-on-ubuntu/
ing, this feature worked surprisingly well, but
[5] HDMI dummy plug:
you have to expect a certain latency, which
https://a.co/d/1vxKJo8
[6] RustDesk web client:
Listing 1: Starting the Server http://web.rustdesk.com/#/
$ ./hbbs -r <Relay-Server-IP:Port>
$ ./hbbr
[7] Configuring RustDesk server:
https://rustdesk.com/docs/en/self-host/
Graham has discovered he can mask his complete tuning and scale configura-
tions. The top half of the
inability to play or perform music by pretending to tune main window contains its
and play things with custom scales. BY GRAHAM MORRISON synthesizer, written by de-
veloper Paul Walker in a
Tuning and scale creation weekend, that offers great
Astronomy
Stellarium 1.0
round 20 years ago, one source space simulation on the
BitTorrent client
Transmission 4
ransmission is another client you use, but for many of
mle
e look at a lot of text scarcity does not affect usability.
Server automation
sake
inux is now so easy to in- jobs. And this is where sake can
Terminal music
MusicPlayerPlus
usicPlayerPlus is an analyzer, all within a freshly config-
Bandwidth control
Wonder Shaper
ith so many of us now tool that can save your job if you
Noise generator
Samplebrain
t’s not often that a cutting- audio files can be
Project Website
Samplebrain transforms perfectly recorded audio into something that sounds broken, https://gitlab.com/then-try-this/
incoherent, and totally unintentional, which must surely have been the intention. samplebrain
360-degree platformer
ROTA
he Godot games engine picked and either learned from or
OpenRCT2
t’s amazing just how many old reimplementation of the games
Migrating Music
Use a Python API to migrate a music library from SQL to a NoSQL document database.
n this article, I will show you how I used a schema. Document databases do not require
I
BY JOHN COFIELD
Python application programming interface each document to have the same fields (though
(API) to migrate my music library from an they can). In fact, it is possible to have different
SQL relational database to a NoSQL document fields in each document throughout the data-
database. Using the Python X DevAPI in the base. That flexibility is one of the key advantages
MySQL Shell application, I will highlight some of a document store over a relational store. It is
basics about document databases, the Python the reason I decided to migrate, because it al-
methods that I used, and the database tool that lows me to easily add new metadata to my
enables migration. Readers who should get the music library. That could include metadata such
most out of this article are those that have as artist background information, song credits,
some basic familiarity with the structured query and/or other miscellaneous metadata that may
language (SQL) and with the Python program- not be immediately available.
ming language.
What Is a JSON Document?
Why Migrate from SQL to Document? In many document store systems, documents
I have my existing personal music library in an are JavaScript Object Notation (JSON) objects,
SQL relational database containing music meta- or JSON-like objects. JSON is becoming in-
data – artist, song title, album title, track number, creasingly popular as a standard for data inter-
genre, release year – that I want to migrate to a change and storage and is beginning to replace
document database. For the purpose of this arti- the Extensible Markup Language (XML) as a
cle, I will use a few examples from my library dominant data exchange format, particularly for
(Figure 1). music metadata. JSON documents are light-
SQL relational databases have been dominant weight, language-independent, and human read-
for decades, making up 60 percent of the data- able. In short, JSON documents are elegant in
base market in 2019 according to a ScaleGrid Da- their simplicity. Many popular music APIs pro-
tabase Trends report. In recent years, use of docu- vide JSON-formatted metadata. These APIs in-
ment databases has increased, largely driven by clude Amazon, Apple Music, Spotify, Sound-
the requirements of big data. One of the criticisms Cloud, and others.
of relational databases is that their schema is The JSON format eases development since it is
rigid. All data fields must be defined in advance object-oriented and easier to parse than XML, be-
with identical fields in every row in a table, making cause JSON documents are comprised of a
it difficult to make schema changes later. comma-separated list of one or more key-value
By contrast, document store databases, some- pairs. The simplest form of a JSON document is
times referred to as NoSQL, do not have a fixed {key:value}. You will note that this is the same
as follows: ('my_collection1')
{"Artist" : "Quincy Jones", "Album" : "Q's Jook U In the statement above, I’ve created a collection
Joint"} object named my_collection1 using the create_
collection() method and assigned it to doc_col-
A group of related documents is referred to as a lection1, which will be the target document collec-
collection. As an analogy between a relational da- tion. I will subsequently add, update, or remove
tabase and a document database, a table in a re- documents as necessary.
lational database is equivalent to a collection in a In the next step, I need to extract my metadata
document database. Each row in a table is equiv- from the source SQL database. This metadata is
alent to a document in the collection, and each in a table named sql_table. To extract data in a
field name (column) in a table is equivalent to a table row, I execute the statements below:
key in a document.
table_result = sql_table.select().execute()
collection.add() doc_collection1.add(table_2document).execute()
collection.find()
The Process
The three steps that I identified above assume
that the relational database exists, that a data-
base connection has already been established,
and the source table exists. Before starting the
migration process, I’m assuming that a connec-
tion to the database has already been made and
that the following instances already exist:
# Session instance
With these three basic steps, I can add a single ("Artist", "Carlos Santana")
The Author
John Cofield is a retired
software marketing man-
ager in Northern California.
His training is in electrical
engineering, and he has
worked at multiple Silicon
Valley semiconductor
and software companies.
His nontechnical interests include Jazz
music, ranging from Modal to Fusion.
QQQ
LINUX
NEWSSTAND Order online:
https://bit.ly/Linux-Newsstand
Linux Magazine is your guide to the world of Linux. Monthly issues are packed with advanced technical
articles and tutorials you won't find anywhere else. Explore our full catalog of back issues for specific
topics or to complete your collection.
#265/December 2022
Quantum Computing
Most Linux users know that this futuristic technology leverages the weird power of quantum
mechanics. But how does it really work? What can I do with it? Are there tools available today
that will help me experiment? This month we take a deep dive into quantum computing.
On the DVD: Manjaro 21.3.7-220816 and Arch Linux 2022.10.01
#264/November 2022
Artificial Intelligence
Machine learning remains shrouded in mystery even though it is now an integral part of our
everyday world. This month we look behind the curtain at some popular techniques for
supervised and unsupervised learning.
On the DVD: Debian 11.5 and Rocky Linux 9.0
#263/October 2022
Build an IoT Linux
The most amazing thing about Linux is its flexibility. Linux systems run on the biggest computers
in the world – and on many of the diminutive devices that populate your home environment. If
you’ve always wondered how developers adapt Linux to run on tiny tech, you’ll appreciate this
month’s stories on Buildroot and the Yocto project.
On the DVD: Linux Magazine Archive issues 1-262
#262/September 2022
Beyond 5G
Behind the scenes, the cellular phone network has always been the preserve of highly specialized
and proprietary equipment, but some recent innovations could be changing that. This month we
explore the Open RAN specification, which could one day allow more of the mobile phone
network to operate on off-the-shelf hardware.
On the DVD: openSUSE Leap 15.4 and MX Linux 21.1
#261/August 2022
USB Boot
Live boot was such an exciting idea 15 years ago – just carry a CD with you and boot from
anywhere. But old-style boot CDs had some limitations. Today’s USB boot tools solve those
problems plus offer a feature that no one even thought about back then: access to several
boot images on a single stick.
On the DVD: Linux Mint MATE 20.3 and FreeBSD 13.1
#260/July 2022
Privacy
If you are really serious about privacy, you’ll need to lean on more than your browser’s no
tracking button. Those who need anonymity the most depend on the Tor network – a global
project offering safe surfing even in surveillance states. We also look at Portmaster, an application
firewall with some useful privacy features.
On the DVD: Ubuntu 22.04 and Fedora Workstation 36
FEATURED
EVENTS
Users, developers, and vendors meet at Linux events around the world.
We at Linux Magazine are proud to sponsor the Featured Events shown here.
For other events near you, check our extensive events calendar online at
https://www.linux-magazine.com/events.
If you know of another Linux event you would like us to add to our calendar,
please send a message with all the details to [email protected].
Events
FOSDEM 2023 Feb. 4-5 Brussels, Belgium https://fosdem.org/2023/
Contact Info
Editor in Chief While every care has been taken in the content of
Joe Casad, [email protected] the magazine, the publishers cannot be held respon-
Copy Editors sible for the accuracy of the information contained
Amy Pettle, Aubrey Vaughn within it or any consequences arising from the use of
News Editors it. The use of the disc provided with the magazine or
Jack Wallen, Amber Ankerholz any material provided on it is at your own risk.
Editor Emerita Nomadica Copyright and Trademarks © 2022 Linux New
Rita L Sooby
Media USA, LLC.
Authors Managing Editor
Lori White No material may be reproduced in any form what-
Bernhard Bablok 70 soever in whole or in part without the written per-
Localization & Translation
Erik Bärwaldt 23, 46, 78 Ian Travis mission of the publishers. It is assumed that all cor-
respondence sent, for example, letters, email,
Layout
Zack Brown 12 faxes, photographs, articles, drawings, are sup-
Dena Friesen, Lori White
Bruce Byfield 6, 20, 34, 58 plied for publication or license to third parties on
Cover Design
Dena Friesen a non-exclusive worldwide basis by Linux New
Joe Casad 3 Media USA, LLC, unless otherwise stated in writing.
Cover Image
John Cofield 92 © Aliaksandr Marko, 123RF.com Linux is a trademark of Linus Torvalds.
Mark Crutch 75 Advertising All brand or product names are trademarks
Brian Osborn, [email protected]
of their respective owners. Contact us if we
Jim Hall 37 phone +49 8093 7679420
haven’t credited your copyright; we will always
Jon “maddog” Hall 76 Marketing Communications
correct any oversight.
Gwen Clark, [email protected]
Thomas Leichtenstern 82 Linux New Media USA, LLC Printed in Nuremberg, Germany by Zeitfracht GmbH.
4840 Bob Billings Parkway, Ste 104 Distributed by Seymour Distribution Ltd, United
Vincent Mealing 75 Lawrence, KS 66049 USA
Kingdom
Graham Morrison 86 Publisher
Brian Osborn Represented in Europe and other territories by:
Mike Schilli 50 Sparkhaus Media GmbH, Bialasstr. 1a, 85625
Customer Service / Subscription
For USA and Canada: Glonn, Germany.
Carina Schipper 16
Email: [email protected] Published monthly as Linux Magazine (Print
Scott Sumner 62 Phone: 1-866-247-2802 ISSN: 1471-5678, Online ISSN: 2833-3950) by
(Toll Free from the US and Canada)
Ferdinand Thommes 40 Linux New Media USA, LLC, 4840 Bob Billings
For all other countries: Parkway, Ste 104, Lawrence, KS 66049, USA. Pe-
Jack Wallen 8 Email: [email protected] riodicals Postage paid at Lawrence, KS and addi-
Franciszek Pokryszko 30 www.linux-magazine.com tional mailing offices. Ride-Along Enclosed.
Backup
All the security in the world won’t help if your hard drive
crashes. Or what if ransomware puts a lock on your
disk? Do you really have to pay? With all the changes in
the computer industry through the years, one important
rule remains the unchanged: Back up your data!
Preview Newsletter
The Linux Magazine Preview is a monthly email
newsletter that gives you a sneak peek at the next
issue, including links to articles posted online.
Sign up at: https://bit.ly/Linux-Update
Image © Timofeev Vladimir, 123RF.com