From nobody Thu Sep 08 11:43:05 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4MNcgt1PnVz4bvpq; Thu, 8 Sep 2022 11:43:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4MNcgt017Zz46rZ; Thu, 8 Sep 2022 11:43:06 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1662637386; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=0taGDCMTPDj3jVBj9iQ+EHV1hHl+V0zo/e3sIy5ABFo=; b=x2qJaU8T15tAn4E3OYj2S3ajY5mPZhVarTdshKFvPZOuFbmK61kQiRjuw8HDGIIYfvxK0E KCiO+AMq780PTwEiCFn/bozm0b5ft7/a2TFsv/uYYjJ58zZ39H07mr7zviAiMFztdPoTCT ugrd5wNbDfZwrUkzQr/TXHnicJXPcfbEEdmX1YtnGfIWx4fGGv8bCS8QhfiDOcsQI6Lhwz tCry0KGfUhtUM3K8Th2sFVc+eED/0O4nHhP1dArOpDjTJIg0cwry/vGscU6MkClaMF9Nz4 v/Y8ffrta2iN5xGEpmmxgJz9xw5+g6TlfUXVV5ZJyghII2rX1cXPPb9qoJ/CfQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4MNcgs686NzrlC; Thu, 8 Sep 2022 11:43:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 288Bh57I035429; Thu, 8 Sep 2022 11:43:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 288Bh58x035428; Thu, 8 Sep 2022 11:43:05 GMT (envelope-from git) Date: Thu, 8 Sep 2022 11:43:05 GMT Message-Id: <202209081143.288Bh58x035428@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Maxim Sobolev Subject: git: dc96fb072300 - stable/13 - daemon(8): when -u option is used set USER, HOME and SHELL variables. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: sobomax X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: dc96fb072300b0d08070f0419e259d55a7c42bb6 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1662637386; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=0taGDCMTPDj3jVBj9iQ+EHV1hHl+V0zo/e3sIy5ABFo=; b=K4zcdF+3v8cZQOUMf7b3ELUPRBrMG6k3tsDMzp0oWy/N+8NK4ts/HOB8IE2m/Se19qJY7L VjepkPwxXtXNLwzo/8k2G+d8ux/K79bpi0d07ZBrPUFY2iEzMTWQVlfs/2I3njNwQ6OqLQ xoJRaON3iOdSNknoKsGHFJIYuDnGyETCcrC3WPATd+sSodmD1W65bvx+DWIKzL/VhlnCXc +KdORx7HrbpJbWagMD/TN/kvfh8x1dsq7kFDzSv8scP81tsKOvAcXNnwpANnrNA6b9wwjk FMCeDugKi1Y5g1S8bfGcvdiLAH/zOwQ8XKYNO5HYixWFq5+x6mAu1xSNBWKXZA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1662637386; a=rsa-sha256; cv=none; b=ZixIsvPnVVr14+EskUae6DhFp/c+xtxbGHIb1Ct+ekNOo7BDtRkWhWRcJy48uu4pq2nfLY D72HPaqy/AYTNFfDt/6EsUGzAhT2zcQyy3I8JzgEUVd67hR5iT3NNLhBqf6U60OI2uJTMU /KWkGYN5+t+lM5jgefXB4vfErw/rHj4PhmUA7w1jXVYmXGmRE70AVBt/Kr8oUzPFeUkk7a Dtxwv1pnWeIdgBf/zSrSN3UDKYmFUwt2wLuK+s22x2et2ibHAV+5CWchlAJGkknmxYxfcH feP6N/LMv6cEMyHrgC3Q89QJ+grrTH5Q/ixRwJN/FzkWZD7mi4L1xU9NLerj6Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by sobomax: URL: https://cgit.FreeBSD.org/src/commit/?id=dc96fb072300b0d08070f0419e259d55a7c42bb6 commit dc96fb072300b0d08070f0419e259d55a7c42bb6 Author: Maxim Sobolev AuthorDate: 2022-08-11 01:44:20 +0000 Commit: Maxim Sobolev CommitDate: 2022-09-08 11:42:56 +0000 daemon(8): when -u option is used set USER, HOME and SHELL variables. This is consistent with what other uid-morphing utilities do, i.e. jexec(1), su(1) etc. Reviewed by: gbe Differential Revision: https://reviews.freebsd.org/D36148 (cherry picked from commit 6b3ad1d737321cf6a70e957fb15d5287c378373c) --- usr.sbin/daemon/daemon.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/usr.sbin/daemon/daemon.c b/usr.sbin/daemon/daemon.c index d8a26132223b..e8cdaa230caa 100644 --- a/usr.sbin/daemon/daemon.c +++ b/usr.sbin/daemon/daemon.c @@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -465,6 +466,10 @@ restrict_process(const char *user) if (setusercontext(NULL, pw, pw->pw_uid, LOGIN_SETALL) != 0) errx(1, "failed to set user environment"); + + setenv("USER", pw->pw_name, 1); + setenv("HOME", pw->pw_dir, 1); + setenv("SHELL", *pw->pw_shell ? pw->pw_shell : _PATH_BSHELL, 1); } /*