On Fri, Oct 27, 2023 at 09:57:55AM +0100, Stuart Henderson wrote: > If we're recycling, I think I'd prefer to start with oldest first.
Sure, reusing _polkituser then, thanks. > > Provide an rc script so I can 'rcctl enable dictd' instead of running > > it as my own user. This way we can make the service listen on localhost > > instead of the wildcard address by default, which I consider a saner > > default. > > > > It won't start until you provide /etc/dictd.conf, but that's fine. > > An rc script seems useful in general, but I think there's a bit > more to be done before this one really adds much benefit. > > If you just install the package and start the daemon, it looks like > it starts: > > # rcctl start dictd > dictd(ok) > > but doesn't really, so that's a bit confusing: > > # rcctl check dictd > dictd(failed) > > in this case it's obviously due to the missing config file, which could > be checked for in the script, but it also does the same with an invalid > config file. dictd(8) has no dry-run config check and even if the file is valid, dictd fails to start if any of the listed data/index files are missing. I'd expect users to look at shipped config/example files before starting package daemons. > > The port ships a manual and examples. > > The examples are not at all useful for the dictionaries provided in > packages, and with neither an @sample'd config file which the user can > easily find, nor a pkg-readme explaining things, it's quite a bit > more difficult to get started than I'd usually expect for something with > an rc script. They were enough for me to adapt database names and file paths and get going before going through all of dictd(8) first, but I also had the context and new about education/freedict/ ports in the first place. > There are also a lot of example files to wade through before > discovering that they're not really useful. Would be nice to > provide a file which can be used directly for @sample that does > something useful with what's available in packages. Sure, new diff ships a simple working example to look up between german and english. > (not related to the diff, but noticed while reviewing - some files > aren't useful with the port as built anyway - dictd_popen.conf.in and > dictd_plugin_dbi.conf could be @comment'ed - dict1.conf is in the > server PLIST but it's actually a client config file). I'll deal with that in a separate diff, thanks. > > > +# for dictd.rc pexp > > +V_REGEX= ${V:S/./\./g} > > +SUBST_VARS= V_REGEX > ... > > +pexp="${daemon##*/} ${V_REGEX}: [0-9]+/[0-9]+" > > $ pgrep -lf dictd > 38602 dictd 1.13.1: 1/1 > > seems complex - any particular reason why this is better than a > simpler alternative like pexp='^dictd .*' ? Just wanted to be specific, but dropping the version works as well. > > I suppose at least having a process string like this gives a good > indication that it's basically 90's software ;) It also has --inetd and --no-mmap, still. How is this? Index: infrastructure/db/user.list =================================================================== RCS file: /cvs/ports/infrastructure/db/user.list,v diff -u -p -r1.430 user.list --- infrastructure/db/user.list 15 Aug 2023 15:54:30 -0000 1.430 +++ infrastructure/db/user.list 27 Oct 2023 15:35:57 -0000 @@ -147,7 +147,7 @@ id user group port 636 _ettercap _ettercap net/ettercap 637 _memcached _memcached misc/memcached 638 _prosody _prosody net/prosody -#639 _polkituser _polkituser sysutils/policykit +639 _dictd _dictd net/dictd,-server 640 _astmanproxy _astmanproxy telephony/astmanproxy 641 _ziproxy _ziproxy net/ziproxy 642 _pure-ftpd _pure-ftpd net/pure-ftpd Index: net/dictd/Makefile =================================================================== RCS file: /cvs/ports/net/dictd/Makefile,v diff -u -p -r1.17 Makefile --- net/dictd/Makefile 26 Oct 2023 16:49:27 -0000 1.17 +++ net/dictd/Makefile 27 Oct 2023 16:29:16 -0000 @@ -6,11 +6,15 @@ DISTNAME= dictd-$V PKGNAME-main= dictd-client-$V PKGNAME-server= dictd-server-$V +REVISION-main=0 +REVISION-server=0 CATEGORIES= net education HOMEPAGE= https://www.dict.org +MAINTAINER= Klemens Nanni <k...@openbsd.org> + # GPL v2 PERMIT_PACKAGE= Yes WANTLIB= c maa z @@ -36,5 +40,6 @@ LDFLAGS += -L/usr/local/lib post-install: ${INSTALL_DATA_DIR} ${EXAMPLEDIR} ${INSTALL_DATA} ${WRKSRC}/examples/* ${EXAMPLEDIR}/ + ${INSTALL_DATA} ${FILESDIR}/dictd.conf ${EXAMPLEDIR}/ .include <bsd.port.mk> Index: net/dictd/files/dictd.conf =================================================================== RCS file: net/dictd/files/dictd.conf diff -N net/dictd/files/dictd.conf --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ net/dictd/files/dictd.conf 27 Oct 2023 17:33:33 -0000 @@ -0,0 +1,14 @@ +# Serve education/freedict/ dictionaries +# # pkg_add freedict-{deu-eng,eng-deu} +# +# Files must be readable by _dictd at startup. + +database fd-deu-eng { + data "/usr/local/freedict/deu-eng/deu-eng.dict.dz" + index "/usr/local/freedict/deu-eng/deu-eng.index" +} + +database fd-eng-deu { + data "/usr/local/freedict/eng-deu/eng-deu.dict.dz" + index "/usr/local/freedict/eng-deu/eng-deu.index" +} Index: net/dictd/patches/patch-dictd_c =================================================================== RCS file: net/dictd/patches/patch-dictd_c diff -N net/dictd/patches/patch-dictd_c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ net/dictd/patches/patch-dictd_c 26 Oct 2023 19:34:14 -0000 @@ -0,0 +1,17 @@ +use dedicated _dictd user/group + +Index: dictd.c +--- dictd.c.orig ++++ dictd.c +@@ -1269,9 +1272,9 @@ static void release_root_privileges( void ) + if (geteuid() == 0) { + struct passwd *pwd; + +- if ((pwd = getpwnam("dictd"))) { ++ if ((pwd = getpwnam("_dictd"))) { + setgid(pwd->pw_gid); +- initgroups("dictd",pwd->pw_gid); ++ initgroups("_dictd",pwd->pw_gid); + setuid(pwd->pw_uid); + } else if ((pwd = getpwnam("nobody"))) { + setgid(pwd->pw_gid); Index: net/dictd/pkg/PLIST-server =================================================================== RCS file: /cvs/ports/net/dictd/pkg/PLIST-server,v diff -u -p -r1.3 PLIST-server --- net/dictd/pkg/PLIST-server 26 Oct 2023 16:49:27 -0000 1.3 +++ net/dictd/pkg/PLIST-server 27 Oct 2023 16:43:36 -0000 @@ -1,3 +1,6 @@ +@newgroup _dictd:639 +@newuser _dictd:639:_dictd::dictd Account:/nonexistent:/sbin/nologin +@rcscript ${RCDIR}/dictd bin/colorit bin/dictdplugin-config @bin bin/dictfmt @@ -15,6 +18,8 @@ include/dictdplugin.h @man man/man8/dictd.8 @bin sbin/dictd share/examples/dictd/ +share/examples/dictd/dictd.conf +@sample ${SYSCONFDIR}/dictd.conf share/examples/dictd/dict1.conf share/examples/dictd/dictd1.conf share/examples/dictd/dictd2.conf Index: net/dictd/pkg/dictd.rc =================================================================== RCS file: net/dictd/pkg/dictd.rc diff -N net/dictd/pkg/dictd.rc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ net/dictd/pkg/dictd.rc 27 Oct 2023 15:29:26 -0000 @@ -0,0 +1,10 @@ +#!/bin/ksh + +daemon="/usr/local/sbin/dictd" +daemon_args="--listen-to localhost" + +. /etc/rc.d/rc.subr + +pexp="${daemon##*/} .*" + +rc_cmd $1