summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Douillet <vincent@vdouillet.fr>2026-07-10 22:15:00 +0200
committerVincent Douillet <vincent@vdouillet.fr>2026-07-10 22:15:00 +0200
commit9669adeceb9cc6ac41ca4ea9b9bc3f89036fc569 (patch)
treecfae231b3b4b937fd4e42fa1b5e0f8a95132cec1
parentc5c9cc569178e732ff3fb81d74050c18667bdec4 (diff)
add linux compatHEADmaster
-rw-r--r--Makefile35
-rw-r--r--README.md24
-rw-r--r--browse.c5
-rw-r--r--browse.h4
-rw-r--r--cgi.h4
-rw-r--r--config.h4
-rw-r--r--create.c4
-rw-r--r--delete.c5
-rw-r--r--http.h4
-rw-r--r--main.c2
-rw-r--r--upload.c6
11 files changed, 78 insertions, 19 deletions
diff --git a/Makefile b/Makefile
index d3de998..77dc536 100644
--- a/Makefile
+++ b/Makefile
@@ -26,11 +26,18 @@
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
+# OpenBSD
+CHROOT=/var/www
+WWW_USER=www
+# Linux
+#CHROOT=
+#WWW_USER=www-data
+
CC=cc
CFLAGS_DEPS != pkg-config --cflags kcgi kcgi-html
LDFLAGS_DEPS != pkg-config --libs kcgi kcgi-html
-CFLAGS=-DLOG_INFO -std=c89 $(CFLAGS_DEPS)
+CFLAGS=-DLOG_INFO -D_POSIX_C_SOURCE=200809L -std=c89 $(CFLAGS_DEPS)
LDFLAGS=-static $(LDFLAGS_DEPS)
.if make(debug) || make(test)
@@ -60,22 +67,22 @@ kcgienv: kcgienv.o
$(CC) -o $@ $> $(LDFLAGS)
install:
- install -D -o www -g www -m 0500 main /var/www/cgi-bin/vault
- install -D -o www -g www -m 0440 template/head.html /var/www/usr/share/vault/template/head.html
- install -D -o www -g www -m 0440 template/foot.html /var/www/usr/share/vault/template/foot.html
- install -D -o www -g www -m 0440 template/browse_head.html /var/www/usr/share/vault/template/browse_head.html
- install -D -o www -g www -m 0440 template/browse_foot.html /var/www/usr/share/vault/template/browse_foot.html
- install -D -o www -g www -m 0440 template/browse_item.html /var/www/usr/share/vault/template/browse_item.html
- install -D -o www -g www -m 0440 template/upload_head.html /var/www/usr/share/vault/template/upload_head.html
- install -D -o www -g www -m 0440 template/delete_head.html /var/www/usr/share/vault/template/delete_head.html
- install -D -o www -g www -m 0440 template/create_head.html /var/www/usr/share/vault/template/create_head.html
- install -D -o www -g www -m 0440 fontawesome-6.5.1/css/fontawesome.css /var/www/vault-static/fontawesome-6.5.1/css/fontawesome.css
+ install -D -o $(WWW_USER) -g $(WWW_USER) -m 0500 main /var/www/cgi-bin/vault
+ install -D -o $(WWW_USER) -g $(WWW_USER) -m 0440 template/head.html $(CHROOT)/usr/share/vault/template/head.html
+ install -D -o $(WWW_USER) -g $(WWW_USER) -m 0440 template/foot.html $(CHROOT)/usr/share/vault/template/foot.html
+ install -D -o $(WWW_USER) -g $(WWW_USER) -m 0440 template/browse_head.html $(CHROOT)/usr/share/vault/template/browse_head.html
+ install -D -o $(WWW_USER) -g $(WWW_USER) -m 0440 template/browse_foot.html $(CHROOT)/usr/share/vault/template/browse_foot.html
+ install -D -o $(WWW_USER) -g $(WWW_USER) -m 0440 template/browse_item.html $(CHROOT)/usr/share/vault/template/browse_item.html
+ install -D -o $(WWW_USER) -g $(WWW_USER) -m 0440 template/upload_head.html $(CHROOT)/usr/share/vault/template/upload_head.html
+ install -D -o $(WWW_USER) -g $(WWW_USER) -m 0440 template/delete_head.html $(CHROOT)/usr/share/vault/template/delete_head.html
+ install -D -o $(WWW_USER) -g $(WWW_USER) -m 0440 template/create_head.html $(CHROOT)/usr/share/vault/template/create_head.html
+ install -D -o $(WWW_USER) -g $(WWW_USER) -m 0440 fontawesome-6.5.1/css/fontawesome.css /var/www/vault-static/fontawesome-6.5.1/css/fontawesome.css
gzip -fk /var/www/vault-static/fontawesome-6.5.1/css/fontawesome.css
- install -D -o www -g www -m 0440 fontawesome-6.5.1/css/solid.css /var/www/vault-static/fontawesome-6.5.1/css/solid.css
+ install -D -o $(WWW_USER) -g $(WWW_USER) -m 0440 fontawesome-6.5.1/css/solid.css /var/www/vault-static/fontawesome-6.5.1/css/solid.css
gzip -fk /var/www/vault-static/fontawesome-6.5.1/css/solid.css
- install -D -o www -g www -m 0440 fontawesome-6.5.1/webfonts/fa-solid-900.ttf /var/www/vault-static/fontawesome-6.5.1/webfonts/fa-solid-900.ttf
+ install -D -o $(WWW_USER) -g $(WWW_USER) -m 0440 fontawesome-6.5.1/webfonts/fa-solid-900.ttf /var/www/vault-static/fontawesome-6.5.1/webfonts/fa-solid-900.ttf
gzip -fk /var/www/vault-static/fontawesome-6.5.1/webfonts/fa-solid-900.ttf
- install -D -o www -g www -m 0440 fontawesome-6.5.1/webfonts/fa-solid-900.woff2 /var/www/vault-static/fontawesome-6.5.1/webfonts/fa-solid-900.woff2
+ install -D -o $(WWW_USER) -g $(WWW_USER) -m 0440 fontawesome-6.5.1/webfonts/fa-solid-900.woff2 /var/www/vault-static/fontawesome-6.5.1/webfonts/fa-solid-900.woff2
gzip -fk /var/www/vault-static/fontawesome-6.5.1/webfonts/fa-solid-900.woff2
clean:
diff --git a/README.md b/README.md
index 8b85103..104d5c5 100644
--- a/README.md
+++ b/README.md
@@ -7,7 +7,7 @@ Vault is an opinionated web-based file manager. It is built in C for OpenBSD aro
* __simple__: browse, create and delete folders; download and upload files. JavaScript support is optional on the client side and its absence should be handled gracefully. Everything should work from a terminal-based web browser
* __fast__: with the server running on an ARM SBC, there should not be any noticeable delay when loading a page
-It should also compile and run on any POSIX OS with minor modifications, although this has not been tested (yet).
+It should also compile and run on any POSIX OS with minor modifications. On Linux, `bmake(1)` should be used instead of `make(1)`, and configuration should be adjusted in the `Makefile`. Please note that sandboxing is implemented for OpenBSD _only_.
## Configure
@@ -20,11 +20,13 @@ Vault comes with a Makefile:
$ make
# make install
-The vault binary will be installed as `/var/www/cgi-bin/vault`. Static resources will be installed in `/var/www/vault-static` and should be served from `/static`. You need to configure your web server accordingly, see below for a sample file. If the log file does not exist, you need to create it. Here is how to do it for a default installation:
+The vault binary will be installed as `/var/www/cgi-bin/vault`. Static resources will be installed in `/var/www/vault-static` and should be served from `/static`. You need to configure your web server accordingly, see below for sample files. If the log file does not exist, you need to create it. Here is how to do it for a chrooted web server, like OpenBSD's `httpd(8)`:
# touch /var/www/logs/vault.log
# chown www /var/www/logs/vault.log
+On other operating systems, assuming a web server that is _not_ chrooted, `config.h` sets the log path to `/var/log/vault.log` instead.
+
By default on OpenBSD, the `slowcgi(8)` daemon allows a timeout of 2 minutes for CGI programs. This might not be enough if you want to allow users to download large files. This timeout can be increased by changing the `slowcgi(8)` parameters in `/etc/rc.conf.local`, for example to allow up to 10 minutes :
slowcgi_flags="-t 600"
@@ -48,3 +50,21 @@ By default on OpenBSD, the `slowcgi(8)` daemon allows a timeout of 2 minutes for
gzip-static
}
}
+
+## Sample lighttpd.conf
+
+ server.modules+=("mod_alias", "mod_cgi", "mod_setenv")
+ server.port=80
+ server.document-root="/var/www/html"
+ server.errorlog="/var/log/lighttpd/error.log"
+ server.pid-file="/run/lighttpd.pid"
+ server.username="www-data"
+ server.groupname="www-data"
+ index-file.names=("index.html")
+
+ setenv.set-environment=("VAULT_DATA_DIR" => "/var/www/vault-data")
+ alias.url = ("/static" => "/var/www/vault-static")
+ $HTTP["url"] =~ "^/vault(?:/|$)" {
+ alias.url = ("/vault" => "/var/www/cgi-bin/vault")
+ cgi.assign = ("" => "")
+ }
diff --git a/browse.c b/browse.c
index 28e2b78..2fa7907 100644
--- a/browse.c
+++ b/browse.c
@@ -28,10 +28,13 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
+#include <sys/types.h>
#include <sys/queue.h>
-#include <dirent.h>
+#include <stdarg.h>
+#include <stdint.h>
#include <kcgi.h>
+#include <dirent.h>
#include <kcgihtml.h>
#include <limits.h>
#include <stdbool.h>
diff --git a/browse.h b/browse.h
index bcfd928..151ca8b 100644
--- a/browse.h
+++ b/browse.h
@@ -31,6 +31,10 @@
#ifndef BROWSE_H
#define BROWSE_H
+#include <sys/types.h>
+
+#include <stdarg.h>
+#include <stdint.h>
#include <kcgi.h>
#include "file.h"
diff --git a/cgi.h b/cgi.h
index b834246..d6f3af7 100644
--- a/cgi.h
+++ b/cgi.h
@@ -31,6 +31,10 @@
#ifndef CGI_H
#define CGI_H
+#include <sys/types.h>
+
+#include <stdarg.h>
+#include <stdint.h>
#include <kcgi.h>
#define K_OK(kcgi_call, r) \
diff --git a/config.h b/config.h
index 4920d42..6adf63a 100644
--- a/config.h
+++ b/config.h
@@ -36,7 +36,11 @@
* otherwise it will quit with an error.
*/
#ifndef LOG_FILE
+#ifdef __OpenBSD__
#define LOG_FILE "/logs/vault.log"
+#else
+#define LOG_FILE "/var/log/vault.log"
+#endif
#endif
/* The directory that contains the HTML template files */
diff --git a/create.c b/create.c
index e5a98b0..5355be0 100644
--- a/create.c
+++ b/create.c
@@ -28,6 +28,10 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
+#include <sys/types.h>
+
+#include <stdarg.h>
+#include <stdint.h>
#include <stdlib.h>
#include <kcgi.h>
#include <kcgihtml.h>
diff --git a/delete.c b/delete.c
index 367b937..8e11597 100644
--- a/delete.c
+++ b/delete.c
@@ -30,9 +30,12 @@
#include <sys/types.h>
#include <sys/stat.h>
-#include <fts.h>
+
+#include <stdarg.h>
+#include <stdint.h>
#include <kcgi.h>
#include <kcgihtml.h>
+#include <fts.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/http.h b/http.h
index 198e6b0..ec2866d 100644
--- a/http.h
+++ b/http.h
@@ -31,6 +31,10 @@
#ifndef HTTP_H
#define HTTP_H
+#include <sys/types.h>
+
+#include <stdint.h>
+#include <stdarg.h>
#include <kcgi.h>
#include "file.h"
diff --git a/main.c b/main.c
index 71ae864..cffd658 100644
--- a/main.c
+++ b/main.c
@@ -85,6 +85,7 @@ main(void)
}
/* A bit of security cannot hurt */
+#ifdef __OpenBSD__
if (-1 == unveil(data_dir, "rwc")
|| -1 == unveil(TEMPLATE_DIR, "r")
|| -1 == unveil(NULL, NULL)) {
@@ -95,6 +96,7 @@ main(void)
http_exit(&r, KHTTP_500, "Pledge failed: %s", strerror(errno));
goto end;
}
+#endif /* __OpenBSD__ */
/*
* Make sure basic request parameters are as expected : GET or POST,
diff --git a/upload.c b/upload.c
index d9b38cb..af80755 100644
--- a/upload.c
+++ b/upload.c
@@ -28,9 +28,13 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <stdlib.h>
+#include <sys/types.h>
+
+#include <stdarg.h>
+#include <stdint.h>
#include <kcgi.h>
#include <kcgihtml.h>
+#include <stdlib.h>
#include <limits.h>
#include <stdio.h>
#include <string.h>