"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Stefan Sperling <stsp@stsp.name>
Subject:
gotwebd non-root install
To:
gameoftrees@openbsd.org
Date:
Fri, 29 Jul 2022 12:00:54 +0200

Download raw body.

Thread
Allow installing gotwebd as a non-root user, provided some directories
in /var/www already exist and are writable by this user. ok?
 
diff 7375fc126e0f55289656336c6c8160c46efaba20 b95ef6ae73ab42b2a473eb68c926c77efa14ca29
commit - 7375fc126e0f55289656336c6c8160c46efaba20
commit + b95ef6ae73ab42b2a473eb68c926c77efa14ca29
blob - 4c0096efb52bb79e4a8f7e5f09c1b1d953009636
blob + 2411823014ec40f7de384de2b1a3b1f749884415
--- gotwebd/Makefile
+++ gotwebd/Makefile
@@ -40,14 +40,18 @@ DEBUG = -O0 -g
 
 realinstall:
 	if [ ! -d ${DESTDIR}${PUB_REPOS_DIR}/. ]; then \
-		${INSTALL} -d -o root -g daemon -m 755 ${DESTDIR}${PUB_REPOS_DIR}; \
+		${INSTALL} -d -o ${BINOWN} -g ${BINGRP} -m 755 \
+			${DESTDIR}${PUB_REPOS_DIR}; \
 	fi
-	${INSTALL} -c -o root -g daemon -m 0755 ${PROG} ${BINDIR}/${PROG}
+	${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 0755 \
+		${PROG} ${BINDIR}/${PROG}
 	if [ ! -d ${DESTDIR}${HTTPD_DIR}/. ]; then \
-		${INSTALL} -d -o root -g daemon -m 755 ${DESTDIR}${HTTPD_DIR}; \
+		${INSTALL} -d -o ${BINOWN} -g ${BINGRP} -m 755 \
+			${DESTDIR}${HTTPD_DIR}; \
 	fi
 	if [ ! -d ${DESTDIR}${PROG_DIR}/. ]; then \
-		${INSTALL} -d -o root -g daemon -m 755 ${DESTDIR}${PROG_DIR}; \
+		${INSTALL} -d -o ${BINOWN} -g ${BINGRP} -m 755 \
+			${DESTDIR}${PROG_DIR}; \
 	fi
 	${INSTALL} -c -o ${WWWUSR} -g ${WWWGRP} -m 0755 \
 	    ${.CURDIR}/files/htdocs/${PROG}/* ${DESTDIR}${PROG_DIR}
blob - 8e5361495585907a0f12661cad8b8b9fbfb0b503
blob + 06e5fea6d5cda0aaf3c3d8d4b0bb4b4c291ef255
--- gotwebd/Makefile.inc
+++ gotwebd/Makefile.inc
@@ -1,11 +1,25 @@
 LDADD +=	-lz -lutil
+
+.if "${GOT_RELEASE}" == "Yes"
 PREFIX ?=	/usr/local
 BINDIR ?=	${PREFIX}/sbin
+BINGRP ?=	daemon
+WWWUSR ?=	www
+WWWGRP ?=	www
+.else
+PREFIX ?= ${HOME}
+BINOWN ?= ${USER}
+BINDIR ?= ${PREFIX}/bin
+.if !defined(BINGRP)
+BINGRP != id -g -n
+.endif
+WWWUSR ?=	${USER}
+WWWGRP ?=	${USER}
+.endif
+
 CHROOT_DIR ?=	/var/www
 GOTWEB_DIR =	/bin/gotwebd
 LIBEXECDIR =	${GOTWEB_DIR}/libexec
 LIBEXEC_DIR =	${CHROOT_DIR}${LIBEXECDIR}
 HTTPD_DIR =	${CHROOT_DIR}/htdocs
 PROG_DIR =	${HTTPD_DIR}/${PROG}
-WWWUSR ?=	www
-WWWGRP ?=	www
blob - 85bee26728643214f5d4570f003572ac1fc36d05
blob + c2fa48af6eaa68d6af39dde2a1708e6d37bf7292
--- gotwebd/libexec/Makefile.inc
+++ gotwebd/libexec/Makefile.inc
@@ -2,10 +2,10 @@
 
 realinstall:
 	if [ ! -d ${DESTDIR}${CHROOT_DIR}${LIBEXECDIR}/. ]; then \
-		${INSTALL} -d -o root -g daemon -m 755 \
+		${INSTALL} -d -o ${USER} -g ${BINGRP} -m 755 \
 		    ${DESTDIR}${CHROOT_DIR}${LIBEXECDIR}; \
 	fi
-	${INSTALL} ${INSTALL_COPY} -o root -g daemon -m 755 ${PROG} \
+	${INSTALL} ${INSTALL_COPY} -o ${USER} -g ${BINGRP} -m 755 ${PROG} \
 	    ${DESTDIR}${CHROOT_DIR}${LIBEXECDIR}/${PROG}
 
 NOMAN = Yes