From e7fa9d3941282eed56a0d5808179cb0e321faae6 Mon Sep 17 00:00:00 2001 From: millert Date: Sat, 26 Feb 2022 17:42:12 +0000 Subject: [PATCH] setuserenv: a missing /etc/login.conf file is not an error. The code to handle LOGIN_SETENV (and thus LOGIN_SETALL) returned an error if /etc/login.conf could not be opened. We should simply return success from setuserenv() in this case like we do for the other flags. From Matthew Martin, OK deraadt@ --- lib/libc/gen/login_cap.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/libc/gen/login_cap.c b/lib/libc/gen/login_cap.c index 67933653349..89dbcb32243 100644 --- a/lib/libc/gen/login_cap.c +++ b/lib/libc/gen/login_cap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: login_cap.c,v 1.41 2022/02/10 13:06:07 robert Exp $ */ +/* $OpenBSD: login_cap.c,v 1.42 2022/02/26 17:42:12 millert Exp $ */ /* * Copyright (c) 2000-2004 Todd C. Miller @@ -700,8 +700,11 @@ setuserpath(login_cap_t *lc, const struct passwd *pwd) char *path = NULL, *opath = NULL, *op, *np; int len, error; + /* + * If we have no capabilities then set _PATH_DEFPATH. + */ if (lc->lc_cap == NULL) - goto setit; /* impossible */ + goto setit; if ((len = cgetustr(lc->lc_cap, "path", &opath)) <= 0) goto setit; @@ -753,8 +756,12 @@ setuserenv(login_cap_t *lc, const struct passwd *pwd) char *beg, *end, *ep, *list, *value; int len, error; + /* + * If we have no capabilities then there is nothing to do and + * we can just return success. + */ if (lc->lc_cap == NULL) - return (-1); /* impossible */ + return (0); if ((len = cgetustr(lc->lc_cap, "setenv", &list)) <= 0) return (0); -- 2.20.1