On Wed, Nov 04, 2026 at 09:18:47PM +0100, Caspar Schutijser wrote: [...] > Thanks, I have committed those two changes. New, shorter diff at > the bottom.
Seems to work properly here. Here's a review. [...] > Index: Makefile > =================================================================== > RCS file: /cvs/ports/x11/xscreensaver/Makefile,v > diff -u -p -r1.127 Makefile > --- Makefile 4 Nov 2026 19:56:11 -0000 1.127 > +++ Makefile 4 Nov 2026 20:04:57 -0000 > @@ -9,7 +9,7 @@ COMMENT= screen saver and locker for the > # Ideally this wants a bsdauth driver to be written, change to being > # installed setgid auth, and figure out any issues resulting. You ought to remove this comment since you're implementing bsd auth support. :) > DISTNAME= xscreensaver-6.15 > -REVISION= 3 > +REVISION= 4 > > CATEGORIES= x11 > [...] > Index: patches/patch-driver_passwd-bsdauth_c > =================================================================== > RCS file: patches/patch-driver_passwd-bsdauth_c > diff -N patches/patch-driver_passwd-bsdauth_c > --- /dev/null 1 Jan 1970 00:00:00 -0000 > +++ patches/patch-driver_passwd-bsdauth_c 4 Nov 2026 20:04:57 -0000 > @@ -0,0 +1,73 @@ > +Index: driver/passwd-bsdauth.c > +--- driver/passwd-bsdauth.c.orig > ++++ driver/passwd-bsdauth.c > +@@ -0,0 +1,69 @@ > ++/* passwd-bsdauth.c --- verifying typed passwords with the BSD > ++ * Authentication system. > ++ * xscreensaver, Copyright © 1993-2022 Jamie Zawinski <[email protected]> > ++ * > ++ * Permission to use, copy, modify, distribute, and sell this software and > its > ++ * documentation for any purpose is hereby granted without fee, provided > that > ++ * the above copyright notice appear in all copies and that both that > ++ * copyright notice and this permission notice appear in supporting > ++ * documentation. No representations are made about the suitability of this > ++ * software for any purpose. It is provided "as is" without express or > ++ * implied warranty. > ++ */ > ++ > ++#ifdef HAVE_CONFIG_H > ++# include "config.h" > ++#endif > ++ > ++#ifndef NO_LOCKING /* whole file */ > ++ > ++#include <stdlib.h> > ++#ifdef HAVE_UNISTD_H > ++# include <unistd.h> > ++#endif > ++ > ++#include <stdio.h> > ++#include <string.h> > ++#include <sys/types.h> > ++#include <pwd.h> > ++#include <login_cap.h> > ++#include <bsd_auth.h> > ++ > ++#ifdef __bsdi__ > ++# include <sys/param.h> > ++# if _BSDI_VERSION >= 199608 > ++# define BSD_AUTH > ++# endif > ++#endif /* __bsdi__ */ I would not cargo-cult this chunk. It is unused in the other files. > Index: patches/patch-driver_xscreensaver-auth_c > =================================================================== > RCS file: > /cvs/ports/x11/xscreensaver/patches/patch-driver_xscreensaver-auth_c,v > diff -u -p -r1.1 patch-driver_xscreensaver-auth_c > --- patches/patch-driver_xscreensaver-auth_c 27 Oct 2026 06:43:30 -0000 > 1.1 > +++ patches/patch-driver_xscreensaver-auth_c 4 Nov 2026 20:04:57 -0000 > @@ -1,3 +1,4 @@ > +diff -u driver/xscreensaver-auth.c.orig driver/xscreensaver-auth.c > Index: driver/xscreensaver-auth.c > --- driver/xscreensaver-auth.c.orig > +++ driver/xscreensaver-auth.c > @@ -6,8 +7,20 @@ Index: driver/xscreensaver-auth.c > #include "auth.h" > > +/* OpenBSD: set[ug]id binary MUST say so in this var */ > -+mode_t _permit_setugid = S_ISUID; > ++mode_t _permit_setugid = S_ISGID; > + > #ifdef __GNUC__ > __extension__ /* shut up about "string length is greater than the > length > ISO C89 compilers are required to support" when > including > +@@ -340,7 +343,11 @@ main (int argc, char **argv) > + if (!splash_p && !init_p) > + lock_priv_init (); > + > ++ /* I have not found a way to drop privileges and have access to > ++ bsdauth at least on OpenBSD. */ > ++#if !defined(HAVE_BSDAUTH) || !defined(__OpenBSD__) > + disavow_privileges (); > ++#endif See the comment at the beginning of the file: * Flow of control within xscreensaver-auth: * * - Privileged password initialization (e.g. read /etc/shadow as root) * - Disavow privileges * - Unprivileged password initialization * - Connect to X server [...] disavow_privileges() calls setgroups, setgid and setuid to drop any extra creds. In fact, if running without root creds its attempt at calling setgroups() would fail and xscreensaver-auth would exit. xscreensaver-auth is built around privdrop because OpenBSD isn't the only system that restricts access to shadow passwords. On the other hand, to use bsdauth, you *need* to belong to the auth group for the whole duration of the xscreensaver-auth process. I suspect that this is the reason why upstream apparently rejected it (unless I understood Manuel incorrectly). Skipping disavow_privileges() completely in this diff makes me kinda nervous for future updates and possible patch conflicts, but I can't see how bsdauth would work otherwise. Another possible approach to drop the loathed setuid bit is to install xscreensaver-auth setgid _shadow. But as noted by ajacoutot@ this also needs special care in the guts of disavow_privileges(). I'm not objecting to the bsdauth addition and I won't push strongly for the diff below, but I suspect this approach would be less intrusive in the long run. Thoughts? Index: Makefile =================================================================== RCS file: /cvs/ports/x11/xscreensaver/Makefile,v diff -u -p -r1.127 Makefile --- Makefile 4 Nov 2026 19:56:11 -0000 1.127 +++ Makefile 9 Nov 2026 16:33:20 -0000 @@ -1,15 +1,7 @@ COMMENT= screen saver and locker for the X Window System -# No driver for BSD Authentication so xscreensaver-auth uses the -# driver/passwd-pwent.c backend using getpwnam_shadow() which is using -# setuid root for access to the shadow password db. For some reason -# unlock fails to ask for a password with just setgid _shadow - maybe -# related to setgroups() failing, maybe something else. -# -# Ideally this wants a bsdauth driver to be written, change to being -# installed setgid auth, and figure out any issues resulting. DISTNAME= xscreensaver-6.15 -REVISION= 3 +REVISION= 4 CATEGORIES= x11 @@ -32,10 +24,6 @@ COMPILER_LANGS= c DEBUG_PACKAGES= ${BUILD_PACKAGES} MODULES= textproc/intltool - -# tar: Unable to link file xscreensaver-6.12/driver/wayland-dpy.c to itself -BUILD_DEPENDS= archivers/gtar -TAR= gtar # xshadertoy-based hacks use "exec -a <name> xshadertoy" which is not # supported by standard shells in base Index: patches/patch-driver_setuid_c =================================================================== RCS file: patches/patch-driver_setuid_c diff -N patches/patch-driver_setuid_c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-driver_setuid_c 9 Nov 2026 16:32:41 -0000 @@ -0,0 +1,38 @@ +Index: driver/setuid.c +--- driver/setuid.c.orig ++++ driver/setuid.c +@@ -78,6 +78,34 @@ setgroups_needed_p (uid_t target_group) + return 0; + else if (n == 1 && groups[0] == target_group) /* one element, the target */ + return 0; ++#ifdef __OpenBSD__ ++/* On OpenBSD we want to be able to run this program without installing ++ xscreensaver-auth setuid root. Installing xscreensaver-auth setgid ++ _shadow to access the shadow password database means we're running ++ with no ability to call setgroups (). Thankfully on OpenBSD running ++ a program setgid only modifies the effective gid, not the groups ++ list. So we only need to call setgid () to get back to the user's ++ base identity. ++ ++ Be extra paranoid and verify this in the code below: ++ - if the program is not running setuid ++ - if it is running setgid ++ - if the effective gid is not present in the groups list ++ then we don't need to call setgroups. ++ */ ++ else if (getuid () == geteuid () && getgid () != getegid ()) ++ { ++ gid_t egid; ++ int i; ++ ++ egid = getegid (); ++ for (i = 0; i < n; i++) { ++ if (groups[i] == egid) ++ return 1; ++ } ++ return 0; ++ } ++#endif /* __OpenBSD__ */ + else /* more than one, or the wrong one. */ + return 1; + } Index: patches/patch-driver_xscreensaver-auth_c =================================================================== RCS file: /cvs/ports/x11/xscreensaver/patches/patch-driver_xscreensaver-auth_c,v diff -u -p -r1.1 patch-driver_xscreensaver-auth_c --- patches/patch-driver_xscreensaver-auth_c 27 Oct 2026 06:43:30 -0000 1.1 +++ patches/patch-driver_xscreensaver-auth_c 9 Nov 2026 16:32:41 -0000 @@ -6,7 +6,7 @@ Index: driver/xscreensaver-auth.c #include "auth.h" +/* OpenBSD: set[ug]id binary MUST say so in this var */ -+mode_t _permit_setugid = S_ISUID; ++mode_t _permit_setugid = S_ISGID; + #ifdef __GNUC__ __extension__ /* shut up about "string length is greater than the length Index: pkg/PLIST =================================================================== RCS file: /cvs/ports/x11/xscreensaver/pkg/PLIST,v diff -u -p -r1.61 PLIST --- pkg/PLIST 4 Nov 2026 19:56:11 -0000 1.61 +++ pkg/PLIST 9 Nov 2026 16:32:41 -0000 @@ -301,8 +301,10 @@ libexec/xscreensaver/webcollage @bin libexec/xscreensaver/xlyap @bin libexec/xscreensaver/xmatrix @bin libexec/xscreensaver/xrayswarm -@mode 4755 +@mode 2755 +@group _shadow @bin libexec/xscreensaver/xscreensaver-auth +@group @mode @bin libexec/xscreensaver/xscreensaver-getimage libexec/xscreensaver/xscreensaver-getimage-file -- jca
