Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Prevent incorrect user_not_volume_owner messages #177

Merged
merged 1 commit into from
Dec 21, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 28 additions & 5 deletions erase-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -898,13 +898,36 @@ get_user_details() {
while read -r line ; do
user=$(/usr/bin/cut -d, -f1 <<< "$line")
guid=$(/usr/bin/cut -d, -f2 <<< "$line")
# passwords are case sensitive, account names are not
shopt -s nocasematch
if [[ $(/usr/bin/grep -A2 "$guid" <<< "$users" | /usr/bin/tail -n1 | /usr/bin/awk '{print $NF}') == "Yes" ]]; then
enabled_users+="$user "
if [[ "$account_shortname" == "$user" ]]; then
echo " [get_user_details] $account_shortname is a Volume Owner"
user_is_volume_owner=1
fi
enabled_users+="$user "
# The entered username might not match the output of fdesetup, so we compare
# all RecordNames for the canonical name given by fdesetup against the entered
# username, and then use the canonical version. The entered username might
# even be the RealName, and we still would end up here.
# Example:
# RecordNames for user are "John.Doe@pretendco.com" and "John.Doe", fdesetup
# says "John.Doe@pretendco.com", and account_shortname is "john.doe" or "Doe, John"
for userline in $( /usr/bin/dscl -q /Search -read Users/$user RecordName dsAttrTypeStandard:RecordName | /usr/bin/awk -F': ' '{print $2}' ); do
if [[ "$account_shortname" == "$userline" ]]; then
account_shortname=$user
echo " [get_user_details] $account_shortname is a Volume Owner"
user_is_volume_owner=1
break
fi
done
# if needed, compare the RealName (which might contain spaces)
if [[ $user_is_volume_owner = 0 ]]; then
realname=$(/usr/bin/dscl -q /Search -read Users/$user RealName | /usr/bin/tail -1 | /usr/bin/cut -d' ' -f 2-)
if [[ "$account_shortname" == "$realname" ]]; then
account_shortname=$user
echo " [get_user_details] $account_shortname is a Volume Owner"
user_is_volume_owner=1
fi
fi
fi
shopt -u nocasematch
done <<< "$(/usr/bin/fdesetup list)"
if [[ $enabled_users != "" && $user_is_volume_owner = 0 ]]; then
echo " [get_user_details] $account_shortname is not a Volume Owner"
Expand Down