Index | Thread | Search

From:
izzy Meyer <izder456@disroot.org>
Subject:
Re: MAINTAINER REGRESSION FIX: x11/emwm-utils
To:
Lucas Gabriel Vuotto <lucas@sexy.is>
Cc:
ports@openbsd.org
Date:
Sat, 24 May 2025 12:56:39 -0500

Download raw body.

Thread
On Sat, 24 May 2025 05:57:41 +0000
Lucas Gabriel Vuotto <lucas@sexy.is> wrote:

> Commited, thanks.
> 
> I tweaked the patch in one place to avoid removing an empty line,
> which increases the context of the diff with no value.
> 

I replied to your request for a -stable capable diff. I am
somewhat new to CVS, so hopefully I generated this correctly. Here's the
diff for 1.2p0 again, but for the list. 

-- 
iz (she/her)

> i like to say mundane things,
> there are too many uninteresting things
> that go unnoticed.

izder456 (dot) neocities (dot) org
Index: Makefile
===================================================================
RCS file: /cvs/ports/x11/emwm-utils/Makefile,v
diff -u -p -u -p -r1.1.1.1 Makefile
--- Makefile	23 Aug 2024 06:03:38 -0000	1.1.1.1
+++ Makefile	23 May 2025 18:16:54 -0000
@@ -3,6 +3,7 @@ COMMENT =	session manager and a toolches
 V =		1.2
 DISTNAME =	emwm-utils-src-${V}
 PKGNAME =	emwm-utils-${V}
+REVISION =	0
 
 CATEGORIES =	x11
 HOMEPAGE =	https://fastestcode.org/emwm.html
@@ -20,7 +21,8 @@ WANTLIB += X11 Xinerama Xm Xrandr Xss Xt
 LIB_DEPENDS =	x11/motif
 
 MAKE_FLAGS =	RCDIR=${PREFIX}/lib/X11 \
-		CFLAGS="${CFLAGS} -I./Xm -I${X11BASE}/include -I${LOCALBASE}/include"
+		CFLAGS="${CFLAGS} -DUNPRIVILEGED_SHUTDOWN \
+			-I./Xm -I${X11BASE}/include -I${LOCALBASE}/include"
 
 FAKE_FLAGS =	PREFIX=${WRKINST}${PREFIX} \
 		APPLRESDIR=${WRKINST}${PREFIX}/lib/X11/app-defaults \
Index: patches/patch-src_smconf_h
===================================================================
RCS file: patches/patch-src_smconf_h
diff -N patches/patch-src_smconf_h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_smconf_h	23 May 2025 18:16:54 -0000
@@ -0,0 +1,12 @@
+Index: src/smconf.h
+--- src/smconf.h.orig
++++ src/smconf.h
+@@ -33,7 +33,7 @@
+ #endif /* SHUTDOWN_CMD */
+ 
+ #ifndef REBOOT_CMD
+-#define REBOOT_CMD      "/sbin/reboot"
++#define REBOOT_CMD      "/sbin/shutdown -r now"
+ #endif
+ 
+ #ifndef SUSPEND_CMD
Index: patches/patch-src_smmain_c
===================================================================
RCS file: patches/patch-src_smmain_c
diff -N patches/patch-src_smmain_c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_smmain_c	23 May 2025 18:16:54 -0000
@@ -0,0 +1,78 @@
+# For bsd-auth support
+
+Index: src/smmain.c
+--- src/smmain.c.orig
++++ src/smmain.c
+@@ -60,6 +60,9 @@
+ #if defined(__linux__) || defined(__svr4__)
+ #include <crypt.h>
+ #include <shadow.h>
++#elif defined(__OpenBSD__)
++#include <bsd_auth.h>
++#include <login_cap.h>
+ #endif
+ #include "smglobal.h"
+ #include "smconf.h"
+@@ -419,6 +422,11 @@ static void lock_screen(void)
+ 		app_res.enable_locking = False;
+ 		return;
+ 	}
++
++#ifdef __OpenBSD__
++	/* BSD-auth handles authentication, no password hash check needed */
++	can_auth = True;
++#else
+ 	
+ 	if(set_privileges(True)) {
+ 
+@@ -441,7 +449,8 @@ static void lock_screen(void)
+ 
+ 		set_privileges(False);
+ 	}
+-
++#endif /* __OpenBSD__ */
++	
+ 	if(!can_auth){
+ 		if(!app_res.silent) XBell(XtDisplay(wshell), 100);
+ 		log_msg("Cannot authenticate. Screen locking disabled!\n");
+@@ -861,6 +870,17 @@ static void passwd_enter_cb(Widget w,
+ 	char *upw = NULL;
+ 	
+ 	login = get_login();
++
++#ifdef __OpenBSD__
++	int auth_result = auth_userokay(login, NULL, "auth-xmsm", pwb);
++	if (auth_result) {
++         	unlock_screen();
++         	set_unlock_message(NULL);
++	} else {
++         	if(!app_res.silent) XBell(XtDisplay(w), 100);
++         	set_unlock_message(MSG_NOACCESS);
++	}
++#else
+ 	
+ 	set_privileges(True);
+ 	
+@@ -896,6 +916,7 @@ static void passwd_enter_cb(Widget w,
+ 		if(!app_res.silent) XBell(XtDisplay(w),100);
+ 		set_unlock_message(MSG_NOACCESS);
+ 	}
++#endif /* __OpenBSD__ */
+ 
+ 	memset(pwb,0,strlen(pwb));
+ 	XmTextFieldSetString(wpasswd,"");
+@@ -988,10 +1009,13 @@ static Boolean set_privileges(Boolean elevate)
+ 	if(!initialized){
+ 		orig_uid = geteuid();
+ 		orig_gid = getegid();
+-
+ 		if(orig_uid != 0){
++			/* BSD-auth handles authentication, no SUID needed.  */
++#ifndef __OpenBSD__
+ 			log_msg("%s must be setuid root to enable "
+ 				"screen locking capabilities.\n",bin_name);
++#endif /* __OpenBSD__ */
++
+ 			initialized = True;
+ 			can_elevate = False;
+ 			return False;
Index: pkg/PLIST
===================================================================
RCS file: /cvs/ports/x11/emwm-utils/pkg/PLIST,v
diff -u -p -u -p -r1.1.1.1 PLIST
--- pkg/PLIST	23 Aug 2024 06:03:38 -0000	1.1.1.1
+++ pkg/PLIST	23 May 2025 18:16:54 -0000
@@ -1,8 +1,13 @@
 bin/xmsession
+@mode g+s
+@group auth
 @bin bin/xmsm
+@mode
+@group
 @bin bin/xmtoolbox
 lib/X11/app-defaults/XmSm
 lib/X11/app-defaults/XmToolbox
 lib/X11/toolboxrc
 @man man/man1/xmsm.1
 @man man/man1/xmtoolbox.1
+share/doc/pkg-readmes/${PKGSTEM}
Index: pkg/README
===================================================================
RCS file: pkg/README
diff -N pkg/README
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ pkg/README	23 May 2025 18:16:54 -0000
@@ -0,0 +1,15 @@
++-------------------------------------------------------------------------------
+| Running ${PKGSTEM} on OpenBSD
++-------------------------------------------------------------------------------
+
+To enable shutdown and reboot, the user should be in _shutdown group:
+
+	# usermod -G _shutdown <username>
+
+To enable suspend, the user needs to be able to run zzz(8).
+In order to do that, the user must be in group "wheel", and apmd(8)
+must be running:
+
+	# rcctl enable apmd
+	# rcctl start apmd
+	# usermod -G wheel <username>