Lines Matching +full:sub +full:- +full:groups
1 ---
2 -- SPDX-License-Identifier: BSD-2-Clause
3 --
4 -- Copyright(c) 2022-2025 Baptiste Daroussin <bapt@FreeBSD.org>
5 -- Copyright(c) 2025 Jesús Daniel Colmenares Oviedo <dtxdf@FreeBSD.org>
12 local f = io.popen("sysctl -in user.localbase 2> /dev/null")
16 -- fallback
29 -- convert all characters in bits
31 local x = input:sub(i, i)
35 local f = b:find(x) - 1
36 for j = 6, 1, -1 do
37 bits = bits .. (f % 2^j - f % 2^(j-1) > 0 and '1' or '0')
42 local byte = bits:sub(i, i + 7)
46 c = c + (byte:sub(j, j) == '1' and 2^(8 - j) or 0)
158 cmd = cmd .. "-R " .. root .. " "
161 local f = io.popen(cmd .. "groupshow -a 2> /dev/null | cut -d: -f1")
162 local groups = f:read("*a")
165 return splitlines(groups)
169 local groups = getgroups()
171 for _, group2chk in ipairs(groups) do
180 local function purge_group(groups)
183 for _, group in ipairs(groups) do
187 warnmsg("ignoring non-existent group '" .. group .. "'")
202 cmd = cmd .. "-R " .. root .. " "
204 local f = io.popen(cmd .. " usershow " .. pwd.name .. " -7 2> /dev/null")
217 if pwd.groups then
218 local list = splitlist(pwd.groups)
219 -- pw complains if the group does not exist, so if the user
220 -- specifies one that cannot be found, nuageinit will generate
221 -- an exception and exit, unlike cloud-init, which only issues
222 -- a warning but creates the user anyway.
225 extraargs = " -G " .. table.concat(list, ",")
228 -- pw will automatically create a group named after the username
229 -- do not add a -g option in this case
231 extraargs = extraargs .. " -g " .. pwd.primary_group
234 extraargs = extraargs .. " -m "
244 postcmd = " -H 0"
247 postcmd = " -h 0"
251 cmd = cmd .. "-R " .. root .. " "
253 cmd = cmd .. "useradd -n " .. pwd.name .. " -M 0755 -w none "
254 cmd = cmd .. extraargs .. " -c '" .. pwd.gecos
255 cmd = cmd .. "' -d '" .. pwd.homedir .. "' -s " .. pwd.shell .. postcmd
270 cmd = cmd .. "-R " .. root .. " "
286 cmd = cmd .. "-R " .. root .. " "
297 extraargs = " -M " .. table.concat(list, ",")
301 cmd = cmd .. "-R " .. root .. " "
303 cmd = cmd .. "groupadd -n " .. grp.name .. extraargs
406 local sudoers = sudoers_dir .. "/90-nuageinit-users"
477 cmd = cmd .. "-R " .. root .. " "
479 local postcmd = " -H 0"
482 postcmd = " -h 0"
486 postcmd = " -w random"
491 cmd = cmd .. " -p 1"
493 cmd = cmd .. " -p 0"
499 -- ignore stdout to avoid printing the password in case of random password
582 f, _, rc = os.execute("tzsetup -s -C " .. root .. " " .. timezone)
594 if os.execute("pkg -N 2>/dev/null") then
605 local install_cmd = "pkg install -y " .. package
606 local test_cmd = "pkg info -q " .. package