From nobody Wed Nov 11 15:22:23 2026 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 4jPnM32HPMz70LlT for ; Wed, 11 Nov 2026 15:22:23 +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) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jPnM30NWKz4TT5 for ; Wed, 11 Nov 2026 15:22:23 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794410543; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=hjukPbxR4IToKW6Me1gxRaFjg6JaSVBTV6FJIfjXmUE=; b=UFFb/yEPKfjg3AyjBAvp6OBObBKmLX56Egt1bXPtZ5xPEhBgyo43qlNc6z0XMWxAJYuMN+ 051ftq5nIcn4yfS+2ra0b3dMLF1Qw/y/vWU1hiYmdtxVtAOIzUYO+VQ1rrm0c+qQS+d8NO +e7s/22ziunPHQ6IZjye1hus+wqR6AG1Ed8eXZ6HCRhkksylqE82bhGID4Dy74tQKVYvPi O5daf6uNStatKwqaDmgstnDN77eXwZjYtzHSfj4Q1GFDhXXbeEwZtkjLdzDRwPqCPm+CPX pDMfNNnvGRjLG3J3dvfk4vvon9zZVi7maT43zZch329McEZM7BVTN87Ie7GQiA== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794410543; b=FSwHxaIGtcKNtXf7Umj+5tqD1VyXM/Wbqw9U8ot1iU9uEhOWYowm4SodB5L2XwBRJvZ0eo x9K8BYuRqSBsi+UvNfToFY1Ld/7IC8K8wAZ59KioU9UkkPBApC3Y+5qA/YnqeY52I0NMss ThTyHuyd63aG4CTn0X56OXhueFCKl9qVK2kVMqoAjDK5srrSaHApOgiPDtsFxXiIqYeTAl d6pIRNje74JAKiCN2V5dHc9AvtWVwADkuFI1mLbY3j+Cdzm2cSyj6VuhTXaZ0qJbPprdh9 a89M3okr9W8NZ9aP4UCnBns2trcLWCUW0lAUxcFn6CL+htYQMvNwrF6YudpfJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794410543; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=hjukPbxR4IToKW6Me1gxRaFjg6JaSVBTV6FJIfjXmUE=; b=Rpt025JiQQWdmMNb8JkwKaATnlFiSSbMBfPdAfXGMUVFSFt4SigHEGCY+aF3MRr99AQbTU SSNBtP0evJ6Xarof7N2arresrS19N/PHlZHTCCiDQcIQeoJa+T5YnPOA1RVrD6XcA7YGK+ UbtL8FxO6+SVJ8jKlJVlgoOy917NSdI58dQCJkXrTtm4DZz1IUvS88bxUzTPif0RZFSRI7 IckcahWGCFjw1LqwAVJhp/bV3DzuZJkMtb/GWCiQrDelkAX9oCyeogfoLNYIqFvCGqPasW 2j4IGk73/8ngavc8Ww0NW0AGknPO2ylIx+RlILmzj07qrNwekTmhq1vubi0Yvg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jPnM30327zKZ5 for ; Wed, 11 Nov 2026 15:22:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 1449c by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 11 Nov 2026 15:22:23 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Cc: Kushagra Chauhan From: Ed Maste Subject: git: eca5b28692ea - main - nuageinit: Add support for uid List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org List-Id: Commit messages for all branches of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: eca5b28692eac5ae597eff6a13629c17c1e40ace Auto-Submitted: auto-generated Date: Wed, 11 Nov 2026 15:22:23 +0000 Message-Id: <6af4882f.1449c.5aa06db8@gitrepo.freebsd.org> The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=eca5b28692eac5ae597eff6a13629c17c1e40ace commit eca5b28692eac5ae597eff6a13629c17c1e40ace Author: Kushagra Chauhan AuthorDate: 2026-11-03 23:48:00 +0000 Commit: Ed Maste CommitDate: 2026-11-11 15:21:58 +0000 nuageinit: Add support for uid Adds support for specifying an explicit UID when creating users through nuageinit. Both numeric and string UID values are supported. Invalid or negative UIDs are rejected. The new uid option is documented in nuageinit(7). Existing automatic UID allocation remains unchanged when no UID is specified. A UID already in use or out of range is left to pw(8) to reject. PR: 293716 Reported by: Einar Bjarni Halldórsson Reviewed by: dtxdf, bapt Signed-off-by: Kushagra Chauhan Differential Revision: https://reviews.freebsd.org/D61174 --- libexec/nuageinit/nuage.lua | 11 +++++++++++ libexec/nuageinit/nuageinit.7 | 4 +++- libexec/nuageinit/tests/Makefile | 1 + libexec/nuageinit/tests/adduser_uid.lua | 27 +++++++++++++++++++++++++++ libexec/nuageinit/tests/nuage.sh | 19 +++++++++++++++++++ 5 files changed, 61 insertions(+), 1 deletion(-) diff --git a/libexec/nuageinit/nuage.lua b/libexec/nuageinit/nuage.lua index 738c6dabf140..8310c4751ece 100644 --- a/libexec/nuageinit/nuage.lua +++ b/libexec/nuageinit/nuage.lua @@ -355,6 +355,17 @@ local function adduser(pwd) if pwd.primary_group and pwd.primary_group ~= pwd.name then extraargs = extraargs .. " -g " .. shell_escape(pwd.primary_group) end + + -- explicitly specify an uid + if pwd.uid ~= nil then + local uid = math.tointeger(pwd.uid) + if not uid or uid < 0 then + warnmsg("invalid uid for user " .. pwd.name) + return nil + end + extraargs = extraargs .. " -u " .. tostring(uid) + end + if not pwd.no_create_home then extraargs = extraargs .. " -m " end diff --git a/libexec/nuageinit/nuageinit.7 b/libexec/nuageinit/nuageinit.7 index 6a72d322cca4..5a0210e43189 100644 --- a/libexec/nuageinit/nuageinit.7 +++ b/libexec/nuageinit/nuageinit.7 @@ -3,7 +3,7 @@ .\" Copyright (c) 2025 Baptiste Daroussin .\" Copyright (c) 2025 Jesús Daniel Colmenares Oviedo .\" -.Dd June 8, 2026 +.Dd November 11, 2026 .Dt NUAGEINIT 7 .Os .Sh NAME @@ -546,6 +546,8 @@ Specify a list of users to be created: .Bl -tag -width "ssh_authorized_keys" .It Ic name Name of the user. +.It Ic uid +The numeric user ID to assign to the user. .It Ic gecos GECOS for the user. .It Ic homedir diff --git a/libexec/nuageinit/tests/Makefile b/libexec/nuageinit/tests/Makefile index fc7765268660..2ec2d20bcdf2 100644 --- a/libexec/nuageinit/tests/Makefile +++ b/libexec/nuageinit/tests/Makefile @@ -12,6 +12,7 @@ ${PACKAGE}FILES+= addgroup.lua ${PACKAGE}FILES+= addsshkey.lua ${PACKAGE}FILES+= adduser.lua ${PACKAGE}FILES+= adduser_passwd.lua +${PACKAGE}FILES+= adduser_uid.lua ${PACKAGE}FILES+= dirname.lua ${PACKAGE}FILES+= err.lua ${PACKAGE}FILES+= sethostname.lua diff --git a/libexec/nuageinit/tests/adduser_uid.lua b/libexec/nuageinit/tests/adduser_uid.lua new file mode 100644 index 000000000000..703b9d65ce59 --- /dev/null +++ b/libexec/nuageinit/tests/adduser_uid.lua @@ -0,0 +1,27 @@ +#!/usr/libexec/flua + +local n = require("nuage") + +local pw1 = {} +pw1.name = "numericuser" +pw1.uid = 1600 +local res = n.adduser(pw1) +if not res then + n.err("adduser with numeric uid should return a path") +end + +local pw2 = {} +pw2.name = "stringuser" +pw2.uid = "1601" +res = n.adduser(pw2) +if not res then + n.err("adduser with string uid should return a path") +end + +local pw3 = {} +pw3.name = "baduser" +pw3.uid = -1 +res = n.adduser(pw3) +if res then + n.err("adduser should reject negative uid") +end diff --git a/libexec/nuageinit/tests/nuage.sh b/libexec/nuageinit/tests/nuage.sh index 1e08c990eacd..c5cea2f138c7 100644 --- a/libexec/nuageinit/tests/nuage.sh +++ b/libexec/nuageinit/tests/nuage.sh @@ -12,6 +12,7 @@ atf_test_case settimezone atf_test_case addsshkey atf_test_case adduser atf_test_case adduser_passwd +atf_test_case adduser_uid atf_test_case addgroup atf_test_case addfile atf_test_case decode_base64 @@ -80,6 +81,23 @@ adduser_passwd_body() $(atf_get_srcdir)/crypt $passhash "barcrypted" } +adduser_uid_head() +{ + atf_set "require.user" root +} + +adduser_uid_body() +{ + mkdir etc + printf "root:*:0:0::0:0:Charlie &:/root:/bin/sh\n" > etc/master.passwd + pwd_mkdb -d etc etc/master.passwd + printf "wheel:*:0:root\n" > etc/group + atf_check -e inline:"nuageinit: invalid uid for user baduser\n" /usr/libexec/flua $(atf_get_srcdir)/adduser_uid.lua + atf_check -s exit:1 grep '^baduser:' etc/master.passwd + atf_check -o inline:"1600\n" awk -F ':' '/^numericuser:/ {print $3}' etc/master.passwd + atf_check -o inline:"1601\n" awk -F ':' '/^stringuser:/ {print $3}' etc/master.passwd +} + addgroup_body() { mkdir etc @@ -122,6 +140,7 @@ atf_init_test_cases() atf_add_test_case addsshkey atf_add_test_case adduser atf_add_test_case adduser_passwd + atf_add_test_case adduser_uid atf_add_test_case addgroup atf_add_test_case addfile atf_add_test_case decode_base64