~emersion/soju-dev

soju: soju: fix crash on start v1 APPLIED

Moritz Poldrack: 2
 soju: fix crash on start
 doc: add documentation for the file-upload key

 2 files changed, 9 insertions(+), 2 deletions(-)
#1139122 .build.yml success
Pushed, thanks!
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~emersion/soju-dev/patches/48967/mbox | git am -3
Learn more about email & git

[PATCH soju 1/2] soju: fix crash on start Export this patch

From: Moritz Poldrack <git@moritz.sh>

When started without specifying a fileupload backend, soju crashes
because of a nil-pointer deref.

	panic: runtime error: invalid memory address or nil pointer dereference
	[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x9484bd]

	goroutine 1 [running]:
	main.loadConfig()
		git.sr.ht/~emersion/soju/cmd/soju/main.go:94 +0x51d
	main.main()
		git.sr.ht/~emersion/soju/cmd/soju/main.go:127 +0x165
	panic: runtime error: invalid memory address or nil pointer dereference

Add a guardclause preventing that crash.

Signed-off-by: Moritz Poldrack <git@moritz.sh>
---
 cmd/soju/main.go | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/cmd/soju/main.go b/cmd/soju/main.go
index ebb9f0e..8752b9e 100644
--- a/cmd/soju/main.go
+++ b/cmd/soju/main.go
@@ -91,7 +91,7 @@ func loadConfig() (*config.Server, *soju.Config, error) {
	}

	var fileUploader fileupload.Uploader
	if raw.FileUpload.Driver != "" {
	if raw.FileUpload != nil && raw.FileUpload.Driver != "" {
		fileUploader, err = fileupload.New(raw.FileUpload.Driver, raw.FileUpload.Source)
		if err != nil {
			return nil, nil, fmt.Errorf("failed to create file uploader: %v", err)
@@ -242,7 +242,7 @@ func main() {
			}
			ln = proxyProtoListener(ln, srv)
			// TODO: this is racy
			if err := os.Chmod(path, 0600); err != nil {
			if err := os.Chmod(path, 0o600); err != nil {
				log.Fatalf("failed to chmod Unix admin socket: %v", err)
			}
			go func() {
-- 
2.43.0
soju/patches/.build.yml: SUCCESS in 1m11s

[soju: fix crash on start][0] from [Moritz Poldrack][1]

[0]: https://lists.sr.ht/~emersion/soju-dev/patches/48967
[1]: mailto:moritz@poldrack.dev

✓ #1139122 SUCCESS soju/patches/.build.yml https://builds.sr.ht/~emersion/job/1139122

[PATCH soju 2/2] doc: add documentation for the file-upload key Export this patch

From: Moritz Poldrack <git@moritz.sh>

Signed-off-by: Moritz Poldrack <git@moritz.sh>
---
 doc/soju.1.scd | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/doc/soju.1.scd b/doc/soju.1.scd
index f09b7d6..5c96557 100644
--- a/doc/soju.1.scd
+++ b/doc/soju.1.scd
@@ -153,6 +153,13 @@ The following directives are supported:

	(_log_ is a deprecated alias for this directive.)

*file-upload* <driver> [source]
	Set the database location for uploaded files.

	Supported drivers:

	- _fs_ stores uploaded files on disk. _source_ is required.

*http-origin* <patterns...>
	List of allowed HTTP origins for WebSocket listeners. The parameters are
	interpreted as shell patterns, see *glob*(7).
-- 
2.43.0
Pushed, thanks!