net-misc/gmid: add 1.7, drop 1.6.2

Signed-off-by: Anna (cybertailor) Vyalkova <cyber+gentoo@sysrq.in>
This commit is contained in:
Anna (cybertailor) Vyalkova
2021-07-10 23:24:50 +05:00
parent 19c5c0a12b
commit b7e12e52c5
5 changed files with 25 additions and 141 deletions

View File

@@ -1 +1 @@
DIST gmid-1.6.2.tar.gz 60293 BLAKE2B 807f4e93d1ed0f2a69a9631504ffe28d5aee4efbba85b9e7d0a8eec5b4fb50a38285478651f196f57fbcf7b4d38ff462f78c37210720353af638d76b2b28e3e1 SHA512 053e2f95449d71c72052c422b1c51657ad48f662422a121452618c69e6bac9b23bbaa2b35b52d314eb7614b9a0f413504c87cd431bc756d455dd198c79270da8
DIST gmid-1.7.tar.gz 78157 BLAKE2B a48cd98621874f1a725b0c4b4ee70af45ebfec56734d00478e52d194f3d5a090ea3c4f8001159863149fdc400619685a1e355ab695b81e76d3b483d0101ef5a4 SHA512 d7aaddcc14ea48b4f8377ca841905071f4d82ce96168a39c38e2896b0d1253e31450a9a3794f6a2699afbbb266ffce2e301adc4acf41075a10e11eb878732ad4

View File

@@ -1,10 +0,0 @@
--- a/regress/Makefile
+++ b/regress/Makefile
@@ -4,7 +4,6 @@
all: puny-test testdata iri_test cert.pem testca.pem valid.crt invalid.cert.pem
./puny-test
- ./runtime
./iri_test
puny-test: puny-test.o ../puny.o ../utf8.o ../utils.o ../log.o ${COMPAT}

View File

