Railroad Diagrams

In the film Planes, Trains, and Automobiles, characters played by Steve Martin and John Candy are faced with one improbable obstacle after another as they struggle to arrive home in time for the Thanksgiving holiday. Having compared this chapter with a sea voyage, it’s reminiscent of that film to consider yet another mode of transportation, railways, as a means of understanding the SELinux policy language.

However, unlike many of the decisions of the film characters, my decision to introduce railroad diagrams is not capricious. Such diagrams were used in the 1970s by famous computer scientist Niklaus Wirth to develop and explain Pascal, one of the most successful programming languages. Since then, they’ve been used to explain many other programming languages. Although they can be cumbersome to create, they’re quick to learn as well as easy to read and understand, so they’re just about ideal as a means of explanation. Let’s further mix our metaphors by diving into an exposition of railroad diagrams.

What Railroad Diagrams Do

Railroad diagrams are also known as syntax diagrams or syntax charts. They present the grammar of a formal language, such as one used for programming. However, formal languages also underlie the files used to configure systems and applications, such as the files that specify the SELinux security policy, so these diagrams are well suited to our immediate purpose.

Railroad diagrams specify two kinds of symbols:

Literal

A literal is a symbol that consists ...

Get SELinux now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.