From 1f2e215df07e49fd2b255cb29e825e5ca61c2cd0 Mon Sep 17 00:00:00 2001 From: jca Date: Mon, 24 Nov 2025 12:37:15 +0000 Subject: [PATCH] Stop doing XDG setup in setusercontext(LOGIN_SETALL) As suggested by kettenis@ and deraadt, including LOGIN_SETXDGENV in LOGIN_SETALL, the latter being used in a bunch of place, appears to be a mistake. The mkdir(2) and fchown(2) / fchmod(2) calls made by setusercontext(LOGIN_SETXDGENV) result in pledge(2) violations in at least calendar(1) and inetd(8), as reported by jmc@ and lucas@ respectively. Also it brings little to no advantage since most of the login managers analyzed so far require an explicit change to export the XDG_RUNTIME_DIR variable. So move LOGIN_SETXDGENV out of LOGIN_SETALL. If you started relying on this in one of your port, please adapt the code to explicitely pass LOGIN_SETXDGENV. xenodm(1) will be fixed shortly, patches for login(1) and sshd(8) are waiting for reviews. ok deraadt@ robert@ --- include/login_cap.h | 5 +++-- lib/libc/gen/login_cap.3 | 10 ++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/include/login_cap.h b/include/login_cap.h index 76b050084dd..96a5f15d7a6 100644 --- a/include/login_cap.h +++ b/include/login_cap.h @@ -1,4 +1,4 @@ -/* $OpenBSD: login_cap.h,v 1.20 2025/11/14 10:08:10 jca Exp $ */ +/* $OpenBSD: login_cap.h,v 1.21 2025/11/24 12:37:15 jca Exp $ */ /*- * Copyright (c) 1995,1997 Berkeley Software Design, Inc. All rights reserved. @@ -55,8 +55,9 @@ #define LOGIN_SETUSER 0x0040 /* Set user */ #define LOGIN_SETENV 0x0080 /* Set environment */ #define LOGIN_SETRTABLE 0x0100 /* Set rtable */ +#define LOGIN_SETALL 0x01ff /* Set all. */ +/* The LOGIN defines below are not part of LOGIN_SETALL */ #define LOGIN_SETXDGENV 0x0200 /* Set XDG environment variables */ -#define LOGIN_SETALL 0x03ff /* Set all. */ #define BI_AUTH "authorize" /* Accepted authentication */ #define BI_REJECT "reject" /* Rejected authentication */ diff --git a/lib/libc/gen/login_cap.3 b/lib/libc/gen/login_cap.3 index e6cbbb20bb8..b413cda6e1d 100644 --- a/lib/libc/gen/login_cap.3 +++ b/lib/libc/gen/login_cap.3 @@ -29,10 +29,10 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $OpenBSD: login_cap.3,v 1.25 2025/11/14 15:23:50 jca Exp $ +.\" $OpenBSD: login_cap.3,v 1.26 2025/11/24 12:37:15 jca Exp $ .\" BSDI $From: login_cap.3,v 1.4 1997/11/07 16:22:27 jch Exp $ .\" -.Dd $Mdocdate: November 14 2025 $ +.Dd $Mdocdate: November 24 2025 $ .Dt LOGIN_GETCLASS 3 .Os .Sh NAME @@ -279,6 +279,8 @@ Sets the user ID to .Ar uid using .Xr setuid 2 . +.It Dv LOGIN_SETALL +Sets all of the above. .It Dv LOGIN_SETXDGENV Ensures the presence and usability of a runtime directory for applications run by @@ -286,8 +288,8 @@ applications run by Sets the .Ev XDG_RUNTIME_DIR variable to the full path of the directory if successfully set up. -.It Dv LOGIN_SETALL -Sets all of the above. +Mostly useful to login managers so not part of +.It Dv LOGIN_SETALL . .El .Sh SEE ALSO .Xr setlogin 2 ,