Compare commits

...

3 Commits

Author SHA1 Message Date
3830dfdc03 Fix SC2162 2024-12-01 23:30:03 -06:00
d6a35ccfcf set -u 2024-12-01 23:24:22 -06:00
5730d3c060 Buffer file before modifying it 2024-12-01 23:21:43 -06:00

View File

@@ -24,8 +24,7 @@
# that the cause is this disparity and that it will be smoothed out when # that the cause is this disparity and that it will be smoothed out when
# systemd-sysusers next runs # systemd-sysusers next runs
# #
set -e set -euo pipefail
set -o pipefail
# Iterate over each file we're interested in # Iterate over each file we're interested in
for file in /etc/shadow /etc/gshadow; do for file in /etc/shadow /etc/gshadow; do
@@ -42,7 +41,7 @@ for file in /etc/shadow /etc/gshadow; do
# Prelim checks succeeded, move forward # Prelim checks succeeded, move forward
echo "Parsing $file for junk" echo "Parsing $file for junk"
# Read each line in the file to iterate over it # Read each line in the file to iterate over it
while read line; do while read -r line; do
# This should never happen, but if for some reason we get an empty line, # This should never happen, but if for some reason we get an empty line,
# continue # continue
[ -z "$line" ] && continue [ -z "$line" ] && continue
@@ -111,5 +110,7 @@ for file in /etc/shadow /etc/gshadow; do
"/^$name:/d" \ "/^$name:/d" \
"$file" "$file"
fi fi
done < "$file" # Not useless use of cat. We're buffering the file here to avoid conditions
# where we edit the file we're reading and face issues.
done < <(cat "$file")
done done