From nobody Thu Feb 01 21:26:03 2024 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 4TQsQh35MRz58hK8; Thu, 1 Feb 2024 21:26:04 +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 4TQsQh0z41z4W5S; Thu, 1 Feb 2024 21:26:04 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1706822764; 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=/ih32X/rGL+7kioNBcLjXf6MJJRQ8MIGvTf10rEy4ho=; b=pKAlPo/iL/X4g/T/531BOiEZugQxNDW9BfX8Nv2iNX1sDt+CsPrbuy/8hJ27r6GocR5oXZ YzOsoMhnFZu+/1qU815uM33f3biYjIvlSHlzYhJCE913SlU9tCpFz5O0r8QNHjKnYSQECS HPbUMAIW6jTjWaTbb6DedTAwyRrqZ5ifiKlNKpD1/z5XBM1nOsaWvPVSPpUd+V5rs0Jdv8 MKPERVhxr+eoX7RfmEg8ZbDoAn/gW8VNZgvZfiNoSKeD2o4DfrOMMrAj1HqAG1Ekyo4yKo fFvP560jS4NSxlkPA95QzceCKPiPkVN/n6jseM1kOrz54N4GCSN8jD7/HAs5xQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1706822764; 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=/ih32X/rGL+7kioNBcLjXf6MJJRQ8MIGvTf10rEy4ho=; b=hI39/sSvFmrW+jbkCiNcYuqvmgJBM+b0UTiwCSvXkeHaskLZD6SOakYICgbJg9A0YZrnHA 7wo2yZ/6m33717/eJzwLM0zdKqqNPl0uo3cShXcWkzePEWemb8RLz/Go7qfFIs6chzmoSW gmabupdrZg9Tox8IhKMNgxribXNdHY66EulIbwFZiunIs41pQoulyQDhGCvvosSJ54L/U/ ULAf6qkUSftR2+ZPrwuZ57P6d0T4RiHG/G4+Hk/GH+8CNvmMyyGghnjGmJ/Tle6ejuJkwI eAGmK+eAyMyDrJ+9WjX7gp2mAkizVa0r9bEZIcrUf05mNy1zZOwQ2soHGOBNoA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1706822764; a=rsa-sha256; cv=none; b=w4Dl2twlVBCpus4Z+dcrHzxeK49/c8wk/GfYUdDsdqdIAs40Y8nR5/gMKhhu7uI0uhyNED CymiUt3Xr5rgzOBwsBNCau+KCYUNcdjVOaUn7/nfRotpXlCGh5q/Nqkns0U26Yo22amGVD jeJQhzBgijcuVM0xeZw4QnjFXrm4N5cNwXxP9EtX0jOSGO5RAUHadt83kt2myXcWe+LL2k 6/mbRxnxQF9dWc1oUoNl1Xb8W2hbxv1NQJfRSO+atGPBnwINSBUjiYkbEQ6kklNgsogWtU pFXLhHT0g5F+/fLGcz7FwGfp67p8GqSwD/FPA3KQ2iaEO5n58iRZCJVOckL9zA== 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 4TQsQg6vk7z1HMD; Thu, 1 Feb 2024 21:26:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 411LQ3fG070292; Thu, 1 Feb 2024 21:26:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 411LQ3Yt070289; Thu, 1 Feb 2024 21:26:03 GMT (envelope-from git) Date: Thu, 1 Feb 2024 21:26:03 GMT Message-Id: <202402012126.411LQ3Yt070289@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Olivier Certner Subject: git: ffd3cd7c6d86 - stable/13 - setusercontext(): Set umask in a separate function, setclassumask() 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: olce X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: ffd3cd7c6d861b3a4a4a91f5301ba37e0ac20f67 Auto-Submitted: auto-generated The branch stable/13 has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=ffd3cd7c6d861b3a4a4a91f5301ba37e0ac20f67 commit ffd3cd7c6d861b3a4a4a91f5301ba37e0ac20f67 Author: Olivier Certner AuthorDate: 2023-06-20 16:46:31 +0000 Commit: Olivier Certner CommitDate: 2024-02-01 21:23:04 +0000 setusercontext(): Set umask in a separate function, setclassumask() Reviewed by: emaste Approved by: emaste (mentor) MFC after: 3 days Sponsored by: Kumacom SAS Differential Revision: https://reviews.freebsd.org/D40686 (cherry picked from commit 0dd1705f584947625892988afe59e4cedb5cdd09) Approved by: markj (mentor) --- lib/libutil/login_class.c | 59 ++++++++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 26 deletions(-) diff --git a/lib/libutil/login_class.c b/lib/libutil/login_class.c index 2b85425d8d8e..69230db32961 100644 --- a/lib/libutil/login_class.c +++ b/lib/libutil/login_class.c @@ -381,6 +381,37 @@ setclasscontext(const char *classname, unsigned int flags) } +/* + * Private function setting umask from the login class. + */ +static void +setclassumask(login_cap_t *lc, const struct passwd *pwd) +{ + /* + * Make it unlikely that someone would input our default sentinel + * indicating no specification. + */ + const rlim_t def_val = INT64_MIN + 1, err_val = INT64_MIN; + const rlim_t val = login_getcapnum(lc, "umask", def_val, err_val); + + if (val != def_val) { + if (val < 0 || val > UINT16_MAX) { + /* We get here also on 'err_val'. */ + syslog(LOG_WARNING, + "%s%s%sLogin class '%s': " + "Invalid umask specification: '%s'", + pwd ? "Login '" : "", + pwd ? pwd->pw_name : "", + pwd ? "': " : "", + lc->lc_class, + login_getcapstr(lc, "umask", "", "")); + } else { + const mode_t mode = val; + + umask(mode); + } + } +} /* * Private function which takes care of processing @@ -394,32 +425,8 @@ setlogincontext(login_cap_t *lc, const struct passwd *pwd, unsigned long flags) if (flags & LOGIN_SETRESOURCES) setclassresources(lc); /* See if there's a umask override */ - if (flags & LOGIN_SETUMASK) { - /* - * Make it unlikely that someone would input our default sentinel - * indicating no specification. - */ - const rlim_t def_val = INT64_MIN + 1, err_val = INT64_MIN; - const rlim_t val = login_getcapnum(lc, "umask", def_val, err_val); - - if (val != def_val) { - if (val < 0 || val > UINT16_MAX) { - /* We get here also on 'err_val'. */ - syslog(LOG_WARNING, - "%s%s%sLogin class '%s': " - "Invalid umask specification: '%s'", - pwd ? "Login '" : "", - pwd ? pwd->pw_name : "", - pwd ? "': " : "", - lc->lc_class, - login_getcapstr(lc, "umask", "", "")); - } else { - const mode_t mode = val; - - umask(mode); - } - } - } + if (flags & LOGIN_SETUMASK) + setclassumask(lc, pwd); /* Set paths */ if (flags & LOGIN_SETPATH) setclassenvironment(lc, pwd, 1);