@@ -1,111 +0,0 @@
--- a/gmid.1
+++ b/gmid.1
@@ -22,6 +22,7 @@
.Bk -words
.Op Fl fnv
.Op Fl c Ar config
+.Op Fl P Ar pidfile
.Ek
.Nm
.Bk -words
@@ -51,6 +52,10 @@ Specify the configuration file.
Stays and logs on the foreground.
.It Fl n
Check that the configuration is valid, but don't start the server.
+.It Fl P Pa pidfile
+Write
+.Nm
+pid to the given path.
.El
.Pp
If no configuration file is given,
--- a/gmid.c
+++ b/gmid.c
@@ -316,7 +316,7 @@ static void
usage(const char *me)
{
fprintf(stderr,
- "USAGE: %s [-fn] [-c config] | [-6h] [-d certs-dir] [-H host]\n"
+ "USAGE: %s [-fn] [-c config] [-P pidfile] | [-6h] [-d certs-dir] [-H host]\n"
" [-p port] [-x cgi] [dir]\n",
me);
}
@@ -411,6 +411,34 @@ serve(int argc, char **argv, struct imsgbuf *ibuf)
_exit(executor_main(ibuf));
}
+static int
+write_pidfile(const char *pidfile)
+{
+ struct flock lock;
+ int fd;
+
+ if (pidfile == NULL)
+ return -1;
+
+ if ((fd = open(pidfile, O_WRONLY|O_CREAT|O_CLOEXEC, 0600)) == -1)
+ fatal("can't open pidfile %s: %s", pidfile, strerror(errno));
+
+ lock.l_start = 0;
+ lock.l_len = 0;
+ lock.l_type = F_WRLCK;
+ lock.l_whence = SEEK_SET;
+
+ if (fcntl(fd, F_SETLK, &lock) == -1)
+ fatal("can't lock %s, gmid is already running?", pidfile);
+
+ if (ftruncate(fd, 0) == -1)
+ fatal("ftruncate: %s: %s", pidfile, strerror(errno));
+
+ dprintf(fd, "%d\n", getpid());
+
+ return fd;
+}
+
static void
setup_configless(int argc, char **argv, const char *cgi)
{
@@ -434,11 +462,12 @@ main(int argc, char **argv)
{
struct imsgbuf exibuf;
int ch, conftest = 0, configless = 0;
- int old_ipv6, old_port;
+ int pidfd, old_ipv6, old_port;
+ const char *pidfile = NULL;
init_config();
- while ((ch = getopt(argc, argv, "6c:d:fH:hnp:vx:")) != -1) {
+ while ((ch = getopt(argc, argv, "6c:d:fH:hnP:p:vx:")) != -1) {
switch (ch) {
case '6':
conf.ipv6 = 1;
@@ -472,6 +501,10 @@ main(int argc, char **argv)
conftest = 1;
break;
+ case 'P':
+ pidfile = optarg;
+ break;
+
case 'p':
conf.port = parse_portno(optarg);
configless = 1;
@@ -536,6 +569,8 @@ main(int argc, char **argv)
return 0;
}
+ pidfd = write_pidfile(pidfile);
+
/* Linux seems to call the event handlers even when we're
* doing a sigwait. These dummy handlers are here to avoid
* being terminated on SIGHUP, SIGINT or SIGTERM. */
@@ -604,5 +639,8 @@ main(int argc, char **argv)
imsg_compose(&logibuf, IMSG_QUIT, 0, 0, -1, NULL, 0);
imsg_flush(&logibuf);
+ if (pidfd != -1)
+ close(pidfd);
+
return 0;
}

View File

@@ -1,8 +1,10 @@
certdir = "/etc/ssl/gmid"
user "gemini" # drop privileges
server "localhost" {
root "/var/gemini/localhost"
auto index on
cert "/etc/ssl/gmid/gmid.crt"
key "/etc/ssl/gmid/gmid.key"
cert $certdir "/gmid.crt"
key $certdir "/gmid.key"
}

View File

@@ -8,23 +8,28 @@ inherit ssl-cert toolchain-funcs
DESCRIPTION="Simple and secure Gemini server"
HOMEPAGE="https://www.omarpolo.com/pages/gmid.html"
SRC_URI="https://git.omarpolo.com/${PN}/snapshot/${P}.tar.gz"
LICENSE="ISC"
if [[ ${PV} == 9999 ]]; then
EGIT_REPO_URI="https://github.com/omar-polo/${PN}.git https://git.omarpolo.com/${PN}"
inherit git-r3
else
SRC_URI="https://git.omarpolo.com/${PN}/snapshot/${P}.tar.gz"
KEYWORDS="~amd64 ~x86"
fi
LICENSE="BSD ISC MIT"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="+seccomp test"
RESTRICT="!test? ( test )"
PATCHES=( "${FILESDIR}"/${P}-make-pidfile.patch )
DEPEND="
acct-user/gemini
dev-libs/imsg-compat
dev-libs/libbsd
dev-libs/libevent
dev-libs/libretls
"
BDEPEND="
sys-devel/flex
virtual/pkgconfig
virtual/yacc
"
@@ -35,34 +40,32 @@ DOCS=( README.md ChangeLog )
src_prepare() {
default
if use seccomp && has usersandbox ${FEATURES} ; then
eapply "${FILESDIR}"/${P}-disable-runtime-test.patch
fi
# QA Notice: make jobserver unavailable
sed 's/make -C regress/${MAKE} -C regress/' -i Makefile || die
}
src_configure() {
local conf_args
tc-export CC
# note: not an autoconf configure script
conf_args=(
CC="$(tc-getCC)"
PREFIX="${EPREFIX}"/usr/share
BINDIR="${EPREFIX}"/usr/bin
CFLAGS="${CFLAGS}"
LDFLAGS="${LDFLAGS} -ltls -lssl -lcrypto -levent"
$(use_enable seccomp sandbox)
)
if ! use seccomp ; then
conf_args+=( --disable-sandbox )
fi
./configure "${conf_args[@]}" || die
if use seccomp && has usersandbox ${FEATURES} ; then
export SKIP_RUNTIME_TESTS=1
fi
}
src_compile() {
emake gmid
if use test ; then
emake gg
emake -C regress puny-test testdata iri_test
emake -C regress gg data puny-test fcgi-test
fi
}