Compare commits
5 Commits
254f8bd3d9
...
master
Author | SHA1 | Date | |
---|---|---|---|
3830dfdc03 | |||
d6a35ccfcf | |||
5730d3c060 | |||
1dee476771 | |||
b7e10dccb9 |
@@ -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,10 @@ 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,
|
||||||
|
# continue
|
||||||
|
[ -z "$line" ] && continue
|
||||||
# Per shadow(5), we are guaranteed that all characters leading up to the
|
# Per shadow(5), we are guaranteed that all characters leading up to the
|
||||||
# first colon are the user's/group's name. To that end, we'll do a bash
|
# first colon are the user's/group's name. To that end, we'll do a bash
|
||||||
# string substitution to extract that first column.
|
# string substitution to extract that first column.
|
||||||
@@ -59,7 +61,7 @@ for file in /etc/shadow /etc/gshadow; do
|
|||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Unknown file to parse for junk: $file"
|
echo "Unknown file to parse for junk: $file"
|
||||||
exit
|
exit 101
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
# Now, we use getent to find a match for the shadow entry. It's at this point
|
# Now, we use getent to find a match for the shadow entry. It's at this point
|
||||||
@@ -108,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
|
||||||
|
Reference in New Issue
Block a user