Skip to content

Commit 5a1da77

Browse files
fold documentation to 80 character width
1 parent 1d40205 commit 5a1da77

File tree

4 files changed

+158
-39
lines changed

4 files changed

+158
-39
lines changed

README.md

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,47 @@
11
werc-on-openbsd
22
===============
33

4-
Automate [Werc](http://werc.cat-v.org/) setup on [OpenBSD](https://www.openbsd.org/).
4+
Automate [Werc](http://werc.cat-v.org/) setup on
5+
[OpenBSD](https://www.openbsd.org/).
56

67
## Useful info
78

8-
Both the `setup.sh` and `unsetup.sh` scripts, in their latest available version ([v2.2](https://github.com/EdoardoLaGreca/werc-on-openbsd/releases/tag/v2.2)), have been successfully tested on the latest available OpenBSD stable release (7.7). Prior or later versions of OpenBSD may not work.
9+
Both the `setup.sh` and `unsetup.sh` scripts, in their latest available version
10+
([v2.2](https://github.com/EdoardoLaGreca/werc-on-openbsd/releases/tag/v2.2)),
11+
have been successfully tested on the latest available OpenBSD stable release
12+
(7.7). Prior or later versions of OpenBSD may not work.
913

10-
**Performing an OpenBSD release upgrade (e.g. by using [sysupgrade(8)](https://man.openbsd.org/sysupgrade.8)) may break the current Werc installation.** It is advised to always test your Werc installation after performing either a system upgrade, a Werc update, or a plan9port update. If it stops working, head to [Troubleshooting](#troubleshooting).
14+
**Performing an OpenBSD release upgrade (e.g. by using
15+
[sysupgrade(8)](https://man.openbsd.org/sysupgrade.8)) may break the current
16+
Werc installation.** It is advised to always test your Werc installation after
17+
performing either a system upgrade, a Werc update, or a plan9port update. If it
18+
stops working, head to [Troubleshooting](#troubleshooting).
1119

1220
### Limitations
1321

14-
For now, the installation resulting from `setup.sh` has only been tested with `GET` requests, which it supports for sure. Other types of HTTP requests may or may not work (e.g. the "user login" feature). The URL-based rules in `/etc/httpd.conf` (`location ...`) may need a different configuration to support HTTP requests other than `GET`.
22+
For now, the installation resulting from `setup.sh` has only been tested with
23+
`GET` requests, which it supports for sure. Other types of HTTP requests may or
24+
may not work (e.g. the "user login" feature). The URL-based rules in
25+
`/etc/httpd.conf` (`location ...`) may need a different configuration to
26+
support HTTP requests other than `GET`.
1527

1628
### Other info
1729

18-
A [tagged commit](https://git-scm.com/book/en/v2/Git-Basics-Tagging) with tag name of the form `vN.M` (where `N` and `M` are integers), is a commit whose working tree has the following characteristics:
30+
A [tagged commit](https://git-scm.com/book/en/v2/Git-Basics-Tagging) with tag
31+
name of the form `vN.M` (where `N` and `M` are integers), is a commit whose
32+
working tree has the following characteristics:
1933

20-
1. It has a readable README which is carefully divided into sections and contains instructions about the usage of the two scripts. The README file may also contain checksums for the two scripts.
21-
2. It has the two scripts, `setup.sh` and `unsetup.sh`, tested against the latest OpenBSD stable version (available at that point in time) with positive outcome and no known side effect on the system.
34+
1. It has a readable README which is carefully divided into sections and
35+
contains instructions about the usage of the two scripts. The README file may
36+
also contain checksums for the two scripts.
37+
2. It has the two scripts, `setup.sh` and `unsetup.sh`, tested against the
38+
latest OpenBSD stable version (available at that point in time) with positive
39+
outcome and no known side effect on the system.
2240

23-
Since the testing process is manual I may overlook some edge cases, sometimes on purpose and sometimes not. I care about the quality of my software but testing every single line against all its possible edge cases is really time consuming and unsustainable.
41+
Since the testing process is manual I may overlook some edge cases, sometimes
42+
on purpose and sometimes not. I care about the quality of my software but
43+
testing every single line against all its possible edge cases is really time
44+
consuming and unsustainable.
2445

2546
## Rationale
2647

@@ -38,9 +59,12 @@ See [doc/testing.md](doc/testing.md).
3859

3960
### Werc stops working after upgrading OpenBSD
4061

41-
It may happen that, after upgrading OpenBSD, your website stops working and only shows "500 internal server error".
62+
It may happen that, after upgrading OpenBSD, your website stops working and
63+
only shows "500 internal server error".
4264

43-
While the exact reason behind this behavior should be carefully analyzed and understood, you might try uninstalling and re-installing Werc and plan9port. The procedure is the same as if you were to update them.
65+
While the exact reason behind this behavior should be carefully analyzed and
66+
understood, you might try uninstalling and re-installing Werc and plan9port.
67+
The procedure is the same as if you were to update them.
4468

4569
```sh
4670
doas ./unsetup.sh uninst rm9env
@@ -53,5 +77,6 @@ Look for files ending in ".sum".
5377

5478
## License
5579

56-
Everything in this repository is licensed under the [ISC license](https://en.wikipedia.org/wiki/ISC_license). See LICENSE file.
80+
Everything in this repository is licensed under the [ISC
81+
license](https://en.wikipedia.org/wiki/ISC_license). See LICENSE file.
5782

doc/rat.md

Lines changed: 54 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,65 @@
11
Rationale and details
22
=====================
33

4-
[Werc](http://werc.cat-v.org/), defined as a "sane web anti-framework", is a set of [CGI](https://en.wikipedia.org/wiki/Common_Gateway_Interface) scripts that take markdown files and HTML templates and spit out a complete HTML page. It is simple (highly functional core is 150 lines), easily extensible, and fast enough.
4+
[Werc](http://werc.cat-v.org/), defined as a "sane web anti-framework", is a
5+
set of [CGI](https://en.wikipedia.org/wiki/Common_Gateway_Interface) scripts
6+
that take markdown files and HTML templates and spit out a complete HTML page.
7+
It is simple (highly functional core is 150 lines), easily extensible, and fast
8+
enough.
59

6-
Werc is quite popular among [Plan 9](https://en.wikipedia.org/wiki/Plan_9_from_Bell_Labs) and [9front](https://9front.org/) users. Two possible and logical reasons are that:
10+
Werc is quite popular among [Plan
11+
9](https://en.wikipedia.org/wiki/Plan_9_from_Bell_Labs) and
12+
[9front](https://9front.org/) users. Two possible and logical reasons are that:
713

8-
1. It was written using Plan 9's default shell, [Rc](https://p9f.org/sys/doc/rc.html).
14+
1. It was written using Plan 9's default shell,
15+
[Rc](https://p9f.org/sys/doc/rc.html).
916
2. Like I said before, it is simple, and Plan 9 folks like simplicity.
1017

11-
I didn't have much knowledge or experience with Plan 9 at the time. However, I did have knowledge and experience with Unix-like systems (a lot more, compared to Plan 9) and I knew about the existence of [plan9port](https://9fans.github.io/plan9port/), a port of the Plan 9 user space to Unix-like systems (thank you [Russ Cox](https://swtch.com/~rsc/)). A Unix-like operating system and plan9port were all I needed to make Werc work outside of Plan 9. On one hand, an operating system family that I was familiar with. On the other, the simplicity of Werc and the Plan 9 user space.
18+
I didn't have much knowledge or experience with Plan 9 at the time. However, I
19+
did have knowledge and experience with Unix-like systems (a lot more, compared
20+
to Plan 9) and I knew about the existence of
21+
[plan9port](https://9fans.github.io/plan9port/), a port of the Plan 9 user
22+
space to Unix-like systems (thank you [Russ Cox](https://swtch.com/~rsc/)). A
23+
Unix-like operating system and plan9port were all I needed to make Werc work
24+
outside of Plan 9. On one hand, an operating system family that I was familiar
25+
with. On the other, the simplicity of Werc and the Plan 9 user space.
1226

13-
The choice I made regarding the specific operating system to use was backed by one main thought: *if it is exposed to the internet, it must be **secure***. I could have chosen Linux, but OpenBSD is much more closely related to Unix (Unix as it was intended by its creators), and it has way stricter policies regarding security.
27+
The choice I made regarding the specific operating system to use was backed by
28+
one main thought: *if it is exposed to the internet, it must be **secure***. I
29+
could have chosen Linux, but OpenBSD is much more closely related to Unix (Unix
30+
as it was intended by its creators), and it has way stricter policies regarding
31+
security.
1432

15-
Another thing I really cared about, back when I started writing this script, is that it had to have the least external dependencies possible. In other words, with the reasonable exception of plan9port, it only had to rely on things that were already available in the default OpenBSD install, if possible. I took this decision for two reasons: the first is that I hate when something installs a gazillion dependencies and bloats your system, the second is that external dependencies may introduce security breaches.
33+
Another thing I really cared about, back when I started writing this script, is
34+
that it had to have the least external dependencies possible. In other words,
35+
with the reasonable exception of plan9port, it only had to rely on things that
36+
were already available in the default OpenBSD install, if possible. I took this
37+
decision for two reasons: the first is that I hate when something installs a
38+
gazillion dependencies and bloats your system, the second is that external
39+
dependencies may introduce security breaches.
1640

17-
In addition to all I said before, and this was by far the hardest goal to achieve, all this had to comply with OpenBSD's [httpd](https://man.openbsd.org/httpd) way of doing things. That is, the hosted website is served from a `chroot`'ed directory, `/var/www`. By doing so, potential breaches are only limited to that portion of the file system. At first, since [symlinks](https://en.wikipedia.org/wiki/Symbolic_link) cannot be accessed from a `chroot`'ed environment, I solved it the naïve way: I just copied all the Plan 9 utilities, together with their shared objects, into `/var/www`. This was not the best solution, not even close, but it worked for a while. Then, I switched to [hard links](https://en.wikipedia.org/wiki/Hard_link). In theory, hard links consume way less data on disk. In practice, most of the times they are not possible because even OpenBSD's default installation splits the filesystem into many partitions and hard links cannot be created from one disk/partition to the other. At that time I wrote the setup script to only hard link files when possible and to copy them otherwise. Given the probabilities of finding an OpenBSD installation with all files on the same partition, this latter solution was basically the same as the former, naïve solution.
41+
In addition to all I said before, and this was by far the hardest goal to
42+
achieve, all this had to comply with OpenBSD's
43+
[httpd](https://man.openbsd.org/httpd) way of doing things. That is, the hosted
44+
website is served from a `chroot`'ed directory, `/var/www`. By doing so,
45+
potential breaches are only limited to that portion of the file system. At
46+
first, since [symlinks](https://en.wikipedia.org/wiki/Symbolic_link) cannot be
47+
accessed from a `chroot`'ed environment, I solved it the naïve way: I just
48+
copied all the Plan 9 utilities, together with their shared objects, into
49+
`/var/www`. This was not the best solution, not even close, but it worked for a
50+
while. Then, I switched to
51+
[hard links](https://en.wikipedia.org/wiki/Hard_link). In theory, hard links
52+
consume way less data on disk. In practice, most of the times they are not
53+
possible because even OpenBSD's default installation splits the filesystem into
54+
many partitions and hard links cannot be created from one disk/partition to the
55+
other. At that time I wrote the setup script to only hard link files when
56+
possible and to copy them otherwise. Given the probabilities of finding an
57+
OpenBSD installation with all files on the same partition, this latter solution
58+
was basically the same as the former, naïve solution.
1859

19-
The final solution, introduced in [v2.0](https://github.com/EdoardoLaGreca/werc-on-openbsd/releases/tag/v2.0), is to clone plan9port's git repository into the `chroot`'ed filesystem and install it there, with its hard-coded paths adjusted through the `-r` option. Not only this improves the system's security, since patches can be applied immedately, but it also eliminates the need of work-arounds to make hard-coded paths work.
60+
The final solution, introduced in
61+
[v2.0](https://github.com/EdoardoLaGreca/werc-on-openbsd/releases/tag/v2.0), is
62+
to clone plan9port's git repository into the `chroot`'ed filesystem and install
63+
it there, with its hard-coded paths adjusted through the `-r` option. Not only
64+
this improves the system's security, since patches can be applied immedately,
65+
but it also eliminates the need of work-arounds to make hard-coded paths work.

doc/testing.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,17 @@
22

33
Unless you'd like to contribute to the development, ignore this document.
44

5-
A test script, namely `test.sh`, automates the testing of the setup and unsetup scripts. The test script contains three main functions:
5+
A test script, namely `test.sh`, automates the testing of the setup and unsetup
6+
scripts. The test script contains three main functions:
67

78
- `init`, which performs all the preliminary tasks
8-
- `setup`, which runs the setup script and collects information about changes in the filesystem
9+
- `setup`, which runs the setup script and collects information about changes
10+
in the filesystem
911
- `unsetup`, which is the same as `setup` but with the unsetup script
1012

11-
The behavior of the test script is similar to that of the setup and unsetup scripts: functions can be called by specifying them as command line arguments. However, there is one little difference, which is that running the script without arguments is no different from not running the script at all. This behavior is a choice which, in theory, should reduce careless testing.
13+
The behavior of the test script is similar to that of the setup and unsetup
14+
scripts: functions can be called by specifying them as command line arguments.
15+
However, there is one little difference, which is that running the script
16+
without arguments is no different from not running the script at all. This
17+
behavior is a choice which, in theory, should reduce careless testing.
1218

0 commit comments

Comments
 (0)