CVS commit: src/distrib/utils/embedded/files
Module Name:src Committed By: mrg Date: Mon Jan 29 05:46:55 UTC 2024 Modified Files: src/distrib/utils/embedded/files: creds_msdos Log Message: properly quote arguments. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/distrib/utils/embedded/files/creds_msdos Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/utils/embedded/files/creds_msdos diff -u src/distrib/utils/embedded/files/creds_msdos:1.5 src/distrib/utils/embedded/files/creds_msdos:1.6 --- src/distrib/utils/embedded/files/creds_msdos:1.5 Sat Dec 11 19:24:18 2021 +++ src/distrib/utils/embedded/files/creds_msdos Mon Jan 29 05:46:55 2024 @@ -1,6 +1,6 @@ #!/bin/sh # -# $NetBSD: creds_msdos,v 1.5 2021/12/11 19:24:18 mrg Exp $ +# $NetBSD: creds_msdos,v 1.6 2024/01/29 05:46:55 mrg Exp $ # # Copyright (c) 2019 Matthew R. Green # All rights reserved. @@ -153,7 +153,7 @@ creds_msdos_start() if [ -f "${creds_file}" ]; then while read type user args; do # strip cr - local clean_args=$(echo "$args" | tr -d '\015') + local clean_args="$(echo "$args" | tr -d '\015')" case "$type" in \#*|'') continue
CVS commit: src/distrib/utils/embedded/files
Module Name:src Committed By: mrg Date: Mon Jan 29 05:46:55 UTC 2024 Modified Files: src/distrib/utils/embedded/files: creds_msdos Log Message: properly quote arguments. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/distrib/utils/embedded/files/creds_msdos Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/distrib/utils/embedded/files
Module Name:src Committed By: riastradh Date: Wed Sep 27 00:27:07 UTC 2023 Modified Files: src/distrib/utils/embedded/files: ec2_init Log Message: ec2_init: Suppress error message for nonexistent sysctl. We're querying to see whether the sysctl node is available and if so what its text is, not interested in the error message. XXX pullup-10 To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/distrib/utils/embedded/files/ec2_init Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/utils/embedded/files/ec2_init diff -u src/distrib/utils/embedded/files/ec2_init:1.5 src/distrib/utils/embedded/files/ec2_init:1.6 --- src/distrib/utils/embedded/files/ec2_init:1.5 Sat Oct 15 18:32:30 2022 +++ src/distrib/utils/embedded/files/ec2_init Wed Sep 27 00:27:07 2023 @@ -1,6 +1,6 @@ #!/bin/sh # -# $NetBSD: ec2_init,v 1.5 2022/10/15 18:32:30 jmcneill Exp $ +# $NetBSD: ec2_init,v 1.6 2023/09/27 00:27:07 riastradh Exp $ # # PROVIDE: ec2_init # REQUIRE: NETWORKING @@ -15,7 +15,7 @@ stop_cmd=":" CLOUD_TYPE=EC2 # default -case "$(/sbin/sysctl -n machdep.dmi.chassis-asset-tag)" in +case "$(/sbin/sysctl -n machdep.dmi.chassis-asset-tag 2>/dev/null)" in OracleCloud*) CLOUD_TYPE=OCI ;;
CVS commit: src/distrib/utils/embedded/files
Module Name:src Committed By: riastradh Date: Wed Sep 27 00:27:07 UTC 2023 Modified Files: src/distrib/utils/embedded/files: ec2_init Log Message: ec2_init: Suppress error message for nonexistent sysctl. We're querying to see whether the sysctl node is available and if so what its text is, not interested in the error message. XXX pullup-10 To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/distrib/utils/embedded/files/ec2_init Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/distrib/utils/embedded/files
Module Name:src Committed By: mlelstv Date: Sat Mar 18 11:36:23 UTC 2023 Modified Files: src/distrib/utils/embedded/files: resize_disklabel Log Message: Can't use disklabel to find the real size of a disk since a fake disklabel read from disk is trusted. Revert to use drvctl again. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/distrib/utils/embedded/files/resize_disklabel Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/utils/embedded/files/resize_disklabel diff -u src/distrib/utils/embedded/files/resize_disklabel:1.4 src/distrib/utils/embedded/files/resize_disklabel:1.5 --- src/distrib/utils/embedded/files/resize_disklabel:1.4 Sat Feb 18 07:58:34 2023 +++ src/distrib/utils/embedded/files/resize_disklabel Sat Mar 18 11:36:23 2023 @@ -1,6 +1,6 @@ #!/bin/sh # -# $NetBSD: resize_disklabel,v 1.4 2023/02/18 07:58:34 mlelstv Exp $ +# $NetBSD: resize_disklabel,v 1.5 2023/03/18 11:36:23 mlelstv Exp $ # # PROVIDE: resize_disklabel @@ -27,8 +27,7 @@ get_total_sectors() local disk disk=$1 - /sbin/disklabel -t "$disk" \ - | sed -ne 's/.*:su#\([0-9]*\):.*/\1/p' + /sbin/drvctl -p "$disk" disk-info/geometry/sectors-per-unit } get_rawpart_sectors()
CVS commit: src/distrib/utils/embedded/files
Module Name:src Committed By: mlelstv Date: Sat Mar 18 11:36:23 UTC 2023 Modified Files: src/distrib/utils/embedded/files: resize_disklabel Log Message: Can't use disklabel to find the real size of a disk since a fake disklabel read from disk is trusted. Revert to use drvctl again. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/distrib/utils/embedded/files/resize_disklabel Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/distrib/utils/embedded/files
Module Name:src Committed By: mlelstv Date: Sat Feb 18 07:58:35 UTC 2023 Modified Files: src/distrib/utils/embedded/files: resize_disklabel Log Message: Handle arbitrary raw partitions. Fetch geometry from disklabel to be consistent. Use disktab format instead of the normal human-readable output for parsing the disklabel. Avoid overflows in size computation. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/distrib/utils/embedded/files/resize_disklabel Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/utils/embedded/files/resize_disklabel diff -u src/distrib/utils/embedded/files/resize_disklabel:1.3 src/distrib/utils/embedded/files/resize_disklabel:1.4 --- src/distrib/utils/embedded/files/resize_disklabel:1.3 Sat Oct 6 09:58:55 2018 +++ src/distrib/utils/embedded/files/resize_disklabel Sat Feb 18 07:58:34 2023 @@ -1,6 +1,6 @@ #!/bin/sh # -# $NetBSD: resize_disklabel,v 1.3 2018/10/06 09:58:55 jmcneill Exp $ +# $NetBSD: resize_disklabel,v 1.4 2023/02/18 07:58:34 mlelstv Exp $ # # PROVIDE: resize_disklabel @@ -16,25 +16,35 @@ stop_cmd=":" get_rawpart() { + local partno + partno=$(/sbin/sysctl -n kern.rawpartition) - test $partno = 2 && echo c || echo d + printf "$(printf %o $((partno + 97)))" } get_total_sectors() { + local disk + disk=$1 - /sbin/drvctl -p $disk disk-info/geometry/sectors-per-unit + /sbin/disklabel -t "$disk" \ + | sed -ne 's/.*:su#\([0-9]*\):.*/\1/p' } get_rawpart_sectors() { + local disk rawpart + disk=$1 rawpart=$2 - /sbin/disklabel $disk | grep "^ $rawpart:" | awk '{ print $2; }' + /sbin/disklabel -t "$disk" \ + | sed -ne 's/.*:p'"$rawpart"'#\([0-9]*\):.*/\1/p' } grow_mbrpart() { + local disk rawpart ts rs oldsize newsize + disk=$1 rawpart=$(get_rawpart) @@ -44,21 +54,23 @@ grow_mbrpart() return fi - ts=$(($(get_total_sectors $disk) - ${PART1START})) + ts=$((${DLSIZE} - ${PART1START})) rs=${PART1SIZE} if [ "$ts" = "$rs" ]; then return fi - oldsize=$(($rs * 512 / 1024 / 1024)) - newsize=$(($ts * 512 / 1024 / 1024)) + oldsize=$(($rs / 2048)) + newsize=$(($ts / 2048)) echo "Growing $disk MBR partition #1 (${oldsize}MB -> ${newsize}MB)" /sbin/fdisk -f -u -1 -s 169/${PART1START}/${ts} ${disk} } grow_disklabel() { + local disk part rawpart ts rs oldsize newsize + disk=$1 part=$2 rawpart=$(get_rawpart) @@ -70,8 +82,8 @@ grow_disklabel() return fi - oldsize=$(($rs * 512 / 1024 / 1024)) - newsize=$(($ts * 512 / 1024 / 1024)) + oldsize=$(($rs / 2048)) + newsize=$(($ts / 2048)) echo "Growing $disk disklabel (${oldsize}MB -> ${newsize}MB)" printf "A\ny\n$part\n\n\n\$\nc\n\n\n\$\nd\n\n\n\$\nW\ny\nQ\n" | \ disklabel -i $disk >/dev/null
CVS commit: src/distrib/utils/embedded/files
Module Name:src Committed By: mlelstv Date: Sat Feb 18 07:58:35 UTC 2023 Modified Files: src/distrib/utils/embedded/files: resize_disklabel Log Message: Handle arbitrary raw partitions. Fetch geometry from disklabel to be consistent. Use disktab format instead of the normal human-readable output for parsing the disklabel. Avoid overflows in size computation. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/distrib/utils/embedded/files/resize_disklabel Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/distrib/utils/embedded/files
Module Name:src Committed By: jmcneill Date: Sun Oct 27 21:35:02 UTC 2019 Modified Files: src/distrib/utils/embedded/files: armv7_boot_nonefi.cmd Log Message: No support for tegra210 in armv7 kernel To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 \ src/distrib/utils/embedded/files/armv7_boot_nonefi.cmd Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/utils/embedded/files/armv7_boot_nonefi.cmd diff -u src/distrib/utils/embedded/files/armv7_boot_nonefi.cmd:1.1 src/distrib/utils/embedded/files/armv7_boot_nonefi.cmd:1.2 --- src/distrib/utils/embedded/files/armv7_boot_nonefi.cmd:1.1 Sun Jul 21 16:05:24 2019 +++ src/distrib/utils/embedded/files/armv7_boot_nonefi.cmd Sun Oct 27 21:35:02 2019 @@ -33,15 +33,6 @@ if test "${soc}" = "tegra124" ; then setenv mmcpart 1:1 setenv use_fdt 1 fi -if test "${soc}" = "tegra210" ; then - setenv kernel netbsd.ub - setenv bootargs root=wd0a - setenv mmcpart 1:1 - setenv use_fdt 1 - setenv fdtfile ${soc}-${board}.dtb - # enable PCIe - pci enum -fi if test "${kernel}" = "" ; then echo '>>>'
CVS commit: src/distrib/utils/embedded/files
Module Name:src Committed By: jmcneill Date: Sun Oct 27 21:35:02 UTC 2019 Modified Files: src/distrib/utils/embedded/files: armv7_boot_nonefi.cmd Log Message: No support for tegra210 in armv7 kernel To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 \ src/distrib/utils/embedded/files/armv7_boot_nonefi.cmd Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/distrib/utils/embedded/files
Module Name:src Committed By: mlelstv Date: Sat Oct 5 09:25:11 UTC 2019 Modified Files: src/distrib/utils/embedded/files: creds_msdos Log Message: Fix typo To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/distrib/utils/embedded/files/creds_msdos Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/utils/embedded/files/creds_msdos diff -u src/distrib/utils/embedded/files/creds_msdos:1.3 src/distrib/utils/embedded/files/creds_msdos:1.4 --- src/distrib/utils/embedded/files/creds_msdos:1.3 Wed Jun 12 03:06:48 2019 +++ src/distrib/utils/embedded/files/creds_msdos Sat Oct 5 09:25:11 2019 @@ -1,6 +1,6 @@ #!/bin/sh # -# $NetBSD: creds_msdos,v 1.3 2019/06/12 03:06:48 mrg Exp $ +# $NetBSD: creds_msdos,v 1.4 2019/10/05 09:25:11 mlelstv Exp $ # # Copyright (c) 2019 Matthew R. Green # All rights reserved. @@ -135,7 +135,7 @@ creds_msdos_start() local fstab_file=/etc/fstab if [ -z "${creds_msdos_partition}" ]; then - echo "Not looking for credientials on msdos" + echo "Not looking for credentials on msdos" return fi while read junk1 mp fstype junk2; do
CVS commit: src/distrib/utils/embedded/files
Module Name:src Committed By: mlelstv Date: Sat Oct 5 09:25:11 UTC 2019 Modified Files: src/distrib/utils/embedded/files: creds_msdos Log Message: Fix typo To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/distrib/utils/embedded/files/creds_msdos Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/distrib/utils/embedded/files
Module Name:src Committed By: mrg Date: Wed Jun 12 03:06:49 UTC 2019 Modified Files: src/distrib/utils/embedded/files: creds_msdos Log Message: various cleanups inspired by reviews: - clean up variable usage - be explicit that $ssh_userkeys is global - don't assig id output to a variable not used To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/distrib/utils/embedded/files/creds_msdos Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/utils/embedded/files/creds_msdos diff -u src/distrib/utils/embedded/files/creds_msdos:1.2 src/distrib/utils/embedded/files/creds_msdos:1.3 --- src/distrib/utils/embedded/files/creds_msdos:1.2 Wed Jun 12 00:28:56 2019 +++ src/distrib/utils/embedded/files/creds_msdos Wed Jun 12 03:06:48 2019 @@ -1,6 +1,6 @@ #!/bin/sh # -# $NetBSD: creds_msdos,v 1.2 2019/06/12 00:28:56 mrg Exp $ +# $NetBSD: creds_msdos,v 1.3 2019/06/12 03:06:48 mrg Exp $ # # Copyright (c) 2019 Matthew R. Green # All rights reserved. @@ -46,35 +46,35 @@ $_rc_subr_loaded . /etc/rc.subr name="creds_msdos" start_cmd="creds_msdos_start" stop_cmd=":" -fstab_file=/etc/fstab fail() { echo "$@" 1>&2 exit 1 } +# This uses $ssh_userkeys global sshkey_setup() { local user="$1" local group="wheel" # don't create existing users - id=$(id -u $user 2>/dev/null) - if [ $? -ne 0 ]; then - useradd -m -G "${group}" "$user" || fail "Useradd failed." + if ! id -u "${user}" > /dev/null 2>&1; then + useradd -m -G "${group}" "${user}" || fail "Useradd failed." fi - eval sshdir=~"${user}/.ssh" - eval mkdir -p -m 755 "${sshdir}" || fail "mkdir ~/.ssh failed." - chown "${user}" "${sshdir}" - eval userkeys="${sshdir}/authorized_keys" + eval ssh_userdir=~"${user}/.ssh" + mkdir -p -m 755 "${ssh_userdir}" || fail "mkdir ~/.ssh failed." + chmod 755 "${ssh_userdir}" + chown "${user}" "${ssh_userdir}" + + ssh_userkeys="${ssh_userdir}/authorized_keys" } sshkey_finish() { local user="$1" - local userkeys="$2" - chmod 644 "${userkeys}" - chown "${user}" "${userkeys}" + chmod 644 "${ssh_userkeys}" + chown "${user}" "${ssh_userkeys}" } do_sshkeyfile() { @@ -85,28 +85,28 @@ do_sshkeyfile() { return fi - sshkey_setup "$user" + sshkey_setup "${user}" # check entry is not present while read type keydata name; do - if fgrep -q "${keydata}" "${userkeys}" 2>/dev/null; then + if fgrep -q "${keydata}" "${ssh_userkeys}" 2>/dev/null; then continue fi - echo "${type} ${keydata} ${name}" >> "${userkeys}" + echo "${type} ${keydata} ${name}" >> "${ssh_userkeys}" done < "${newkeys}" - sshkey_finish "$user" "${userkeys}" + sshkey_finish "${user}" } do_sshkey() { local user="$1" local newkey="$2" - sshkey_setup "$user" + sshkey_setup "${user}" - echo "${newkey}" >> "${userkeys}" + echo "${newkey}" >> "${ssh_userkeys}" - sshkey_finish "$user" "${userkeys}" + sshkey_finish "${user}" } do_useraddpwhash() { @@ -115,8 +115,7 @@ do_useraddpwhash() { local group="wheel" # don't add to existing users - id=$(id -u "${user}" 2>/dev/null) - if [ $? -eq 0 ]; then + if id -u "${user}" > /dev/null 2>&1; then return fi @@ -133,48 +132,49 @@ do_useradd() { creds_msdos_start() { + local fstab_file=/etc/fstab + if [ -z "${creds_msdos_partition}" ]; then echo "Not looking for credientials on msdos" - return; + return fi - check_fs= while read junk1 mp fstype junk2; do if [ "${mp}" != "${creds_msdos_partition}" ]; then continue fi if [ "${fstype}" != "msdos" ]; then echo "Not checking for creds on ${creds_msdos_partition}: not an msdos file system" - return; + return fi break done < "${fstab_file}" - delete_creds=no - creds_file="${creds_msdos_partition}/creds.txt" + local delete_creds=no + local creds_file="${creds_msdos_partition}/creds.txt" if [ -f "${creds_file}" ]; then - while read type user arg1; do + while read type user args; do # strip cr - arg1=$(echo "$arg1" | tr -d '\015') + local clean_args=$(echo "$args" | tr -d '\015') case "$type" in \#*|'') continue ;; sshkeyfile) echo "Added user ${user} via ssh key file method." -do_sshkeyfile "${user}" "${arg1}" +do_sshkeyfile "${user}" "${clean_args}" ;; sshkey) echo "Added user ${user} via ssh key string method." -do_sshkey "${user}" "${arg1}" +do_sshkey "${user}" "${clean_args}" ;; useraddpwhash) echo "Added user ${user} via password hash method." -do_useraddpwhash "${user}" "${arg1}" +do_useraddpwhash "${user}" "${clean_args}" ;; useradd) echo "Added user ${user} via password method, shredding credentials file." -do_useradd "${user}" "${arg1}" +do_useradd "${user}" "${clean_args}" delete_creds=yes ;; *)
CVS commit: src/distrib/utils/embedded/files
Module Name:src Committed By: mrg Date: Wed Jun 12 03:06:49 UTC 2019 Modified Files: src/distrib/utils/embedded/files: creds_msdos Log Message: various cleanups inspired by reviews: - clean up variable usage - be explicit that $ssh_userkeys is global - don't assig id output to a variable not used To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/distrib/utils/embedded/files/creds_msdos Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/distrib/utils/embedded/files
Module Name:src Committed By: mrg Date: Wed Jun 12 00:28:56 UTC 2019 Modified Files: src/distrib/utils/embedded/files: creds_msdos Log Message: explicitly strip carriage return so that non-unix text files work. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/distrib/utils/embedded/files/creds_msdos Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/utils/embedded/files/creds_msdos diff -u src/distrib/utils/embedded/files/creds_msdos:1.1 src/distrib/utils/embedded/files/creds_msdos:1.2 --- src/distrib/utils/embedded/files/creds_msdos:1.1 Tue Jun 11 10:50:57 2019 +++ src/distrib/utils/embedded/files/creds_msdos Wed Jun 12 00:28:56 2019 @@ -1,6 +1,6 @@ #!/bin/sh # -# $NetBSD: creds_msdos,v 1.1 2019/06/11 10:50:57 mrg Exp $ +# $NetBSD: creds_msdos,v 1.2 2019/06/12 00:28:56 mrg Exp $ # # Copyright (c) 2019 Matthew R. Green # All rights reserved. @@ -154,6 +154,8 @@ creds_msdos_start() if [ -f "${creds_file}" ]; then while read type user arg1; do + # strip cr + arg1=$(echo "$arg1" | tr -d '\015') case "$type" in \#*|'') continue
CVS commit: src/distrib/utils/embedded/files
Module Name:src Committed By: mrg Date: Wed Jun 12 00:28:56 UTC 2019 Modified Files: src/distrib/utils/embedded/files: creds_msdos Log Message: explicitly strip carriage return so that non-unix text files work. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/distrib/utils/embedded/files/creds_msdos Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.